//createCookie("dcerr", "", 1);


function valphone(s) {
	var xs = new String(s.value);
	var xc = xs.charAt(0);
	
	if (xc != 0) {
		document.getElementById("ErrMsg").innerHTML = "Telephone number must start with \"0\"";
		s.focus();
		s.select();
	}
}

function DisableButton() {
     document.forms[0].submit();
     window.setTimeout("disableButton('" + 
           window.event.srcElement.id + "')", 0);
}

function disableButton(buttonID) {
    document.getElementById(buttonID).disabled=true;
}
            
function PCase(STRING){
				
	var strReturn_Value = "";
	var iTemp = STRING.length;

	STRING = STRING.toLowerCase();				
	
	if (iTemp==0){
		return "";
	}
				
	var UcaseNext = false;
	strReturn_Value += STRING.charAt(0).toUpperCase();

	for (var iCounter=1;iCounter < iTemp;iCounter++){
		
		if (UcaseNext == true) {
			strReturn_Value += STRING.charAt(iCounter).toUpperCase();
		}
		else {
			strReturn_Value += STRING.charAt(iCounter).toLowerCase();
		}
					
		var iChar = STRING.charCodeAt(iCounter);
		if (iChar == 32 || iChar == 45 || iChar == 46 || iChar == 39) {
			UcaseNext = true;
		}
		else {
			UcaseNext = false;
		}
		
		if(iChar == 39){
			if(STRING.charCodeAt(iCounter+1)==115){
				UcaseNext = false;
			}
		}
					
		if(iChar == 99 || iChar == 67){
			if(STRING.charCodeAt(iCounter-1)==77 || STRING.charCodeAt(iCounter-1)==109){
				UcaseNext = true;
			}
		}
	} //End For

return strReturn_Value;
} //End Function

function makedate(strdate) {
						
	var xlen = strdate.length;
	var strReturn_Value = "";
	var finalstr = ""
					
	if (strdate.indexOf("/") == -1) {
				
		if (xlen == 0) {
			return "";
		}
						
		if (xlen >= 6) {
					
			for (var iCounter = 0; iCounter < xlen; iCounter++) {
							
				strReturn_Value += strdate.charAt(iCounter).toUpperCase();
				finalstr += strdate.charAt(iCounter).toUpperCase();
								
				if  (strReturn_Value.length == 2 || strReturn_Value.length == 4) {
						finalstr += "/";
				}
			}
		}
		else {
			finalstr = strdate;
		}
	}
	else {
		finalstr = strdate;
	}
	return finalstr;
} //makedate close

function blockbackspace() {
	if (window.event && window.event.keyCode == 8 ) {
		// try to cancel the backspace
		window.event.cancelBubble = true;
		window.event.returnValue = false;
		return false;
	}
}

function mykeyhandler() {
	var e = event.srcElement.tagName;
	if (window.event && window.event.keyCode == 8 && e != "INPUT" && e != "TEXTAREA") {
		// try to cancel the backspace
		window.event.cancelBubble = true;
		window.event.returnValue = false;
		return false;
	}
}

function leftTrim(sString) 
{
	while (sString.substring(0,1) == ' ')
	{
		sString = sString.substring(1, sString.length);
	}
	return sString;
}
			
function rightTrim(sString) 
{
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}
			
