/* Call this script like this:

<script src="/includes/javaScript/main.js"></script>

*/


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

function userLogin()  {
  document.loginForm.loginAction.value = "userLogin";
  document.loginForm.submit();
}

function userLogout()  {
  document.loginForm.loginAction.value = "userLogout";
  document.loginForm.submit();
}


// Function to open a new window
function NewWindow(mypage,myname,w,h,scroll){
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings =
	'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
	win = window.open(mypage,myname,settings)
}


// Function to make text blink.  
// In order for the text to blink, you have to tage it like this <blink>text that blinks</blink>
// Then set the <body> tag for the page to this:  <body onload="setInterval('blinkIt()',500)">
function blinkIt()  {
  if(!document.all)  {
    return;
  }  else  {
    for(i = 0; i < document.all.tags('blink').length; i++)  {
      s = document.all.tags('blink')[i];
      s.style.visibility = (s.style.visibility == 'visible') ? 'hidden' : 'visible';
    }
  }
}


// Function to reload a page with new parameters, called from jump-type drop down boxes
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


// This function takes a drop down called "dropDownName" and loops through its options looking for "selectedValue".  When it finds it, it sets the selectedIndex
function setDropDownSelected(dropDownName, selectedValue)  {
  //alert('setting ' + rightName + ' to ' + newValue);
  var y = document.getElementById(dropDownName);
  var i;
  for (i = 0; i < y.options.length; i++) {
  	//alert('checking option: ' + y.options[i].value);
    if(y.options[i].value == selectedValue) {
      y.selectedIndex = i;
    }
  }
}


// Function to trap the enter key and submit a form
function submitOnEnter(e, formName)  {
  var intKey = (window.Event) ? e.which : e.keyCode;
  if(intKey == 13)  { //enter key
    userLogin();
  }
  return;
}


// Function to show Divs when its tab is clicked on
function showDiv(e)  {
  var x=document.getElementById(e);
  if (x)x.className='moduleDataDivBlue';
  var x=document.getElementById(e + 'TabSelected');
  if (x)x.className='moduleTabDivSelected';
  var x=document.getElementById(e + 'TabNotSelected');
  if (x)x.className='hide';
}


// Function to hide Divs when another Div's tab is clicked on
function hideDiv(e)  {
  var x=document.getElementById(e);
  if (x)x.className="hide";
  var x=document.getElementById(e + 'TabSelected');
  if (x)x.className='hide';
  var x=document.getElementById(e + 'TabNotSelected');
  if (x)x.className='moduleTabDivNotSelected';
}


// Function to show page when its tab is clicked on
function showPage(e)  {
  var x=document.getElementById('page' + e);
  if (x)x.className='insetSection';
  var x=document.getElementById(e + 'PageSelected');
  if (x)x.className='pageSelected';
  var x=document.getElementById(e + 'PageNotSelected');
  if (x)x.className='hide';
}


// Function to hide page when another page's tab is clicked on
function hidePage(e)  {
  var x=document.getElementById('page' + e);
  if (x)x.className="hide";
  var x=document.getElementById(e + 'PageSelected');
  if (x)x.className='hide';
  var x=document.getElementById(e + 'PageNotSelected');
  if (x)x.className='pageNotSelected';
}

