function trim(s) {
	while (s.substring(0,1) == ' ') {
		s = s.substring(1,s.length);
	}
	while (s.substring(s.length-1,s.length) == ' ') {
		s = s.substring(0,s.length-1);
	}	
	return s;
}
function IsNumeric(t_string) {
   var t_validChars = "0123456789.,";
   var b_num = true;
   var c_char;
 
   for (i = 0; i < t_string.length && b_num == true; i++) { 
      c_char = t_string.charAt(i); 
      if (t_validChars.indexOf(c_char) == -1) {
         b_num = false;
      }
   }
   return b_num;   
}
function isDateVal(dateStr) {
	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
	var matchArray = dateStr.match(datePat); // is the format ok?
	if (matchArray == null) {
		return false;
	}
	month = matchArray[1]; // p@rse date into variables
	day = matchArray[3];
	year = matchArray[5];
	if (month < 1 || month > 12) { // check month range
		//alert("Month must be between 1 and 12.");
		return false;
	}
	if (day < 1 || day > 31) {
		//alert("Day must be between 1 and 31.");
		return false;
	}
	if ((month==4 || month==6 || month==9 || month==11) && day==31) {
		//alert("Month "+month+" doesn`t have 31 days!")
		return false;
	}
	if (month == 2) { // check for february 29th
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		if (day > 29 || (day==29 && !isleap)) {
			//alert("February " + year + " doesn`t have " + day + " days!");
		return false;
		}
	}
	return true; // date is valid
}
/*
Auto tabbing script- By JavaScriptKit.com
http://www.javascriptkit.com
This credit MUST stay intact for use
*/
function autotab(original,destination){
if (original.getAttribute&&original.value.length==original.getAttribute("maxlength"))
destination.focus()
}
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;
}

<!--
// Kaosweaver Calendar Settings - do not remove
// by Paul Davis - http://www.kaosweaver.com
// KW_lang[English]
// KW_order[0,1,2]
// KW_del1[/]
// KW_del2[/]
// KW_dd[true]

var sDate = new Array();
var mName = new Array("January","February","March","April","May","June","July","August","September","October","November","December")
var wName = new Array("Su","Mo","Tu","We","Th","Fr","Sa")
var cFontName = "Arial, Helvetica, sans-serif;"
var KW_color = new Array("#ffffff","#ffcccc","#999999","#ffffff","#ccffcc","#cccccc","#000000","#000000")
var KW_cl=0;
var KW_od=-1;
var KW_tmo=0;
function m_class(m,d,y) { 
	this.month=m;this.day=d;this.year=y;this.output=this.month+"/"+this.day+"/"+this.year;
	var kd=new Date();this.special=checkDates(this.month,this.day,this.year)
	this.today=((kd.getMonth()+1)==this.month && kd.getDate()==this.day && kd.getFullYear()==this.year)
	var td=new Date(this.year, (this.month-1), this.day+KW_od);this.past=(KW_od==-1)?0:(kd>td)
}

// Kaosweaver End of Calendar Settings - do not remove

function checkDates(m1,d1,y1) {
	var rStr=false;for(var i=0;i<sDate.length;i++) {var tDate=sDate[i].split(",");
		if (tDate[2]=="*" || tDate[2]==y1) {if (tDate[1]==d1 && tDate[0]==m1)	rStr=true;
		}}return rStr;
}

