
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.0
  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 && document.getElementById) x=document.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 jump(menu){
  var loc = menu[menu.selectedIndex].value.split("|");
  if(loc.length == 2)
    window.open(loc[1], loc[0]);
	
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


function checkAll(wotForm,wotState) {
	for (a=0; a<wotForm.elements.length; a++) {
		if (wotForm.elements[a].id.indexOf("delete_") == 0) {
			wotForm.elements[a].checked = wotState ;
		}
	}
}

// These variables are for saving the original background colors
var previousElements=new Array();
var previousColors=new Array();
var highlightColor='#DDDDDD';

function highlightTableRow(tableRow)
{
  var i=0;
  // Restore color of the previously highlighted row
  for (i; i<previousElements.length; i++)
  {
    var myElement=previousElements[i];
    // hack!!! code to support Netscape 6 and 7
    if (previousColors[i]==0)
    {
      if (myElement.style)
      {
        myElement.style.background=0;
      }
    }
    // end hack
    else
    {
      myElement.style["backgroundColor"]=previousColors[i];
    }
    previousElements[i]=previousColors[i]=0;
  }
  // Highlight every cell on the row
  if (tableRow)
  {
    // The first child will be (or should be) a <TD>
    var tableCell=tableRow.firstChild;
    while (tableCell && tableCell.tagName!="TD")
    {
      tableCell=tableCell.nextSibling;
    }

    var i=0;
    // Loop through every sibling (a sibling of a cell should be a cell)
    // We then highlight every siblings
    while (tableCell)
    {
      // Make sure it's actually a cell (a TD)
      if (tableCell.tagName=="TD")
      {
        previousElements[i]=tableCell;
        // If no style has been assigned, assign it, otherwise Netscape will 
        // behave weird.
        if (!tableCell.style)
        {
          tableCell.style={};
        }
        else
        {
          // If, row color already defined, save it so we can restore the color
          // when the cursor is no longer over the row
          if (tableCell.parentNode.style["backgroundColor"])
          {
            previousColors[i]=tableCell.parentNode.style["backgroundColor"];
          }
          else
            previousColors[i]=tableCell.style["backgroundColor"];
        }
        // Assign the highlight color
        tableCell.style["backgroundColor"]=highlightColor;


        // Optional: alter cursor
        tableCell.style.cursor='default';
        i++;
      }
      // Go to the next cell in the row
      tableCell=tableCell.nextSibling;
    }
    tableRow.onMouseOut="highlightTableRow(0);";
  }
}



var weekdaystxt=["Sun", "Mon", "Tues", "Wed", "Thurs", "Fri", "Sat"]

function showLocalTime(container, offsetMinutes, timezonecode, displayversion){
if (!document.getElementById || !document.getElementById(container)) return
this.container=document.getElementById(container)
this.displayversion=displayversion
this.timezonecode=timezonecode
this.localtime=this.serverdate=new Date('<%=Now()%>')
this.localtime.setTime(this.serverdate.getTime()+offsetMinutes*60*1000) //add user offset to server time
this.updateTime()
this.updateContainer()
}

showLocalTime.prototype.updateTime=function(){
var thisobj=this
this.localtime.setSeconds(this.localtime.getSeconds()+1)
setTimeout(function(){thisobj.updateTime()}, 1000) //update time every second
}

showLocalTime.prototype.updateContainer=function(){
var thisobj=this
if (this.displayversion=="long")
this.container.innerHTML=this.localtime.toLocaleString()
else{
var timezonecode=this.timezonecode
var hour=this.localtime.getHours()
var minutes=this.localtime.getMinutes()
var seconds=this.localtime.getSeconds()
var ampm=(hour>=12)? "PM" : "AM"
var dayofweek=weekdaystxt[this.localtime.getDay()]
this.container.innerHTML=formatField(timezonecode)+" "+formatField(hour, 1)+":"+formatField(minutes)+":"+formatField(seconds)+" "+ampm+" ("+dayofweek+")"
}
setTimeout(function(){thisobj.updateContainer()}, 1000) //update container every second
}

function formatField(num, isHour){
if (typeof isHour!="undefined"){ //if this is the hour field
var hour=(num>12)? num-12 : num
return (hour==0)? 12 : hour
}
return (num<=9)? "0"+num : num//if this is minute or sec field
}


function toggleLayer(whichLayer)
{
	if (document.getElementById)
	{
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"block";
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
}//togglelayer


function selectAll(theField) {
var tempval=eval("document."+theField)
tempval.focus()
tempval.select()
}

function Toggle_Menu_Ins(item, imagefolder) {
   obj=document.getElementById(item);
   if (obj != null) {
	   visible=(obj.style.display!="none")
	   key=document.getElementById("X" + item);
	   imagefileExpand = imagefolder+"expand1.gif"
	   imagefileCollapse = imagefolder+"collapse1.gif"
	   if (visible) {
		 obj.style.display="none";
		 key.innerHTML="<img src='"+imagefileExpand+"' border=0>";
	   } else {
		  obj.style.display="block";
		  key.innerHTML="<img src='"+imagefileCollapse+"' border=0>";
	   }
   }
}


function Toggle_Menu_Ins2(item, imagefolder) {
   obj=document.getElementById(item);
   visible=(obj.style.display!="none")
   key=document.getElementById("X" + item);
   imagefileExpand = imagefolder+"expand2.gif"
   imagefileCollapse = imagefolder+"collapse2.gif"
   if (visible) {
     obj.style.display="none";
     key.innerHTML="<img src='"+imagefileExpand+"' border=0>";
   } else {
      obj.style.display="block";
      key.innerHTML="<img src='"+imagefileCollapse+"' border=0>";
   }
}

function Toggle_Help_Over(item) {
	obj=document.getElementById(item);
	if(obj != null)
		obj.style.display="block";
}

function Toggle_Help_Out(item) {
	obj=document.getElementById(item);
	if(obj != null)
		obj.style.display="none";
}


$(document).ready(function(){

	$("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled (Adds empty span tag after ul.subnav*)

	$("ul.topnav li span").click(function() { //When trigger is clicked...

		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click

		$(this).parent().hover(function() {
		}, function(){
			$(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
		});

		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() {
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});

	 //$('table .tableHeaderBG:first-child').css('border-radius','6px');
});



