﻿

function ValidPhoneCallback(sPhone,mobileCheck)
{
    var bValid;

    bValid = true;

    if((sPhone.length != 11) && (sPhone.length != 12) && (sPhone.length != 13))  {
        bValid = false;
    }
    else {
        for(i = 0; i < sPhone.length; i++) {
            if((sPhone.charAt(i) < "0" || sPhone.charAt(i) > "9") && (sPhone.charAt(i) != " " && sPhone.charAt(i) != "-")) {
                bValid = false;
                break;
            }
        }
    }
	
	if (mobileCheck == true)
	{
		if (sPhone.substring(0,2) != "07") {
	        bValid = false;
		}
	}

    return bValid;
}

function isNumericCallback(num)
{
	var chkStr ='0123456789 ';
	var ctr;
	var ok;
	ok = true;

	for(ctr=0;ctr<num.length;ctr++)
	{
		if(chkStr.indexOf(num.charAt(ctr))==-1)
		{
			ok=false;
		}
	}
	return ok;
}

function CheckCallbackForm()
{
	var bOK;
	var obj;
	var strCheck;
	var i;
	bOK=true;
		

	txtCallbackName = document.getElementById("txtCallbackName");
	txtCallbackContactNo = document.getElementById("txtCallbackContactNo");
	cbocallTime =  document.getElementById("cbocallTime");
	cbocallReason = document.getElementById("cbocallReason");
	
	

	if((txtCallbackName.value == "")   && (bOK == true))
	{
		
		alert("Form Help\n=====================\nPlease enter your name, so that\nwe can address you on the call");
		txtCallbackName.focus();
		bOK = false; 
	}
	
	
   	if(((txtCallbackContactNo.value == "") || (ValidPhoneCallback(txtCallbackContactNo.value,false) == false))  && (bOK == true))
	{
		
		alert("Form Help\n=====================\nPlease enter your telephone number,\nso that we can call you");
		txtCallbackContactNo.focus();
		bOK = false;
	}
	
	

   	if((cbocallTime.value == "#")   && (bOK == true))
	{
		
		alert("Form Help\n=====================\nPlease tell us the best time\nto call you back");
		cbocallTime.focus();
		bOK = false; 
	}
	

 	

   	if((cbocallReason.value == "#")   && (bOK == true))
	{ 
		alert("Form Help\n===================\nPlease tell us the reason\nfor the call back");
		cbocallReason.focus();
		bOK = false;
	}
	

	
 	return bOK;
 	   
}
