// javascript includes

moQualify = (((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 3 )) || ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4 )))

function PreloadThis(img)
{
  if(document.images)
  {
    var a=new Image();
  }
  a.src=img;
  return a;
}

function MouseHandle(img, fm, msg)
{
  if(document.images)
  {
    document.images[fm].src=img;
  }
  status = msg;
  return true;
}

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_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function go1()
{
  if (document.lookup1.product.options[document.lookup1.product.selectedIndex].value != "")
  {
    parent.location = document.lookup1.product.options[document.lookup1.product.selectedIndex].value
  }
}

function go2()
{
  if (document.lookup2.product.options[document.lookup2.product.selectedIndex].value != "")
  {
    parent.location = document.lookup2.product.options[document.lookup2.product.selectedIndex].value
  }
}

function go3()
{
  if (document.lookup3.product.options[document.lookup3.product.selectedIndex].value != "")
  {
    parent.location = document.lookup3.product.options[document.lookup3.product.selectedIndex].value
  }
}

function openpage(page,w,h)
{
  var options = 'width='+w+',height='+h;
  colleges = window.open(page,"colleges",options);
  colleges.window.focus();
}


function openimagewindow(image, windowTitle, fontcolor)
{
		lrgimg = window.open("","lrgimgwin","width=750, height=440, scrollbars=0");
		lrgimg.moveTo(100,100)
		lrgimg.document.write("<html><title>" + windowTitle +"</title><body leftmargin='0' topmargin='0' marginheight='0' marginwidth='0' bgcolor='#ffffff' onload='self.resizeTo(document.popwindow.width+36,document.popwindow.height+120)'>")
		lrgimg.document.write("<table align='center' border='0' cellpadding='0' cellspacing='0'><tr><td><img src='../spirit/graphics/single_pixel.gif' width='1' height='5' alt='' border='0'></td></tr>")
		lrgimg.document.write("<tr><td align='right'><a href='' onclick='javascript:self.close()'><font size='2' color='" + fontcolor + "' face='arial'><B>Close window</B></font></a></td></tr>")
		lrgimg.document.write("<tr><td align='center'><img src='../spirit/graphics/single_pixel.gif' width='1' height='8' alt='' border='0'><br><img src='" + image + "' name='popwindow'></td></tr>")
		lrgimg.document.write("</table></body></html>")
		lrgimg.document.close()
		lrgimg.focus()
}

//----------------------------------------------------------------------------------
//
// mOvr(src,clrOver) - called from mouseover event to change pointer to a hand and
//                     to change the color of the mouseovered item to the specified
//                     color.
//
//----------------------------------------------------------------------------------
var alreadyclicked = 0;

function mOvr(src,clrOver)
{
  if (!src.contains(event.fromElement))
  {
    if (alreadyclicked == 0)
    {
      src.style.cursor = 'hand';
    }
    src.bgColor = clrOver;
  }
}

function mOut(src,clrIn)
{
  if (!src.contains(event.toElement))
  {
    if (alreadyclicked == 0)
    {
      src.style.cursor = 'default';
    }
    src.bgColor = clrIn;
  }
}

function mClk(src)
{
  if(event.srcElement.tagName=='TD')
  {
    //prompt(src.children.tags('A')[0]);
    alreadyclicked = 1;
    src.children.tags('A')[0].click();
    //src.style.cursor = 'busy';
  }
}

//-------------------------------------------------------------------------------------------------
//
// update_form(formname, formtask, misc, block) - called from mouseover event to submit a form with
//                                                the specified form name but first will update the
//                                                value of the hidden form element 'Task' and the
//                                                values of the hidden form elements 'Misc' and
//                                                'Block' if they are specified.
//
//-------------------------------------------------------------------------------------------------
function update_form(formname, formtask, misc, misc2, misc3, misc4, misc5, misc6, misc7)
{
  if (formtask)
  {
    document[formname].elements.Task.value=formtask;
  }
  if (misc)
  {
    document[formname].elements.Misc.value=misc;
  }
  if (misc2)
  {
    document[formname].elements.Misc2.value=misc2;
  }
  if (misc3)
  {
    document[formname].elements.Misc3.value=misc3;
  }
  if (misc4)
  {
    document[formname].elements.Misc4.value=misc4;
  }
  if (misc5)
  {
    document[formname].elements.Misc5.value=misc5;
  }
  if (misc6)
  {
    document[formname].elements.Misc6.value=misc6;
  }
  if (misc7)
  {
    document[formname].elements.Misc7.value=misc7;
  }
  document[formname].submit();
}

