﻿
// ############################## Starting for Registration form ##################################################
 var invalidCount=0;
var IsUserValidate = 0;
function ShowRegistrationForm()
{
    document.getElementById("popupContact").style.display="";
    centerPopup();		
	loadPopup();
	ClearValues();
}




function loadPopup(){
	//loads popup only if it is disabled

		$("#backgroundPopup").css({
			"opacity": "0.5"
		});
		$("#backgroundPopup").fadeIn("slow");
		$("#popupContact").fadeIn("slow");		 
}
//centering popup
function centerPopup(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupContact").height();
	var popupWidth = $("#popupContact").width();
	
	
	
	var ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
	//centering
	$("#popupContact").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});	
}
 $(document).ready(function(){    
  $("#popupContactClose").click(function(){
		        disablePopup();
	        });
	        $("#backgroundPopup").click(function(){
		        disablePopup();
	        });
});	        
//disabling popup with jQuery magic!
function disablePopup()
{
	//disables popup only if it is enabled	
	$("#backgroundPopup").fadeOut("slow");
	$("#popupContact").fadeOut("slow");		
}


function RegisterSubmitform()
{

  if($('#txtagencyName').val() =="")
  {

    alert('Please Enter AgencyName');
			
	     return false;		
  }
  
  if($('#txtaddress').val() =="")
  {

    alert('Please enter address');
     return false;		   
 }		
 if($('#CityNameCombo').val() =="")
 {		    

    alert('Please select city');
	return false;	 
 }	
 if($('#CountryCombo').val() =="")
 {			   

alert('Please select country');
    return false;	
 }
 
 //////////////////
 
 ///////////////////
 	
 if($('#txtpostcode').val() =="")
 {			    			 

alert('Please enter  Postcode ');
  return false;
 }	
 
 ///////////////check value is blank or not //////////////
  	

 
if($('#txtpostcode').val()=="")
{
alert('Please specify Postcode ');
return false ;
}

if($('#txtpostcode').val()=="")
{
alert('Please specify Postcode ');
return false ;
}
if($('#txtofficeCountryCode').val()=="")
{
alert('Please specify office country code  ');
return false ;
}
if($('#txtofficeCityCode').val()=="")
{
alert('Please specify office city code  ');
return false ;
}
if($('#txtofficeNo').val()=="")
{
alert('Please specify office No  ');
return false ;
}
//if($('#txtCountryResNo').val()== "")
//{
//alert('Please specify residence country code ');
//return false ;
//}
//if($('#txtCityResNo').val()=="")
//{
//alert('Please specify residence city code ');
//return false ;
//}
//if($('#txtResidenceNo').val()=="")
//{
//alert('Please specify residenceNo ');
//return false ;
//}
//if($('#txtfaxCountryCode').val()=="")
//{
//alert('Please specify fax country code ');
//return false ;
//}
//if($('#txtfaxCityCode').val()=="")
//{
//alert('Please specify faxNo city code ');
//return false ;
//}
//if($('#txtFaxNo').val()=="")
//{
//alert('Please specify fax  ');
//return false ;
//}

 
 /////////////////// check is numeric or not ///////////////
if(isNaN($('#txtpostcode').val()))
{
alert('Please specify Postcode in numbers');
return false ;
}

if(isNaN($('#txtpostcode').val()))
{
alert('Please specify Postcode in numbers');
return false ;
}
if(isNaN($('#txtofficeCountryCode').val()))
{
alert('Please specify office country code  in numbers');
return false ;
}
if(isNaN($('#txtofficeCityCode').val()))
{
alert('Please specify office city code  in numbers');
return false ;
}
if(isNaN($('#txtofficeNo').val()))
{
alert('Please specify office No  in numbers');
return false ;
}
if(isNaN($('#txtCountryResNo').val()))
{
alert('Please specify residence country code  in numbers');
return false ;
}
if(isNaN($('#txtCityResNo').val()))
{
alert('Please specify residence city code in numbers');
return false ;
}
if(isNaN($('#txtResidenceNo').val()))
{
alert('Please specify residenceNo in numbers');
return false ;
}
if(isNaN($('#txtfaxCountryCode').val()))
{
alert('Please specify fax country code in numbers');
return false ;
}
if(isNaN($('#txtfaxCityCode').val()))
{
alert('Please specify faxNo city code  in numbers');
return false ;
}
if(isNaN($('#txtFaxNo').val()))
{
alert('Please specify fax  in numbers');
return false ;
}
 if($('#txtemail').val() =="")
{

alert('Please enter  Email');
	 return false;   
}	

var TestEmail = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
if( !TestEmail.test( $('#txtemail').val() ) ) {
 alert( 'Please enter a valid email address' );
 return false;
}
	    
if($('#txtfirstname').val() =="")
{

alert('Please enter  FirstName');
    return false; 
}
if($('#txtsurname').val() =="")
{

alert('Please enter SurName');
    return false;  
}

if( !TestEmail.test( $('#txtuseremail').val() ) ) {
 alert( 'Please enter a valid user email address' );
 return false;
}

if($('#txtuserDesignation').val() =="")
{

alert('Please enter user designation ');
 return false;  
}

/////////////////////check is not blank 

if($('#txtuserCountryCode').val()== "")
{
alert('Please contact country code ');
return false ;
}
if($('#txtuserCityCode').val()== "")
{
alert('Please contact city code ');
return false ;
}
if($('#txtUserContactNo').val()=="")
{
alert('Please contact No.');
return false ;
}
if($('#txtmobileCountryCode').val()=="")
{
alert('Please mobile country code ');
return false ;
}
if($('#txtmobileNo').val()=="")
{
alert('Please specify mobile No. ');
return false ;
}
/////////////////// check is numeric 

if(isNaN($('#txtuserCountryCode').val()))
{
alert('Please contact country code  in numbers');
return false ;
}
if(isNaN($('#txtuserCityCode').val()))
{
alert('Please contact city code in numbers');
return false ;
}
if(isNaN($('#txtUserContactNo').val()))
{
alert('Please contact No.  in numbers');
return false ;
}
if(isNaN($('#txtmobileCountryCode').val()))
{
alert('Please mobile country code  in numbers');
return false ;
}
if(isNaN($('#txtmobileNo').val()))
{
alert('Please specify mobile No. in numbers');
return false ;
}


//if($('#txtRegsitrationuserid').val().length > 0)
//{
//   var RegstrationUserId = $('#txtRegsitrationuserid').val();
//   $.ajax({
//            type        : "POST",
//            url         : "LocalServices/LocalService.asmx/UserNameChecking",
//            data        : "{'UserName' : '"+ RegstrationUserId.toString() +"'}",
//            //data        : "{RegstrationUserId : "+ RegstrationUserId +"}",
//            beforeSend  : function(xhr){
//                xhr.setRequestHeader("Content-type", "application/json; charset=utf-8");
//            },
//            contentType : "application/json; charset=utf-8",
//            dataType    : "json",
//            
//            success     : function(msg, status)
//            {
//                
//                 if(msg.d ==false)
//                 {
////                    $("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
////                    {
////                        $(this).html('Username available to register').addClass('messageboxerror').fadeTo(900,1);
////                        setTimeout(function(){$("#msgbox").fadeOut() }, 5000);
////                    } );
//                    //     alert('This User Name Is Avilable');
//                    
//                 }
//                 else
//                 {
//                     alert("This User name Already exists");
//                     return false;
//                 }                                    
//            },
//            error       : function(xhr, msg){
//                alert(msg.toString());
//            }
//            
//            
//        });
//        
//}	
if($('#txtRegsitrationuserid').val() == "" )
{
    alert('enter user id ');
    return false ;
}
if(IsUserValidate == 0) 
{
    alert('UserId is already exist ');
    return false ;
}
if($('#txtUserPassword').val() =="")
{

alert('Please enter UserPassword');
	 return false;  
}	
if($('#txtUserPassword').val().length < parseInt(6) )
{

alert('Password must contain at least six characters!');
	 return false;  
}	

if($('#txtUserPassword').val() != $('#txtConfirmPassword').val())
{
alert('Confirm Password is not same ');
return false ;
}


if($('#txtuserSecurityanswer').val() =="0")
{

alert('Please select UserSecurity answer');
  return false; 	  
}



if($('#txtRegsitrationuserid').val() =="")
{

alert('Enter UserId ');
	return false;

}

  return true; 
}
 
 $(document).ready(function(){ 

				$('#txtRegsitrationuserid').blur(function (){				
				if($('#txtRegsitrationuserid').val().length > 0)
				{
				   var RegstrationUserId = $('#txtRegsitrationuserid').val();
				   $.ajax({
                            type        : "POST",
                            url         : "LocalServices/LocalService.asmx/UserNameChecking",
                            data        : "{'UserName' : '"+ RegstrationUserId.toString() +"'}",
                            //data        : "{RegstrationUserId : "+ RegstrationUserId +"}",
                            beforeSend  : function(xhr){
                                xhr.setRequestHeader("Content-type", "application/json; charset=utf-8");
                            },
                            contentType : "application/json; charset=utf-8",
                            dataType    : "json",
                            
                            success     : function(msg, status)
                            {
                                
                                 if(msg.d ==false)
                                 {
                                    alert('This User Name Is Avilable');
                                    IsUserValidate=1;
                                 }
                                 else
                                 {
                                    $("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
                                    {
                                        //$(this).html('This User name Already exists').addClass('messageboxerror').fadeTo(900,1);
                                        //setTimeout(function(){$("#msgbox").fadeOut() }, 5000);
                                        alert('This User name Already exists');
                                        IsUserValidate=0;
                                           
                                    });
                                 }                                    
                            },
                            error       : function(xhr, msg){
                                alert(msg.toString());
                            }
                            
                            
                        });
				}				    
	 });
	 
	          
				 
 });



