// Standard Function START

//---- Citrus Functions by Dave Sharpe START ----

      // Browser and OS detect
   IE=(navigator.appName.indexOf('Microsoft') >= 0);
   NS=(navigator.appName.indexOf('Netscape') >= 0);
   V4=(parseInt(navigator.appVersion) >= 4);
   V5=(parseInt(navigator.appVersion)>=5||navigator.appVersion.indexOf("MSIE 5")!=-1);
   V6=(parseInt(navigator.appVersion)>=6||navigator.appVersion.indexOf("MSIE 6")!=-1);
   MAC=(navigator.userAgent.indexOf('Mac')!=-1);

      // Print functionality Start
   function checkPrintAbility()
   {
      if (!MAC)
      {
         window.print();
      }
      else
      {
         if(IE) 
         {
            alert("You are using Internet Explorer on a Macintosh computer. To print the comp card:\n - Use the PRINT button on the toolbar at the top of the Comp Card window.");
         }
         else
         {
            window.print();
         }
      }
   }

      //load and center popup
   function loadWindowCenter(url, options, wndName, wndWidth, wndHeight)
   {
      
      xPos = ((screen.availHeight/2) - (wndHeight/2) + 22);
      yPos = ((screen.availWidth/2) - (wndWidth/2) - 12);
      
      window.open(url, wndName, options + ",width=" + wndWidth + ",height=" + wndHeight + ",left=" + yPos + ",top=" + xPos + ",scrollbars=yes");
   }

//---- Citrus Functions by Dave Sharpe END ----

//---- Dreamweaver Functions START ----

   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.01
      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_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 MM_showHideLayers() 
   { //v3.0
      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')?'visible':(v='hide')?'hidden':v; 
            }
            obj.visibility=v; 
         }
   }

   function MM_displayStatusMsg(msgStr) 
   { //v1.0
      status=msgStr;
      document.MM_returnValue = true;
   }

//---- Dreamweaver Functions END----

// Standard Function END

window.onload = init;

function init() {
	msgStatusAllLinks();
	startlist();
}

window.onerror = function() {
    window.status = 'Error on page.';
}

function attachFocus() {

	if (this.className.indexOf(" focus")<0) {
		this.className+=" focus";
	}

	if (this.tempOnFocus) {
		// call existing onFocus event.
		this.tempOnFocus();
	}

}

function attachBlur() {

	if (this.className.indexOf(" focus")>0) {
		this.className = this.className.substring(0,this.className.indexOf(" focus"));
	} else {
		this.className.replace(" focus","");
	}

	if (this.tempOnBlur) {
		// call existing onBlur event.
		this.tempOnBlur();
	}

}