function trimAll(sString) 
{
	while (sString.substring(0,1) == ' ')
	{
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}		

function isDate(strDate) 
{
	var err = 0
	string = strDate
	var valid = "0123456789/"
	var ok = "yes";
	var temp;
				
	if (string.length > 0) {
			
		for (var i=0; i< string.length; i++) {
			temp = "" + string.substring(i, i+1);
			if (valid.indexOf(temp) == "-1") 
			{
				err = 1;
				document.getElementById("ErrMsg").innerText = "Invalid date format (dd/mm/yyyy).";
			}
		}
		
				
		if (string.length < 8 || string.length > 10) 
		{
			err=1;
			document.getElementById("ErrMsg").innerText = "Invalid date format (dd/mm/yy or dd/mm/yyyy).";
		}
						
					
		d = string.substring(0, 2) // day
		c = string.substring(2, 3)// '/'
		b = string.substring(3, 5) // month
		e = string.substring(5, 6)// '/'
		//f = string.substring(6, 10) // year
		
		if (string.length > 8) {
			f = string.substring(6, 10) // year

			if (f<1900 || f>2099) {
				err = 1;
				document.getElementById("ErrMsg").innerText = "Invalid date format must be dd/mm/yyyy!";
			}
			
		}
		else {
			f = string.substring(6, 8) // year

			if (f<00 || f>99) {
				err = 1;
				document.getElementById("ErrMsg").innerText = "Invalid date format must be dd/mm/yyyy!";
			}

		}
		
		
					
		if (b<1 || b>12) {
			err = 1;
			document.getElementById("ErrMsg").innerText = "Invalid month of the year entered!";
		}
						
		if (c != '/') {
			err = 1;
			document.getElementById("ErrMsg").innerText = "Invalid date seperator, only use '/'";
		}
					
					
		if (d<1 || d>31) {
			err = 1;
			document.getElementById("ErrMsg").innerText = "Invalid day of the month entered!";
		}

		if (e != '/') {
			err = 1;
			document.getElementById("ErrMsg").innerText = "Invalid date seperator, only use '/'";
		}
					
				
		if (b==4 || b==6 || b==9 || b==11)
		{
			if (d==31) {
				err=1;
				document.getElementById("ErrMsg").innerText = "Invalid day of the month, it only has 30 days";
			}
		}
			
		if (b==2)
		{
			var g=parseInt(f/4)
			if (isNaN(g)) 
			{
				err=1;
				document.getElementById("ErrMsg").innerText = "Invalid day of month, check the calender!";
			}
					
			if (d>29) err=1
			
			if (d==29 && ((f/4)!=parseInt(f/4))) {
				err=1;
				document.getElementById("ErrMsg").innerText = "Invalid day of the month, check the calender!";
			}	
		}
					
		if (err==1) 
		{
			return false;
		}
		else 
		{
			return true;
		}
	}
}

function emailval(field, cname) 
{
	if (field.value != "") {
	
		if	(emailCheck(field.value) == false) 
		{
			//document.getElementById("ErrMsg").innerText = "Invalid email address !";
			createCookie(cname, "1", "1");
						
			field.focus();
			field.blur();
			field.select();
		}
		else {
			eraseCookie(cname);
			document.getElementById("ErrMsg").innerText = ""
		}
	}
	else {
		eraseCookie(cname);
		document.getElementById("ErrMsg").innerText = ""
	}
}

function emailCheck (emailStr) {

/* The following variable tells the rest of the function whether or not
to verify that the address ends in a two-letter country or well-known
TLD.  1 means check it, 0 means don't. */

	var checkTLD=1;

	/* The following is the list of known TLDs that an e-mail address must end with. */

	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

	/* The following pattern is used to check if the entered e-mail address
	fits the user@domain format.  It also is used to separate the username
	from the domain. */

	var emailPat=/^(.+)@(.+)$/;

	/* The following string represents the pattern for matching all special
	characters.  We don't want to allow special characters in the address. 
	These characters include ( ) < > @ , ; : \ " . [ ] */

	var specialChars="\\(\\)><@,'!£$%^+={}#~?|`&*;:\\\\\\\"\\.\\[\\]";

	/* The following string represents the range of characters allowed in a 
	username or domainname.  It really states which chars aren't allowed.*/

	var validChars="\[^\\s" + specialChars + "\]";

	/* The following pattern applies if the "user" is a quoted string (in
	which case, there are no rules about which characters are allowed
	and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
	is a legal e-mail address. */

	var quotedUser="(\"[^\"]*\")";

	/* The following pattern applies for domains that are IP addresses,
	rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
	e-mail address. NOTE: The square brackets are required. */

	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

	/* The following string represents an atom (basically a series of non-special characters.) */

	var atom=validChars + '+';

	/* The following string represents one word in the typical username.
	For example, in john.doe@somewhere.com, john and doe are words.
	Basically, a word is either an atom or quoted string. */

	var word="(" + atom + "|" + quotedUser + ")";

	// The following pattern describes the structure of the user

	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

	/* The following pattern describes the structure of a normal symbolic
	domain, as opposed to ipDomainPat, shown above. */

	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

	/* Finally, let's start trying to figure out if the supplied address is valid. */

	/* Begin with the coarse pattern to simply break up user@domain into
	different pieces that are easy to analyze. */

	var matchArray=emailStr.match(emailPat);

	if (matchArray==null) {

	/* Too many/few @'s or something; basically, this address doesn't
	even fit the general mould of a valid e-mail address. */

	document.getElementById("ErrMsg").innerText = "Email address seems incorrect (check @ and .'s)";

	/*alert("Email address seems incorrect (check @ and .'s)");*/
	return false;
	}

	var user=matchArray[1];
	var domain=matchArray[2];

	// Start by checking that only basic ASCII characters are in the strings (0-127).

	for (i=0; i<user.length; i++) {
		if (user.charCodeAt(i)>127) {
			document.getElementById("ErrMsg").innerText = "This username contains invalid characters.";

		/*alert("Ths username contains invalid characters.");*/
			return false;
		}
	}
	for (i=0; i<domain.length; i++) {
		if (domain.charCodeAt(i)>127) {
			document.getElementById("ErrMsg").innerText = "This domain name contains invalid characters.";
			return false;
		}
	}

	// See if "user" is valid 

	if (user.match(userPat)==null) {

		// user is not valid
		document.getElementById("ErrMsg").innerText = "The username doesn't seem to be valid.";

		//alert("The username doesn't seem to be valid.");
		return false;
	}

	/* if the e-mail address is at an IP address (as opposed to a symbolic
	host name) make sure the IP address is valid. */

	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) {

		// this is an IP address

		for (var i=1;i<=4;i++) {
			if (IPArray[i]>255) {
				document.getElementById("ErrMsg").innerText = "Destination IP address is invalid!";
			//alert("Destination IP address is invalid!");
				return false;
			}
		}
		return true;
	}

	// Domain is symbolic name.  Check if it's valid.
			 
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	
	for (i=0;i<len;i++) {
		if (domArr[i].search(atomPat)==-1) {
			document.getElementById("ErrMsg").innerText = "The domain name does not seem to be valid.";

			//alert("The domain name does not seem to be valid.");
			return false;
		}
	}

	/* domain name seems valid, but now make sure that it ends in a
	known top-level domain (like com, edu, gov) or a two-letter word,
	representing country (uk, nl), and that there's a hostname preceding 
	the domain or country. */

	//alert(domArr[domArr.length-1].search(knownDomsPat));
	//alert(domArr[domArr.length-1].length);
	//alert(len);
	
	/*if (domArr[domArr.length-1].search(knownDomsPat)==-1 && len == 2) {
		document.getElementById("ErrMsg").innerText = "The address must end in a well-known domain or two letter " + "country.";
		return false;
	}
	else {
		if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) {
			document.getElementById("ErrMsg").innerText = "The address must end in a well-known domain or two letter " + "country.";
			return false;
		}
	}*/
	
	
	if ((checkTLD && domArr[domArr.length-1].search(knownDomsPat)==-1) && domArr[domArr.length-1].length!=2 ) {
	
				document.getElementById("ErrMsg").innerText = "The address must end in a well-known domain or two letter " + "country.";

			//alert("The address must end in a well-known domain or two letter " + "country.");
			return false;
	}

			// Make sure there's a host name preceding the domain.

	if (len<2) {
		document.getElementById("ErrMsg").innerText = "This address is missing a hostname!";

		//alert("This address is missing a hostname!");
		return false;
	}

	// If we've gotten this far, everything's valid!
	return true;
}

