﻿//////////////////////////////COODING START HERE////////////////////////////
$(document).ready(function() {
//////////////////////////////COODING START HERE////////////////////////////
 
     IfHiddenJobIDRow();
     ApplyMasking();
     
     SetOtherOptionCmbSetting('cmbDegree1','txtDegree1','txtDegreeDesc1');
     SetOtherOptionCmbSetting('cmbDegree2','txtDegree2','txtDegreeDesc2');
     SetOtherOptionCmbSetting('cmbDegree3','txtDegree3','txtDegreeDesc3');
    
     SetOtherOptionCmbSetting('cmbInst1','txtInst1');
     SetOtherOptionCmbSetting('cmbInst2','txtInst2');
     SetOtherOptionCmbSetting('cmbInst3','txtInst3');

     SetOtherOptionCmbSetting('cmbEmp1','txtEmp1');
     SetOtherOptionCmbSetting('cmbEmp2','txtEmp2');
     SetOtherOptionCmbSetting('cmbEmp3','txtEmp3');
 


 	$('#cmdSubmit').click(function() {       
            ValidatePage();	
            ValidateOnEverBlur(); 
            window.scrollTo(0,0);     
	  
	
            if (GetErrors() == ''){
                
                return true;
            }else{
                
                return false;
            }
	  
	});//$('#cmdSubmit').click(function() {       
 
    
    
    $('#ErrorDiv').addClass("WHidden");
    $('#ErrorDiv_Back').addClass("WHidden");
    Pagescrolling($(window));
    
    $(window).scroll(function () { 
      Pagescrolling($(this))
    });
    
    $(window).resize(function () { 
      Pagescrolling($(this))
    });
    

//////////////////////////////COODING END HERE////////////////////////////
});//$(document).ready(function() {
//////////////////////////////COODING END HERE////////////////////////////


function IfHiddenJobIDRow(){

    if ($('#cmbJobID').css('display') == undefined){
            $('#Row_JobID').addClass("WHidden"); 
    }
    
}//function IfHiddenJobIDRow(){



function ValidateOnEverBlur(){
    
    $('input,img,select').blur(function() {       
	       
	       ValidatePage();	      
    });//$('#lkProf').click(function() {
    
}//function ValidateOnEverBlur(){


function ValidatePage(){
    
    ClearErrorsMsgs();
      
    LogErrorStartNow("Applicant's Details");
    Validate_ApplicationDetail();
    LogErrorEndNow();	     

    LogErrorStartNow("Educational Qualifications");
    Validate_Education();
    LogErrorEndNow();	     

    LogErrorStartNow("Professional Skills & Strengths");
    Validate_Skills();
    LogErrorEndNow();	     

    LogErrorStartNow("Professional Experiences");
    Validate_Professional();
    LogErrorEndNow();	     

    LogErrorStartNow("Reference");
    Validate_Reference();
    LogErrorEndNow();	     

    ShowError();
    Pagescrolling($(window));

}//function validatepage(){



function Pagescrolling(WindowObj){

  var FixedObj = $('#ErrorDiv');
  var FixedObj_Back = $('#ErrorDiv_Back');
  
  var SepratorObj = $('#ErrorDiv_topSeprator');
 
 
  if ( FixedObj.css('display')== 'none'){
        SepratorObj.addClass("WHidden")
        FixedObj_Back.addClass("WHidden")
        return false
  }else{
        SepratorObj.removeClass("WHidden")
        FixedObj_Back.removeClass("WHidden")

  }//  if ( FixedObj.css('display')== 'none'){
 
  
  FixedObj_Back.css('position', 'absolute'); 
  FixedObj_Back.css('z-index', '998'); 
  FixedObj_Back.css('top',WindowObj.scrollTop() + WindowObj.height() -  FixedObj.get(0).offsetHeight )
  FixedObj_Back.css('width',WindowObj.width() - 22 )
  FixedObj_Back.css('height', FixedObj.get(0).offsetHeight )

    
  FixedObj.css('position', 'absolute'); 
  FixedObj.css('z-index', '999'); 
  FixedObj.css('top',WindowObj.scrollTop()  + WindowObj.height() - FixedObj.get(0).offsetHeight)
  FixedObj.css('width',WindowObj.width() - 22 )
  
  SepratorObj.css('height', FixedObj.get(0).offsetHeight )

}//function Pagescrolling(Page){

function ApplyMasking(){

 
	$('#txtNIC').numeric({allow:"-"});
 
	$('#txtSal').numeric();

	$('#txtResNo').numeric({allow:"()-+"});
	$('#txtMobNo').numeric({allow:"()-+"});
 
	$('#txtTotalExp').numeric({allow:"."});
 
	$('#txtGPA1').numeric({allow:"."});
	$('#txtGPA2').numeric({allow:"."});
	$('#txtGPA3').numeric({allow:"."});

	$('#txtYr1').numeric();
	$('#txtYr2').numeric();
	$('#txtYr3').numeric();

	$('#txtLastSal1').numeric();
	$('#txtLastSal2').numeric();
	$('#txtLastSal3').numeric();

 	 
};//function ApplyMasking(){

function SetOtherOptionCmbSetting(CmbID,TxtBoxID1,TxtBoxID2){


    $('#'+ CmbID).change(function() {   
          SetOtherOptionCmbSetting_1(CmbID,TxtBoxID1,TxtBoxID2)
    });//    $('#'+ SrcID).change(function() {
 

}//function SetOtherOptionCmbSetting(CmbID,TxtBoxID){

function SetOtherOptionCmbSetting_1(CmbID,TxtBoxID1,TxtBoxID2){

    var SelText = GetComboSelectedText(CmbID)
   
    var txtbox1 = $('#'+ TxtBoxID1).get(0);
    var txtbox2;
    
    if (TxtBoxID2 == undefined || TxtBoxID2 == ''){
        txtbox2 = txtbox1;
    }else{
        txtbox2 = $('#'+ TxtBoxID2).get(0);
    }
    
    
    
    txtbox1.value ='';
    txtbox2.value ='';
   
    if   (SelText.toLowerCase() == WgetHdn_OthersText().toLowerCase()  ) {        
        txtbox1.disabled=false;
        txtbox2.disabled=false;
    }else {
        txtbox1.disabled=true;
        txtbox2.disabled=true;
    };

}//function SetOtherOptionCmbSetting_1(CmbID,TxtBoxID){

