//**** Start - Dreamweaver Autogenerated Codes ****
/*
document.oncontextmenu = function(){return false}
if(document.layers) {
    window.captureEvents(Event.MOUSEDOWN);
   window.onmousedown = function(e){
        if(e.target==document)
		return false;
    }
}
else {
    document.onmousedown = function(){return false}
}
*/

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_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_showHideLayers() { //v6.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_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//**** End - Dreamweaver Autogenerated Codes ****

//**** Start - Set server date code ***
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
	year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
var daym1=mydate.getDate()+1
var daym2=mydate.getDate()+2
if (daym<10)	
	daym="0"+daym 
var montharray=new Array("01","02","03","04","05","06","07","08","09","10","11","12")

function scrolldate(no_days,compare_date,preselect) //input either scrolldate(31,daym,yes) or scrolldate(12,montharray[month],no)
{
	var i, j;	
	for(i=1;i<=no_days;i++)
	{
		if (i<=9) 
		{
			j = "0" + i;
			if (j == compare_date)
			{
				if (preselect == "yes")
					document.write("<option value='"+j+"' selected>"+j+"</option><br>");
				else
					document.write("<option value='"+j+"'>"+j+"</option><br>");
			}
			else {document.write("<option value='"+j+"'>"+j+"</option><br>");}
		}
		else
		{
			if (i == compare_date)
			{
				if (preselect == "yes")
					document.write("<option value='"+ i + "' selected>" + i + "</option><br>");
				else
					document.write("<option value='"+ i + "'>" + i + "</option><br>");
			}
			else {document.write("<option value='"+ i + "'>" + i + "</option><br>");}
		}
	}
}
function scrollyear(preselect_yr)
{
	var i=year-4;
	for(i;i<=year;i++)
	{
		if (i == year)
		{
			if (preselect_yr == "yes")
				document.write("<option value='"+ i + "' selected>" + i + "</option><br>");
			else
				document.write("<option value='"+ i + "'>" + i + "</option><br>");
		}
		else {document.write("<option value='"+ i + "'>" + i + "</option><br>");}
	}
}

function scrollyear_appt(preselect_yr)
{
	var i=year;
	lastyear = year + 1;
	for(i;i<=lastyear;i++)
	{
		if (i == year)
		{
			if (preselect_yr == "yes")
				document.write("<option value='"+ i + "' selected>" + i + "</option><br>");
			else
				document.write("<option value='"+ i + "'>" + i + "</option><br>");
		}
		else {document.write("<option value='"+ i + "'>" + i + "</option><br>");}
	}
}
//**** End - Set server date code ***

//****Start - Validate common strings****
function checkEnter(e) //e is event object passed from function invocation literal character code will be stored in this variable
{ 
	var characterCode; 
	if(e && e.which) //if which property of event object is supported (NN4)
	{ 
		e = e;
		characterCode = e.which; //character code is contained in NN4's which property
	}
	else
	{
		e = event;
		characterCode = e.keyCode; //character code is contained in IE's keyCode property
	}
	
	if(characterCode == 13) //if generated character code is equal to ascii 13 (if enter key)
		return false;
	else
		return true; 
}

function onlyNumber(e)
{
	var characterCode; 
	if(e && e.which) //if which property of event object is supported (NN4)
	{ 
		e = e;
		characterCode = e.which; //character code is contained in NN4's which property
	}
	else
	{
		e = event;
		characterCode = e.keyCode; //character code is contained in IE's keyCode property
	}
	
  	if( ((characterCode<48)||(characterCode>57)) && ((characterCode != 8) || (characterCode == 13)) )//exclude all characters except numeric
  		return false;
	else
		return true;
}

function onlyCharacter(e)
{
	var characterCode; 
	if(e && e.which) //if which property of event object is supported (NN4)
	{ 
		e = e;
		characterCode = e.which; //character code is contained in NN4's which property
	}
	else
	{
		e = event;
		characterCode = e.keyCode; //character code is contained in IE's keyCode property
	}
	
  	if( ((characterCode<65)||(characterCode>90)) && ((characterCode<97)||(characterCode>122)) && 
		 (characterCode!=32) && (characterCode != 8) || (characterCode == 13))//exclude all characters except numeric
  		return false;
	else
		return true;
}

function checkText(string) 
{
  var Textpattern = /^([A-Za-z]{1,})$/;
  return Textpattern.test(string);
}

function checkN(string) 
{
  var Npattern = /^([N]{1,})$/;
  return Npattern.test(string);
}

function checkNumber(string) 
{
  var Numberpattern = /^([0-9]{10,})$/;
  return Numberpattern.test(string);
}

function checkAlphaNumeric(string) 
{
  var AlphaNumericpattern = /^([a-zA-Z0-9]{10,})$/;
  return AlphaNumericpattern.test(string);
}

function checkLoginID(string) 
{
  var LoginIDpattern = /^([A-Za-z0-9]{5,12})$/;
  return LoginIDpattern.test(string);
}

function checkPassword(string) 
{
  var Passwordpattern = /^([A-Za-z0-9]{7,})$/;
  return Passwordpattern.test(string);
}

function checkPassport(string)
{
	var Passportpattern = /^([0-9]{2})+((\.)+[0-9]{4})+((\.)[0-9]{6})+((\.)[0-9]{4})+$/;
	return Passportpattern.test(string);
}

function checkEmail(string) 
{
  var Emailpattern = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
  return Emailpattern.test(string);
}

function checkPostalCode(string) 
{
  var PostalCodepattern = /^(\d{4,})$/;
  return PostalCodepattern.test(string);
}

function checkAreaPhone(string) 
{
  var AreaPhonepattern = /^(\d{2,})$/;
  return AreaPhonepattern.test(string);
}

function checkPhone(string) 
{
  var Phonepattern = /^(\d{5,})$/;
  return Phonepattern.test(string);
}
//****End - Validate common strings****

//**** Start - Calculate Age Group ***
function displayage(yr, mon, day, unit, decimal, round, display)
{
	//year     : should be a valid full year (ie: 1978)
	//month    : integer from 1 to 12
	//day      : should be a valid day of the month
	//unit     : "years", "months", "days"
	//decimals : specifies demical places to round to (ie: 2)
	//rounding : "roundup" or "rounddown"
	//display  : "y" to return value, "n" to display value
	//sample   : displayage(1997, 11, 24, "years", 0, "rounddown")
	today=new Date()
	var pastdate=new Date(yr, mon-1, day)
	var countunit = unit
	var decimals = decimal
	var rounding = round
	
	var one_day = 1000*60*60*24
	var one_month = 1000*60*60*24*30
	var one_year = 1000*60*60*24*30*12
	var finalresult;
	
	finalunit=(countunit=="days")? one_day : (countunit=="months")? one_month : one_year
	decimals=(decimals<=0)? 1 : decimals*10

	if (unit!="years")
	{
		if (display == "y")
		{
			if (rounding=="rounddown")
				finalresult = Math.floor((today.getTime()-pastdate.getTime())/(finalunit)*decimals)/decimals+" "+countunit;
			else
				finalresult = Math.ceil((today.getTime()-pastdate.getTime())/(finalunit)*decimals)/decimals+" "+countunit;
			return finalresult;
		}
		if (display == "n")
		{
			if (rounding=="rounddown")
				document.write(Math.floor((today.getTime()-pastdate.getTime())/(finalunit)*decimals)/decimals+" "+countunit)
			else
				document.write(Math.ceil((today.getTime()-pastdate.getTime())/(finalunit)*decimals)/decimals+" "+countunit)
		}
	}
	else
	{
		yearspast = today.getFullYear()-yr-1
		tail = (today.getMonth()>mon-1 || today.getMonth()==mon-1 && today.getDate()>=day)? 1 : 0
		pastdate.setFullYear(today.getFullYear())
		pastdate2 = new Date(today.getFullYear()-1, mon-1, day)
		tail = (tail==1)? tail+Math.floor((today.getTime()-pastdate.getTime())/(finalunit)*decimals)/decimals : Math.floor((today.getTime()-pastdate2.getTime())/(finalunit)*decimals)/decimals
		
		if (display == "y")
		{
			finalresult = yearspast+tail+" "+countunit;
			return finalresult;
		}
		if (display == "n")
			document.write(yearspast+tail+" "+countunit)
	}
}
//**** End - Calculate Age Group ***

// Start - Show / Hide row or table as selected
var enablepersist="on" 			//Enable saving state of content structure using session cookies? (on/off)
var collapseprevious="yes" 	//Collapse previously open content when opening present? (yes/no)

if (document.getElementById)
{
	document.write('<style type="text/css">')
	document.write('.switchcontent{display:none;}')
	document.write('</style>')
}

function getElementbyClass(classname)
{
	ccollect=new Array()
	var inc=0
	var alltags=document.all? document.all : document.getElementsByTagName("*")
	for (i=0; i<alltags.length; i++)
	{
		if (alltags[i].className==classname)
		ccollect[inc++]=alltags[i]
	}
}

function contractcontent(omit)
{
	var inc=0
	while (ccollect[inc])
	{
		if (ccollect[inc].id!=omit)
		ccollect[inc].style.display="none"
		inc++
	}
}

function expandcontent(cid)
{
	if (typeof ccollect!="undefined")
	{
		if (collapseprevious=="yes")
		contractcontent(cid)
		document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
	}
}

function revivecontent()
{
	contractcontent("omitnothing")
	selectedItem=getselectedItem()
	selectedComponents=selectedItem.split("|")
	for (i=0; i<selectedComponents.length-1; i++)
		document.getElementById(selectedComponents[i]).style.display="block"
}

function get_cookie(Name) 
{ 
	var search = Name + "="
	var returnvalue = "";
	if (document.cookie.length > 0) 
	{
		offset = document.cookie.indexOf(search)
		if (offset != -1) 
		{ 
			offset += search.length
			end = document.cookie.indexOf(";", offset);
			if (end == -1) end = document.cookie.length;
				returnvalue=unescape(document.cookie.substring(offset, end))
		}
	}
	return returnvalue;
}

function getselectedItem()
{
	if (get_cookie(window.location.pathname) != "")
	{
		selectedItem=get_cookie(window.location.pathname)
		return selectedItem
	}
	else
		return ""
}

function do_onload()
{
	getElementbyClass("switchcontent")
	if (enablepersist=="on" && typeof ccollect!="undefined")
		revivecontent()
}

if (window.addEventListener)
	window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
	window.attachEvent("onload", do_onload)
else if (document.getElementById)
	window.onload=do_onload
// End - Show / Hide row or table as selected

// Start - Miscellanous Scripts
function textCounter(field, countfield, maxlimit) 
{
	if (field.value.length > maxlimit)
		field.value = field.value.substring(0, maxlimit);
	else 
		countfield.value = maxlimit - field.value.length;
}

function replace(string,text,by) 		// Replaces text with by in string
{
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}
// End - Miscellanous Scripts