function valdate(valdt, field) 
{
	var dt = isDate(trimAll(valdt));
	field.value = trimAll(valdt);
									
		
	if (dt == false) {

		if (document.getElementById("ErrMsg").innerText == "") 
		{
			document.getElementById("ErrMsg").innerText = "* Invalid date entered, please check the details.!";
		}

		field.focus();
		field.select();
	}
	else if (dt == true) {
		document.getElementById("ErrMsg").innerText = ""
	}	
}

function futuredate(field) {
				
	var dt = trimAll(field.value);
	field.value = trimAll(field.value);
	document.getElementById("ErrMsg").innerText = "";
					
	if (dt != "") 
	{
					
		if (isDate(dt) == true) {
						
			var today = new Date();
					
			/*var dt = dt.split("/");
			var xmydate = new Date(dt[2], dt[1]-1, dt[0]);
			*/
							
			if (dt.length > 8) {
				var d = getDateFromFormat(dt,'dd/MM/yyyy');
			}
			else {
				var d = getDateFromFormat(dt,'dd/MM/yy');
			}
			
			var xmydate = new Date(d);
			
													
			if (xmydate.setDate(xmydate.getDate()) > today) {					
				document.getElementById("ErrMsg").innerText = "Invalid date keyed, must be less then today's date.";
				field.focus();
				field.select();
			}
		}
		else {
			if (document.getElementById("ErrMsg").innerText == "") 
			{
				document.getElementById("ErrMsg").innerText = "* Invalid date entered, please check the details.!";
			}
			field.focus();
			field.select();
		}	
	}
}

