function which( whichLayer ) { if( whichLayer.style ) return whichLayer; if( document.getElementById ) return document.getElementById( whichLayer ); if( document.all ) return document.all[whichLayer]; if( document.layers ) document.layers[whichLayer]; return null; }
function toggleLayer( whichLayer ) { var vis = which(whichLayer).style;  vis.display = (vis.display==''||vis.display=='block')?'none':'block'; }
function hideLayer( whichLayer ) { which(whichLayer).style.display='none'; }
function showLayer( whichLayer ) { which(whichLayer).style.display='block'; }
function showLayerHideRest(layers, layerName) { for(var x=0;x<layers.length;x++) if (layers[x]==layerName)  showLayer(layers[x]);  else  hideLayer(layers[x]); }
function MM_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=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x;}
function MM_showHideLayers() { var i,p,v,obj,args=MM_showHideLayers.arguments; for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2]; if (obj.style) { obj=obj.style; v=(v=='show')?'block':(v=='hide')?'none':v; } obj.display=v; }}
function showHide(id,show) {MM_showHideLayers(id,'',show ? 'show' : 'hide');}
function printWindow() { window.print(); } 
//function listBoxSetSelected(listBox, setTo) { var i, vals; for (i=0; i<listBox.options.length; i++) {vals += listBox.options[i].value + ", "; if (listBox.options[i].value == setTo) { listBox.options[i].selected = true; return; }}}
//function getRadioValue(radio) { for (i=0;i<radio.length;i++) if (radio[i].checked) return radio[i].value; return null; }
//function listGetSelected(listBox) { var obj = document.getElementById(listBox); return obj.options[obj.selectedIndex].value; }
//function getCurrentValue(item) { var itemId = document.getElementById(item); return itemId[itemId.selectedIndex].value; }
//function setInputValue(itemName, value) { var id = document.getElementById(itemName); id.value = value; }
//function importOrig(path){ var i, base, src = "replace.js", scripts = document.getElementsByTagName("script");for (i=0; i<scripts.length; i++){if (scripts[i].src.match(src)){ base = scripts[i].src.replace(src, "");break;}} document.write("<" + "script src=\"" + base + path + "\"></" + "script>");}
//function checkItem(fieldName, fieldValue, fieldLength, fieldIsNUll, fieldDescription, allowNull, minLength, maxLength, regExpr) {   var alertMsg = fieldDescription + "\n"; if (allowNull && fieldIsNUll) { alert(alertMsg + "Field is mandatory please provide a value"); return false; } if (fieldIsNUll) return true;    if (fieldLength > maxLength) { alert(alertMsg + "Field should be a maximum of " + maxLength + " characters the current length is " + fieldLength);  return false;   }   if (fieldLength < minLength) { alert(alertMsg + "Field should be a minimum of " + minLength + " characters the current length is only " + fieldLength); return false; } if (regExpr && regExpr.test(fieldValue)) { alert(alertMsg + "Field has invalid characters"); return false; } return true;}
//function pleaseWait(replacementLayer) {	MM_showHideLayers('pleaseWaitWrapper','','hide',replacementLayer,'','show') };

// ITC code here down to start of dockit.
// work around for radio button list in ASP.NET.  
function SetUniqueRadioButton(nameregex, current)
{

   re = new RegExp(nameregex);
   for(i = 0; i < document.forms[0].elements.length; i++)
   {
      elm = document.forms[0].elements[i]
      if (elm.type == 'radio')
      {
         if (re.test(elm.name))
         {
            elm.checked = false;
         }
      }
   }
 
   current.checked = true;
}

// parses the querystring looking for a parameter with the name passed in.
// if found the value of the parameter is returned.
function getQueryVariable(variable) 
{  
    var query = window.location.search.substring(1);  
    var vars = query.split("&");  
    for (var i=0;i<vars.length;i++) 
    {    
        var pair = vars[i].split("=");    
        if (pair[0] == variable) 
        {      
            return pair[1];   
        }  
    }   
        
     return null;
}
// Check a date is valid.  
function CheckDateValid(day, month, year) 
{
    if (month < 1 || month > 12) 
    {
        return false;
    }
    if (day < 1 || day > 31) 
    {
        return false;
    }
    if ((month == 4 || month == 6 || month == 9 || month == 11) &&
        (day == 31)) 
    {
        return false;
    }
    if (month == 2) 
    {
        var leap = (year % 4 == 0 &&
           (year % 100 != 0 || year % 400 == 0));
        if (day>29 || (day == 29 && !leap)) 
        {
            return false;
        }
    }
    if (year.length < 4)
    {
        return false;
    }

    return true;
}

// fix for z index issue in IE6.  Call this function before modal popups are popped.
function disabledropdowns()
{
    setSelectElementVisibility('hidden');
}

function enableDropDowns()
{
    setSelectElementVisibility('visible');
}

function setSelectElementVisibility(visibilityValue)
{
    var selects = document.getElementsByTagName("select");
    for (var i=0; i<selects.length; i++){
        selects[i].style.visibility = visibilityValue;
    }
}

/***********************************************
* Dock Content script- Created by and © Dynamicdrive.com
* This notice must stay intact for use
* Visit http://www.dynamicdrive.com/ for full script
***********************************************/

var offsetfromedge=100      //offset from window edge when content is "docked". Change if desired.
var dockarray=new Array() //array to cache dockit instances
var dkclear=new Array()   //array to cache corresponding clearinterval pointers

function dockit(el, duration){
this.source=document.all? document.all[el] : document.getElementById(el);
this.source.height=this.source.offsetHeight;
this.docheight=truebody().clientHeight;
this.duration=duration;
this.pagetop=25;
this.elementoffset=this.getOffsetY();
dockarray[dockarray.length]=this;
var pointer=eval(dockarray.length-1);
var dynexpress='dkclear['+pointer+']=setInterval("dockornot(dockarray['+pointer+'])",100);';
dynexpress=(this.duration>0)? dynexpress+'setTimeout("clearInterval(dkclear['+pointer+']); dockarray['+pointer+'].source.style.top=0", duration*1000)' : dynexpress;
eval(dynexpress);
}

dockit.prototype.getOffsetY=function(){
var totaloffset=parseInt(this.source.offsetTop);
var parentEl=this.source.offsetParent;
while (parentEl!=null){
totaloffset+=parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function dockornot(obj){
obj.pagetop=truebody().scrollTop;
if (obj.pagetop>obj.elementoffset) //detect upper offset
obj.source.style.top=obj.pagetop-obj.elementoffset+offsetfromedge + "px";
else if (obj.pagetop+obj.docheight<obj.elementoffset+parseInt(obj.source.height)) //lower offset
obj.source.style.top=obj.pagetop+obj.docheight-obj.source.height-obj.elementoffset-offsetfromedge + "px";
else
obj.source.style.top=100;
}

function truebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}