function send_form(formaction)
{
  document.forms.main.action=formaction;
  document.main.submit();
}

function submit_form(formname)
{
  document[formname].submit();
}

var windowNameArray = null
var windowPntrArray = null
var browserType = "Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)"

function launchWindow( url, HT, WD )
{
  var windowOptions
  var myLocation = url
  var WN = "newWindow"
  var AR = "yes"
  var TB = "no"
  var LC = "no"
  var SB = "no"
  var DR = "no"
  var ST = "no"
  var MB = "no"
  var RS = "yes"
  var CH = "yes"
  switch( arguments.length )
  {
    case 16:
    case 15:
    case 14:
    case 13: CH = arguments[12];
    case 12: RS = arguments[11];
    case 11: MB = arguments[10];
    case 10: ST = arguments[9];
    case  9: DR = arguments[8];
    case  8: SB = arguments[7];
    case  7: LC = arguments[6];
    case  6: TB = arguments[5];
    case  5: AR = arguments[4];
    case  4: WN = arguments[3];
  }

  windowOptions  = "height="
  windowOptions += HT
  windowOptions += ",width="
  windowOptions += WD
  windowOptions += ",alwaysRaised="
  windowOptions += AR
  windowOptions += ",toolbar="
  windowOptions += TB
  windowOptions += ",location="
  windowOptions += LC
  windowOptions += ",scrollbars="
  windowOptions += SB
  windowOptions += ",directories="
  windowOptions += DR
  windowOptions += ",status="
  windowOptions += ST
  windowOptions += ",menubar="
  windowOptions += MB
  windowOptions += ",resizable="
  windowOptions += RS
  windowOptions += ",copyhistory="
  windowOptions += CH
  if( ! windowNameArray )
  {
    windowNameArray = new Array()
    windowPntrArray = new Array()
  }
  for( index=0; index < windowNameArray.length; ++index )
  {
    if( windowNameArray[index] == WN )
    {
      break
    }
  }

  var msieBrowser = navigator.appName.indexOf("Microsoft") != -1
  if( ! windowPntrArray[index] || windowPntrArray[index].closed  )
  {
    windowNameArray[index] = WN
    windowPntrArray[index] = window.open( myLocation, WN ,windowOptions )
  }
  else
  {
    if( msieBrowser )
    {
      windowPntrArray[index].close()
      while( ! windowPntrArray[index].closed )
      {
      }
      windowPntrArray[index] = window.open( myLocation, WN ,windowOptions )
    }
    else
    {
      windowPntrArray[index].focus()
    }
  }
}

function openmodule(filename)
{
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4 ))
  {
    //alert('popup qulified');
    var popupQualify = 1;
  }
  else
  {
   // alert('popup not qualified');
    var popupQualify = -1;
  }

  //var NN = (document.layers ? true : false);
  if ( popupQualify != 1 )
  {
    var options = 'width=400,height=300';
    forgotpassword = window.open('filename.html','filename',options);
    forgotpassword.window.focus();
  }
  else
  {
    dialogoptions  = 'dialogHeight:300px;'
    dialogoptions += 'dialogWidth:400px;'
    dialogoptions += 'scroll:no;'
    dialogoptions += 'status:no;'
    dialogoptions += 'help:no;'
    dialogoptions += 'edge:raised;'
    dialogoptions += 'center:yes;'
    window.showModalDialog('filename.html','', dialogoptions);
  }
}

function toggle_display_state(curobj)
{
  if (curobj)
  {
    if (document.getElementById(curobj).style.display=="none")
    {
      document.getElementById(curobj).style.display="block";
    }
    else
    {
      document.getElementById(curobj).style.display="none";
    }
  }
}

function prefill_field(formname, field1, field2)
{
    if (formname)
    {
        if (document.getElementById(field2).value == '')
        {
            document.getElementById(field2).value=document.getElementById(field1).value;
        }
        else
        {
            //alert ('skipp update because a value exists:' + document.getElementById(field2).value);
        }
    }
}