function KW_doCalendar(obj,E,m,y) {
  var d=new Date();f=0;d.setDate(1);if (!m && m!=0) {m=d.getMonth();f=KW_cl}
  if (f==1 && MM_findObj('KW_selectedMonth').value!=-1) 
  m=MM_findObj('KW_selectedMonth').value-1;d.setMonth(m);	
  if (!y) y=d.getFullYear();if (f==1 && MM_findObj('KW_selectedYear').value!=-1) 
  y=MM_findObj('KW_selectedYear').value;d.setFullYear(y);dy=d.getDay();if (!E) E=0;
  if(E==1)dy=(dy==0)?6:dy-1;dP=new Date();dP.setMonth(m);dP.setDate(0);
  pStart=dP.getDate()-dy+1;dStr=new Array();for (i=pStart;i<dP.getDate()+1;i++) { tmo=(KW_tmo)?"":i;
  tMonth=(m==0)?"12":m;tYear=(m==0)?y-1:y;dStr[dStr.length]=new m_class(tMonth,tmo,tYear);
  }EOM=false;for (i=1;!EOM;i++){d.setDate(i);if (m!=d.getMonth()) EOM=true; else { 
  dStr[dStr.length]=new m_class((Number(m)+1),i,y);}}cnt=1;si=0;
  if(E==1)si=(d.getDay()==0)?6:d.getDay()-1;else si=d.getDay();	for (i=si;i<7;i++) {
  tMonth=(m==11)?"1":Number(m)+2;tYear=(m==11)?Number(y)+1:y; tmo=(KW_tmo)?"":cnt;
  dStr[dStr.length]=new m_class(tMonth,tmo,tYear); cnt++;}pM=(m==0)?11:m-1;
  pY=(m==0)?y-1:y;nM=(m==11)?0:Number(m)+1;nY=(m==11)?Number(y)+1:y;
  wStr="<html><head><style type=\"text/css\"><!--td {  font-family: "+cFontName+" font-size: 12px; }\n.tblHdr { font-weight: bold; color: "+KW_color[0]+"; background-color: "+KW_color[6]+" }\n.subTbl{ color: "+KW_color[0]+"; background-color: #666666;  text-align: center}-->\n</style>\n<title>"+mName[m]+", "+y+"</title>\n</head>\n<body  topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" leftmargin=\"0\" onLoad=\"window.focus()\">\n<table width=\"100%\" border=\"0\" cellspacing=\"0\">\n<tr>\n<td bgcolor=\""+KW_color[6]+"\">\n<table width=\"100%\" border=0>\n"
  wStr+="<tr>\n<td align=center bgcolor=\""+KW_color[6]+"\" class=\"tblHdr\" colspan=\"4\"><a href=\"javascript:window.opener.KW_doCalendar('"+obj+"',"+E+",'"+pM+"','"+pY+"');\" class=\"tblHdr\">&laquo</a>&nbsp;&nbsp;"+mName[m]+"&nbsp;&nbsp;<a href=\"javascript:window.opener.KW_doCalendar('"+obj+"',"+E+",'"+nM+"','"+nY+"');\"  class=\"tblHdr\">&raquo</a></td>\n<td colspan=3 align=center class=\"tblHdr\"><a href=\"javascript:window.opener.KW_doCalendar('"+obj+"',"+E+",'"+m+"','"+(y-1)+"');\" class=\"tblHdr\">&laquo</a>&nbsp;&nbsp;"+y+"&nbsp;&nbsp;<a href=\"javascript:window.opener.KW_doCalendar('"+obj+"',"+E+",'"+m+"','"+(Number(y)+1)+"');\"  class=\"tblHdr\">&raquo</a></td>\n</tr>\n"
  wStr+="<tr>\n<td class=\"subTbl\">"+wName[0]+"</td><td class=\"subTbl\">"+wName[1]+"</td><td class=\"subTbl\">"+wName[2]+"</td><td class=\"subTbl\">"+wName[3]+"</td><td class=\"subTbl\">"+wName[4]+"</td><td class=\"subTbl\">"+wName[5]+"</td><td class=\"subTbl\">"+wName[6]+"</td>\n</tr>\n"
  for (x=0;x<parseInt(dStr.length/7);x++) {	wStr+="<tr>\n";	for (y=0;y<7;y++) {
  yT=(E==1)?5:0;bC=(y==yT||y==6)?KW_color[2]:KW_color[3];
  if ((Number(m)+1)!=dStr[x*7+y].month) bC=KW_color[5]; if (dStr[x*7+y].special) 
  bC=KW_color[4];if (dStr[x*7+y].today) bC=KW_color[1];
  a0=(KW_cl!=1)?"":"window.opener.MM_findObj('KW_selectedMonth',window.opener.document).value='"+dStr[x*7+y].month+"';window.opener.MM_findObj('KW_selectedYear',window.opener.document).value='"+dStr[x*7+y].year+"'; "  
  a1=(dStr[x*7+y].past)?"":"<a href=\"javascript:window.opener.MM_findObj('"+obj+"',window.opener.document).value='"+dStr[x*7+y].output+"';"+a0+" window.close();\" >";
  a2=(dStr[x*7+y].past)?"":"</a>";
  wStr+="<td align=\"center\" bgcolor="+bC+">"+a1+dStr[x*7+y].day+a2+"</td>\n";
	}	wStr+="</tr>\n";}	wStr+="<tr><td colspan=7></td></tr></table></td></tr></table></body></html>";
	var w = parseInt(screen.width/2-75); var h=parseInt(screen.height/2-75);
	var look='width=170,height=155,left='+w+',top='+h;	popwin=window.open('','calendar',look);
	popwin.document.open();	popwin.document.write(wStr);	popwin.document.close();
}

function openPopUp(url, i_hi, i_wi, i_top) {
	i_screenWidth = screen.width;
	i_screenHeight = screen.height;
	if((i_hi == '') || (i_hi == 0) || (i_hi == 'undefined')) {
		i_winHeight = 570;
	}
	else {
		i_winHeight = i_hi;
	}	
	if((i_wi == '') || (i_wi == 0) || (i_wi == 'undefined')) {
		i_winWidth = 770;
	}
	else {
		i_winWidth = i_wi;
	}	
	if((i_top == '') || (i_top == 0) || (i_top == 'undefined')) {
		i_top = 1;
	}
	else {
		i_top = i_top;
	}	
	i_left = (i_screenWidth-i_winWidth)/2;				
	w_child = window.open(url, "_blank", "scrollbars,height=" + i_winHeight + ",width=" + i_winWidth + ",top=" + i_top + ",left=" + i_left + ",resizable=1");
	//w_child.focus;
	return;
}

