
//DIV Show Error
function show(id)
{
	
	el = document.getElementById(id);
	
	if (el.style.display == 'none')
	{
		el.style.display = '';
	} 
	
}

function hide(id)
{
	
	el = document.getElementById(id);
	
	if(id=='ShowSchedule')
	{							//if id is from list property form and clicked YES radio of list with package, reset schedule radio to unchecked if checked
		get_chk = document.getElementById('chkSchedule');
		get_chk.checked = false;
		get_chk.value = 0;
	}
	
	if (el.style.display == '')
	{
		el.style.display = 'none';
	} 
	
}















// COMMON FUNCTIOn

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

//Email check
function isEmail(str)
{
   //  var regex = /^[-_.a-z0-9]+@(([-_a-z0-9]+\.)+|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i;
var regex = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
return regex.test(str);
}

//DIV Show Error
function show_error(id)
{
	
	el = document.getElementById(id);
	
	if (el.style.display == 'none')
	{
		el.style.display = '';
	} 
	
}

function hide_error(id)
{
	
	el = document.getElementById(id);
	
	if (el.style.display == '')
	{
		el.style.display = 'none';
	} 
	
}
//-------------------------


//FOR MAIN TOP SEARCH USE


function showT(f){

	if(f.radCategory[0].checked)
	{
		
	    var combobox = document.getElementById("py_budget1");
		
		combobox.options.length = 0;
		combobox.options.add(new Option("Below 10 Lacs.","1"));
		combobox.options.add(new Option("10 to 15 Lacs.","10"));
		combobox.options.add(new Option("15 to 20 Lacs.","15"));
		combobox.options.add(new Option("20 to 30 Lacs.","20"));
		combobox.options.add(new Option("30 to 40 Lacs.","30"));
		combobox.options.add(new Option("40 to 50 Lacs.","40"));
		combobox.options.add(new Option("50 to 60 Lacs.","50"));
		combobox.options.add(new Option("60 to 75 Lacs.","60"));
		combobox.options.add(new Option("75 to 1 Crore","75"));
		combobox.options.add(new Option("Above 1 Crore","11"));
		combobox.options.add(new Option("Any","0"));
		


		
	}
	else if(f.radCategory[1].checked)
	{
	
		
		var combobox = document.getElementById("py_budget1");
		
		combobox.options.length = 0;
		
		combobox.options.add(new Option("Below 5,000","1"));
		combobox.options.add(new Option("5,000 to 10,000","5"));
		combobox.options.add(new Option("10,000 to 15,000","10"));
		combobox.options.add(new Option("15,000 to 20,000","15"));
		combobox.options.add(new Option("20,000 to 25,000","20"));
		combobox.options.add(new Option("25,000 to 30,000","25"));
		combobox.options.add(new Option("Above 30,000","30"));
		combobox.options.add(new Option("Any","0"));

	
	}
	
}


//FOR OTHER FORM USE


function showT_form(f){

	if(f.radCategory[0].checked)
	{
		
	    var combobox = document.getElementById("py_budget");
		
		combobox.options.length = 0;
		combobox.options.add(new Option("Below 10 Lacs.","1"));
		combobox.options.add(new Option("10 to 15 Lacs.","10"));
		combobox.options.add(new Option("15 to 20 Lacs.","15"));
		combobox.options.add(new Option("20 to 30 Lacs.","20"));
		combobox.options.add(new Option("30 to 40 Lacs.","30"));
		combobox.options.add(new Option("40 to 50 Lacs.","40"));
		combobox.options.add(new Option("50 to 60 Lacs.","50"));
		combobox.options.add(new Option("60 to 75 Lacs.","60"));
		combobox.options.add(new Option("75 to 1 Crore","75"));
		combobox.options.add(new Option("Above 1 Crore","11"));
		combobox.options.add(new Option("Any","0"));
		
	}
	else if(f.radCategory[1].checked)
	{
	
		
		var combobox = document.getElementById("py_budget");
		
		combobox.options.length = 0;
		
		combobox.options.add(new Option("Below 5,000","1"));
		combobox.options.add(new Option("5,000 to 10,000","5"));
		combobox.options.add(new Option("10,000 to 15,000","10"));
		combobox.options.add(new Option("15,000 to 20,000","15"));
		combobox.options.add(new Option("20,000 to 25,000","20"));
		combobox.options.add(new Option("25,000 to 30,000","25"));
		combobox.options.add(new Option("Above 30,000","30"));
		combobox.options.add(new Option("Any","0"));
	
	
	}
	
}






function checkForm()
{

var selectedCombobox=(Msearch.py_locality.value);

		if (selectedCombobox=='Select') {
		show('err_msg');
		return false;
		}

}




function checkRate()
{
	var selectedCombobox=(frm_py_rate.py_rates.value);

		if (selectedCombobox=='Select') {
		show_rate('err_msg2');
		return false;
		}
	
}


//show err msg search
function show(id)
{
	el = document.getElementById(id);
	
	if (el.style.display == 'none')
	{
		el.style.display = '';
	} 
}	


//show err py rate
function show_rate(id)
{
	el = document.getElementById(id);
	
	if (el.style.display == 'none')
	{
		el.style.display = '';
	} 
}	




//------------------------------------- USER REGISTRATION FORM VALIDATION---------------------------------



