function popup() {
	window.open("/themes/forrest_group/displays/t_and_c.html","","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=400,left=50,top=50");
}

function buildDate(){
	var todaysDate = new Date();
	var todaysMonth = todaysDate.getMonth();
	var todaysDay = todaysDate.getDate();
	var todaysYear = todaysDate.getFullYear();
	todaysMonth += 1
	switch (todaysMonth){
		case 1 :
		todaysMonth = "Jan";
		break;
		case 2 :
		todaysMonth = "Feb";		
		break;
		case 3 :
		todaysMonth = "Mar";		
		break;
		case 4 :
		todaysMonth = "Apr";		
		break;
		case 5 :
		todaysMonth = "May";
		break;
		case 6 :
		todaysMonth = "Jun";
		break;
		case 7 :
		todaysMonth = "Jul";
		break;
		case 8 :
		todaysMonth = "Aug";
		break;
		case 9 :
		todaysMonth = "Sep";
		break;
		case 10 :
		todaysMonth = "Oct";
		break;
		case 11 :
		todaysMonth = "Nov";
		break;
		case 12 :
		todaysMonth = "Dec";
		break;
	}
	if (todaysDay < 10){
		todaysDay = "0" + todaysDay;
	}
	var dateString = todaysDay + " - " + todaysMonth + " - " + todaysYear;
	document.applyForm.applyDate.value = dateString;
}

function checkValue(theInput){
	if (theInput.value.length > 0){
		if (theInput.value.indexOf(".") == -1){
			theInput.value = theInput.value + ".00";
		}
		if(theInput.value.indexOf(".") != theInput.value.lastIndexOf(".")){
			return false;
		}
		for(i=0; i<=theInput.value.length-1; i++){
			if ((theInput.value.charAt(i) < 0) && (theInput.value.charAt(i) > 9) && (theInput.value.charAt(i) != ".")){
				return false;
			}
		}		
	} else {
		return false;
	}
	return true;
}

var errors='';
function checkForm(theForm){
errors='';
	if (isBlank(theForm.yourReference)){
		errors+='\nYour Reference';
	}

	if (isBlank(theForm.occupierName)){
		errors+='\nOccupier Name';
	}	 
    if (isBlank(theForm.applyDate)){
    	errors+='\nDate';
	}	 
    if (isBlank(theForm.propertyAddressLine1)){
    	errors+='\nProperty Address Line 1';
	}
    if (isBlank(theForm.propertyAddressLine2)){
    	errors+='\nProperty Address Line 2';
	}
    if (isBlank(theForm.postcode)){
    	errors+='\nPostcode';
	}
	propertyTypeChecked = false;
	for (i=0; i< theForm.propertyType.length; i++){
		if (theForm.propertyType[i].checked == true){
			propertyTypeChecked = true;
		}
	}
	if (propertyTypeChecked == false) {
		errors+='\nProperty Type';
	}
    if (isBlank(theForm.quantity)){
    	errors+='\nSign Quanity';
	}
    if (isNotANumber(theForm.quantity)){
    	errors+='\nSign Quanity';
	}
    if (isBlank(theForm.signSize)){
    	errors+='\nSign Size';
	}
	signTypeChecked = false;
	for (i=0; i< theForm.signType.length; i++){
		if (theForm.signType[i].checked == true){
			signTypeChecked = true;
		}
	}
	if (signTypeChecked == false) {
		errors+='\nSign Type';
	}
	if (isBlank(theForm.fixing)){
		errors+='\nFixing Instructions';
	}
	keysRequiredChecked = false;
	for (i=0; i< theForm.keysRequired.length; i++){
		if (theForm.keysRequired[i].checked == true){
			keysRequiredChecked = true;
		}
	}
	if (keysRequiredChecked == false) {
		errors+='\nKeys Required';
	}	
	if (isBlank(theForm.signWording)){
		errors+='\nSign Wording';
	}
	if (isBlank(theForm.company)){
		errors+='\nCompany';
	}
	if (isBlank(theForm.office)){
		errors+='\nOffice';
	}
	if (isBlank(theForm.orderedBy)){
		errors+='\nOrdered By';
	}
	if (isNotEmail(theForm.email)){
        	errors+='\nContact Email';
	}
	if (theForm.tandc.checked != true){
        	errors+='\nPlease read the Terms and Conditions';
	}
}