function msgStatus() {
	if (this.tagName=="INPUT") {
		switch(this.type) {
			case 'image': // form button is an <input type="image"> (graphic);
				if (this.getAttribute('src').indexOf('_a.')!=-1) {
					this.src = this.getAttribute('src').replace('_a.','_b.');
					txtStatus=this.getAttribute('alt');
				}
				if (this.getAttribute('src').indexOf('-a.')!=-1) {
					this.src = this.getAttribute('src').replace('-a.','-b.');
					txtStatus=this.getAttribute('alt');
				}
				break;
			case 'button': // form button is an <input type="button"> (webtext);
			case 'submit': // form button is an <input type="submit"> (webtext);
			case 'reset': // form button is an <input type="reset"> (webtext);
			case 'file': // form button is an <input type="file"> (webtext);
				//this.className="bnover";
				txtStatus=this.getAttribute('value');
				break;
			default:
				break;
		}
	} else {
		if (this.name) {
			for (i=0;i<document.getElementsByName(this.name).length;i++) {
				if (document.getElementsByName(this.name)[i]!=this) {
					if (document.getElementsByName(this.name)[i].tagName=='A') {
						if (document.getElementsByName(this.name)[i].getElementsByTagName('img').length!=0) {
							if (document.getElementsByName(this.name)[i].getElementsByTagName('img')[0].src.indexOf('_a.')!=-1) {
								document.getElementsByName(this.name)[i].getElementsByTagName('img')[0].src = document.getElementsByName(this.name)[i].getElementsByTagName('img')[0].src.replace('_a.','_b.');
							}
							if (document.getElementsByName(this.name)[i].getElementsByTagName('img')[0].src.indexOf('-a.')!=-1) {
								document.getElementsByName(this.name)[i].getElementsByTagName('img')[0].src = document.getElementsByName(this.name)[i].getElementsByTagName('img')[0].src.replace('-a.','-b.');
							}
						} else {
							document.getElementsByName(this.name)[i].className="rollover";
						}
					}
				}
			}
		}
		if (this.innerText) {
			txtStatus=this.innerText;
		} else {
			if (this.text) txtStatus=this.text;
		}
		if (this.getElementsByTagName('img').length!=0) {
			txtStatus=this.getElementsByTagName('img')[0].getAttribute('alt');
			if (this.getElementsByTagName('img')[0].src.indexOf('_a.')!=-1) {
				this.getElementsByTagName('img')[0].src = this.getElementsByTagName('img')[0].src.replace('_a.','_b.');
			}
			if (this.getElementsByTagName('img')[0].src.indexOf('-a.')!=-1) {
				this.getElementsByTagName('img')[0].src = this.getElementsByTagName('img')[0].src.replace('-a.','-b.');
			}
		} else {
			if (this.tagName=="AREA") {
				txtStatus=this.getAttribute('alt');
			}
		}
	}
	// txtStatus=toTitleCase(txtStatus);
	window.status=toTitleCase(txtStatus); return true;
}

function msgStatus() {
	if (this.tagName=="INPUT") {
		switch(this.type) {
			case 'image': // form button is an <input type="image"> (graphic);
				if (this.getAttribute('src').indexOf('_a.')!=-1) {
					this.src = this.getAttribute('src').replace('_a.','_b.');
					txtStatus=this.getAttribute('alt');
				}
				if (this.getAttribute('src').indexOf('-a.')!=-1) {
					this.src = this.getAttribute('src').replace('-a.','-b.');
					txtStatus=this.getAttribute('alt');
				}
				break;
			case 'button': // form button is an <input type="button"> (webtext);
			case 'submit': // form button is an <input type="submit"> (webtext);
			case 'reset': // form button is an <input type="reset"> (webtext);
			case 'file': // form button is an <input type="file"> (webtext);
				//this.className="bnover";
				txtStatus=this.getAttribute('value');
				break;
			default:
				break;
		}
	} else {
		if (this.name) {
			for (i=0;i<document.getElementsByName(this.name).length;i++) {
				if (document.getElementsByName(this.name)[i]!=this) {
					if (document.getElementsByName(this.name)[i].tagName=='A') {
						if (document.getElementsByName(this.name)[i].getElementsByTagName('img').length!=0) {
							if (document.getElementsByName(this.name)[i].getElementsByTagName('img')[0].src.indexOf('_a.')!=-1) {
								document.getElementsByName(this.name)[i].getElementsByTagName('img')[0].src = document.getElementsByName(this.name)[i].getElementsByTagName('img')[0].src.replace('_a.','_b.');
							}
							if (document.getElementsByName(this.name)[i].getElementsByTagName('img')[0].src.indexOf('-a.')!=-1) {
								document.getElementsByName(this.name)[i].getElementsByTagName('img')[0].src = document.getElementsByName(this.name)[i].getElementsByTagName('img')[0].src.replace('-a.','-b.');
							}
						} else {
							document.getElementsByName(this.name)[i].className="rollover";
						}
					}
				}
			}
		}
		if (this.innerText) {
			txtStatus=this.innerText;
		} else {
			if (this.text) txtStatus=this.text;
		}
		if (this.getElementsByTagName('img').length!=0) {
			txtStatus=this.getElementsByTagName('img')[0].getAttribute('alt');
			if (this.getElementsByTagName('img')[0].src.indexOf('_a.')!=-1) {
				this.getElementsByTagName('img')[0].src = this.getElementsByTagName('img')[0].src.replace('_a.','_b.');
			}
			if (this.getElementsByTagName('img')[0].src.indexOf('-a.')!=-1) {
				this.getElementsByTagName('img')[0].src = this.getElementsByTagName('img')[0].src.replace('-a.','-b.');
			}
		} else {
			if (this.tagName=="AREA") {
				txtStatus=this.getAttribute('alt');
			}
		}
	}
	// txtStatus=toTitleCase(txtStatus);
	window.status=toTitleCase(txtStatus); return true;
}

