function isNotEmpty(obj)
{
	if(obj.value!='') return true;
	obj.className='alert';
	obj.focus();
	respopnseObj=document.getElementById('jsResponse');
	respopnseObj.style.display='block';
	respopnseObj.innerHTML='All fields marked with asterisk should be filled in';
	return false;
}

function isEmailValid(obj)
{
    if (/^([\w-~_]+\.)*[\w-~_]+@([\w-_]+\.){1,3}\w{2,4}$/.test(obj.value)) return true;
	obj.className='alert';
	obj.focus();
	respopnseObj=document.getElementById('jsResponse');
	respopnseObj.style.display='block';
	respopnseObj.innerHTML='Email is not valid';
	return false;
}

function agreement() {
	obj=document.getElementById('agreementMessage');
	obj.style.display='block';
	return false;
}
function agree() {
	obj=document.getElementById('findForm');
	obj.submit();
}

function disagree() {
	obj=document.getElementById('agreementMessage');
	obj.style.display='none';
}

function isAreaCode(obj)
{
	str=obj.value;
	if(str.length==3 && parseInt(str)+0==str) return true;
	obj.className='alert';
	obj.focus();
	respopnseObj=document.getElementById('jsResponse');
	respopnseObj.style.display='block';
	respopnseObj.innerHTML='Wrong Area Code';
	return false;
}

function isAgreed(obj)
{
	if(obj.checked) return true;
	obj.className='alert';
	obj.focus();
	respopnseObj=document.getElementById('jsResponse');
	respopnseObj.style.display='block';
	respopnseObj.innerHTML='You have to check the box "I have read and agree with The Terms and Conditions"';
	return false;
}

function selectMainAreaCode(obj) {
	objSel=document.getElementById('areaCodeSelect')
	objSel.style.display='none';
	clearOptions(objSel);
	document.getElementById('submitButton').disabled=true;
	areaCode=parseInt(obj.value);
	obj.value=areaCode;
	if(areaCode > 0){
		change('areaCodeSelect',areaCode);
	}
	return false;
}

function checkSelected(obj){
	if(obj.value > 0) state=false;
	else state=true;
	document.getElementById('mainAreaCodeId').value=obj.value;
	document.getElementById('submitButton').disabled=state;
}




var ldr=null;

function change(queryName,params)
{
	 if(ldr&&ldr.readyState!=0) { ldr.abort() }
	 ldr=selector();
	 if(ldr)
	 {
		var now = new Date();
		ldr.open("GET","/ajax.php?q="+queryName+"&params="+params+"&t="+now.getSeconds(),true);
		ldr.onreadystatechange=function()
		{
			if(ldr.readyState==4 && ldr.responseText)
			{
				eval(ldr.responseText);
			}
		};
		ldr.send(null)
	 }
}

function selector()
{
	var A=null;
	try{A=new ActiveXObject("Msxml2.XMLHTTP")}
	catch(e){try{A=new ActiveXObject("Microsoft.XMLHTTP")}
	catch(oc){A=null}}
	if(!A&&typeof XMLHttpRequest!="undefined") {A=new XMLHttpRequest()}
	return A
}

function clearOptions(selObj) {
	if(selObj.options.length>0) {
		selObj.options[0]=null;
		clearOptions(selObj);
	}
}

function add(sel,v,n){
	var obj=document.getElementById(sel);
	var newOpt=obj.appendChild(document.createElement('option'));
	newOpt.text=n;
	newOpt.value=v;
}