function chknvalue(field) {
// check for only numeric values on the address lines

	var strValidChars = "0123456789";
	var strChar;
	var blnResult = false;
	var blnfirst = false;
	var blnsecond = false;
	field.value = trimAll(field.value);
	var xtemp = trimAll(field.value);
	//alert(xtemp.length);


	if (xtemp.length != 0) {
	
		for (i = 0; i < xtemp.length && blnResult == false; i++)
		{
			strChar = xtemp.charAt(i);
			//alert(strChar);
			//alert(strValidChars.indexOf(strChar));
			
			if (i > 0 && strValidChars.indexOf(strChar) == -1)
			{
				blnResult = true;
			}
			
			if (i == 0 && strValidChars.indexOf(strChar) == -1) {
				blnfirst = true;
			}
			
			if (i == 1 && strValidChars.indexOf(strChar) == -1) {
				blnsecond = true;
			}
			
		} // for loop close
					
		if (xtemp.length < 2) {
			field.focus();
			field.select();
			document.getElementById("ErrMsg").innerText = "Oops! One character in length is not allowed.";
		}
		else if (blnsecond == false && blnfirst == true) {
			field.focus();
			field.select();
			document.getElementById("ErrMsg").innerText = "Oops! Invalid address detected, alpha character before numeric not allowed."
		}
		else if (blnResult == false) {
			field.focus();
			field.select();
			document.getElementById("ErrMsg").innerText = "Numerics only is allowed in this field.";		
		}
		else {document.getElementById("ErrMsg").innerText = "";}			
	}
}