function msgStatusOff() {
	txtStatus=window.defaultStatus;
	if (this.tagName=="INPUT") {
		switch(this.type) {
			case 'image': // form button is an <input type="image"> (graphic);
				if (this.getAttribute('src').indexOf('_b.')!=-1) {
					this.src = this.getAttribute('src').replace('_b.','_a.');
				}
				if (this.getAttribute('src').indexOf('-b.')!=-1) {
					this.src = this.getAttribute('src').replace('-b.','-a.');
				}
				break;
			case 'button': // form button is an <input type="button"> (webtext);
			case 'submit': // form button is an <input type="submit"> (webtext);
			case 'reset': // form button is an <input type="reset"> (webtext);
				this.className+=" bnout";
				break;
			default:
				break;
		}
	} else {
		if (this.name) {
			for (i=0;i<document.getElementsByName(this.name).length;i++) {
				if (document.getElementsByName(this.name)[i]!=this) {
					if (document.getElementsByName(this.name)[i].tagName=='A') {
						if (document.getElementsByName(this.name)[i].getElementsByTagName('img').length!=0) {
							if (document.getElementsByName(this.name)[i].getElementsByTagName('img')[0].src.indexOf('_b.')!=-1) {
								document.getElementsByName(this.name)[i].getElementsByTagName('img')[0].src = document.getElementsByName(this.name)[i].getElementsByTagName('img')[0].src.replace('_b.','_a.');
							}
							if (document.getElementsByName(this.name)[i].getElementsByTagName('img')[0].src.indexOf('-b.')!=-1) {
								document.getElementsByName(this.name)[i].getElementsByTagName('img')[0].src = document.getElementsByName(this.name)[i].getElementsByTagName('img')[0].src.replace('-b.','-a.');
							}
						} else {
							document.getElementsByName(this.name)[i].className="";
						}
					}
				}
			}
		}
	}
	if (this.getElementsByTagName('img').length!=0 && this.getElementsByTagName('img')[0].src.indexOf('_b.')!=-1 && this.getElementsByTagName('img')[0].name.indexOf('img_')==-1) {
		this.getElementsByTagName('img')[0].src = this.getElementsByTagName('img')[0].src.replace('_b.','_a.');
	}
	if (this.getElementsByTagName('img').length!=0 && this.getElementsByTagName('img')[0].src.indexOf('-b.')!=-1 && this.getElementsByTagName('img')[0].name.indexOf('img_')==-1) {
		this.getElementsByTagName('img')[0].src = this.getElementsByTagName('img')[0].src.replace('-b.','-a.');
	}
	window.status=txtStatus; return true;
}

function bodyResize() {
	window.location.href = window.location.href;
}

