
function calculateIndexCssProperties() { 

  // div heights
  var headerHeight = document.getElementById("header").offsetHeight;
  var copyHeight = document.getElementById("copy").offsetHeight;
  var formHeight = document.getElementById("formarea").offsetHeight;
  var campusLocHeight = document.getElementById("copyFooter").offsetHeight;
  var mainRegionHeight = copyHeight > formHeight ? copyHeight : formHeight;
  var extraHeight = 10;

  // Position top and height attribute for copy and form
  document.getElementById("copy").style.top=headerHeight;
  document.getElementById("copy").style.height=mainRegionHeight+extraHeight;
  document.getElementById("formarea").style.top=headerHeight+20;
  document.getElementById("formarea").style.height=mainRegionHeight+campusLocHeight-100;

  // Position campus location region
  document.getElementById("copyFooter").style.top=headerHeight+mainRegionHeight+extraHeight;

  // Position Footer
  document.getElementById("footerLinks").style.top=headerHeight+mainRegionHeight+campusLocHeight;
  document.getElementById("copyright").style.top=headerHeight+mainRegionHeight+campusLocHeight;

  // Position Right copy spacer
  document.getElementById("rightSpacer").style.top=headerHeight;
  document.getElementById("rightSpacer").style.height=mainRegionHeight+extraHeight;
  document.getElementById("copyFooterRight").style.top=headerHeight+mainRegionHeight+extraHeight;

  // Position form border
  document.getElementById("formHeader").style.top=headerHeight;
  document.getElementById("formFooter").style.top=headerHeight+mainRegionHeight+campusLocHeight-80;

 hadleprequalJs();   

}

function calculateIndexImgBrdrCssProperties() { 

  // Retrieve region div heights
  var headerHeight = document.getElementById("header").offsetHeight;
  var formHeight = document.getElementById("formImg").offsetHeight;
  var campusLocHeight = document.getElementById("copyFooter").offsetHeight;
  var copyHeight = document.getElementById("copy").offsetHeight + campusLocHeight;
  var mainRegionHeight = copyHeight > formHeight ? copyHeight : formHeight;

  // Position top and height attribute for copy and form
  document.getElementById("copy").style.top=headerHeight;
  document.getElementById("copy").style.height=mainRegionHeight-campusLocHeight;
  document.getElementById("formImg").style.top=headerHeight+1;
  document.getElementById("formImg").style.height=mainRegionHeight;

  // Position campus location region
  document.getElementById("copyFooter").style.top=headerHeight+mainRegionHeight-campusLocHeight;

  // Position Footer
  document.getElementById("footerLinks").style.top=headerHeight+mainRegionHeight;
  document.getElementById("copyright").style.top=headerHeight+mainRegionHeight;

  // Position Right copy spacer
  document.getElementById("rightSpacer").style.top=headerHeight;
  document.getElementById("rightSpacer").style.height=mainRegionHeight-campusLocHeight;
  document.getElementById("copyFooterRight").style.top=headerHeight+mainRegionHeight-campusLocHeight;

  // Position form border
  document.getElementById("formImgHeader").style.top=headerHeight;
  document.getElementById("formImgLeft").style.top=headerHeight+20;
  document.getElementById("formImgLeft").style.height=mainRegionHeight;
  document.getElementById("formImgRight").style.top=headerHeight+20;
  document.getElementById("formImgRight").style.height=mainRegionHeight;
  document.getElementById("formImgFooter").style.top=headerHeight+mainRegionHeight-19;

}

function calculateNonFormCssProperties() {

 	var headerHeight = document.getElementById("header").offsetHeight;
	var copyHeight = document.getElementById("nonFormCopy").offsetHeight;

	document.getElementById("nonFormCopy").style.top=headerHeight;
	document.getElementById("nonFormFooter").style.top=headerHeight+copyHeight;
	document.getElementById("footerLinks").style.top=headerHeight+copyHeight+98;
    	document.getElementById("copyright").style.top=headerHeight+copyHeight+98;
    
} 

function calculatePopPrgCssProperties() { 

    var maximumHeight = calculateHeight();
    leftHeight = document.getElementById("popupLeftCopy").offsetHeight;
    rightHeight = document.getElementById("popupMainCopy").offsetHeight;

    if ( maximumHeight > leftHeight && maximumHeight > rightHeight ) {

        document.getElementById("popupLeftCopy").style.height=maximumHeight;
        document.getElementById("popupMainCopy").style.height=maximumHeight;
        document.getElementById("popupFooter").style.top=maximumHeight+127;

    } else if(leftHeight < rightHeight) {

        document.getElementById("popupLeftCopy").style.height=document.getElementById("popupMainCopy").offsetHeight;
        document.getElementById("popupFooter").style.top=document.getElementById("popupMainCopy").offsetHeight+127;
        

    } else {

        document.getElementById("popupMainCopy").style.height=document.getElementById("popupLeftCopy").offsetHeight;
        document.getElementById("popupFooter").style.top=document.getElementById("popupLeftCopy").offsetHeight+127;
        
    }

    document.getElementById("popUpRightSpacer").style.height=document.getElementById("popupMainCopy").offsetHeight;

} 



