

var validationOptions = {
    validGroups: 0,
    additionalValidationRules: [['validate-length-5', '', function(v){
        return (v.length != 5 && v != "") ? false : true;
    }
],['validate-length-2', '', function(v){
        return (v.length != 2 && v != "") ? false : true;
    }
],['validate-length-2-4', '', function(v){
        return ( (v!=null || v != "") && (v.length < 2 || v.length > 4)) ? false : true;
    }
],['validate-length-3', '', function(v){
        return ((v!=null || v != "") && v.length != 3) ? false : true;
    }
],['validate-length-3-6', '', function(v){
        return ((v.length < 3 || v.length > 6)&& v != "") ? false : true;
    }
],['validate-length-3-5', '', function(v){
        return ((v.length < 3 || v.length > 5)&& v != "") ? false : true;
    }
], ['validate-length-lte-4', '', function(v){
        return (v.length > 4 && v != "") ? false : true;
    }
], ['validate-length-4', '', function(v){
        return (v.length != 4 && v != "") ? false : true;
    }
]
, ['validate-name', 'Please use only letters (a-z), numbers (0-9), a hypen (-), an apostrophe (\'), a period (.), or a space in this field. No other characters are allowed.', function(v) {
				return Validation.get('IsEmpty').test(v) ||  /^[a-zA-Z0-9 \.\'\-]+$/.test(v)
			}]
, ['validate-length-20', '', function(v){
    return (v != ""&& v.length >15 && v.length<21  ) ? true:false;
}
]
,	['validate-uk-address', 'Please use only letters (a-z), numbers (0-9), a comma (,), a hypen (-), an apostrophe (\'), a period (.), a pound sign (#), a forward-slash (/), or a space in this field. No other characters are allowed.', function(v) {
				return Validation.get('IsEmpty').test(v) ||  /^[a-zA-Z0-9 \.\'\-,#\/]+$/.test(v)
	}
]
,	['validate-uk-phone', 'Please use only numbers (0-9), a comma (,), a hypen (-), an apostrophe (\'), a period (.), a pound sign (#), a forward-slash (/), or a space in this field. No other characters are allowed.', function(v) {
				return Validation.get('IsEmpty').test(v) ||  /^[0-9\+ () \.\-]+$/.test(v)
	}
]
, ['validate-length-16', '', function(v){
        return (v.length != 16 && v != "") ? false : true;
    }
],['validate-email-confirm', 'Please re-enter your Email Address for verification.', {
					equalToField : 'email'
				}]]
};
	function pay(obj)
	{
		alert('pay');
		
		if (!obj.disabled)
		{
			window.location.href = "lotDetailConfirmPayment.html";
		}
	}
	
	function loginShow(yes)
	{
		alert('loginShow');
		if(yes)
		{
			document.getElementById("copartLogin").style.display = "block";
		}
		else
		{
			document.getElementById("copartDiscountLabel").style.display = "none";
			document.getElementById("copartDiscountValue").style.display = "none";
			document.getElementById("copartLogin").style.display = "none";
		}
	}
	
	function validateOutGoingPostCode(){
		var outGoingCode = $("outGoingCode").value;
		return validatePostCode(outGoingCode);		
	}
	
	function validateInComingPostCode(){
		var inComingCode = $("inComingCode").value;
		return validatePostCode(inComingCode);	
	}
	
	function validatePostCode(postCode){	
		return !Validation.get('IsEmpty').test(postCode);				
	}
	
	function validateCCExpiry( ) {
		var expiryMonth = $("expiryMonth");
		var expiryYear = $("expiryYear");
		
		var month = expiryMonth.options[expiryMonth.options.selectedIndex].value;
		var year = expiryYear.options[expiryYear.options.selectedIndex].value;
//		alert("month"+month);
//		alert("year"+year);
		var now = new Date();							// this function is designed to be Y2K compliant.
		now.setMonth(now.getMonth()+1);	
		var expiresIn = new Date(year,month,0,0,0);		// create an expired on date object with valid thru expiration date
    	expiresIn.setMonth(expiresIn.getMonth()+1);		// adjust the month, to first day, hour, minute & second of expired month
//    	alert("now.getTime() "+now.getMonth()+"year"+now.getYear());
//    	alert("expiresIn.getTime() "+expiresIn.getMonth()+"year"+expiresIn.getYear());
    	
    	if( now.getTime() < expiresIn.getTime() ) return true;
    	return false;									// then we get the miliseconds, and do a long integer comparison
}

	function validateCCStartingYear( ) {
		var startingMonth = $("cardStartMonth");
		var startingYear = $("cardStartYear");
		
		var month = startingMonth.options[startingMonth.options.selectedIndex].value;
		var year = startingYear.options[startingYear.options.selectedIndex].value;
//		alert("month"+month);
//		alert("year"+year);
		var now = new Date();							
		now.setMonth(now.getMonth()+1);	
		var startIn = new Date(year,month,0,0,0);		// create an expired on date object with valid thru expiration date
		// startIn.setMonth(startIn.getMonth()+1);		// adjust the month, to first day, hour, minute & second of start month
//    	alert("    now.getTime() "+ now.getMonth()     + "year" + now.getYear() + 
//    	      "\n  startIn.getTime() "+ startIn.getMonth() + "year" + startIn.getYear());

//		alert('now:' + now.getTime() + 'startIn:' + startIn.getTime());
//		alert(now.getTime() - startIn.getTime());
    	
    	if( now.getTime() >= startIn.getTime() ) return true;
    	return false;									// then we get the miliseconds, and do a long integer comparison
}
/*	function validateCC( ) {
		var expiryMonth = $("expiryMonth");
		var expiryYear = $("expiryYear");
		var startingMonth = $("cardStartMonth");
		var startingYear = $("cardStartYear");
		var endingMonth = expiryMonth.options[expiryMonth.options.selectedIndex].value;
		var endingYear = expiryYear.options[expiryYear.options.selectedIndex].value;
		var startingMonth = startingMonth.options[startingMonth.options.selectedIndex].value;
		var startingYear = startingYear.options[startingYear.options.selectedIndex].value;
//		alert("startingYear"+startingYear);
//		alert("startingMonth"+startingMonth);
//		alert("endingMonth"+endingMonth);
//		alert("endingYear"+endingYear);
		var startIn = new Date(startingYear,startingMonth,0,0,0);		
		startIn.setMonth(startIn.getMonth()+1);		// adjust the month, to first day, hour, minute & second of expired month
		var expiresIn = new Date(endingYear,endingMonth,0,0,0);		// create an expired on date object with valid thru expiration date
    	expiresIn.setMonth(expiresIn.getMonth()+1);		// adjust the month, to first day, hour, minute & second of expired month
    	//alert("StartIn.getTime() "+StartIn.getMonth()+"year"+StartIn.getYear());
    	//alert("expiresIn.getTime() "+expiresIn.getMonth()+"year"+expiresIn.getYear());
    	
    	if( startIn.getTime() < expiresIn.getTime() ) return true;
    	return false;									// then we get the miliseconds, and do a long integer comparison
}
*/

function clearNamesforfirstName(txtBox, defaultValue, otherTxtBox, otherDefault)
{
	if(txtBox.value==defaultValue) 
	
	{
		txtBox.value='';
	}
	
	if(otherTxtBox.value = otherDefault)
	{
		otherTxtBox.value='';
	}
}

function clearNamesforlastName(txtBox, defaultValue, otherTxtBox, otherDefault)
{
	if(txtBox.value==defaultValue) 
	
	{
		txtBox.value='';
	}
	
	if(otherTxtBox.value = otherDefault)
	{
		otherTxtBox.value='';
	}
}
	function registrationSubmit(formName, valid)
	{	
		valid.reset();
		var isValid = valid.validate();
		var errorMsg = "";
		if(!validateCCStartingYear()){
			errorMsg += message.invalidCardStartingDate + "<br>";
			isValid = false;
		}
		if(!validateCCExpiry()){
			errorMsg += message.invalidCardExpiryDate + "<br>";
			isValid = false;
		}
		
		var country = $("country");
		var selectedCountry = country.options[country.options.selectedIndex].value; 
		
		/*Do post code validations only for UK*/
		if(selectedCountry=="GBR"){
				
			if(!validateOutGoingPostCode()){
				errorMsg += message.requiredOutGoingPostCode + "<br>";
				isValid = false;
			}
			if(!validateInComingPostCode()){
				errorMsg += message.requiredInComingPostCode + "<br>";
				isValid = false;
			}	
		}
		
						
		if(errorMsg != "")
	    {
			$("errorContent").innerHTML = errorMsg;
			isValid = false;
	    }
	    if (isValid) 
    	{
			$("_eventId").value = "submitPaymentInfo";
			$(formName).submit();
    	}
    	return false;
 	}
 	
 	function lotDetailPage(formName){
		$("_eventId").value = "cancelPaymentScreen";
		$(formName).action="searchLot.html";
		$(formName).submit();
	}
	

 	function setCardType(labelId, valueId, yes){
 		if(yes)
		{
 			$('cardNumber').value="";
			$('cardNumber').maxLength=20;
			showHide(labelId, valueId, yes)
		}
		else
		{
			$('cardNumber').value="";
			$('cardNumber').maxLength=16;
			showHide(labelId, valueId, yes)
		}
 	}
 	function showHide(labelId, valueId, yes)
	{
		if(yes)
		{
		
			document.getElementById(labelId).style.display = "block";
			document.getElementById(valueId).style.display = "block";
		}
		else
		{
			document.getElementById(labelId).style.display = "none";
			document.getElementById(valueId).style.display = "none";
		}
	}
	function showloginForm(){
    
    getInfoDivPage(null, 'Divs/loginForm');
   // populateDivEmail();
	}
	function showAddresses(){
	    var inComingCode = $('inComingCode').value;
	     var outGoingCode = $('outGoingCode').value;
	   getInfoDivPage('addressList.ajax?inComingCode='+inComingCode+'&outGoingCode='+outGoingCode, 'Divs/address');

	}
function populateDivEmail(){
 
    	alert( document.form1._flowExecutionKey.value);
        	document.loginForm._flowExecutionKey.value = document.form1._flowExecutionKey.value;
}

function confirmRererveBay(selectedDate,dbDate){
		
    	$('confirmation').style.visibility='visible';
    	$('seletedDate').innerHTML= selectedDate;
    	$('reserveDate').value = dbDate;
    	$('bottomText').className = "red_alert"
    	$('avilableDatesText').className = "red_alert"
    	$('submitButton').disabled=false;		
}

function changeColor(){
	$('test').src =  'images/global/printer_icon2.jpg';
	$('test2').src =  'images/global/printer_icon2.jpg';
}





