function swapImgRestore() {
  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function preloadImages() {
  var d=document; if(d.images){ if(!d.p) d.p=new Array();
  var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
  if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}
function findObj(n, d) {
  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=findObj(n,d.layers[i].document); return x;
}
function swapImage() {
  var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
  if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function  _CF_checkfillIn(_CF_this) {
  location.href=document.forms.fillIn.newURL.value; return false;
  return true;
}

function jump(field, ctr) {
  var frm=field.form;
  for (var x=0; x<frm.elements.length; x++) {
	  if (frm.elements[x]==field) {
		  var newField=x+1;
		  break;
	  }
	}
  if(field.value.length==ctr)
	  frm.elements[newField].focus();
  return;
}

function navON(navname){
  if (document.getElementById(navname)){
     document.getElementById(navname).style.display = 'block';
  }
}
  
function navOFF(navname){
  if (document.getElementById(navname)){
    document.getElementById(navname).style.display = 'none';
  }
}

var secs
var timerID = null
var timerRunning = false
var delay = 1000
var whererul

function InitializeTimer(where)
{
  whererul = where;
    // Set the length of the timer, in seconds
    secs = 15
    StopTheClock();
    StartTheTimer();
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{
    if (secs==0)
    {
        StopTheClock()
        // Here's where you put something useful that's
        // supposed to happen after the allotted time.
        // For example, you could display a message:
    //alert(whererul);
    window.opener.location.href = whererul;
    window.close();
    }
    else
    {
        self.status = secs
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}


function postBackHiddenField(hiddenFieldID) {
  var hiddenField = $get(hiddenFieldID);
  if (hiddenField) {
      hiddenField.value = (new Date()).getTime();
      __doPostBack(hiddenFieldID,'');
  } else {
    //alert("hiddenField not found!");
  }
}
function linkOffsiteClick(obj) {
  if(obj.checked){
    document.getElementById('ctl00_MainContent_NamePrefix').style.display="none";
    document.getElementById('ctl00_MainContent_FilePathTitle').innerHTML = "URL:";
    if(document.getElementById('ctl00_MainContent_Name').value=="") {
      document.getElementById('ctl00_MainContent_Name').value="http://";
    }
  } else {
    document.getElementById('ctl00_MainContent_NamePrefix').style.display="inline";
    document.getElementById('ctl00_MainContent_FilePathTitle').innerHTML = "File Path:";
    if(document.getElementById('ctl00_MainContent_Name').value=="http://") {
      document.getElementById('ctl00_MainContent_Name').value="";
    }
  }
}
function highlightQuestion(divId) {
  if(document.getElementById) {
    for(i=1;i<=13;i++) {
      if(document.getElementById("q"+i)) {
        document.getElementById("q"+i).style.border = "0";
        document.getElementById("q"+i).style.padding = "0";
        document.getElementById("q"+i).style.backgroundColor = "#FFFFFF";
      }
    }
    if(document.getElementById(divId)) {
      document.getElementById(divId).style.border = "solid 1px #006576";
      document.getElementById(divId).style.padding = "4px";
      document.getElementById(divId).style.backgroundColor = "#FFFFCC";
    }
  }
}


function curDate() {
  var d=new Date();
  return (d.getMonth()+1)+"/"+d.getDate()+"/"+d.getFullYear()+" "+((d.getHours()==0) ? "12" : ((d.getHours()>12) ? "1" : d.getHours()))+":"+((d.getMinutes().toString().length==1) ? "0" : "")+d.getMinutes()+":"+((d.getSeconds().toString().length==1) ? "0" : "")+d.getSeconds()+" "+((d.getHours()>12) ? "PM" : "AM");
}

function showDay(val) {
  if(document.getElementById("ctl00_MainContent_date_greater") && document.getElementById("ctl00_MainContent_date_less")) {
    document.getElementById("ctl00_MainContent_date_greater").value=val;
    document.getElementById("ctl00_MainContent_date_less").value=val;
  } else if(document.getElementById("ctl00_MainContent_date_greater_hidden") && document.getElementById("ctl00_MainContent_date_less_hidden")) {
    document.getElementById("ctl00_MainContent_date_greater_hidden").value=val;
    document.getElementById("ctl00_MainContent_date_less_hidden").value=val;
  }
}
  
function clickInput()
{
    if($find('popupCalBhvr')!=null) 
      if(typeof($find('popupCalBhvr').hide)=="function")
        $find('popupCalBhvr').hide();
}

function pageLoad()
{
    // the ensureCalendar must be called in the pageLoad to hookup the PopupBehavior
    if($find('popupCalBhvr')!=null) 
      if(typeof($find('popupCalBhvr')._ensureCalendar)=="function")
        $find('popupCalBhvr')._ensureCalendar();
}

/*
    Given an element (el) and an event (ev) this method fires a javascript
    function attached to the element...such as onclick, onfocus, onchange etc...
*/    
function FireEvent(el, ev)
{
    if (document.createEventObject) 
    {
        el.fireEvent(ev);
    } 
    else if (document.createEvent) 
    {
        var localE = document.createEvent("HTMLEvents");
        localE.initEvent(ev.substring(2, ev.length), true, true);
        el.dispatchEvent(localE);        
    }    
}
    
function hideCal(cal)
{
  cal.hide();
}

/*
    Takes the Date value in the txtHidden field and sees if it is different from
    the one already in the parentElement. If they are different, then change the
    value of the parentElement to reflect the new date and fire the onchange event of the parent.
*/  
function UpdateClientDate(cal)
{
    if($find('popupCalBhvr')==null)
      return;
    var parentDateElement = $find('popupCalBhvr')._popupBehavior.get_parentElement();
    var hiddenTxtBox = $get('ctl00_MainContent_txtHidden'); // the ID could be ctl00_txtHidden if you're using master pages
     
    if(parentDateElement.value != hiddenTxtBox.value)
    {
        parentDateElement.value = hiddenTxtBox.value;        
        FireEvent(parentDateElement, 'onchange');
    }
    
    $find('popupCalBhvr').hide();
}   

function ShowPopupCalendar(calPopupTarget)
{     
    
    $find('popupCalBhvr').hide();  // hide the calendar if it already showing
    
    // set the parentElement of the CalendarPopup behavior...this is what the calendar will popup under.        
    $find('popupCalBhvr')._popupBehavior.set_parentElement(calPopupTarget);       
    
    var hiddenTxtBox = $get('ctl00_MainContent_txtHidden'); // the ID could be ctl00_txtHidden if you're using master pages
        
    var theDate = new Date(calPopupTarget.value); // figure out what date is selected...default is today
    if(isNaN(theDate))
    {
        // Set the currently selected date to today's date b/c no date exists
        // in the parentElement right now.
        $find('popupCalBhvr').set_selectedDate(new Date());
        hiddenTxtBox.value = '';           
    }
    else
    {
        // Set the currently selected date to that date that already exists in the
        // parentElement.
        $find('popupCalBhvr').set_selectedDate(theDate);
        hiddenTxtBox.value = calPopupTarget.value;            
    }
    
    // fire the onfocus event of the hiddentTextBox to make the Calendar popup.                
    FireEvent(hiddenTxtBox, 'onfocus');
}

function setCaretTo(element, pos) { 
	if (element.setSelectionRange)
	{
	  if(navigator.userAgent.indexOf("Gecko")!=-1)
	    element.focus();
		element.setSelectionRange(pos,pos);
	}
	else if (element.createTextRange)
	{
		var range = element.createTextRange();
		range.move("character",pos);
		range.select();
	}
} 

function reportMonthChanged(month, date_greater, date_less) {
  if(typeof(month)!="undefined" && typeof(date_greater)!="undefined" && typeof(date_less)!="undefined") {
    var mval = month.options[month.selectedIndex].value;
    if(mval=="all") {
      date_greater.value = "";
      date_less.value = "";
    } else if(mval!="") {
      date_greater.value = mval.substring(0,mval.indexOf("-"));
      date_less.value = mval.substring(mval.indexOf("-") + 1);
    }
  }
}

/***********************************************
* AnyLink Drop Down Menu-  Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
var menuwidth='200' //default menu width
var menubgcolor='#ababab'  //menu bgcolor
var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?
/////No further editting needed
var ie4=document.all
var ns6=document.getElementById&&!document.all
if (ie4||ns6)
document.write('<div id="dropmenudiv" style="position: absolute;visibility:hidden;overflow: hidden;width:200px;background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')
//document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')
function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}
function showhide(obj, e, visible, hidden, menuwidth){
if (ie4||ns6)
//dropmenuobj.style.left=dropmenuobj.style.top=-500
if (menuwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
//dropmenuobj.widthobj.width=menuwidth
dropmenuobj.widthobj.width=200
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}
function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="leftedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}
function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}
function dropdownmenu(obj, e, menucontents, menuwidth){
if (menucontents.length > 0) {
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)
if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "leftedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}
}
return clickreturnvalue()
}
function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}
function contains_ns6(a, b) {
if(!b)return false;
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}
function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}
function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}
function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}
function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}
if (hidemenu_onclick=="yes")
document.onclick=hidemenu

function doClearInterval() {
  if(typeof(interval)!="undefined") {
    clearInterval(interval);
  }
}

window.onload = function() {
  setTimeout("doClearInterval()",1000);
}