function runConfirm(t_url, t_msg) {
	if(confirm(t_msg)) {
		window.location.href = t_url
	}	
}
function checkemail(str){
//var str=document.validation.emailcheck.value
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str)){
		testresults=true;
	}
	else{
	
		testresults=false;
	}
	return testresults;
}
function runClose() {		
	window.opener.location.reload();
	window.close();	
	return;
}
//function for the expand/collapse list
function toggle(box,fontId,whichRow) {
 	//alert(whichRow);
	//box is the id of the DIV tag
	//fontId is the id of the font tag
	//whichRow is the subscript of the repeating row
	var whichSign, plusSign, minusSign;
 	//whichSign is what the font tag is set to, it is a + to start with 
	whichSign = (document.getElementById(fontId + whichRow).innerHTML);
  	//alert(box);
	plusSign = '+'
	minusSign = '-'
	if (whichSign == '+'){
	//the default style of the DIV is set to none, reset that to block(which shows the DIV contents)
		if ((document.getElementById(box).style.display)=='none'){
			(document.getElementById(box).style.display) = "block";
		}
		//change the sign to minus when plus is cliked and change the display style of the DIV 
		document.getElementById(fontId + whichRow).innerHTML = minusSign;
		document.getElementById(box).style.display = "block";
	}
	else if (whichSign == '-'){
		document.getElementById(fontId + whichRow).innerHTML = plusSign;
		document.getElementById(box).style.display = "none";
	}
}
function populateCountries(f_form, t_default) {	
	a_Countries = new Array("United States of America","Canada","Germany","France","United Kingdom",
						"Afghanistan","Albania","Algeria","American Samoa","Andorra","Angola",
						"Anguilla","Antarctica","Antigua and Barbuda","Argentina","Armenia","Aruba",
						"Australia","Austria","Azerbaijan","Bahamas","Bahrain","Bangladesh","Barbados",
						"Belarus","Belgium","Belize","Benin","Bermuda","Bhutan","Bolivia","Bosnia and Herzegowina",
						"Botswana","Bouvet Island","Brazil","British Indian Ocean Territory","Brunei Darussalam",
						"Bulgaria","Burkina Faso","Burundi","Cambodia","Cameroon","Cape Verde","Cayman Islands",
						"Central African Republic","Chad","Chile","China","Christmas Island","Cocoa (Keeling) Islands",
						"Colombia","Comoros","Congo","Cook Islands","Costa Rica","Cote Divoire","Croatia",
						"Cuba","Cyprus","Czech Republic","Denmark","Djibouti","Dominica","Dominican Republic",
						"East Timor","Ecuador","Egypt","El Salvador","Equatorial Guinea","Eritrea","Estonia",
						"Ethiopia","Falkland Islands (Malvinas)","Faroe Islands","Fiji","Finland",
						"France, Metropolitan","French Guiana","French Polynesia","French Southern Territories",
						"Gabon","Gambia","Georgia","Ghana","Gibraltar","Greece","Greenland","Grenada",
						"Guadeloupe","Guam","Guatemala","Guinea","Guinea-Bissau","Guyana","Haiti",
						"Heard and Mc Donald Islands","Honduras","Hong Kong","Hungary","Iceland","India",
						"Indonesia","Iran (Islamic Republic of)","Iraq","Ireland", "Israel","Italy","Jamaica",
						"Japan","Jordan","Kazakhstan","Kenya","Kiribati","Korea, Democratic Peoples Republic of",
						"Korea, Republic of","Kuwait","Kyrgyzstan","Lao Peoples Democratic Republic","Latvia",
						"Lebanon","Lesotho","Liberia","Libyan Arab Jamahiriya","Liechtenstein","Lithuania",
						"Luxembourg","Macau","Macedonia, The Former Yugoslav Republic of","Madagascar",
						"Malawi","Malaysia","Maldives","Mali","Malta","Marshall Islands","Martinique","Mauritania",
						"Mauritius","Mayotte","Mexico","Micronesia", "Federated States of","Moldova, Republic of",                                         
						"Monaco","Mongolia","Montserrat","Morocco","Mozambique","Myanmar","Namibia","Nauru",                    
						"Nepal","Netherlands","Netherlands Antilles","New Caledonia","New Zealand","Nicaragua",
						"Niger","Nigeria","Niue","Norfolk Island","NorthParaguayern Mariana Islands","Norway","Oman",
						"Pakistan","Palau","Panama","Papua New Guinea","Peru","Philippines","Pitcairn", 
						"Poland","Portugal","Puerto Rico","Qatar","Reunion","Romania","Russian Federation", 
						"Rwanda","Saint Kitts and Nevis","Saint Lucia","Saint Vincent and the Grenadines",                     
						"Samoa","San Marino","Sao Tome and Principe","Saudi Arabia","Senegal","Seychelles",                        
						"Sierra Leone","Singapore","Slovakia (Slovak Republic)","Slovenia","Solomon Islands",
						"Somalia","South Africa","South Georgia and the South Sandwich Islands","Spain",                     
						"Sri Lanka","St. Helena","St. Pierre and Miquelon","Sudan","Suriname",
						"Svalbard and Jan Mayen Islands","Swaziland","Sweden","Switzerland","Syrian Arab Republic",
						"Taiwan","Tajikistan","Tanzania, United Republic of","Thailand","Togo","Tokelau",
						"Tonga","Trinidad and Tobago","Tunisia","Turkey","Turkmenistan","Turks and Caicos Islands",
						"Tuvalu","Uganda","Ukraine","UniteVatican City Stated Arab Emirates","United States Minor Outlying Islands",
						"Uruguay","Uzbekistan","Vanuatu","Venezuela","Viet Nam","Virgin Islands (British)",
						"Virgin Islands (U.S.)","Wallisw and Futuna Islands"," Western Sahara","Yeman",
						"Yugoslavia","Zaire","Zambia","Zimbabwe","Not Listed");

	for(count=0; count < a_Countries.length; count++){
   		f_form.options[count] = new Option(a_Countries[count]);
		f_form.options[count].value = a_Countries[count];
 	}	
	f_form.value = t_default;	
	return;
}