function GetCityname()
{
   var CountryId = $('#CountryCombo option:selected').val();
   $.ajax({
            type        : "POST",
            url         : "LocalServices/LocalService.asmx/GetCityName",
            data        : "{_CountryId : "+ parseInt(CountryId) +"}",
            beforeSend  : function(xhr){
                xhr.setRequestHeader("Content-type", "application/json; charset=utf-8");
            },
            contentType : "application/json; charset=utf-8",
            dataType    : "json",
            
            success     : function(msg, status){
                 $('#CityNameCombo >option').remove();
                 $('#CityNameCombo' ).append($('<option></option>').val("").html("----Select City----"));
                 $.each(msg.d, function(index) {
                    $('#CityNameCombo' ).append($('<option></option>').val(this.CityId).html(this.CityName));
                 });
                    
            },
            error       : function(xhr, msg){
                alert(msg.toString());
            }
            
            
        });
}

function GetCityID()
{
    var CityId = $('#CityNameCombo option:selected').val();  
    var CityName =$('#CityNameCombo option:selected').text()
    document.getElementById("CityId").value =CityId;
}

function FillCountryCityCode()
{
   var _countryCode =  $('#txtofficeCountryCode').val();
   var _CityCode =$('#txtofficeCityCode').val();
   document.getElementById("txtCountryResNo").value =_countryCode;
   document.getElementById("txtfaxCountryCode").value=_countryCode;
   document.getElementById("txtCityResNo").value=_CityCode;
   document.getElementById("txtfaxCityCode").value=_CityCode;
}