// This function adds a drop shadow behind a div
function divShadow(elementID)  {

  // Get ready to create shadows, we need dimensions on the div
  var divHeight  = document.getElementById(elementID).offsetHeight;
  var divWidth   = document.getElementById(elementID).offsetWidth;
  var divBorder  = document.getElementById(elementID).style.border.substr(0, 1) ? document.getElementById(elementID).style.border.substr(0, 1) : 0;
  var divZIndex  = document.getElementById(elementID).style.zIndex;

  // Create the shadowBottomLeftDiv
  var shadowTop  = (divHeight * 1) - 12 - (divBorder * 1);
  var shadowLeft = (-19);
  var newdiv = document.createElement('div');
  newdiv.setAttribute('id', 'shadowBottomLeftDiv');
  newdiv.style.position = "absolute";
  newdiv.style.width = "30px";
  newdiv.style.height = "30px";
  newdiv.style.left = shadowLeft + "px";
  newdiv.style.top = shadowTop + "px";
  newdiv.style.backgroundImage = 'url(/img/shadow/bottomLeft.png)';
  newdiv.style.layerBackgroundImage = 'url(/img/shadow/bottomLeft.png)';
  newdiv.style.zIndex = divZIndex;
  newdiv.style.border = "0px";
  document.getElementById(elementID).appendChild(newdiv);

  // Create the shadowTopLeftDiv
  var shadowTop  = (-18);
  var shadowLeft = (-18);
  var newdiv = document.createElement('div');
  newdiv.setAttribute('id', 'shadowTopLeftDiv');
  newdiv.style.position = "absolute";
  newdiv.style.width = "30px";
  newdiv.style.height = "30px";
  newdiv.style.left = shadowLeft + "px";
  newdiv.style.top = shadowTop + "px";
  newdiv.style.backgroundImage = 'url(/img/shadow/topLeft.png)';
  newdiv.style.layerBackgroundImage = 'url(/img/shadow/topLeft.png)';
  newdiv.style.zIndex = divZIndex;
  newdiv.style.border = "0px";
  document.getElementById(elementID).appendChild(newdiv);

  // Create the shadowTopRightDiv
  var shadowTop  = (-18);
  var shadowLeft = (divWidth * 1) - 12 - (divBorder * 1);
  var newdiv = document.createElement('div');
  newdiv.setAttribute('id', 'shadowTopRightDiv');
  newdiv.style.position = "absolute";
  newdiv.style.width = "30px";
  newdiv.style.height = "30px";
  newdiv.style.left = shadowLeft + "px";
  newdiv.style.top = shadowTop + "px";
  newdiv.style.backgroundImage = 'url(/img/shadow/topRight.png)';
  newdiv.style.layerBackgroundImage = 'url(/img/shadow/topRight.png)';
  newdiv.style.zIndex = divZIndex;
  newdiv.style.border = "0px";
  document.getElementById(elementID).appendChild(newdiv);

  // Create the shadowBottomRightDiv
  var shadowTop  = (divHeight * 1) - 12 - (divBorder * 1);
  var shadowLeft = (divWidth * 1) - 12 - (divBorder * 1);
  var newdiv = document.createElement('div');
  newdiv.setAttribute('id', 'shadowBottomRightDiv');
  newdiv.style.position = "absolute";
  newdiv.style.width = "30px";
  newdiv.style.height = "30px";
  newdiv.style.left = shadowLeft + "px";
  newdiv.style.top = shadowTop + "px";
  newdiv.style.backgroundImage = 'url(/img/shadow/bottomRight.png)';
  newdiv.style.layerBackgroundImage = 'url(/img/shadow/bottomRight.png)';
  newdiv.style.zIndex = divZIndex;
  newdiv.style.border = "0px";
  document.getElementById(elementID).appendChild(newdiv);

  // Create the shadowTopDiv
  var shadowTop  = (-18);
  var shadowLeft = (12);
  var shadowWidth = (divWidth * 1) - 24 - (divBorder * 1);
  var newdiv = document.createElement('div');
  newdiv.setAttribute('id', 'shadowTopDiv');
  newdiv.style.position = "absolute";
  newdiv.style.width = shadowWidth + "px";
  newdiv.style.height = "19px";
  newdiv.style.left = shadowLeft + "px";
  newdiv.style.top = shadowTop + "px";
  newdiv.style.backgroundImage = 'url(/img/shadow/top.png)';
  newdiv.style.layerBackgroundImage = 'url(/img/shadow/top.png)';
  newdiv.style.zIndex = divZIndex;
  newdiv.style.border = "0px";
  document.getElementById(elementID).appendChild(newdiv);

  // Create the shadowLeftDiv
  var shadowTop  = (12);
  var shadowLeft = (-18);
  var shadowHeight = (divHeight * 1) - 24 - (divBorder * 1);
  var newdiv = document.createElement('div');
  newdiv.setAttribute('id', 'shadowLeftDiv');
  newdiv.style.position = "absolute";
  newdiv.style.width = "19px";
  newdiv.style.height = shadowHeight + "px";
  newdiv.style.left = shadowLeft + "px";
  newdiv.style.top = shadowTop + "px";
  newdiv.style.backgroundImage = 'url(/img/shadow/left.png)';
  newdiv.style.layerBackgroundImage = 'url(/img/shadow/left.png)';
  newdiv.style.zIndex = divZIndex;
  newdiv.style.border = "0px";
  document.getElementById(elementID).appendChild(newdiv);

  // Create the shadowBottomDiv
  var shadowTop  = (divHeight * 1) - 1 - (divBorder * 1);
  var shadowLeft = (11);
  var shadowWidth = (divWidth * 1) - 23 - (divBorder * 1);
  var newdiv = document.createElement('div');
  newdiv.setAttribute('id', 'shadowBottomDiv');
  newdiv.style.position = "absolute";
  newdiv.style.width = shadowWidth + "px";
  newdiv.style.height = "19px";
  newdiv.style.left = shadowLeft + "px";
  newdiv.style.top = shadowTop + "px";
  newdiv.style.backgroundImage = 'url(/img/shadow/bottom.png)';
  newdiv.style.layerBackgroundImage = 'url(/img/shadow/bottom.png)';
  newdiv.style.zIndex = divZIndex;
  newdiv.style.border = "0px";
  document.getElementById(elementID).appendChild(newdiv);

  // Create the shadowRightDiv
  var shadowTop  = (12);
  var shadowLeft = (divWidth * 1) - 1 - (divBorder * 1);
  var shadowHeight = (divHeight * 1) - 24 - (divBorder * 1);
  var newdiv = document.createElement('div');
  newdiv.setAttribute('id', 'shadowRightDiv');
  newdiv.style.position = "absolute";
  newdiv.style.width = "19px";
  newdiv.style.height = shadowHeight + "px";
  newdiv.style.left = shadowLeft + "px";
  newdiv.style.top = shadowTop + "px";
  newdiv.style.backgroundImage = 'url(/img/shadow/right.png)';
  newdiv.style.layerBackgroundImage = 'url(/img/shadow/right.png)';
  newdiv.style.zIndex = divZIndex;
  newdiv.style.border = "0px";
  document.getElementById(elementID).appendChild(newdiv);
  
}

MM_reloadPage(true);