function openWin(page,win_width,win_height) {

    try {
    	popup_window.close();
    } catch(e) {
					
    }

    if ( page.indexOf("mailto") == -1 ) {
    	var options = "scrollbars=yes, width=" + win_width + ", height=" + win_height;
    	var win = window.open(page, 'MyWin', options);
     	if (window.focus) { win.focus() }
    }
}

function showLayer( layerToShow ) {
            
           var layerValue = layerToShow;
            var idArray = layerArray();

              for ( var i=0; i<idArray.length; i++ ) {
                  
                  var idTmp = idArray[i];
                  if ( layerValue == idTmp ) {
                      document.getElementById( idTmp ).style.visibility='visible';
                  } else {
                      document.getElementById( idTmp ).style.visibility='hidden';
                  }
              }

              

}

function calculateHeight() {

            var maxHeight = 0;

            var idArray_ = layerArray();

              for ( var i=0; i<idArray_.length; i++ ) {

                  var divId = idArray_[i];
                  var divIdHeight = document.getElementById( divId ).offsetHeight;

                  if ( divIdHeight > maxHeight ) {

                      maxHeight = divIdHeight + 20;

                  }
                   

              }

              return maxHeight;
              

}

function doProcessing() {
  document.getElementById('submitBtn').className = 'thide'; 	
  document.getElementById('processing').className = 'tshow';
  if(navigator.userAgent.indexOf("Firefox")!=-1)
      {                               
       window.location.reload( true );
      }
}