function msgStatusAllLinks() {
	for(i=0; i<document.links.length; i++) {
		if (!document.links[i].onmouseover) {
			document.links[i].onmouseover=msgStatus;
			document.links[i].onmouseout=msgStatusOff;
		}
	}
	for(i=0; i<document.getElementsByTagName('input').length; i++) {
		switch(document.getElementsByTagName('input')[i].type) {
			case 'image': // form button is an <input type="image"> (graphic);
			case 'button': // form button is an <input type="button"> (webtext);
			case 'submit': // form button is an <input type="submit"> (webtext);
			case 'reset': // form button is an <input type="reset"> (webtext);
				document.getElementsByTagName('input')[i].onmouseover=msgStatus;
				document.getElementsByTagName('input')[i].onmouseout=msgStatusOff;
				break;
			case 'text':
			case 'password':

				// Add element's existing blur/focus event (if it has one) before adding a new blur/focus event 'attachBlur/Focus'
				// This ensures that any existing onBlur/onFocus event the element has is still executed, as well as the 'attachBlur/Focus' event.
				// Check if IE or Netscape and use appropriate syntax accordingly.
				if (navigator.appName == 'Microsoft Internet Explorer') {

					if (document.getElementsByTagName('input')[i].onblur) {
						// Assign existing onBlur to a temp event 'tempOnBlur' - Later executed in attachBlur function.
						document.getElementsByTagName('input')[i].tempOnBlur = document.getElementsByTagName('input')[i].onblur;
					}

					if (document.getElementsByTagName('input')[i].onfocus) {
						// Assign existing onBlur to a temp event 'tempOnFocus' - Later executed in attachFocus function.
						document.getElementsByTagName('input')[i].tempOnFocus = document.getElementsByTagName('input')[i].onfocus;
					}

					// attach new event. This will cause the input field colour to change.
					document.getElementsByTagName('input')[i].onfocus=attachFocus;
					document.getElementsByTagName('input')[i].onblur=attachBlur;

				}
				else {
				
					// attach existing blur/focus event.
					document.getElementsByTagName('input')[i].addEventListener('focus',attachFocus,false);
					document.getElementsByTagName('input')[i].addEventListener('blur',attachBlur,false);

				}		
				break;
			default:
				break;
		}
	}
	for(i=0; i<document.getElementsByTagName('textarea').length; i++) {
		document.getElementsByTagName('textarea')[i].onfocus=attachFocus;
		document.getElementsByTagName('textarea')[i].onblur=attachBlur;
	}
}

// toTitleCase
function toTitleCase(strString) {
	// strString = fnTrim(strString);
	var firstSpace = strString.indexOf(' ');
	var currentWord;
	strString = strString.charAt(0).toUpperCase()+strString.substring(1,strString.length);
	if (firstSpace > -1) strString=strString.substring(0,firstSpace+1) + toTitleCase(strString.substring(firstSpace+1,strString.length));
	return strString;
}

// displayDateTime
function displayDateTime() {

	var a_p = "";
	var d = new Date();
	var curr_hour = d.getHours();
	if (curr_hour < 12)
	   {
	   a_p = "am";
	   }
	else
	   {
	   a_p = "pm";
	   }
	if (curr_hour == 0)
	   {
	   curr_hour = 12;
	   }
	if (curr_hour > 12)
	   {
	   curr_hour = curr_hour - 12;
	   }
	
	var curr_min = d.getMinutes();
	
	curr_min = curr_min + "";
	
	if (curr_min.length == 1)
	   {
	   curr_min = "0" + curr_min;
	   }
	
	var m_names = new Array("January", "February", "March", 
	"April", "May", "June", "July", "August", "September", 
	"October", "November", "December");
	
	var curr_date = d.getDate();
	var curr_month = d.getMonth();
	var curr_year = d.getFullYear();

	document.write(curr_hour + ":" + curr_min + a_p + "<span class='dash'> - </span>" + curr_date + " " + m_names[curr_month] + " " + curr_year);

}

// setFocus (clear form text field contents onfocus)
function setFocus(oCtl) {
    if (oCtl.value == oCtl.defaultValue) oCtl.value = '';
}

// toggleNav (show/hide sublist)
function toggleNav(strID) {

	var oDiv;

	if (oDiv = document.getElementById(strID)) {
		oDiv.style.display = oDiv.style.display == 'none' ? 'block' : 'none';
	}
	
	return false;

}

// Dropdown Submenu
// submenus function in modern browsers via CSS only;
// however, IE5, IE5.5, IE6 require this Javascript in order to function

function startlist() { 
            if (document.all&&document.getElementById) {
                        if (document.getElementById("navlist")) { 
                                    navRoot = document.getElementById("navlist");
                                    for (i=0; i<navRoot.childNodes.length; i++) { 
                                                node = navRoot.childNodes[i];
                                                if (node.nodeName=="LI") { 
                                                            node.onmouseover=function() { 
                                                                        this.className+=" over";			
                                                            }
                                                            node.onmouseout=function() {
                                                                        this.className=this.className.replace(" over", "");
                                                            }
                                                }
                                    }
                       }
            }
}