function showhidediv(id, type){
	var mobile=trim($('MOBILE').value);
	var name=trim($('NAME').value);	
	var city='';	
	if($('nameerr')){$('nameerr').innerHTML='';}
	if($('mobilerr')){$('mobilerr').innerHTML='';}
	if($('cityerr')){$('cityerr').innerHTML='';}
	if($('nameerr')){$('nameerr').style.display='none';}
	if($('mobilerr')){$('mobilerr').style.display='none';}
	if($('cityerr')){$('cityerr').style.display='none';}
	if(type){
		city=trim($('CITY').value);
		if($('cityerr')){$('cityerr').innerHTML='';}		
		if($('cityerr')){$('cityerr').style.display='none';}
	}
	if(id==1){
		$('interestdiv').style.display='none';
		$('thankudiv').style.display='none';
		$('detaildiv').style.display='block';
		$('MOBILE').value='';
		$('NAME').value='';
	}
	if(id==2){
		if ($('interestdiv')) { $('interestdiv').style.display='none'; }
		if ($('detaildiv')) { $('detaildiv').style.display='block'; }
		if ($('thankudiv')) { $('thankudiv').style.display='none';}		
		if(name==''){
			$('nameerr').style.display='block';
			$('nameerr').innerHTML='Enter your name';
			$('NAME').focus();
			return false;
		}
		else if(name.search((/^[0-9a-zA-Z\- ]+$/))) {
			$('nameerr').style.display='block';
			$('nameerr').innerHTML='Enter a valid name';
			return false;
		}
		else if(mobile==''){
			$('mobilerr').style.display='block';
			$('mobilerr').innerHTML='Enter your number';
			$('MOBILE').focus();
			return false;
		}
		else if(mobile.search((/^[0-9\- ]+$/))){
			$('mobilerr').style.display='block';
			$('mobilerr').innerHTML='Enter a valid number';
			return false;
		}
		else if((city=='' && type==1) || (city.search((/^[a-zA-Z\- ]+$/)) && type==1)){
			if(city==''){
				$('cityerr').style.display='block';
				$('cityerr').innerHTML='Enter your city name';
				$('CITY').focus();
				return false;
			}
			else if(city.search((/^[a-zA-Z\- ]+$/))) {
				$('cityerr').style.display='block';
				$('cityerr').innerHTML='Enter a valid city name';
				return false;
			}
		}
		else {
			var xmlHttp = createajax();			
			/* file name split */
			var pmlocvar=location.href;
			var pmlocvarsplt=pmlocvar.split("/");
			var pmlocvarspltend=pmlocvarsplt[pmlocvarsplt.length-1];
			var pmlocvarspltendsplt=pmlocvarspltend.split(".");
			var pmlocvarfilename=pmlocvarspltendsplt[0];
			//alert(pmlocvarfilename);
			/* file name split */
			if (pmlocvarfilename=="call-us"){
				var url= "callus-form.php?mobile="+mobile+"&name="+name;
				if(type=='1'){
					url+="&city="+city+"&clicktrack="+type;
				}
			} else {
				var url= "homeform.php?mobile="+mobile+"&name="+name;
				if(type=='1'){
					url+="&city="+city+"&clicktrack="+type;
				}
			}
			xmlHttp.open("GET",url,true);
			xmlHttp.onreadystatechange=function() {
			  if (xmlHttp.readyState==4){
				if ($('interestdiv')) { $('interestdiv').style.display='none'; }
				$('detaildiv').style.display='none';
				$('thankudiv').style.display='block';
				$("thankudiv").innerHTML=xmlHttp.responseText;
				}
			  }
			xmlHttp.send(null);
		}
	}
	if(id==3){		
		$('interestdiv').style.display='block';
		$('detaildiv').style.display='none';
		$('thankudiv').style.display='none';
		$('MOBILE').value='';
		$('NAME').value='';

	}
}

function trim(str) {
    return str.replace(/^\s+|\s+$/g,'');
}