function populateStates(f_form, t_default)
{	
	a_States = new Array("AL","AK","AZ","AR","CA","CO","CT","DE","FL","GA",
						 "HI","ID","IL","IN","IA","KS","KY","LA","ME","MD",
						 "MA","MI","MN","MS","MO","MT","NE","NV","NH","NJ",
						 "NM","NY","NC","ND","OH","OK","OR","PA","RI","SC",
						 "SD","TN","TX","UT","VT","VA","WA","WV","WI","WY");

	for(count=0; count < a_States.length; count++){
   		f_form.options[count] = new Option(a_States[count]);
		f_form.options[count].value = a_States[count];
 	}
	
	f_form.value = t_default;
	
	return;
}
function checkpopupblocker(){
	var test_pop_up = window.open('','','width=1,height=1,left=0,top=0,scrollbars=no');
	var popUpsBlocked;
	if(test_pop_up){
		popUpsBlocked = false;
	 }
	else{
		popUpsBlocked = true;
	}
	test_pop_up.close();
	//alert(popUpsBlocked);
	if(popUpsBlocked == true){
	  alert('Please turn off the popup blocker in your browser options.\n');
	  (document.getElementById("pop_up_instr").style.display) = "block";
	}
	else{
		(document.getElementById("pop_up_instr").style.display) = "none";
	}
}
function showMessage(msg){
	//alert(msg);
	document.getElementById("pop_up_instr").innerHTML = msg;
	setTimeout("hideMessage()", 10000);
}
function hideMessage(){
	//alert("gets to hideMessage");
	document.getElementById("pop_up_instr").style.visibility = "hidden";
}
//open pop up with toolbars
function openPopUpToolbars(url, i_hi, i_wi, i_top) {
	i_screenWidth = screen.width;
	i_screenHeight = screen.height;
	if((i_hi == '') || (i_hi == 0) || (i_hi == 'undefined')) {
		i_winHeight = 570;
	}
	else {
		i_winHeight = i_hi;
	}	
	if((i_wi == '') || (i_wi == 0) || (i_wi == 'undefined')) {
		i_winWidth = 770;
	}
	else {
		i_winWidth = i_wi;
	}	
	if((i_top == '') || (i_top == 0) || (i_top == 'undefined')) {
		i_top = 1;
	}
	else {
		i_top = i_top;
	}	
	i_left = (i_screenWidth-i_winWidth)/2;				
	w_child = window.open(url, "_blank", "menubar=1,scrollbars,height=" + i_winHeight + ",width=" + i_winWidth + ",top=" + i_top + ",left=" + i_left + ",resizable=1");
	//w_child.focus;
	return;
}
function disableForm(f_form){
	
	//alert(f_form);
	for (i=0; i < f_form.elements.length; i++){
		if(f_form.elements[i].type != 'text'){
			(f_form.elements[i].disabled = true);
		}
		else{
			(f_form.elements[i].readOnly = true);
		}
	}	
}

