function swapImgRestore() { //v3.0
  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.p) d.p=new Array();
    var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}

function 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=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function swapImage() { //v3.0
  var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function DL_GetElementLeft(eElement)
{
    if (!eElement && this)                       // if argument is invalid
    {                                            // (not specified, is null or is 0)
        eElement = this;                         // and function is a method
    }                                            // identify the element as the method owner
    
    var nLeftPos = eElement.offsetLeft;          // initialize var to store calculations
    var eParElement = eElement.offsetParent;     // identify first offset parent element  
    while (eParElement != null)
    {                                            // move up through element hierarchy
        nLeftPos += eParElement.offsetLeft;      // appending left offset of each parent
        eParElement = eParElement.offsetParent;  // until no more offset parents exist
    }
    return nLeftPos;                             // return the number calculated
}

function DL_GetElementTop(eElement)
{
    if (!eElement && this)
    {
        eElement = this;
    }

    var nTopPos = eElement.offsetTop;
    var eParElement = eElement.offsetParent;
    while (eParElement != null)
    {
        nTopPos += eParElement.offsetTop;
        eParElement = eParElement.offsetParent;
    }
    return nTopPos;
}

function newWindow(mypage, myname, w, h)
{
	day = new Date();
	id = day.getTime();
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings = 'toolbar=0,statusbar=0,menubar=0,scrollbars=1,location=0,resizable=1,width=730,height=600,left = 20,top = 20';
	//toolbar=no,location=no,directories=no,menubar=no,height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,resizable=yes';
	window.open(mypage,myname+id,settings);
}

showMenuHandler = null;
function mainMenu(menu, elem)
{
	if (showMenuHandler)
		window.clearTimeout(showMenuHandler);
	x = DL_GetElementLeft(elem)+80;
	y = DL_GetElementTop(elem);
	hideActiveMenus();
	MM_clearTimeout();
	hideActiveMenus();
	MM_clearTimeout();
	showMenuHandler = setTimeout("window.MM_showMenu("+menu+","+x+","+y+")", 200);
}

function navMenu(menu, elemName)
{
	var x;
	col = document.getElementsByName(elemName);
	if (col == null ||
		col.length == 0) return;
	elem = col.item(0);
	//alert(DL_GetElementTop(elem));
	//alert(elem.height);
	if (elem.height == null)
		x = 0;
	else
		x = elem.height;
	window.MM_showMenu(menu,DL_GetElementLeft(elem),DL_GetElementTop(elem)+x)
}

function navMenu2(menu, elemName)
{
	var x;
	var y, z;
	col = document.getElementsByName(elemName);
	if (col == null ||
		col.length == 0) return;
	elem = col.item(0);

	if (elem.offsetHeight == null)
		x = 0;
	else
		x = elem.offsetHeight;
	//how to get the current width of that element? -> elem.offsetWidth
	y = menu.menuWidth - elem.offsetWidth;		
	//alert(z);
	window.MM_showMenu(menu,DL_GetElementLeft(elem)-y,DL_GetElementTop(elem)+x)
}

function caseStudies(nodeId, languageId)
{
	newWindow("News_CaseStudy.aspx?NodeId="+nodeId+"&amp;LanguageId="+languageId, "CaseStudy", 730, 600);//CaseStudyDemo.aspx
}

function popUp(URL)
{
	day = new Date();
	id = day.getTime();
	LeftPosition = (screen.width) ? (screen.width-600)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-500)/2 : 0;
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=1,statusbar=0,menubar=0,resizable=1,width=730,height=600,left = " + LeftPosition + ",top = " + TopPosition + "');");
}

function openWindow(theURL,winName,features) 
{
  window.open(theURL,winName,features);
}

function doSection (secNum){
//display the section if it's not displayed; hide it if it is displayed
if (secNum.style.display=="none"){secNum.style.display="block"}
else{secNum.style.display="none"}
}

function noSection (secNum){
//remove the section when user clicks in the opened DIV
if (secNum.style.display=="block"){secNum.style.display="none"}
}
