﻿// JScript File

/**************Start Email validation and password validation***********/
function ValidationPasword(str)
{
   var Password=document.getElementById("txtPasswordR").value;
    if(Password=="")
    {
         document.getElementById("Divpass").style.display='block';
	    document.getElementById("Divpass").innerHTML="Please Enter Password.. ";
        return false;
    }
    else
    {
        document.getElementById("Divpass").style.display='none';
	    document.getElementById("Divpass").innerHTML="";
    }
}
function ValidationMatchingPasword(str)
{
      var Password=document.getElementById("txtPasswordR").value;
	  var ConfirmPassword = document.getElementById("txtConfirmPasswordR").value; 
	 if(ConfirmPassword=="")
        {
          document.getElementById("DivCompass").style.display='';
	      document.getElementById("DivCompass").innerHTML="Please Enter Confirm Password.. ";
	      return false;
        }
  	  if(Password !="" && ConfirmPassword !="")
	    {
	       if ( Password != ConfirmPassword )
           {
            document.getElementById("Divpass").style.display='block';
	        document.getElementById("Divpass").innerHTML="Password and Confirm Password are not match.. ";
	        document.getElementById("DivCompass").style.display='none';
	        document.getElementById("DivCompass").innerHTML="";
	            return false;
            }	
            else
            {
              document.getElementById("Divpass").style.display='none';
	          document.getElementById("Divpass").innerHTML="";
            }	
	     }
	  else
	     {
	        document.getElementById("Divpass").style.display='none';
	        document.getElementById("Divpass").innerHTML="";
	     }  
    }
    var destinationDDL;
	function ValidateEmail(str)
	{
		
	if(document.getElementById("txtEmailR").value=="")
	    {	
	        document.getElementById("tdEmailCheck").style.display='';
	        document.getElementById("lblemail").innerHTML="Please Enter Email Address ";
	        return false;
	    } 
	 
	    if(document.getElementById("txtEmailR").value!="")
	         {
	           var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
                var address = document.getElementById("txtEmailR").value;
                if(reg.test(address) == false) 
                {
                    document.getElementById("lblemail").innerHTML="Invalid Email Address ";
	                document.getElementById("tdEmailCheck").style.display='';
	                return false;
                }
            }
		/*Get xmlHttpObject */
		
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Your browser does not support AJAX!");
			return;
		}
		/*Make asyncrhonouz request to searchajax.aspx*/
		var url="AjaxValidation.aspx";
		url=url+"?mode=100&email="+str;	
		xmlHttp.onreadystatechange=stateChanged;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
	function stateChanged() 
	{ 
	var str;
		if (xmlHttp.readyState==4)
		{ 			
			str=xmlHttp.responseText;			
		}
  if (str==1)
		{	
		    document.getElementById("lblemail").style.color='red'
		    document.getElementById("lblemail").innerHTML=" Your are already a network member..";
	        document.getElementById("tdEmailCheck").style.display='';
	        return;
		}
	else
	   {	   
	        document.getElementById("lblemail").innerHTML="";
	  	}			
	}	
	/*This funcion returns object of XMLHTTPRequest class depending on the client browese */
function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

/**************End Email validation and password validation***********/
/***********************Start home page Brand and city ( Fill listbox to another list box) ********************/

function  AddItem(lstbxFrom,lstbxTo,lstCity2,hdnSubCity,a)
		    {
		       var varFromBox = lstbxFrom;
	           var varToBox = lstbxTo; 
	           if (a==1)
	             {
	               if(varToBox.length==5)
	                 {
	                    alert("You can't select more than 5 Subcity!"); 
	                    return;
	                 }
	             }
	           if (a==3)
	             {
	             
	               if(varToBox.length==3)
	                 {
	                    alert("You can't select more than 3 Brand!"); 
	                    return;
	                 }
	            }

             if ((varFromBox != null) && (varToBox != null)) 
             { 
                  if(varFromBox.length < 1) 
                  {
                   alert('There are no items in the source ListBox');
                   return false;
                  }
                  if((varFromBox.options.selectedIndex ==-1)) // when no Item is selected the index will be -1
                  {
                   alert('Please select an Item to move');
                   return false;
                  }
                  while ( varFromBox.options.selectedIndex >= 0 ) 
                  { 
                   var newOption = new Option(); // Create a new instance of ListItem 
                   newOption.text = varFromBox.options[varFromBox.options.selectedIndex].text; 
                   newOption.value = varFromBox.options[varFromBox.options.selectedIndex].value; 
                   varToBox.options[varToBox.length] = newOption; //Append the item in Target Listbox
                   varFromBox.remove(varFromBox.options.selectedIndex); //Remove the item from Source Listbox 
                  }
   
              var i ;
              var lstCityBox;
              lstCityBox=document.getElementById(lstCity2);
               document.getElementById(hdnSubCity).value='';

              for(i=0;i<=lstCityBox.length-1;i++ ) 
              { 


               var newOption1 = new Option(); // Create a new instance of ListItem 
                 newOption1=lstCityBox.options[i]  ; //Append the item in Target Listbox
               document.getElementById(hdnSubCity).value=newOption1.value + '#' + document.getElementById(hdnSubCity).value;
              } 
              
           }         
           	    if (a==3)
	             {
	               getLaunchDate1(document.getElementById(hdnSubCity).value)
	              
	             } 
	                    
           return false; 
   
   }	
   
/***********************************************************************************************************/