function checkUserForm()
{
//FORM 1 VALIDATION
//reseting form error msg
   var cFname,cAddress,cMobile,cEmail,cCity,cState,cLandL1,cLandL2,cSecurityQ,cSecurityA,cLogin,cPass1,cPass2;
   	var anum=/(^\d+$)|(^\d+\.\d+$)/;
	var flag=0;
   with(window.document.user_signup)
   {
      cFname    = txtName;
	  cAddress = txtAddress;
	  cMobile = txtMobile;
      cEmail   = txtEmail;
	  cCity = txtCity
	  cState = txtState
	  cLandL1 = txtLandline1;
	  cLandL2 = txtLandline2;
	  cSecurityQ = txtSecurityQ;
	  cSecurityA = txtSecurityA;
	  cLogin = txtLoginID;
	  cPass1 = txtPassword1;
	  cPass2 = txtPassword2;
   }


    if(trim(cFname.value) == '')
   {
      alert('Please enter a valid name.');
      return false;
   }
   
   		if ((cFname.value).length<3)
		{
      		alert('Please enter a valid name.');
     		return false;
		}

   
     if(trim(cAddress.value) == '')
     {
      alert('Please enter a valid address.');
	   return false;
	}
	
	   if ((cAddress.value).length<4)
		{
      alert('Please enter a valid address.');
	   return false;

		}
	
	  if(trim(cCity.value) == '')
     {
      alert('Please enter a valid city name.');
	   return false;
	}
	
		   if ((cCity.value).length<3)
		{
     	 alert('Please enter a valid city name.');
	   return false;
		}
	
	
	if(trim(cState.value) == '')
     {
      alert('Please enter a valid state name.');
	   return false;
	}
	
			   if ((cState.value).length<4)
		{
      alert('Please enter a valid state name.');
	   return false;
		}
	
		if((cLandL1.value).length>0 || (cLandL2.value).length>0)
		{
			
		
								if (!anum.test(cLandL1.value))
								{
      							alert('Please enter a valid area code');
	  							 return false;
								}
								
									
								
								if ((cLandL1.value).length<3 )
								{
      							alert('Please enter a valid area code');
	  							 return false;
								}
								
								
								if (!anum.test(cLandL2.value))
								{
      							alert('Please enter a valid landline number');
	  							 return false;
								}
								
							
								if ((cLandL2.value).length<6)
								{
      							alert('Please enter a valid landline number');
	  							 return false;
								}
		}
		

     if(trim(cMobile.value) == '')
    {
      							alert('Please enter a valid mobile number');
	  							 return false;
   }


		if (!anum.test(cMobile.value))
		{
      							alert('Please enter a valid mobile number');
	  							 return false;
		}
		
			
		
		if ((cMobile.value).length<10)
		{
      							alert('Please enter a valid mobile number');
	  							 return false;
		}


   if(trim(cEmail.value) == '')
   {
      							alert('Please enter a valid email address');
	  							 return false;
   }
	
   if(!isEmail(trim(cEmail.value)))
   {
      							alert('Please enter a valid email address');
	  							 return false;
   }
   
   


    if(trim(cLogin.value) == '')
   {
      alert('Please enter a valid user ID. Enter minimum 6 Characters.');
      return false;
   }
   
    if(trim(cLogin.value).length <6)
   {
      alert('Please enter a valid user ID. Enter minimum 6 Characters.');
      return false;
   }
   
	if(trim(cPass1.value) == '')
   {
      alert('Please enter a valid Password 1. Enter minimum 6 Characters.');
      return false;
   }
   
    if(trim(cPass1.value).length <6)
   {
      alert('Please enter a valid Password 1. Enter minimum 6 Characters.');
      return false;
   }
   
       if(trim(cPass1.value) != trim(cPass2.value))
   {
      alert('Passwords did not matched.');
      return false;
   }
   
   
       if(trim(cPass2.value) == '')
   {
      alert('Please enter a valid Password 2. Enter minimum 6 Characters.');
      return false;
   }
   
    if(trim(cPass2.value).length <6)
   {
      alert('Please enter a valid Password 2. Enter minimum 6 Characters.');
      return false;
   }

	
	if(trim(cSecurityQ.value) == '')
   {

   }
   
    if(trim(cSecurityQ.value).length <6)
   {

   }


    if(trim(cSecurityA.value) == '')
   {
      alert('Please enter a valid security answer. Enter minimum 6 Characters.');
      return false;
   }
   
    if(trim(cSecurityA.value).length <6)
   {
      alert('Please enter a valid security answer. Enter minimum 6 Characters.');
      return false;
   }

   else
   {

		  	cFname.value    = trim(cFname.value);
			cAddress.value    = trim(cAddress.value);
			cMobile.value    = trim(cMobile.value);
			cEmail.value    = trim(cEmail.value);
			cCity = trim(cCity.value);
			cState = trim(cState.value);
			cLandL1 = trim(cLandL1.value);
			cLandL2 = trim(cLandL2.value);
			cSecurityQ = trim(cSecurityQ.value);
			cSecurityA = trim(cSecurityA.value);
			cLogin = trim(cLogin.value);
			cPass1 = trim(cPass1.value);
			cPass2 = trim(cPass2.value);
      	return true;

   }

}


//------------------------- user reg form val over



//---------------------LOGIN FIELDS USERNAME N PASSWORD

function login_check()
{
	
	hide_error('err_indexLogin');

	
   var clogin,cPassword
   
   with(window.document.user_login)
   {
      clogin    = txtLogin;
	  cPassword = txtPassword;
	  
   }

	if(trim(clogin.value) == '')
   {
      show_error('err_indexLogin');
	  return false;
   }
   
    if(trim(cPassword.value)=='')
   {
      show_error('err_indexLogin');
      return false;
   }
   
   
   else
   {
	   		clogin.value    = trim(clogin.value);
			cPassword.value    = trim(cPassword.value);
			return true;
   }
	
}