function IsNumeric(field, xlen, xcomp, cname)
//  check for valid numeric strings	
{
	var strValidChars = "0123456789";
	var strChar;
	var blnResult = true;
	field.value = trimAll(field.value);
	var xtemp = trimAll(field.value);
	
	
	//document.getElementById("ErrMsg").innerText = "";
	
	if (xtemp.length != 0 && readCookie("qas") == "1") { 
		//  test strString consists of valid characters listed above
		for (i = 0; i < xtemp.length && blnResult == true; i++)
		{
			strChar = xtemp.charAt(i);
			if (strValidChars.indexOf(strChar) == -1)
			{
				blnResult = false;
			}
		} // for loop close
			//return blnResult;	 
		if (blnResult == true)  {
			eraseCookie(cname);
			
			// 0 means its must be xlen
			// 1 means its must not be more then xlen
			// 2 means phone validation
			if (xcomp == 0) {
			
				if (xtemp.length != xlen) {
					createCookie(cname, "1", "1");			
					document.getElementById("ErrMsg").innerText  = "Invalid number , should be a whole "+ xlen + " digits.";
					field.focus();
					field.blur();
					field.select();			
				}
				else {
					eraseCookie(cname);
				}
			}
			else if (xcomp == 1) {
			
				if (xtemp.length > xlen) {
					createCookie(cname, "1", "1");			
					document.getElementById("ErrMsg").innerText  = "Invalid number, should a less or equal to "+ xlen + " digits.";
					field.focus();
					field.blur();
					field.select();
				}
				else {
					eraseCookie(cname);
				}
			}
			else if (xcomp == 2) {
			
				if (xtemp.length < xlen || xtemp.length > 11) {
					createCookie(cname, "1", "1");			
					document.getElementById("ErrMsg").innerText  = "Invalid phone number, should be between 10 - 11 digits.";
					field.focus();
					field.blur();
					field.select();
							
				}
				else {
					eraseCookie(cname);
				}			
			}			
			
		}
		else {
		    createCookie(cname,"1","1");
			document.getElementById("ErrMsg").innerText = "Please check - non numeric value!";
			field.focus();
			field.blur();
			field.select();
		}										
	} // Main IF STATEMENT
	else {
		eraseCookie(cname);
		//document.getElementById("ErrMsg").innerText = "";
	}
}

function checkError(field, cname) {
	var xcheck = readCookie(cname);
	//alert(xcheck);
	if (xcheck != null) {
		field.focus();
		field.select();
	}
}

function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0; i<ca.length; i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}

function spiltText(field, xc) {
	var xpcode = trimAll(field.value);
	if (xpcode != "") {
	
		var pcode = xpcode.split(xc);
			
		if (pcode.length == 2 ) {
			document.getElementById("pcodeout").value = pcode[0];
			document.getElementById("pcodein").value = pcode[1];
		}
		else {
			document.getElementById("ErrMsg").innerText = "The postcode field must have space character";
			document.getElementById("pcodein").innerText = "";
			document.getElementById("pcodeout").innerText = "";
			field.focus();
			field.select();
		}
	}
	else {
		document.getElementById("ErrMsg").innerText = "";
		document.getElementById("pcodein").innerText = "";
		document.getElementById("pcodeout").innerText = "";
	}	
}

function Init()
	{
	if (window.XMLHttpRequest) { //Non-IE Browsers
		_req = new XMLHttpRequest();
	}
	else if (window.ActiveXObject){ //IE
		_req = new ActiveXObject("Microsoft.XMLHttp");
	}
}

processStateChange = function()
{
	if (_req.readyState == 4) { // only if "OK"
		if (_req.status == 200) {
			if (_req.responseText == "")
				return false;
			else {
				eval(_req.responseText);
			}
		}
	}
}