/********************************** Start validation for Used-Car-Bike-Buy-Sell.aspx ******************************************/


  function validateInput(form,a)
     {
     
           if(a==1 || a==2)
              {              
                 if(document.getElementById('hdnlstTypemov').value=='')
                      {
                        alert("Pls select atlest one Brand.");
                        return false;
                      }
                  if(document.getElementById('hdncity').value=='')
                      {
                        alert("Pls select atlest one City.");
                        return false;
                      }    
                      
                  if(document.getElementById('ddlprice1').value=='0' && document.getElementById('ddlprice2').value=='0')
                      {
                        alert("Pls select Price.");
                        return false;
                      }
                      
                  if(document.getElementById('ddlkm1').value=='0' && document.getElementById('ddlkm2').value=='0')
                      {
                        alert("Pls select Driven Range.");
                        return false;
                      }
                    var check=checkCheckboxes();
                  if(check==false)
                     {
                       alert("Pls fill all the compulsory field.");
                       return false;
                     }        
            }
              
              
//            
//               if(document.getElementById('txttitle').value=='')
//                  {
//                    alert('Please provide a title to your post.');
//                    return false;
//                  }
//                  
//                if(document.getElementById('txtdesc').value=='')
//                  {
//                    alert('Please provide a brief description about your property.');
//                    return false;
//                  }
//                  
//                 
            
//                   if (transaction==1)
//                   {
//                      
//                        if(document.getElementById('txtaddress').value=='')
//                          {
//                            alert('Please provide the complete Address.');
//                            return false;
//                          } 
//                          
//                        if(document.getElementById('txtArea').value=='')
//                          {
//                            alert('Please provide the area where it is located.');
//                            return false;
//                          }        
//                          
//                         if(document.getElementById('txtPrice1').value=='')
//                          {
//                            alert('Please provide Total Price at which you would like to sell.');
//                            return false;
//                          }          
//                
//                   }  
//                else if (transaction==2)
//                   {
//                                                 
//                        if(document.getElementById('txtaddress').value=='')
//                          {
//                            alert('Please provide the complete Address.');
//                            return false;
//                          } 
//                          
//                        if(document.getElementById('txtArea').value=='')
//                          {
//                            alert('Please provide the area where it is located.');
//                            return false;
//                          }        

//                        if(document.getElementById('txtDeposit').value=='')
//                          {
//                            alert("Pls enter Deposit.");
//                            return false;
//                          } 
//                         
//                        if(document.getElementById('txtMonthlyRent').value=='')
//                          {
//                            alert('Please provide Monthly Rent at which you would like to rent your property.');
//                            return false;
//                          } 
//             
//                   } 
//                 else 
//                   {
//                                          
//                        if(document.getElementById('lstsubClass').value=='' )
//                          {
//                            alert('Please select Property Type.');
//                            return false;
//                          } 
//                         
//                        if(document.getElementById('txtBudget1').value=='' || document.getElementById('txtBudget2').value=='')
//                          {
//                            alert("Pls enter Expected Budget.");
//                            return false;
//                          } 
//                         
//                      
//                   } 
//                   
                   
                                  
                if(a==2)
                {
                    var RB1=document.getElementById('rbindividual');
                    var RB2=document.getElementById('rbdealer');
                    
                    if(RB1.checked == false && RB2.checked == false)
                    {
                      alert("Please Check Individual or Dealer ");      
                      return false;                       
                    }   
                    
                   var VarFirstName=document.getElementById('txtfirstname');
                   var VarLastName=document.getElementById('txtlastname');
                   if(VarFirstName.value=="")
                   {
                        alert("Please Enter First Name..");
                        return false;
                   } 
                   if(VarLastName.value=="")
                   {
                        alert("Please Enter Last Name..");
                        return false;
                   } 
                   var VarEmail=document.getElementById('txtEmailR');
                   if(VarEmail.value=="")
                   {
                        alert("Please Enter Email Address..");
                        return false;
                   } 
                   var VarPass=document.getElementById('txtPasswordR');
                   if(VarPass.value=="")
                   {
                        alert("Please Enter Password..");
                        return false;
                   } 

                   var VarCPass=document.getElementById('txtConfirmPasswordR');
                   if(VarCPass.value=="")
                   {
                        alert("Please Enter Confirm Password..");
                        return false;
                   }    
                                     
                   var VarCountry=document.getElementById('ddlCountry');
                   if(VarCountry.value=="0")
                   {
                        alert("Please Select Country..");
                        return false;
                   }            
                   
                   var VarState=document.getElementById('ddlState');
                   if(VarState.value=="0" || VarState.value=="" )
                   {
                        alert("Please Select State..");
                        return false;
                   }            
                   
                   var VarCity=document.getElementById('ddlCity');
                   if(VarCity.value=="0")
                   {
                        alert("Please Select City..");
                        return false;
                   }       
                   var VarCompanyName=document.getElementById('txtcompany');
                   if(VarCompanyName.value=="")
                   {
                        alert("Please Enter Company Name..");
                        return false;
                   }         
                           
               }
  
     }
   
  
    function checkCheckboxes()
       {
         var count;
         var check;
         check=true;
          count=0;
            var Parent; 
 
              Parent = document.getElementById('dgdSpecificationHead');        
              var items = Parent.getElementsByTagName('input');   
           
              for(i=0;i<items.length;i++)
              {   
              if(items[i].title=="adarsh")
                  {  
                    var a; 
                     a=items[i].value;
                       if(a=='')
                         {
                           check=false;
                         }
                   }
              }
              items = Parent.getElementsByTagName('select');   
              for(i=0;i<items.length;i++)
              {  
                  if(items[i].title=="adarsh")
                  {  
                    var a; 
                     a=items[i].value;
                       if(a==0)
                         {
                           check=false;
                         }
                   }
              }
           return check;                 
       }

/********************************End validation for Used-Car-Bike-Buy-Sell.aspx***********************************/





