<!--
// setdate is to create a SQL server date from a series of 2 text boxes and a select menu
// All fields use the same stem for naming to facilitate the generic nature of the function
function setdate(frm,datefld) {
	var thisobj = ("document." + frm);
	var thisday = eval(thisobj + "." + datefld + "1.value");
	var thismon = eval(thisobj+"."+datefld+"2.options["+thisobj+"."+datefld+"2.selectedIndex].value");
	var thisyea = eval(thisobj + "." + datefld + "3.value");
	// irrespective of the rest of the date values, update the year to a 4 figure year
  	if ((thisyea<=100)&&(isNaN(parseInt(thisyea))==false))
		{if(thisyea>=31)
			{thisyea=(1900 + parseInt(thisyea));}
		else
			{thisyea=(2000 + parseInt(thisyea));}
		 eval(thisobj + "." + datefld + "3.value="+thisyea);
		}

	if (isNaN(parseInt(thisday))||thismon==0||isNaN(parseInt(thisyea)))
		{ eval(thisobj+"."+datefld+".value=''");}
	else
		{ 
		  if (thisday.length==1) thisday=("0" + thisday);
		  if (isDate(""+thisyea+thismon+thisday+"")==false) {
			alert(" "+thisday+"/"+thismon+"/"+thisyea+" is not a valid date");
			eval(thisobj+"."+datefld+".value=''");
			}
		  else  {var thisDate = new Date();
			if((datefld=="empDob")&&((thisDate.getFullYear()-thisyea)<15))
				{alert("Sorry, but that would make the age less than 16 - please try again");}
			else {thisfld = eval(thisobj+"."+datefld);thisfld.value=(""+thisyea+thismon+thisday+"");}
			}
		}
}

// Whereas this one allows the month to be a hidden or text field for year only choices
function setdateyr(frm,datefld) {
	var thisobj = ("document." + frm);
	var thisday = eval(thisobj + "." + datefld + "1.value");
	var thismon = eval(thisobj+"."+datefld+"2.value");
	if (thismon.length==1) thismon=("0" + thismon);
	var thisyea = eval(thisobj + "." + datefld + "3.value");
	// irrespective of the rest of the date values, update the year to a 4 figure year
  	if ((thisyea<=100)&&(isNaN(parseInt(thisyea))==false))
		{if(thisyea>=31)
			{thisyea=(1900 + parseInt(thisyea));}
		else
			{thisyea=(2000 + parseInt(thisyea));}
		 eval(thisobj + "." + datefld + "3.value="+thisyea);
		}

	if (isNaN(parseInt(thisday))||thismon==0||isNaN(parseInt(thisyea)))
		{ eval(thisobj+"."+datefld+".value=''");}
	else
		{ 
		  if (thisday.length==1) thisday=("0" + thisday);
		  if (isDate(""+thisyea+thismon+thisday+"")==false) {
			alert(" "+thisday+"/"+thismon+"/"+thisyea+" is not a valid date");
			eval(thisobj+"."+datefld+".value=''");
			}
		  else  {var thisDate = new Date();
			if((datefld=="empDob")&&((thisDate.getFullYear()-thisyea)<15))
				{alert("Sorry, but that would make the age less than 16 - please try again");}
			else {thisfld = eval(thisobj+"."+datefld);thisfld.value=(""+thisyea+thismon+thisday+"");}
			}
		}
}


function isDate(dateStr) {
    month = dateStr.substring(4,6);
    day = dateStr.substring(6,8);
    year = dateStr.substring(0,4);
    if (day < 1 || day > 31) { return false;}
    if ((month==4 || month==6 || month==9 || month==11) && day>=31) {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)) {return false;}
    }
    return true; // date is valid
}

// setzero is to turn a text string (which is a number) into a number with two padded decimal places
function setzero(sz_num) {
	sz_num = "" + sz_num;
	sz_num = sz_num.replace(",","");
	if(isNaN(sz_num)) sz_num = "0" 
	sz_num = parseFloat(sz_num);
	sz_num = Math.round(sz_num*100)/100;
	sz_num = "" + sz_num;
	var sz_dotpos = sz_num.indexOf('.');
	if (sz_dotpos < 0) sz_num+=".00";
	if (sz_dotpos==(sz_num.length-1)) sz_num+="00";
	if (sz_dotpos==(sz_num.length-2)) sz_num+="0";
	return sz_num ;
}

function showhide(id) { 
	obj = document.getElementById(id); 
	if (obj.style.display == "none") obj.style.display = ""; else obj.style.display = "none"; 
} 
function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
    if(document.layers)	   //NN4+
       if(document.layers[szDivID].visibility == "show") document.layers[szDivID].visibility = "hide"; else document.layers[szDivID].visibility = "show";
    else if(document.getElementById)	  //gecko(NN6) + IE 5+
    {
        var obj = document.getElementById(szDivID);
        if(obj.style.visibility == "visible") obj.style.visibility = "hidden"; else obj.style.visibility = "visible";
    }
    else if(document.all)	// IE 4
        if(document.all[szDivID].style.visibility=="visible") document.all[szDivID].style.visibility = "hidden"; else document.all[szDivID].style.visibility = "visible";
		 showhide(szDivID)
}

// Ajax functions
function GetXmlHttpObjectForum() {
	var xmlHttp=null;
	try { xmlHttp=new XMLHttpRequest(); } // Firefox, Opera 8.0+, Safari
	catch (e) { // Internet Explorer
		try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
	catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
	}
	return xmlHttp;
}
function forumajax(div, qtype, thispage, chkval) {
	//if(qtype==1) 
	//if(handle=="" && notempty) { alert("Sorry, but you have not entered a <%=checktitle%> to check"); return false; }
	//if(handle=="" && !notempty) { return false; }
	//document.getElementById(div).innerHTML='<div>Checking ...</div>';
	srch=chkval
	xmlHttp=GetXmlHttpObjectForum();
	if (xmlHttp==null) { alert ("Your browser does not support AJAX!"); return; } 
	xmlHttp.onreadystatechange=function() { if (xmlHttp.readyState==4) { document.getElementById(div).innerHTML=xmlHttp.responseText } }
	xmlHttp.open("GET",thispage+"?ajax="+div+"|"+qtype+"|"+srch+"|"+new Date().getTime(),true);
	xmlHttp.send(null);
} 

function checkusername(div, qtype, nameval, urn, fullpath) {
	xmlHttp=GetXmlHttpObjectForum();
	if (xmlHttp==null) { alert ("Your browser does not support AJAX!"); return; } 
	xmlHttp.onreadystatechange=function() { if (xmlHttp.readyState==4) { document.getElementById(div).innerHTML=xmlHttp.responseText } }
	xmlHttp.open("GET",fullpath+"forum/inc/handlecheck.asp?x="+div+"|"+qtype+"|"+nameval+"|"+urn+"|"+new Date().getTime(),true);
	xmlHttp.send(null);
} 
//-->