// Cokkie Set For Location {Start}


function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return 'saurabh';
}

function getcookie(){
        
		var x = readCookie('location');
	   	if(x.toString()=='saurabh'){
     	  document.getElementById("notset").style.display="";
     	  document.getElementById("set").style.display="none";
		  document.getElementById("showlocal").style.display="none";
     	  document.getElementById("showlocalmesage").style.display="";
		}else{
		  document.getElementById("notset").style.display="none";
     	  document.getElementById("set").style.display="";
          document.getElementById("showlocal").style.display="";
     	  document.getElementById("showlocalmesage").style.display="none";

		}
}
function getcookieheader(){
        var h = readCookie('location');
	   	if(h.toString()=='saurabh'){
     	  document.getElementById("notset").style.display="";
     	  document.getElementById("set").style.display="none";
		 
		}else{
		  document.getElementById("notset").style.display="none";
     	  document.getElementById("set").style.display="";
         
		}
}
function getname(){
  var z = readCookie('visitorname');
  if(z.toString() != 'NULL'){
    document.frmcomment.vname.value = z;
	
  }
}
// Cokkie Set For Location {End}


// Other Function { Start }

function removeAllOptions(selectbox) {
var i;
for(i=selectbox.options.length-1;i>=0;i--) {
selectbox.remove(i);
}
}

function addOption(selectbox,text,value ) {
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
selectbox.options.add(optn);
}


function addOption_list(selectbox, text, value){
	addOption(selectbox, text, value);
}


// End of  Other Function { End }


// clear the input box
function clearbox(name){
document.getElementById(name).value= "";
}


//// Call the function //////////////////////////////

// call for cookie


function getlocation(){
	    
		 createCookie('location',document.getElementById("location").value,365);
		 getcookie();
		 location.href = "http://www.fastnews_rss";
//		 location.href = "http://localhost/ATS";
}
function getlocation1(){
	    
		 createCookie('location',document.getElementById("location").value,365);
		 getcookie();
		 location.href = "http://www.fastnews_rss/index.php?module=category&subcatname=Local";
//		 location.href = "http://localhost/ATS/index.php?module=category&subcatname=Local";
}
function show(layer_ref) {
if(layer_ref == "a"){
document.getElementById(layer_ref).style.display ="";
document.getElementById("b").style.display ="none";
document.getElementById("c").style.display ="none";
}
else if(layer_ref == "b"){
document.getElementById(layer_ref).style.display ="";
document.getElementById("a").style.display ="none";
document.getElementById("c").style.display ="none";
}
else if(layer_ref == "c"){
document.getElementById(layer_ref).style.display ="";
document.getElementById("a").style.display ="none";
document.getElementById("b").style.display ="none";
}
}

function classifiedsearch(){
	 var flag = 0;
	if(document.getElementById("csearch").value == "" || document.getElementById("csearch").value == "Keyword" ){
	  document.getElementById("ckeyword").innerHTML = "<font color=red>Enter a keyword.</font>";
	  document.getElementById("csearch").focus();
	  return false;
	}
	if(document.getElementById("cloc").value == ""){
	  document.getElementById("clocation").innerHTML = "<font color=red>Please enter a location. Ex: 110006 or Delhi.</font>";
	  document.getElementById("cloc").focus();
	  return false;
	}
	if(document.getElementById("cloc").value != ""){
		
	   if((!is_char(document.getElementById("cloc").value))  && (!is_validZip(document.getElementById("cloc").value))){
	     flag = 1;
	   }else{
	     flag = 0;
	   }
	 
       if(flag == 1){
	     document.getElementById("clocation").innerHTML = "<font color=red>Please enter a valid location. Ex: 110006 or Delhi.</font>";
		 return false;
	   }document.getElementById("scategory").value
	}
	location.href='Classified/'+document.getElementById("scategory").value+','+document.getElementById("csearch").value+'/'+document.getElementById("cloc").value+'/0.html';
}
function jobsearch(){
		 var flag = 0;
	if(document.getElementById("jsearch").value == "" || document.getElementById("jsearch").value == "Keyword" ){
	  document.getElementById("jkeyword").innerHTML = "<font color=red>Enter a keyword.</font>";
	  document.getElementById("jsearch").focus();
	  return false;
	}
	if(document.getElementById("jloc").value == ""){
	  document.getElementById("jlocation").innerHTML = "<font color=red>Please enter a location. Ex: 110006 or Delhi.</font>";
	  document.getElementById("jloc").focus();
	  return false;
	}
	if(document.getElementById("jloc").value != ""){
		
	  if((!is_char(document.getElementById("jloc").value))  && (!is_validZip(document.getElementById("jloc").value))){
	     flag = 1;
	   }else{
	     flag = 0;
	   }
	   if(flag == 1){
	     document.getElementById("jlocation").innerHTML = "<font color=red>Please enter a valid location. Ex: 110006 or Delhi.</font>";
		 return false;
	   }
	}
	location.href='Jobs/'+document.getElementById("jsearch").value+'/'+document.getElementById("jloc").value+'/0.html';
}


function apartmentsearch(){
	 var flag = 0;
	if(document.getElementById("asearch").value == "" || document.getElementById("asearch").value == "Keyword,Category" ){
	  document.getElementById("akeyword").innerHTML = "<font color=red>Enter a keyword, category.</font>";
	  document.getElementById("asearch").focus();
	  return false;
	}
	if(document.getElementById("aloc").value == ""){
	  document.getElementById("alocation").innerHTML = "<font color=red>Please enter a location. Ex: 110006 or Delhi.</font>";
	  document.getElementById("aloc").focus();
	  return false;
	}
	if(document.getElementById("aloc").value != ""){
		
	   if((!is_char(document.getElementById("aloc").value))  && (!is_validZip(document.getElementById("aloc").value))){
	     flag = 1;
	   }else{
	     flag = 0;
	   }
	   if(flag == 1){
	     document.getElementById("alocation").innerHTML = "<font color=red>Please enter a valid location. Ex: 110006 or Delhi.</font>";
		 return false;
	   }
	}
	location.href='index.php?module=category&catname=Classified&q='+document.getElementById("asearch").value+'&l='+document.getElementById("aloc").value;
}