function ClearValues()
{
    document.getElementById("txtagencyName").value="";
    document.getElementById("txtaddress").value="";
    document.getElementById("txtpostcode").value="";
    document.getElementById("txtofficeCountryCode").value="";
    document.getElementById("txtofficeCityCode").value="";
    document.getElementById("txtofficeNo").value="";
    document.getElementById("txtCountryResNo").value="";
    document.getElementById("txtCityResNo").value="";
    document.getElementById("txtResidenceNo").value="";
    
    document.getElementById("txtfaxCountryCode").value="";
    document.getElementById("txtfaxCityCode").value="";
    document.getElementById("txtFaxNo").value="";
    document.getElementById("txtemail").value="";
    document.getElementById("txtwebsite").value="";
    document.getElementById("txtfirstname").value="";
    document.getElementById("txtsurname").value="";
    document.getElementById("txtuseremail").value="";
    document.getElementById("txtuserDesignation").value="";
    document.getElementById("txtuserCountryCode").value="";
    document.getElementById("txtuserCityCode").value="";
    document.getElementById("txtUserContactNo").value="";
    document.getElementById("txtmobileCountryCode").value="";
    document.getElementById("txtmobileNo").value="";
    document.getElementById("txtRegsitrationuserid").value="";
    
    document.getElementById("ddluserSecurityQuestion").value="0";
    document.getElementById("txtuserSecurityanswer").value="";
}





function loadPopup4()
{
	$("#backgroundPopup4").css({
		"opacity": "0.3"
	});
	$("#backgroundPopup4").fadeIn("slow");
	$("#popupContact4").fadeIn("slow");
}

//centering popup
function centerPopup4(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupContact4").height();
	var popupWidth = $("#popupContact4").width();
	
	var ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
	//centering
	$("#popupContact4").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup4").css({
		"height": windowHeight
	});	
}

$(document).ready(function(){    
  $("#popupContactClose4").click(function(){
		        disablePopup4();
	        });
	        $("#backgroundPopup4").click(function(){
		        disablePopup4();
	        });
});	        
//disabling popup with jQuery magic!
function disablePopup4()
{
	//disables popup only if it is enabled	
	$("#backgroundPopup4").fadeOut("slow");
	$("#popupContact4").fadeOut("slow");		
}

