// JavaScript Document for Global Mobility
// NOTE not all these functions are used, but this is our standard catalog of functions for internal sites


 //include iFrame function
function includeIframe(url, height, width, border, scrolling)
 {
   document.write("<iframe height='"+height+"' width='"+width+"' frameborder='"+border+"' scrolling='"+scrolling+"'src='"+url+"'></iframe>");
 }   
 function windowOpen(url,left,top,width,height,csn,lsn) { 
	page = envn.GlobalPortalRedirect + 'csn=' + csn + '&lsn=' + lsn + '&url=' + url;
	var win = window.open(page,'_blank','left='+left+',top='+top+','+width+','+height+',resizable=yes,menubar=no,toolbar=no,status=no,scrollbars=yes'); win.focus(); 
 
}
 
 //Open PopUp Window -adding portal services popup
  var popupWindow ='';

 function windowOpenPopUp(url,left,top,lsn, pwidth, pheight) 
{ 
	var dPage ='';
	var page = envn.GlobalPortalRedirect + "csn=HelpPopUp&lsn=" + lsn + "&url=" + url;
	//alert('left='+left+',top='+top+',width='+pwidth+',height='+pheight);
	pheight = parseInt(pheight);
	pwidth = parseInt(pwidth);

	var windowproperties = "left="+left+",top="+top+",width="+pwidth+",height="+pheight+",resizable=no,menubar=no,toolbar=no,status=no,scrollbars=no";
    var  openin = lsn;
      
	 if (popupWindow !='' && !popupWindow.closed && popupWindow.location)
	{
		 popupWindow.close();
	}
		dPage = page;
	//	alert(windowproperties);
		popupWindow = window.open(dPage,openin,windowproperties);
		popupWindow.focus();
	
	return; 
 }

//Retrieves cursor position as X , Y coordinates and returns int array
function getMousePos(e){ 
	posx=0;posy=0; 
	var ev=(!e)?window.event:e; 
	posx = ev.screenX;
	posy = ev.screenY;
	s = posx+','+posy;  
	ss = s.split(',');  //place values into array
	ss[0] = parseInt(ss[0]); //Convert text numbers to their numerical equavalent
	ss[1] = parseInt(ss[1]); //Convert text numbers to their numerical equavalent
	return(ss);
}

// Gathers information required to open PopUp windows
function OpenPopUp(e,url,lsn, pwidth, pheight) 
{
	Pos = getMousePos(e);
	PosY = Pos[1]+21;	// moves 21 px down from the curson
	PosX = Pos[0]-200;  //Move top left corner of window over 200px so window opens to left of cursor	

	windowOpenPopUp(url,PosX,PosY,lsn, pwidth, pheight);
}


function CreateFlashObject(URL, WIDTH, HEIGHT, ALIGN, OBJECTID, OBJECTNAME, PARAMS)
{
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+WIDTH+'" height="'+HEIGHT+'" id="'+OBJECTID+'" name="'+OBJECTNAME+'" align="'+ALIGN+'">');
document.write('<param name="movie" value="'+URL+'">');
   for(key in PARAMS) {
      document.write('<param name="'+key+'" value="'+PARAMS[key]+'">');
   }
 
embed = '<embed type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" src="'+URL+'" width="'+WIDTH+'" height="'+HEIGHT+'" id="'+OBJECTID+'" name="'+OBJECTNAME+'" align="'+ALIGN+'" ';
   for(key in PARAMS) {
      embed += [key] +'="'+ PARAMS[key] +'" ';
   }
embed += '/>';
document.write(embed);
document.write('</object>');
}
                                                                                          

//Collapsable section function
function csToggle(csTextDiv, csImg, csImgsrc1, csImgsrc2)
 {
   if (csTextDiv.style.display=="none")
   {
     csImg.src=csImgsrc1;
     csTextDiv.style.display="";
   }
   
   else 
   {   
     csImg.src=csImgsrc2;
     csTextDiv.style.display="none";
   }
 }

 //Collapsable section function specific
function csArrowToggle(csTextDiv, csImg)
 {
   if (csTextDiv.style.display=="none")
   {
     csImg.src =envn.image + "arrow_down.gif";
     csTextDiv.style.display="";
   }
   
   else 
   {   
     csImg.src= envn.image + "arrow.gif";
     csTextDiv.style.display="none";
   }
 }
 
//Create Applet
function CreateApplet(CODEBASE, CODE, ARCHIVE, WIDTH, HEIGHT, PARAMS)
{
document.write('<applet codebase="'+CODEBASE+'" code="'+CODE+'" archive="'+ARCHIVE+'" width="'+WIDTH+'" height="'+HEIGHT+'" mayscript>');
   for(key in PARAMS) {
      document.write('<param name="'+key+'" value="'+PARAMS[key]+'">');
   }
document.write('</applet>');
}