function hadleprequalJs(){

//  document.getElementById('CurrentEmployer').className = 'thide'; 
 //   document.getElementById('CurrentEmployer').className = 'thide'; 
   
$(document).ready(function() {
	$('#CurrentEmployer4').hide();
	$('#CurrentEmployer5').hide();
	$('#degreeStartDateFormat').hide();
	$('#degreeStartDateMonthFormat').hide();
	$('#degreeStartDateYearFormat').hide();
	$('#gradDateFormat').hide();
	$('#gradDateMonthFormat').hide();
	$('#gradDateYearFormat').hide();
	$('#submitBtn').show();
	$('#trackValue5').hide();    
//	$('#degreeStartDateString1').hide(); 
//	$('#degreeStartDateString2').hide();
	$('#degreeStartDateFormatReq').hide();
	var radioValueStart = $('input[name=Question1]:checked').val();
	if(radioValueStart=='Yes'){
		$('#CurrentEmployer4').show();
		$('#CurrentEmployer5').show();
//		$('#degreeStartDateString1').show();
//		$('#degreeStartDateString2').show();
		
	}

     var submitVar = true; 
     var submitVariable = true;
     var submitVariableDSD = true;
	$('select[name=EducationLevel]').change(
		function()
		{
		var radioValue = $('select[name=EducationLevel]').val(); 
//		 alert($('input[name=Question1[0]:checked]').val()); 
 		if(radioValue=='Bachelor\'s Degree'){
				$('#CurrentEmployer4').show();
				$('#CurrentEmployer5').show();
	//			$('#degreeStartDateString1').show();
	//			$('#degreeStartDateString2').show();
             	$('#degreeStartDateFormat').hide();
				var degreeStartDateValue2 = $('input[name=DegreeStartDate]').val();
		//		if (degreeStartDateValue2 != '')
		//		{
	 				//alert("Please enter in correct format. Example: 06/2002")
			//		$('#degreeStartDateFormat').show();
			//		$('#degreeStartDateYearFormat').hide();
			//		$('#degreeStartDateMonthFormat').hide();
			//		submitVariable = false;
		//		}
			}else{
				$('#CurrentEmployer4').hide();
				$('#CurrentEmployer5').hide();
	//			$('#degreeStartDateString1').hide();
	//			$('#degreeStartDateString2').hide(); 
				$('#degreeStartDateFormatReq').hide();
	     		$('#degreeStartDateFormat').hide();
				$('#degreeStartDateYearFormat').hide();
				$('#degreeStartDateMonthFormat').hide();
				$('#trackValue').hide();
				submitVar = true;
				submitVariableDSD = true;
			}
		}
	
	);	// end of radio click event
	
/*	var degreeStartDateValueCheck = $('input[name=DegreeStartDate]').val();
    var radioValueCheck = $('input[name=Question1]:checked').val();
    if(radioValueCheck=='No'){
         	$('#degreeStartDateFormatReq').hide();
	     	$('#degreeStartDateFormat').hide();
			$('#degreeStartDateYearFormat').hide();
			$('#degreeStartDateMonthFormat').hide();
			$('#trackValue').hide();
	     	submitVar = true;
  }*/
	
	$('input[name=DegreeStartDate]:text').blur(
		function()
		{
			var degreeStartDateValue = $('input[name=DegreeStartDate]').val();
				if (degreeStartDateValue.indexOf("/") != 2)
				{
     				//alert("Please enter in correct format. Example: 06/2002")
					$('#degreeStartDateFormat').show();
					$('#degreeStartDateYearFormat').hide();
					$('#degreeStartDateMonthFormat').hide();
					submitVariableDSD = false;
				}else{
					var monthValidation = degreeStartDateValue.substr(0,2);
					var yearValidation = degreeStartDateValue.substr(3,7);
					if(!(monthValidation >0 && monthValidation <13)){
						$('#degreeStartDateMonthFormat').show();
						$('#degreeStartDateFormat').hide();
						$('#degreeStartDateYearFormat').hide();
						submitVariableDSD = false;
					}
					if(!(yearValidation >1953  && yearValidation <2009)){
						$('#degreeStartDateYearFormat').show();
						$('#degreeStartDateFormat').hide();
						$('#degreeStartDateMonthFormat').hide();
						submitVariableDSD = false;
					}
					
					if(monthValidation >0 && monthValidation <13 && yearValidation >1953  && yearValidation <2009){
						$('#degreeStartDateFormat').hide();
						$('#degreeStartDateYearFormat').hide();
						$('#degreeStartDateMonthFormat').hide();
						submitVariableDSD = true; 
						submitVariable = true;
					}
				}
		}
	);	
	
	$('input[name=GradDate]:text').blur(
		function()
		{
			var gradDateValue = $('input[name=GradDate]').val();
				if (gradDateValue.indexOf("/") != 2)
				{
     				//alert("Please enter in correct format. Example: 06/2002")
					$('#gradDateFormat').show();
					$('#gradDateYearFormat').hide();
					$('#gradDateMonthFormat').hide();
					submitVar = false;
				}else{
					var monthValidation1 = gradDateValue.substr(0,2);
					var yearValidation1 = gradDateValue.substr(3,7);
					if(!(monthValidation1 >0 && monthValidation1 <13)){
						$('#gradDateMonthFormat').show();
						$('#gradDateFormat').hide();
						$('#gradDateYearFormat').hide();
						submitVar = false;
					}
					if(!(yearValidation1 >1953  && yearValidation1 <2009)){
						$('#gradDateYearFormat').show();
						$('#gradDateFormat').hide();
						$('#gradDateMonthFormat').hide();
						submitVar = false;
					}
					
					if(monthValidation1 >0 && monthValidation1 <13 && yearValidation1 >1953  && yearValidation1 <2009){
						$('#gradDateFormat').hide();
						$('#gradDateYearFormat').hide();
						$('#gradDateMonthFormat').hide();
						submitVar = true;
					}
				}
		}
	);	// end of radio click event  
		
	var trackVar = false;
	$('input[name=EducationType]:radio').click( 
		function()
			{
			     $('input[name=CurrentEmployer]:checked').attr('checked', false);
			     trackVar = true;
		     	$('#trackValue').hide();
		   }	
	
	);
	
	$('input[name=CurrentEmployer]:radio').click( 
		function()
			{
			     $('input[name=EducationType]:checked').attr('checked', false);
			     trackVar = true;
		     	$('#trackValue').hide();
			}	
	
	);
	
		
   $("form").submit(function() {  
	    var radioValueQue1 = $('select[name=EducationLevel]').val();
	    if(radioValueQue1=='Bachelor\'s Degree'){
	    	  var radioValueCurrentEmployer = $('input[name=CurrentEmployer]:checked').val();
	    	  var radioValueEducationType = $('input[name=EducationType]:checked').val();
	    	if(radioValueCurrentEmployer || radioValueEducationType){
	    	 trackVar = true;
	    	}
	    }
	    
//	 alert("---submit-"+submitVar);   
	    
	 if(submitVar == false){
	 	 $('#submitBtn').show();
	 	 $('#processing').hide();
		 return false; 
	 }else if(submitVariable == false){
	     $('#submitBtn').show();
	 	 $('#processing').hide();
	 	  return false; 
	 }else if(submitVariableDSD == false){
	     $('#submitBtn').show();
	 	 $('#processing').hide();
	 	  return false; 
	 }else if(radioValueQue1=='Bachelor\'s Degree' && !trackVar){
//	     alert("submit  + "+radioValueQue1 +"  "+trackVar); submitVariableDSD
	 	$('#submitBtn').show();
	 	$('#processing').hide();
	 	$('#trackValue5').show();
	   	return false;
	 //   alert("i am not going to let form submit");
	 }else{
		return true;
		doProcessing();
	 }

   });
		
	
});
 
// if ($("input[@name='option_layout']:checked").val())    
//  var msnDegrees = document.forms[0].Question1.value;
//  alert("--------"+msnDegrees);
//var msnDegrees =  document.getElementById("Question1").value;


}