function loadPopup5()
{
	$("#backgroundPopup5").css({
		"opacity": "0.3"
	});
	$("#backgroundPopup5").fadeIn("slow");
	$("#popupContact5").fadeIn("slow");
}

//centering popup
function centerPopup5(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupContact5").height();
	var popupWidth = $("#popupContact5").width();
	
	var ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
	//centering
	$("#popupContact5").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup5").css({
		"height": windowHeight
	});	
}

$(document).ready(function(){    
  $("#popupContactClose5").click(function(){
		        disablePopup5();
	        });
	        $("#backgroundPopup5").click(function(){
		        disablePopup5();
	        });
});	        
//disabling popup with jQuery magic!
function disablePopup5()
{
	//disables popup only if it is enabled	
	$("#backgroundPopup5").fadeOut("slow");
	$("#popupContact5").fadeOut("slow");		
}



// ############################## Starting for Password Reminder ####################################################


function GetPasswordReminder()
{
    document.getElementById("popupContact1").style.display="";
    centerPopup1();		
	loadPopup1();
	document.getElementById("txtpwduserid").value="";
	document.getElementById("ddlSecurityQuestion").value="0";
	document.getElementById("txtsecurityanswer").value="";
}

function SubmitForm()
{
    var userid      =document.getElementById("txtpwduserid").value;
    var SQuestion   =document.getElementById("ddlSecurityQuestion").value;
    var Answer      =document.getElementById("txtsecurityanswer").value;
    var frm = document.getElementById("SelectedValues");
    frm.value="";    
    frm.value =userid+"~"+SQuestion+"~"+Answer;
    return true;
}




function loadPopup1(){
	//loads popup only if it is disabled

		$("#backgroundPopup1").css({
			"opacity": "0.5"
		});
		$("#backgroundPopup1").fadeIn("slow");
		$("#popupContact1").fadeIn("slow");		 
}
//centering popup
function centerPopup1(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupContact1").height();
	var popupWidth = $("#popupContact1").width();
	
	var ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
	//centering
	$("#popupContact1").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup1").css({
		"height": windowHeight
	});	
}
 $(document).ready(function(){    
  $("#popupContactClose1").click(function(){
		        disablePopup1();
	        });
	        $("#backgroundPopup1").click(function(){
		        disablePopup1();
	        });
});	        
//disabling popup with jQuery magic!
function disablePopup1()
{
	//disables popup only if it is enabled	
	$("#backgroundPopup1").fadeOut("slow");
	$("#popupContact1").fadeOut("slow");		
}

function loadPopup2()
{
	$("#backgroundPopup2").css({
		"opacity": "0.3"
	});
	$("#backgroundPopup2").fadeIn("slow");
	$("#popupContact2").fadeIn("slow");
}

//centering popup
function centerPopup2(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupContact2").height();
	var popupWidth = $("#popupContact2").width();
	
	var ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
	//centering
	$("#popupContact2").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup2").css({
		"height": windowHeight
	});	
}

$(document).ready(function(){    
  $("#popupContactClose2").click(function(){
		        disablePopup2();
	        });
	        $("#backgroundPopup2").click(function(){
		        disablePopup2();
	        });
});	        
//disabling popup with jQuery magic!
function disablePopup2()
{
	//disables popup only if it is enabled	
	$("#backgroundPopup2").fadeOut("slow");
	$("#popupContact2").fadeOut("slow");		
}


function loadPopup3()
{
	$("#backgroundPopup3").css({
		"opacity": "0.3"
	});
	$("#backgroundPopup3").fadeIn("slow");
	$("#popupContact3").fadeIn("slow");
}

//centering popup
function centerPopup3(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupContact3").height();
	var popupWidth = $("#popupContact3").width();
	
	var ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
	//centering
	$("#popupContact3").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup3").css({
		"height": windowHeight
	});
	
}

$(document).ready(function(){    
  $("#popupContactClose3").click(function(){
		        disablePopup3();
	        });
	        $("#backgroundPopup3").click(function(){
		        disablePopup3();
	        });
});	        
//disabling popup with jQuery magic!
function disablePopup3()
{
	//disables popup only if it is enabled	
	$("#backgroundPopup3").fadeOut("slow");
	$("#popupContact3").fadeOut("slow");		
}

// ###########################################  END HERE ###############################################################




function Submitform()
{
    if($("#txtUserId").val()=="")
    {
      alert("Please Enter Your UserName");
      return false;
    }
    if($("#txtPassword").val()=="")
    {
      alert("Please Enter Your Password");
      return false;
    }
    return true;
}