/*==============================================================================
		estylez.js
		Client-side scripting
==============================================================================*/

//window.onresize = handleWindowResize;


//===================================================================================================== ISM BUILT FUNCTIONS


function handleWindowResize()
{
	var isGeckoBrowser = document.getElementById && !document.all;
	var oMenu = document.getElementById("left_menu");
	var Xoffset = -391;

	var x = (isGeckoBrowser) ? document.width : document.body.scrollWidth;
	oMenu.style.left = (x / 2) + Xoffset;
}


function ism_swapImageById(strTargetID, strImagePath)
// Swaps src of element with ID == strTargetID
{
	document.getElementById(strTargetID).src = strImagePath
}


function showInfoPopup(oSender, strContent)
{	
	// Insert the content into the div
	document.getElementById("info_popup").innerHTML = strContent
	
	// Position the div based on the anchor's position
	infoPopupStyle.left = oSender.offsetLeft + Xoffset
	infoPopupStyle.top = oSender.offsetTop + Yoffset
	
	// Display the div
	infoPopupStyle.display="block"
	
	startObjectFadeIn(document.getElementById("info_popup"))
}

function hideInfoPopup()
{
	startObjectFadeOut(document.getElementById("info_popup"))
	//infoPopupStyle.display = "none"
}

function doNothing() {}


//======================================================================================================== Fade scripts

var global_iFadeStep = 5		// By what percent should I change the opacity per cycle?
var global_iFadeRate = 1		// How long should a fade cycle be (msec)?

var global_iCurrentOpacity = 0
var global_oTimerOpacity
var global_oTarget


function startObjectFadeIn(oTarget)
{
	global_oTarget = oTarget									// has to be accessible to the timer after this function has lost scope
	clearInterval(global_oTimerOpacity)
	global_oTimerOpacity = setInterval("doObjectFade('in')",global_iFadeRate)
}

function startObjectFadeOut(oTarget)
{
	global_oTarget = oTarget									// has to be accessible to the timer after this function has lost scope
	clearInterval(global_oTimerOpacity)
	global_oTimerOpacity = setInterval("doObjectFade('out')",global_iFadeRate)
}

function setObjectOpacity(iOpacity)
// Sets the opacity of oTarget based on a 0-100 index where 0 is transparent and 100 is opaque.
{
	// Are we in IE?
	if (window.global_oTarget.filters) { global_oTarget.filters.alpha.opacity = iOpacity }
	else { global_oTarget.style.MozOpacity = iOpacity / 100 }
}

function doObjectFade(strFadeDirection)
// Handles actually changing the opacity of the object depending on if we're 
// fading in or out.  Clears timer if we're done fading.
{
	// Are we fading in and we're not maxed out yet?
	if (strFadeDirection == "in" && global_iCurrentOpacity < 100)
	{
		setObjectOpacity(global_iCurrentOpacity += global_iFadeStep)
	}
	// Are we fading out and we haven't bottomed out?
	else if (strFadeDirection == "out" && global_iCurrentOpacity > 0)
	{
		setObjectOpacity(global_iCurrentOpacity -= global_iFadeStep)
	}
	else if (window.global_oTimerOpacity)
	{
		clearInterval(global_oTimerOpacity)
		global_iCurrentOpacity = (strFadeDirection == "in") ? 100 : 0
		if (strFadeDirection == "out") { global_oTarget.style.display = "none" }
	}
}



//===================================================================================================== CANNED FUNCTIONS


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function popup(msg,bak){
var content="<TABLE WIDTH=550 BORDER=1 BORDERCOLOR=#999999 CELLPADDING=4 CELLSPACING=0 style=border-collapse: collapse "+
"BGCOLOR="+bak+"><TD ALIGN=left>"+msg+"</FONT></TABLE>";
yyy=Yoffset;
 if(ns4){skn.document.write(content);skn.document.close();skn.visibility="visible"}
 if(ns6){document.getElementById("dek").innerHTML=content;skn.display=''}
 if(ie4){document.all("dek").innerHTML=content;skn.display=''}
}

function get_mouse(e){
var x=(ns4||ns6)?e.pageX:event.x+document.body.scrollLeft;
skn.left=x+Xoffset;
var y=(ns4||ns6)?e.pageY:event.y+document.body.scrollTop;
skn.top=y+yyy;
}

function kill(){
yyy=-1000;
if(ns4){skn.visibility="hidden";}
else if (ns6||ie4)
skn.display="none"
}


MM_preloadImages('layout_images/btn_next_over.gif','layout_images/btn_prev_over.gif','layout_images/btn_green_reg_over.gif','layout_images/btn_green_family_over.gif','layout_images/btn_green_cit_over.gif','layout_images/btn_green_edu_over.gif','layout_images/btn_green_schools_over.gif','layout_images/btn_green_tests_over.gif','layout_images/btn_green_extra_over.gif','layout_images/btn_green_work_over.gif','layout_images/btn_green_honors_over.gif','layout_images/btn_green_fin_over.gif','layout_images/btn_green_essays_over.gif','layout_images/btn_green_glaf_over.gif','layout_images/btn_green_elsie_over.gif','layout_images/btn_green_reg_over_check.gif','layout_images/btn_green_family_over_check.gif','layout_images/btn_green_cit_over_check.gif','layout_images/btn_green_edu_over_check.gif','layout_images/btn_green_schools_over_check.gif','layout_images/btn_green_tests_over_check.gif','layout_images/btn_green_extra_over_check.gif','layout_images/btn_green_work_over_check.gif','layout_images/btn_green_honors_over_check.gif','layout_images/btn_green_fin_over_check.gif','layout_images/btn_green_essays_over_check.gif','layout_images/btn_green_glaf_over_check.gif','layout_images/btn_green_elsie_over_check.gif')


// ***EOF*** \\