function Mod10(field) {  // v2.0
	var ccNumb = field.value;
	var valid = "0123456789"  // Valid digits in a credit card number
	var len = trimAll(ccNumb).length;  // The length of the submitted cc number
	var iCCN = parseInt(ccNumb);  // integer of ccNumb
	var sCCN = ccNumb.toString();  // string of ccNumb
	sCCN = sCCN.replace (/^\s+|\s+$/g,'');  // strip spaces
	var iTotal = 0;  // integer total set at zero
	var bNum = true;  // by default assume it is a number
	var bResult = false;  // by default assume it is NOT a valid cc
	var temp;  // temp variable for parsing string
	var calc;  // used for calculation of each digit

	document.getElementById("ErrMsg").innerHTML = "";

	if (len != 0) {
				
		// Determine if the ccNumb is in fact all numbers
		for (var j=0; j<len; j++) {
		temp = "" + sCCN.substring(j, j+1);
		if (valid.indexOf(temp) == "-1"){bNum = false;}
		}

		// if it is NOT a number, you can either alert to the fact, or just pass a failure
		if(!bNum){
		/*alert("Not a Number");*/bResult = false;
		}

		// Determine if it is the proper length 
		if((len == 0)&&(bResult)){  // nothing, field is blank AND passed above # check
		bResult = false;
		} else{  // ccNumb is a number and the proper length - let's see if it is a valid card number
		if(len >= 15){  // 15 or 16 for Amex or V/MC
			for(var i=len;i>0;i--){  // LOOP throught the digits of the card
			calc = parseInt(iCCN) % 10;  // right most digit
			calc = parseInt(calc);  // assure it is an integer
			iTotal += calc;  // running total of the card number as we loop - Do Nothing to first digit
			i--;  // decrement the count - move to the next digit in the card
			iCCN = iCCN / 10;                               // subtracts right most digit from ccNumb
			calc = parseInt(iCCN) % 10 ;    // NEXT right most digit
			calc = calc *2;                                 // multiply the digit by two
			// Instead of some screwy method of converting 16 to a string and then parsing 1 and 6 and then adding them to make 7,
			// I use a simple switch statement to change the value of calc2 to 7 if 16 is the multiple.
			switch(calc){
				case 10: calc = 1; break;       //5*2=10 & 1+0 = 1
				case 12: calc = 3; break;       //6*2=12 & 1+2 = 3
				case 14: calc = 5; break;       //7*2=14 & 1+4 = 5
				case 16: calc = 7; break;       //8*2=16 & 1+6 = 7
				case 18: calc = 9; break;       //9*2=18 & 1+8 = 9
				default: calc = calc;           //4*2= 8 &   8 = 8  -same for all lower numbers
			}                                               
			iCCN = iCCN / 10;  // subtracts right most digit from ccNum
			iTotal += calc;  // running total of the card number as we loop
		}  // END OF LOOP
		
		if ((iTotal%10)==0){  // check to see if the sum Mod 10 is zero
			bResult = true;  // This IS (or could be) a valid credit card number.
		} 
		else {
			bResult = false;  // This could NOT be a valid credit card number
		}
		}
	}
	
	// change alert to on-page display or other indication as needed.
	/*if(bResult) {
	alert("This IS a valid Credit Card Number!");
	}*/

		if(!bResult){
		//alert("This is NOT a valid Credit Card Number!");
		document.getElementById("ErrMsg").innerHTML = "Error: This is NOT a valid credit card number!";
		field.focus();
		field.blur();
		field.select();  
		}
	} // If len!=0 end
  return bResult; // Return the results
}

function getatsign(field) {
	document.getElementById("ErrMsg").innerHTML = "";
	var xstr = new String();
	xstr = field.value;
	var xi = xstr.indexOf("@");
	if (xi >= 0) {
		document.getElementById("ErrMsg").innerHTML = "Invalid postcode !!";
		field.focus();
		field.select();
	}
}

function valtime(S) {

	var xtime = new String()
	xtime = S.value;
	var xreturn = true;
	
	if (xtime != "") {
		xtime = xtime.replace(".", ":")
		S.value = xtime;
		xreturn = /^([01]?[0-9]|[2][0-3])(:[0-5][0-9])?$/.test(xtime);
	}
	else {
		document.getElementById("ErrMsg").innerHTML = "";	
	}
	
	if 	(xreturn == false) {
		document.getElementById("ErrMsg").innerHTML = "Invalid Time Entered !";
		S.focus();
		S.select();
	}
	
}

function sentenceCase(aForm) {
    var theText = aForm.value;
    theText = theText.toLowerCase().replace(/(^\s*\w|[\.\!\?]\s*\w)/g,function(c){return c.toUpperCase()});
    aForm.value = theText;
}




function fnamefocus(field) {
	var xfname = trimAll(document.getElementById("fname").value);
	
	if (xfname != "") {
		document.getElementById("lname").focus();
		document.getElementById("lname").select();
	}
	else {
		document.getElementById("initials").focus();
		document.getElementById("initials").select();
	}
}

function daysInMonth(month,year) {
	var m = [31,28,31,30,31,30,31,31,30,31,30,31];
	
	if (month != 2) return m[month - 1];
	if (year%4 != 0) return m[1];
	if (year%100 == 0 && year%400 != 0) return m[1];
	return m[1] + 1;
} 

