// JScript source code
function isValidEmail(str) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str)){
		return true;
	}
	else {
		return false;
	}
}

function addLoadEvent(func) {	
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;		
	} 
	else {
		window.onload = function() {
		oldonload();		
		func();
		}
	}
}

function clearText(field){
    if (field.defaultValue == field.value) field.value = '';
    else if (field.value == '') field.value = field.defaultValue;
}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function displayText(textid,maxtext){   
    for (var i=1;i<maxtext+1;i++){        
        document.getElementById("intro" + i).style.display='none';
    }
    
    //alert(textid);
    document.getElementById("intro" + textid).style.display='block';
}

function checkenquiry(){
	var ftxt = '';

	if (document.enquiryform.Name.value==''){
		ftxt += '\n- Please enter your Name.';
	}
	
	if (document.enquiryform.Telephone.value==''){
		ftxt += '\n- Please enter your Telephone Number.';
	}
	
	if (document.enquiryform.Enquiry.value==''){
		ftxt += '\n- Please enter your Enquiry.';
	}
	
	if (ftxt!==''){
		alert('One or more errors were found while submitting this form. The errors found are displayed below.\n' + ftxt + '\n\nPlease correct the above errors and try again.');
		return false;
	}
	else {
		return true;
	}
}

function checkinstallationform(){
	var ftxt = '';

	if (document.CustomerForm.CustomerName.value==''||document.CustomerForm.CustomerName.value=='your name'){
		ftxt += '\n- Please enter your Name.';
	}
	
	if (document.CustomerForm.CustomerTel.value==''||document.CustomerForm.CustomerTel.value=='your tel. no.'){
		ftxt += '\n- Please enter your Telephone Number.';
	}
		
	if (document.CustomerForm.CustomerDate.value=='preffered installation date'){
		ftxt += '\n- Please select a date.';
	}

	if (ftxt!==''){
		alert('One or more errors were found while submitting this form. The errors found are displayed below.\n' + ftxt + '\n\nPlease correct the above errors and try again.');
		return false;
	}
	else {
		return true;
	}
}

