// overly simplistic test for IE
isIE = (document.all ? true : false);
// both IE5 and NS6 are DOM-compliant (well, sort of...)
isDOM = (document.getElementById ? true : false);

// get the true offset of anything on NS4, IE4/5 & NS6, even if it's in a table!
function getAbsX(elt) { return (elt.x) ? elt.x : getAbsPos(elt,"Left"); }
function getAbsY(elt) { return (elt.y) ? elt.y : getAbsPos(elt,"Top"); }
function getAbsPos(elt,which) {
 iPos = 0;
 while (elt != null) {
  iPos += elt["offset" + which];
  elt = elt.offsetParent;
 }
 return iPos;
}

function getDivStyle(divname) {
 var style;
 if (isDOM) { style = document.getElementById(divname).style; }
 else { style = isIE ? document.all[divname].style
                     : document.layers[divname]; } // NS4
 return style;
}

function hideElement(divname) {
 getDivStyle(divname).visibility = 'hidden';
}

function showElement(divname) {
 getDivStyle(divname).visibility = 'visible';
}

// annoying detail: IE and NS6 store elt.top and elt.left as strings.
function moveBy(elt,deltaX,deltaY) {
 elt.left = parseInt(elt.left) + deltaX;
 elt.top = parseInt(elt.top) + deltaY;
}

function toggleVisible(divname) {
 divstyle = getDivStyle(divname);
 if (divstyle.visibility == 'visible' || divstyle.visibility == 'show') {
   divstyle.visibility = 'hidden';
 } else {
   fixPosition(divname);
   divstyle.visibility = 'visible';
 }
}

function setPosition(elt,positionername,isPlacedUnder) {
 var positioner;
 var modified_y=0, modified_x ;
 
 if (positionername == 'subcat3Pos') modified_x = -20 ;
 else modified_x = 0 ;
 
 if (isIE) {
  positioner = document.all[positionername];
 } else {
  if (isDOM) {
    positioner = document.getElementById(positionername);
  } else {
    // not IE, not DOM (probably NS4)
    // if the positioner is inside a netscape4 layer this will *not* find it.
    // I should write a finder function which will recurse through all layers
    // until it finds the named image...
    positioner = document.images[positionername];
  }
 }
 elt.left = getAbsX(positioner) + modified_x ;
 
 if (isIE) modified_y = getAbsY(positioner) + 6 ;
 else {
// 	alert (getAbsY(positioner)) ; 
 	if (getAbsY(positioner) <= 100) modified_y = 81 ;
 	else modified_y = getAbsY(positioner) + 1 ;
 }
 
 elt.top = modified_y ;
}

function fixPosition(divname) {
	divstyle = getDivStyle(divname);
	positionerImgName = divname + 'Pos';
	setPosition(divstyle,positionerImgName,true);
}

// Show-Hide Drop Down Menus
function dropMenu(divname,tf) {
	alert("Visibility (" + divname + ") = " + getDivStyle(divname).visibility) ;
//	theLayer = eval("document.all['" + x + "']")
//	if (! isIE) theLayer.style.visibility = (tf) ? "show" : "hidden";
//	else theLayer.style.visibility = (tf) ? "visible" : "hidden";
	
	if (! isIE) {
		alert("NN") ;
		getDivStyle(divname).visibility = "show";
	}
	else getDivStyle(divname).visibility = (tf) ? "visible" : "hidden";
	alert("Visibility (" + divname + ") = " + getDivStyle(divname).visibility) ;
}

function openPopup(url) {
	window.open(url,'','width=460,height=300,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0') ;
}

function openPopupProps(url, props) {
	window.open(url,'',props) ;
}

function swapClass(element, className) {
	element.className = className;
	element.parentNode.className = className;
}

function switchImage(curobj, direction, switch_on) {
	var ns6=document.getElementById && !document.all?1:0 ;
	var altobj="" ;

	if (ns6 == 0) {
		altobj=document.all[curobj.sourceIndex+direction].style ;
		if (switch_on) altobj.display="" ;
		else altobj.display="none" ;
	}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document;
  if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
  }
  if(!(x=d[n])&&d.all) {
    x=d.all[n];
  }
  for (i=0;!x&&i<d.forms.length;i++) {
    x=d.forms[i][n];
  }
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) {
    x=MM_findObj(n,d.layers[i].document);
  }
  if(!x && d.getElementById) {
    x=d.getElementById(n);
  }
  // alert('object ' + n + ' is ' + x);
  return x;
}

function changeZone(active, combo_name) {
	combo_element = MM_findObj(combo_name) ;

	combo_element.options.length=0 ;
	for (i=0; i<countries[active].length; i++)
		combo_element.options[combo_element.options.length]=new Option(countries[active][i].split("|")[1], countries[active][i].split("|")[0])
}

function openCountrySERoaming(page) {
	if (page.length != 0) {
		window.open('http://www2.acneuro.com/acn/se_en/products/mobile_telephony/roaming/'+page+'.html','','width=800,height=600,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=1,status=0,toolbar=0');
	}
}
