 var curr = "#tab1";

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->


$(document).ready(function() {

    var options = { 
        target:        '#tab5',   // target element(s) to be updated with server response 
        beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse  // post-submit callback 
 	//	url:       'submit_value,php'     
        // other available options: 
        //    // override for form's 'action' attribute 
        //type:      type        // 'get' or 'post', override for form's 'method' attribute 
        //dataType:  null        // 'xml', 'script', or 'json' (expected server response type) 
        //clearForm: true        // clear all form fields after successful submit 
        //resetForm: true        // reset the form after successful submit 
 
        // $.ajax options can be used here too, for example: 
        //timeout:   3000 
    }; 
 
    // bind form using 'ajaxForm' 
    $('#form1').ajaxForm(options); 

 
// pre-submit callback 
function showRequest(formData, jqForm, options) { 

	// submit AJAX form 
	if(document.getElementById("tab_no").value!="1")
	{
	var flg1 = validate4();
	if(flg1 == 0)
	{	
	
	 return false;
	}
	}
	$('.loading').show();
	// formData is an array; here we use $.param to convert it to a string to display it 
    // but the form plugin does this for you automatically when it submits the data 
    var queryString = $.param(formData); 
 
    // jqForm is a jQuery object encapsulating the form element.  To access the 
    // DOM element for the form do this: 
    // var formElement = jqForm[0]; 
 
   // alert('About to submit: \n\n' + queryString); 
 
    // here we could return false to prevent the form from being submitted; 
    // returning anything other than false will allow the form submit to continue 
    return true; 
	
  
} 
 
// post-submit callback 
function showResponse(responseText, statusText)  { 
    // for normal html responses, the first argument to the success callback 
    // is the XMLHttpRequest object's responseText property 
 
    // if the ajaxForm method was passed an Options Object with the dataType 
    // property set to 'xml' then the first argument to the success callback 
    // is the XMLHttpRequest object's responseXML property 
 
    // if the ajaxForm method was passed an Options Object with the dataType 
    // property set to 'json' then the first argument to the success callback 
    // is the json data object returned by the server 
   // alert("-"+responseText+"-");
    if(responseText == "no_change")
    {
    	
    }
    else
    	{
	$('img#imgTab4').attr({ src: "images/tab_payroll_dist4.png"});
	$(".tab_content").hide(); //Hide all content
  $('#tab5').fadeIn();
			}
			$('.loading').hide();
  //  alert('status: ' + statusText + '\n\nresponseText: \n' + responseText + '\n\nThe output div should have already been updated with the responseText.'); 
} 



 document.getElementById('pay_card1').style.display = "none";
 document.getElementById('pay_card2').style.display = "none";
 document.getElementById('deposit_1').style.display = "none";
 document.getElementById('deposit_2').style.display = "none";

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}
function countChecked() {
      var n = $(".mclass:checked").length;
	  document.getElementById("no_states").value = n;
  //   alert(n);
  if(n==0)
  {
  		document.getElementById("states").value="Select states";
  }
  else
  {
  		document.getElementById("states").value=n+" selected";
   }
    }
    countChecked();
    $(".mclass").click(countChecked);


	//Default Action
	$(".tab_content").hide(); //Hide all content
	//$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	  $('img#imgTab1').attr({ src: "images/tab_company_background_hover.png" });
	//$(".tab_content:first").show(); //Show first tab content
	$('#tab1').fadeIn();
	
	  
 //      var $tabs = $("#ul.tabs li").tabs();
  
        $('#next1').click(function() { // bind click event to link

	var flg1 = validate1();
	if(flg1 == 1)
	{
		
		document.getElementById("tab_no").value="1";
			document.form1.finish1.click();
		$(".tab_content").hide(); 
            	   $('#tab2').fadeIn();
			  //calculate($('#tab2'));
			      $('img#imgTab2').attr({ src: "images/tab_payroll_process_hover.png" });
				 
				  $('img#imgTab1').attr({ src: "images/tab_company_background4.png"});
              
                  $('img#imgTab3').attr({  src: "images/tab_frequency4.png"});
                  $('img#imgTab4').attr({ src: "images/tab_payroll_dist4.png"});
  				 document.getElementById("tab_no").value="0";
     	           return false;
       
	}
	else
	{
	
	}
	 });
	function validate1()
	{
	$("#company_name").removeClass("invalid");
	$("#name").removeClass("invalid");
	$("#title").removeClass("invalid");
	$("#phone").removeClass("invalid");
	$("#email").removeClass("invalid");
	$("#usemployee").removeClass("invalid");
	$("#locations").removeClass("invalid");
	$("#states").removeClass("invalid");
	$("#no_computer_location_popup").removeClass("invalid");
	$("#no_computer_access_popup").removeClass("invalid");


		error_msg="";
		if(document.getElementById("company_name").value == "")
		{
			error_msg=error_msg+"Company Name \n";
			$("#company_name").addClass("invalid");
		}
		if(document.getElementById("name").value == "")
		{
			error_msg=error_msg+"Name \n";
			$("#name").addClass("invalid");
		}
		if(document.getElementById("title").value == "")
		{
			error_msg=error_msg+"Title \n";
			$("#title").addClass("invalid");
		}
		if(document.getElementById("phone").value == "")
		{
			error_msg=error_msg+"Phone \n";
			$("#phone").addClass("invalid");
		}
		if(document.getElementById("email").value == "")
		{
			error_msg=error_msg+"Email \n";
			$("#email").addClass("invalid");
		}
		 with (document.getElementById("email"))
		  {
  			  apos=value.indexOf("@");
 			  dotpos=value.lastIndexOf(".");
			  if (apos<1||dotpos-apos<2)
    		  {
			  alert("Sorry to be a pain but we need a valid email address so we can send you your savings information");
				$("#email").addClass("invalid");
				return 0;
			  }
 		   }
		 if(document.getElementById("usemployee").value == "")
		 {	
			error_msg=error_msg+"No. of U.S. Employee \n";
			$("#usemployee").addClass("invalid");
			
			
		  }
	
		  	  
		if(!isInteger(document.getElementById("usemployee").value))
			{
				error_msg=error_msg+"U.S. Employee \n";
				$("#usemployee").addClass("invalid");
			}
	
			
		 if(document.getElementById("locations").value == "")
		{
			error_msg=error_msg+"No. of Locations \n";
			$("#locations").addClass("invalid");
		}
		if(!isInteger(document.getElementById("locations").value))
			{
				error_msg=error_msg+"No. of Locations \n";
				$("#locations").addClass("invalid");
			}
		if(document.getElementById("states").value == "Select states")
		{
			error_msg=error_msg+"States \n";
			$("#states").addClass("invalid");
		}
//pay advice	
if(document.getElementsByName("curr_dist_pay")[0].checked)
{	
}
else if(document.getElementsByName("curr_dist_pay")[1].checked)
{
		if(document.getElementsByName("dist_pay")[0].checked || document.getElementsByName("dist_pay")[1].checked)
		{
//			  if(document.getElementsByName("pay_advice_popup")[0].checked || document.getElementsByName("pay_advice_popup")[1].checked)
//			  {
//			  }
//			  else
//			  {
//			  			error_msg=error_msg+"Select Pay Advices service type \n";
//			  }
		}
		else
		{
			error_msg=error_msg+"Select Pay Advices service type \n";
		}
}
else
{
				error_msg=error_msg+"Pay Advice \n";
}		
// computer access
	if(document.getElementsByName("comp_access")[0].checked)
		{
			  
		}
		else if(document.getElementsByName("comp_access")[1].checked)
		{
			  if(document.getElementById("no_computer_location_popup").value == "" )
			  {
			  error_msg=error_msg+"Fill Computer access details \n";
					    $("#no_computer_location_popup").addClass("invalid");
			  }
			  if(document.getElementById("no_computer_access_popup").value=="")
			  {
			  error_msg=error_msg+"Fill Computer access details \n";
			  			$("#no_computer_access_popup").addClass("invalid");
			  }
		}
		else
		{
			error_msg=error_msg+"Computer Access \n";
		}		
// 	paycards

		if(document.getElementsByName("pay_cards")[0].checked)
		{
			
			  if(document.getElementById("paycard_provider").selectedIndex==0)
			  {
			  	error_msg=error_msg+"select Pay Card Provider \n";
				$("#paycard_provider").addClass("invalid");
				
			  }
			  else
			  {
			  			document.getElementById("paypard_new1").value = document.getElementById("paycard_provider").value;
			  		
			  }
		}
		else if(document.getElementsByName("pay_cards")[1].checked)
		{
			  
		}
		else
		{
			error_msg=error_msg+"Pay Cards \n";
		}
	
	//new1
	if(document.getElementsByName("direct_deposit12")[0].checked || document.getElementsByName("direct_deposit12")[1].checked)
		{
			
		}
		else
		{
			error_msg=error_msg+"Direct Deposit \n";
		}
	
//	final check	

		if(error_msg=="")
		{
			
			return 1;
			
		}
		else
		{
			error_msg = "Sorry to pest. But we need all fields filled out in order to calculate your savings information";
			alert(error_msg);
			return 0;
		}
		
		
	}
  $('#next2').click(function() { // bind click event to link
	
	var flg1 = validate2();
	if(flg1 == 1)
	{	
			document.getElementById("tab_no").value="1";
		document.form1.finish1.click();
		$(".tab_content").hide(); 
        $('#tab3').fadeIn();
		 //calculate($('#tab2'));
		$('img#imgTab3').attr({ src: "images/tab_frequency_hover.png" });
		 
		 $('img#imgTab1').attr({ src: "images/tab_company_background4.png"});
         $('img#imgTab2').attr({ src: "images/tab_payroll_process4.png"});
         
         $('img#imgTab4').attr({ src: "images/tab_payroll_dist4.png"});
         	document.getElementById("tab_no").value="0";

                return false;
	}
	else
	{
	
	
	}			
				
      });
	  
	  function validate2()
	  {
	  		error_msg="";
			$("#payroll_team").removeClass("invalid");
			if(document.getElementById("payroll_team").value == "")
			{
				
				error_msg=error_msg+"Please Insert Payroll Team Size \n";
				$("#payroll_team").addClass("invalid");
			}
			
			if(!isInteger(document.getElementById("payroll_team").value))
			{
				error_msg=error_msg+"payroll_team \n";
				$("#payroll_team").addClass("invalid");
			}
		
				
//	final check	
		if(error_msg=="")
		{
			return 1;
		}
		else
		{
			//alert(error_msg);
			alert("Sorry to pest. But we need all fields filled out in order to calculate your savings information");
			return 0;
		}
	  	
	  
	  }
		
	  $('#next3').click(function() { // bind click event to link
	
	
	var flg1 = validate3();
	if(flg1 == 1)
	{
			document.getElementById("tab_no").value="1";
		document.form1.finish1.click();
		$(".tab_content").hide(); 
               $('#tab4').fadeIn();
			  //calculate($('#tab2'));
			       $('img#imgTab4').attr({ src: "images/tab_payroll_dist_hover.png" });
				 
				  $('img#imgTab1').attr({ src: "images/tab_company_background4.png"});
                 $('img#imgTab2').attr({ src: "images/tab_payroll_process4.png"});
                 $('img#imgTab3').attr({  src: "images/tab_frequency4.png"});
                 	document.getElementById("tab_no").value="0";

                return false;
				
	}
	else
	{
	
	}
        });

 function validate3()
	  {
	  		error_msg="";
			
			
			$("#new_hires").removeClass("invalid");
			$("#payroll_calendars").removeClass("invalid");
			$("#offcycle_payment").removeClass("invalid");
			$("#banks_permited").removeClass("invalid");
			$("#weekly_paid").removeClass("invalid");
			$("#exempt_employee").removeClass("invalid");
			$("#nonexempt_employee").removeClass("invalid");
			$("#semimonthly_paid").removeClass("invalid");
			$("#union_employee").removeClass("invalid");
			$("#monthly_paid").removeClass("invalid");
			$("#other_paid").removeClass("invalid");
			$("#bargaining_agreements").removeClass("invalid");
			$("#biweekly_paid").removeClass("invalid");
			$("#emp_unbankable").removeClass("invalid");
			//emp_unbankable
			if(document.getElementById("new_hires").value == "")
			{
				
				error_msg=error_msg+"New hire \n";
					$("#new_hires").addClass("invalid");
			}
			if(!isInteger(document.getElementById("new_hires").value))
			{
				error_msg=error_msg+"New Hire \n";
				$("#new_hires").addClass("invalid");
			}
			if(document.getElementById("payroll_calendars").value == "")
			{
				
				error_msg=error_msg+"Payroll calendars \n";
				$("#payroll_calendars").addClass("invalid");
			}
			if(!isInteger(document.getElementById("payroll_calendars").value))
			{
				error_msg=error_msg+"payroll_calendars \n";
				$("#payroll_calendars").addClass("invalid");
			}
			if(document.getElementById("offcycle_payment").value == "")
			{
				
				error_msg=error_msg+"Offcycle payment \n";
				$("#offcycle_payment").addClass("invalid");
			}
			if(!isInteger(document.getElementById("offcycle_payment").value))
			{
				error_msg=error_msg+"Offcycle payment\n";
				$("#offcycle_payment").addClass("invalid");
			}
			if(document.getElementById("banks_permited").value == "")
			{
				
				error_msg=error_msg+"Banks permited \n";
				$("#banks_permited").addClass("invalid");
			}
			if(!isInteger(document.getElementById("banks_permited").value))
			{
				error_msg=error_msg+"Banks permited \n";
				$("#banks_permited").addClass("invalid");
			}
			if(document.getElementById("weekly_paid").value == "")
			{
				
				error_msg=error_msg+"Weekly paid \n";
				$("#weekly_paid").addClass("invalid");
			}
			if(!isInteger(document.getElementById("weekly_paid").value))
			{
				error_msg=error_msg+"Weekly paid \n";
				$("#weekly_paid").addClass("invalid");
			}
			if(document.getElementById("exempt_employee").value == "")
			{
				
				error_msg=error_msg+"Exempt employee \n";
				$("#exempt_employee").addClass("invalid");
			}
			if(!isInteger(document.getElementById("exempt_employee").value))
			{
				error_msg=error_msg+"Exempt employee \n";
				$("#exempt_employee").addClass("invalid");
			}
			if(document.getElementById("nonexempt_employee").value == "")
			{
				
				error_msg=error_msg+"Nonexempt employee \n";
				$("#nonexempt_employee").addClass("invalid");
			}
			if(!isInteger(document.getElementById("nonexempt_employee").value))
			{
				error_msg=error_msg+"Nonexempt employee \n";
				$("#nonexempt_employee").addClass("invalid");
			}
			if(document.getElementById("semimonthly_paid").value == "")
			{
				
				error_msg=error_msg+"Semimonthly paid \n";
				$("#semimonthly_paid").addClass("invalid");
			}
			if(!isInteger(document.getElementById("semimonthly_paid").value))
			{
				error_msg=error_msg+"Semimonthly paid \n";
				$("#semimonthly_paid").addClass("invalid");
			}
			if(document.getElementById("union_employee").value == "")
			{
				
				error_msg=error_msg+"Union employee \n";
				$("#union_employee").addClass("invalid");
			}
			if(!isInteger(document.getElementById("union_employee").value))
			{
				error_msg=error_msg+"Union employee \n";
				$("#union_employee").addClass("invalid");
			}
			if(document.getElementById("monthly_paid").value == "")
			{
				
				error_msg=error_msg+"Monthly paid \n";
				$("#monthly_paid").addClass("invalid");
			}
			if(!isInteger(document.getElementById("monthly_paid").value))
			{
				error_msg=error_msg+"Monthly paid \n";
				$("#monthly_paid").addClass("invalid");
			}
			if(document.getElementById("other_paid").value == "")
			{
				
				error_msg=error_msg+"Other paid \n";
				$("#other_paid").addClass("invalid");
			}
			if(!isInteger(document.getElementById("other_paid").value))
			{
				error_msg=error_msg+"Other paid \n";
				$("#other_paid").addClass("invalid");
			}
			if(document.getElementById("emp_unbankable").value == "")
			{
				
				error_msg=error_msg+"Unbankable employees \n";
					$("#emp_unbankable").addClass("invalid");
			}
			if(!isInteger(document.getElementById("emp_unbankable").value))
			{
				error_msg=error_msg+"Unbankable employees \n";
				$("#emp_unbankable").addClass("invalid");
			}
			if(document.getElementById("bargaining_agreements").value == "")
			{
				
				error_msg=error_msg+"Bargaining agreements \n";
				$("#bargaining_agreements").addClass("invalid");
			}
			if(!isInteger(document.getElementById("bargaining_agreements").value))
			{
				error_msg=error_msg+"Bargaining agreements \n";
				$("#bargaining_agreements").addClass("invalid");
			}
			if(document.getElementById("biweekly_paid").value == "")
			{
				
				error_msg=error_msg+"Biweekly paid \n";
				$("#biweekly_paid").addClass("invalid");
			}
			if(!isInteger(document.getElementById("biweekly_paid").value))
			{
				error_msg=error_msg+"Biweekly paid \n";
				$("#biweekly_paid").addClass("invalid");
			}
		
		/*	if(document.getElementById("usemployee").value < document.getElementById("new_hires").value)
		 {	

			error_msg=error_msg+"No. of New Hires should not exceed total employees \n";
		//	$("#usemployee").addClass("invalid");
			$("#new_hires").addClass("invalid");
		
		  }
		  if(document.getElementById("usemployee").value < document.getElementById("payroll_calendars").value)
		 {	

			error_msg=error_msg+"No. of Payroll calendars should not exceed total employees \n";
		//	$("#usemployee").addClass("invalid");
			$("#payroll_calendars").addClass("invalid");
		
		  }
		  if(document.getElementById("usemployee").value < document.getElementById("offcycle_payment").value)
		 {	

			error_msg=error_msg+"No. of offcycle payments should not exceed total employees \n";
		//	$("#usemployee").addClass("invalid");
			$("#offcycle_payment").addClass("invalid");
		
		  }
		if(document.getElementById("usemployee").value < document.getElementById("emp_unbankable").value)
		 {	

			error_msg=error_msg+"No. of unbankable employees should not exceed total employees \n";
		//	$("#usemployee").addClass("invalid");
			$("#emp_unbankable").addClass("invalid");
		
		  }*/
		  var add1 = parseInt(document.getElementById("weekly_paid").value) + parseInt(document.getElementById("semimonthly_paid").value) + parseInt(document.getElementById("monthly_paid").value) + parseInt(document.getElementById("other_paid").value) + parseInt(document.getElementById("biweekly_paid").value);
		 
		  if(add1 != document.getElementById("usemployee").value) 
		 {	
			
		//	error_msg=error_msg+"Employees paid should not exceed total no. of employees \n";
		//	$("#usemployee").addClass("invalid");
			$("#weekly_paid").addClass("invalid");
			$("#semimonthly_paid").addClass("invalid");
		  $("#monthly_paid").addClass("invalid");
			$("#biweekly_paid").addClass("invalid");
			$("#other_paid").addClass("invalid");
			alert("Sorry to bother you but the number of employees paid weekly, biweekly, semimonthly, monthly and other should sum to the  total number of employees you inputted on the first tab");
			return 0;
		  }
/*				
 var add2 = parseInt(document.getElementById("exempt_employee").value) + parseInt(document.getElementById("nonexempt_employee").value) + parseInt(document.getElementById("union_employee").value);
		 
		  if(add2 != document.getElementById("usemployee").value) 
		 {	

			error_msg=error_msg+"Employees types should not exceed total no. of employees \n";
		//	$("#usemployee").addClass("invalid");
			$("#exempt_employee").addClass("invalid");
			$("#nonexempt_employee").addClass("invalid");
		  $("#union_employee").addClass("invalid");
		
		  }*/
					
				
//	final check	
		if(error_msg=="")
		{
			return 1;
		}
		else
		{
				error_msg = "Please correct the following fields :\n-----------------------------------------\n"+error_msg;
				alert("Sorry to pest. But we need all fields filled out in order to calculate your savings information");
			return 0;
		}
	  	
	  
	  }
//next4 here
  $('#next4').click(function() { // bind click event to link
//	document.form1.submit();
	/*var flg1 = validate4();
	if(flg1 == 1)
	{	
	
	// submit AJAX form 
	 
document.form1.submit();
	}
	else
	{
	
	
	}			*/
				
      });
	  
	  function validate4()
	  {

	  		error_msg="";
			$("#printed_check").removeClass("invalid");
			$("#direct_deposit").removeClass("invalid");
			$("#pay_card_payment").removeClass("invalid");
			$("#usmail_distributed_w").removeClass("invalid");
			$("#usmail_distributed_b").removeClass("invalid");
			$("#usmail_distributed_s").removeClass("invalid");
			$("#usmail_distributed_m").removeClass("invalid");
			$("#hand_distributed_w").removeClass("invalid");
			$("#hand_distributed_b").removeClass("invalid");
			$("#hand_distributed_s").removeClass("invalid");
			$("#hand_distributed_m").removeClass("invalid");
			$("#direct_deposit_payment").removeClass("invalid");
			$("#print_pay_adv_w").removeClass("invalid");
			$("#print_pay_adv_b").removeClass("invalid");
			$("#print_pay_adv_s").removeClass("invalid");
			$("#print_pay_adv_m").removeClass("invalid");
			$("#print_hand_w").removeClass("invalid");
			$("#print_hand_b").removeClass("invalid");
			$("#print_hand_s").removeClass("invalid");
			$("#print_hand_m").removeClass("invalid");
			$("#envelopes_machine_w").removeClass("invalid");
			$("#envelopes_machine_b").removeClass("invalid");
			$("#envelopes_machine_s").removeClass("invalid");
			$("#envelopes_machine_m").removeClass("invalid");
			$("#envelopes_hand_w").removeClass("invalid");
			$("#envelopes_hand_b").removeClass("invalid");
			$("#envelopes_hand_s").removeClass("invalid");
			$("#envelopes_hand_m").removeClass("invalid");
			$("#w2_electronically").removeClass("invalid");
			$("#w2_printed").removeClass("invalid");
			$("#usmail_w2_distributed").removeClass("invalid");
			$("#hand_w2_distributed").removeClass("invalid");
			
			if(document.getElementById("printed_check").value == "")
			{
				$("#printed_check").addClass("invalid");
				error_msg=error_msg+"printed_check \n";
			}
			if(!isInteger(document.getElementById("printed_check").value))
			{
				error_msg=error_msg+"printed_check \n";
				$("#printed_check").addClass("invalid");
			}
			
			if(document.getElementById("direct_deposit").value == "")
			{
				if(document.getElementsByName('direct_deposit12')[1].checked)
				{
				
				}
				else
				{
//1				$("#direct_deposit").addClass("invalid");
//1				error_msg=error_msg+"direct_deposit \n";
			}
			}
			if(!isInteger(document.getElementById("direct_deposit").value))
			{
				error_msg=error_msg+"direct_deposit \n";
				$("#direct_deposit").addClass("invalid");
			}
			
			if(document.getElementById("pay_card_payment").value == "")
			{
			
				if(document.getElementsByName('pay_cards')[1].checked)
				{
				
				}
				else
				{
//1				$("#pay_card_payment").addClass("invalid");
//1				error_msg=error_msg+"pay_card_payment \n";
				}
			}
			if(!isInteger(document.getElementById("pay_card_payment").value))
			{
				error_msg=error_msg+"pay_card_payment \n";
				$("#pay_card_payment").addClass("invalid");
			}
			
			if(document.getElementById("usmail_distributed_w").value == "")
			{
				$("#usmail_distributed_w").addClass("invalid");
				error_msg=error_msg+"usmail_distributed_w \n";
			}
			if(!isInteger(document.getElementById("usmail_distributed_w").value))
			{
				error_msg=error_msg+"usmail_distributed_w \n";
				$("#usmail_distributed_w").addClass("invalid");
			}
			
			if(document.getElementById("usmail_distributed_b").value == "")
			{
				$("#usmail_distributed_b").addClass("invalid");
				error_msg=error_msg+"usmail_distributed_b \n";
			}
			if(!isInteger(document.getElementById("usmail_distributed_b").value))
			{
				error_msg=error_msg+"usmail_distributed_b \n";
				$("#usmail_distributed_b").addClass("invalid");
			}
			
			if(document.getElementById("usmail_distributed_s").value == "")
			{
				$("#usmail_distributed_s").addClass("invalid");
				error_msg=error_msg+"usmail_distributed_s \n";
			}
			if(!isInteger(document.getElementById("usmail_distributed_s").value))
			{
				error_msg=error_msg+"usmail_distributed_s \n";
				$("#usmail_distributed_s").addClass("invalid");
			}
			
			if(document.getElementById("usmail_distributed_m").value == "")
			{
				$("#usmail_distributed_m").addClass("invalid");
				error_msg=error_msg+"usmail_distributed_m \n";
			}
			if(!isInteger(document.getElementById("usmail_distributed_m").value))
			{
				error_msg=error_msg+"usmail_distributed_m \n";
				$("#usmail_distributed_m").addClass("invalid");
			}
			
			if(document.getElementById("hand_distributed_w").value == "")
			{
				$("#hand_distributed_w").addClass("invalid");
				error_msg=error_msg+"hand_distributed_w \n";
			}
			if(!isInteger(document.getElementById("hand_distributed_w").value))
			{
				error_msg=error_msg+"hand_distributed_w \n";
				$("#hand_distributed_w").addClass("invalid");
			}
			
			if(document.getElementById("hand_distributed_b").value == "")
			{
		
				$("#hand_distributed_b").addClass("invalid");
				error_msg=error_msg+"hand_distributed_b \n";
			}
			if(!isInteger(document.getElementById("hand_distributed_b").value))
			{
				error_msg=error_msg+"hand_distributed_b\n";
				$("#hand_distributed_b").addClass("invalid");
			}
			
			if(document.getElementById("hand_distributed_s").value == "")
			{
				$("#hand_distributed_s").addClass("invalid");
				error_msg=error_msg+"hand_distributed_s \n";
			}
			if(!isInteger(document.getElementById("hand_distributed_s").value))
			{
				error_msg=error_msg+"hand_distributed_s \n";
				$("#hand_distributed_s").addClass("invalid");
			}
			
			if(document.getElementById("hand_distributed_m").value == "")
			{
				$("#hand_distributed_m").addClass("invalid");
				error_msg=error_msg+"hand_distributed_m \n";
			}
			if(!isInteger(document.getElementById("hand_distributed_m").value))
			{
				error_msg=error_msg+"hand_distributed_m \n";
				$("#hand_distributed_m").addClass("invalid");
			}
			
			if(document.getElementById("direct_deposit_payment").value == "")
			{
				$("#direct_deposit_payment").addClass("invalid");
				error_msg=error_msg+"direct_deposit_payment \n";
			}
			if(!isInteger(document.getElementById("direct_deposit_payment").value))
			{
				error_msg=error_msg+"direct_deposit_payment \n";
				$("#direct_deposit_payment").addClass("invalid");
			}
			
			if(document.getElementById("print_pay_adv_w").value == "")
			{
				$("#print_pay_adv_w").addClass("invalid");
				error_msg=error_msg+"print_pay_adv_w \n";
			}
			if(!isInteger(document.getElementById("print_pay_adv_w").value))
			{
				error_msg=error_msg+"print_pay_adv_w \n";
				$("#print_pay_adv_w").addClass("invalid");
			}
			
			if(document.getElementById("print_pay_adv_b").value == "")
			{
				$("#print_pay_adv_b").addClass("invalid");
			error_msg=error_msg+"print_pay_adv_b \n";
			}
			if(!isInteger(document.getElementById("print_pay_adv_b").value))
			{
				error_msg=error_msg+"print_pay_adv_b \n";
				$("#print_pay_adv_b").addClass("invalid");
			}
			
			if(document.getElementById("print_pay_adv_s").value == "")
			{
				$("#print_pay_adv_s").addClass("invalid");
				error_msg=error_msg+"print_pay_adv_s \n";
			}
			if(!isInteger(document.getElementById("print_pay_adv_s").value))
			{
				error_msg=error_msg+"print_pay_adv_s \n";
				$("#print_pay_adv_s").addClass("invalid");
			}
			
			if(document.getElementById("print_pay_adv_m").value == "")
			{
			$("#print_pay_adv_m").addClass("invalid");
				error_msg=error_msg+"print_pay_adv_m \n";
			}
			if(!isInteger(document.getElementById("print_pay_adv_m").value))
			{
				error_msg=error_msg+"print_pay_adv_m\n";
				$("#print_pay_adv_m").addClass("invalid");
			}
			
			if(document.getElementById("print_hand_w").value == "")
			{
				$("#print_hand_w").addClass("invalid");
				error_msg=error_msg+"print_hand_w \n";
			}
			if(!isInteger(document.getElementById("print_hand_w").value))
			{
				error_msg=error_msg+"print_hand_w \n";
				$("#print_hand_w").addClass("invalid");
			}
			
			if(document.getElementById("print_hand_b").value == "")
			{
				$("#print_hand_b").addClass("invalid");
				error_msg=error_msg+"print_hand_b \n";
			}
			if(!isInteger(document.getElementById("print_hand_b").value))
			{
				error_msg=error_msg+"print_hand_b \n";
				$("#print_hand_b").addClass("invalid");
			}
			
			if(document.getElementById("print_hand_s").value == "")
			{
				$("#print_hand_s").addClass("invalid");
				error_msg=error_msg+"print_hand_s \n";
			}
			if(!isInteger(document.getElementById("print_hand_s").value))
			{
				error_msg=error_msg+"print_hand_s \n";
				$("#print_hand_s").addClass("invalid");
			}
			
			if(document.getElementById("print_hand_m").value == "")
			{
				$("#print_hand_m").addClass("invalid");
				error_msg=error_msg+"print_hand_m \n";
			}
			if(!isInteger(document.getElementById("print_hand_m").value))
			{
				error_msg=error_msg+"print_hand_m \n";
				$("#print_hand_m").addClass("invalid");
			}
			
			if(document.getElementById("envelopes_machine_w").value == "")
			{
				$("#envelopes_machine_w").addClass("invalid");
				error_msg=error_msg+"envelopes_machine_w \n";
			}
			if(!isInteger(document.getElementById("envelopes_machine_w").value))
			{
				error_msg=error_msg+"envelopes_machine_w \n";
				$("#envelopes_machine_w").addClass("invalid");
			}
			
			if(document.getElementById("envelopes_machine_b").value == "")
			{
				$("#envelopes_machine_b").addClass("invalid");
				error_msg=error_msg+"envelopes_machine_b \n";
			}
			if(!isInteger(document.getElementById("envelopes_machine_b").value))
			{
				error_msg=error_msg+"envelopes_machine_b \n";
				$("#envelopes_machine_b").addClass("invalid");
			}
			
			if(document.getElementById("envelopes_machine_s").value == "")
			{
				$("#envelopes_machine_s").addClass("invalid");
			error_msg=error_msg+"envelopes_machine_s \n";
			}
			if(!isInteger(document.getElementById("envelopes_machine_s").value))
			{
				error_msg=error_msg+"envelopes_machine_s \n";
				$("#envelopes_machine_s").addClass("invalid");
			}
			
			if(document.getElementById("envelopes_machine_m").value == "")
			{
				$("#envelopes_machine_m").addClass("invalid");
			error_msg=error_msg+"envelopes_machine_m \n";
			}
			if(!isInteger(document.getElementById("envelopes_machine_m").value))
			{
				error_msg=error_msg+"envelopes_machine_m \n";
				$("#envelopes_machine_m").addClass("invalid");
			}
			if(document.getElementById("envelopes_hand_w").value == "")
			{
				$("#envelopes_hand_w").addClass("invalid");
				error_msg=error_msg+"envelopes_hand_w \n";
			}
			if(!isInteger(document.getElementById("envelopes_hand_w").value))
			{
				error_msg=error_msg+"envelopes_hand_w \n";
				$("#envelopes_hand_w").addClass("invalid");
			}
			if(document.getElementById("envelopes_hand_b").value == "")
			{
				$("#envelopes_hand_b").addClass("invalid");
			error_msg=error_msg+"envelopes_hand_b \n";
			}
			if(!isInteger(document.getElementById("envelopes_hand_b").value))
			{
				error_msg=error_msg+"envelopes_hand_b \n";
				$("#envelopes_hand_b").addClass("invalid");
			}
			if(document.getElementById("envelopes_hand_s").value == "")
			{
				$("#envelopes_hand_s").addClass("invalid");
				error_msg=error_msg+"envelopes_hand_s \n";
			}
			if(!isInteger(document.getElementById("envelopes_hand_s").value))
			{
				error_msg=error_msg+"envelopes_hand_s \n";
				$("#envelopes_hand_s").addClass("invalid");
			}
			if(document.getElementById("envelopes_hand_m").value == "")
			{
				$("#envelopes_hand_m").addClass("invalid");
			error_msg=error_msg+"envelopes_hand_m \n";
			}
			if(!isInteger(document.getElementById("envelopes_hand_m").value))
			{
				error_msg=error_msg+"envelopes_hand_m \n";
				$("#envelopes_hand_m").addClass("invalid");
			}
			if(document.getElementById("w2_electronically").value == "")
			{
				$("#w2_electronically").addClass("invalid");
				error_msg=error_msg+"w2_electronically \n";
			}
			if(!isInteger(document.getElementById("w2_electronically").value))
			{
				error_msg=error_msg+"w2_electronically \n";
				$("#w2_electronically").addClass("invalid");
			}
			if(document.getElementById("w2_printed").value == "")
			{
				$("#w2_printed").addClass("invalid");
				error_msg=error_msg+"w2_printed \n";
			}
			if(!isInteger(document.getElementById("w2_printed").value))
			{
				error_msg=error_msg+"w2_printed \n";
				$("#w2_printed").addClass("invalid");
			}
			if(document.getElementById("usmail_w2_distributed").value == "")
			{
				$("#usmail_w2_distributed").addClass("invalid");
				error_msg=error_msg+"usmail_w2_distributed \n";
			}
			if(!isInteger(document.getElementById("usmail_w2_distributed").value))
			{
				error_msg=error_msg+"usmail_w2_distributed \n";
				$("#usmail_w2_distributed").addClass("invalid");
			}
			if(document.getElementById("hand_w2_distributed").value == "")
			{
				$("#hand_w2_distributed").addClass("invalid");
				error_msg=error_msg+"hand_w2_distributed \n";
			}
			if(!isInteger(document.getElementById("hand_w2_distributed").value))
			{
				error_msg=error_msg+"hand_w2_distributed \n";
				$("#hand_w2_distributed").addClass("invalid");
			}
			var tsum1;
			if(document.getElementById("printed_check").value == "")
			{
					tsum1 = 0;
			}else
			{	
			 		tsum1 = parseInt(document.getElementById("printed_check").value);
			}
			
			var tsum2;
			if(document.getElementById("direct_deposit").value == "")
			{
					tsum2 = 0;
			}else
			{	
			 		tsum2 = parseInt(document.getElementById("direct_deposit").value);
			}
			
			var tsum3;
			if(document.getElementById("pay_card_payment").value == "")
			{
					tsum3 = 0;
			}else
			{	
			 		tsum3 = parseInt(document.getElementById("pay_card_payment").value);
			}

			
			var add4 = tsum1 + tsum2 + tsum3 ;
		// alert(add4);
if(add4 != document.getElementById("usemployee").value) 
 {	

//  document.write("You pressed Cancel!");

		//	error_msg=error_msg+"Total of Printed check, Direct deposit and Paycard payment should equal to No of Employees\n";
				error_msg=error_msg+" ";
		//	$("#usemployee").addClass("invalid");
			$("#printed_check").addClass("invalid");
			$("#direct_deposit").addClass("invalid");
		   $("#pay_card_payment").addClass("invalid");
  		  alert("Sorry to bother you but the number of employees paid by printed check, direct deposit and pay card does not equal the total number of employees you input on the first tab");
		  return 0;	
				
 }	
	
		
		/*
			var t1p1;
			if(document.getElementById("usmail_distributed_w").value == "")
			{
					t1p1 = 0;
			}else
			{	
			 		t1p1 = parseInt(document.getElementById("usmail_distributed_w").value);
			}
			var t1p2;
			if(document.getElementById("usmail_distributed_b").value == "")
			{
					t1p2 = 0;
			}else
			{	
			 		t1p2 = parseInt(document.getElementById("usmail_distributed_b").value);
			}
			var t1p3;
			if(document.getElementById("usmail_distributed_s").value == "")
			{
					t1p3 = 0;
			}else
			{	
			 		t1p3 = parseInt(document.getElementById("usmail_distributed_s").value);
			}
			var t1p4;
			if(document.getElementById("usmail_distributed_m").value == "")
			{
					t1p4 = 0;
			}else
			{	
			 		t1p4 = parseInt(document.getElementById("usmail_distributed_m").value);
			}
			var t1p5;
			if(document.getElementById("hand_distributed_w").value == "")
			{
					t1p5 = 0;
			}else
			{	
			 		t1p5 = parseInt(document.getElementById("hand_distributed_w").value);
			}
			var t1p6;
			if(document.getElementById("hand_distributed_b").value == "")
			{
					t1p6 = 0;
			}else
			{	
			 		t1p6 = parseInt(document.getElementById("hand_distributed_b").value);
			}
			var t1p7;
			if(document.getElementById("hand_distributed_s").value == "")
			{
					t1p7 = 0;
			}else
			{	
			 		t1p7 = parseInt(document.getElementById("hand_distributed_s").value);
			}
			var t1p8;
			if(document.getElementById("hand_distributed_m").value == "")
			{
					t1p8 = 0;
			}else
			{	
			 		t1p8 = parseInt(document.getElementById("hand_distributed_m").value);
			}
			
		var temp_by_check1 = t1p1 + t1p2 + t1p3 + t1p4 + t1p5 + t1p6 + t1p7 + t1p8;
		
			var t1ddp;
			if(document.getElementById("direct_deposit_payment").value == "")
			{
					t1ddp = 0;
			}else
			{	
			 		t1ddp = parseInt(document.getElementById("direct_deposit_payment").value);
			}
		var final_t1 =  temp_by_check1 - t1ddp;
//use		
		
		
		
			var print1p1;
			if(document.getElementById("print_pay_adv_w").value == "")
			{
					print1p1 = 0;
			}else
			{	
			 		print1p1 = parseInt(document.getElementById("print_pay_adv_w").value);
			}
			var print1p2;
			if(document.getElementById("print_pay_adv_b").value == "")
			{
					print1p2 = 0;
			}else
			{	
			 		print1p2 = parseInt(document.getElementById("print_pay_adv_b").value);
			}
			var print1p3;
			if(document.getElementById("print_pay_adv_s").value == "")
			{
					print1p3 = 0;
			}else
			{	
			 		print1p3 = parseInt(document.getElementById("print_pay_adv_s").value);
			}
			var print1p4;
			if(document.getElementById("print_pay_adv_m").value == "")
			{
					print1p4 = 0;
			}else
			{	
			 		print1p4 = parseInt(document.getElementById("print_pay_adv_m").value);
			}
			var print1p5;
			if(document.getElementById("print_hand_w").value == "")
			{
					print1p5 = 0;
			}else
			{	
			 		print1p5 = parseInt(document.getElementById("print_hand_w").value);
			}
			var print1p6;
			if(document.getElementById("print_hand_b").value == "")
			{
					print1p6 = 0;
			}else
			{	
			 		print1p6 = parseInt(document.getElementById("print_hand_b").value);
			}
			var print1p7;
			if(document.getElementById("print_hand_s").value == "")
			{
					print1p7 = 0;
			}else
			{	
			 		print1p7 = parseInt(document.getElementById("print_hand_s").value);
			}
			var print1p8;
			if(document.getElementById("print_hand_m").value == "")
			{
					print1p8 = 0;
			}else
			{	
			 		print1p8 = parseInt(document.getElementById("print_hand_m").value);
			}
			
			
			var other_paid1;
			if(document.getElementById("other_paid").value == "")
			{
					other_paid1 = 0;
			}else
			{	
			 		other_paid1 = parseInt(document.getElementById("other_paid").value);
			}
			var temp_with_advice1 = print1p8 + print1p8 + print1p8 + print1p8 + print1p8 + print1p8 + print1p8 + print1p8;
				
				
				var ans_check = temp_by_check1 + final_t1 + temp_with_advice1 + tsum3 +other_paid1;
		
		if(ans_check != document.getElementById("usemployee").value) 
		 {	
		 
					var r=confirm("The sum of employees receiving checks, direct deposit with no printed advice, direct deposit with printed advice, and pay cards does not equal total number of U.S. employees.  Do you wish to continue without changing?");
					if (r==true)
					  {
					 // document.write("You pressed OK!");
					  }
					else
					  {
//  document.write("You pressed Cancel!");

		//	error_msg=error_msg+"Total of Printed check, Direct deposit and Paycard payment should equal to No of Employees\n";
				error_msg=error_msg+" ";
		//	$("#usemployee").addClass("invalid");
		
		
		  }
		 	

		
		  }*/
//	final check	
		if(error_msg=="")
		{
			return 1;
		}
		else if(error_msg==" " || error_msg=="  ")
			{
				return 0;
				}
		else
		{
			alert("Sorry to pest. But we need all fields filled out in order to calculate your savings information");
			return 0;
		}
	  	
	  return 0;
	  }





//next4 ends
	//On Click Event
	$("ul.tabs li").click(function() {
		calculate(this);
		return false;
	});
	  	
function calculate(ths)
{
	
		if(curr[4]=="1")
		{
			
			var flg1 = validate1();
			if(flg1 == 1)
				{
					document.getElementById("tab_no").value="1";
					document.form1.finish1.click();
				}
				else
				{
					return;	
				}
		}
		else if(curr[4]=="2")
		{
			var flg1 = validate2();
			if(flg1 == 1)
				{
					document.getElementById("tab_no").value="1";
					document.form1.finish1.click();
				}
				else
				{
					return;	
				}
		}
		else if(curr[4]=="3")
		{
			var flg1 = validate3();
			if(flg1 == 1)
				{
					document.getElementById("tab_no").value="1";
					document.form1.finish1.click();
				}
				else
				{
					return;	
				}
		}
		
		
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(ths).addClass("active"); //Add "active" class to selected tab

		               
                
		$(".tab_content").hide(); //Hide all tab content
		var activeTab = $(ths).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active content
		
		curr = activeTab;
		
		
		
		
		if(activeTab=="#tab1")
		{
		  // tab 1 selected

                 $('img#imgTab1').attr({ src: "images/tab_company_background_hover.png" });
				 
				
                 $('img#imgTab2').attr({ src: "images/tab_payroll_process4.png"});
                 $('img#imgTab3').attr({  src: "images/tab_frequency4.png"});
                 $('img#imgTab4').attr({ src: "images/tab_payroll_dist4.png"});
				

		}
		else if(activeTab=="#tab2")
		{
		  // tab 2 selected

                 $('img#imgTab2').attr({ src: "images/tab_payroll_process_hover.png" });
				 
				  $('img#imgTab1').attr({ src: "images/tab_company_background4.png"});
              
                 $('img#imgTab3').attr({  src: "images/tab_frequency4.png"});
                 $('img#imgTab4').attr({ src: "images/tab_payroll_dist4.png"});

		}
		else if(activeTab=="#tab3")
		{
		  // tab 3 selected

                 $('img#imgTab3').attr({ src: "images/tab_frequency_hover.png" });
				 
				  $('img#imgTab1').attr({ src: "images/tab_company_background4.png"});
                 $('img#imgTab2').attr({ src: "images/tab_payroll_process4.png"});
              
                 $('img#imgTab4').attr({ src: "images/tab_payroll_dist4.png"});

		}
		else if(activeTab=="#tab4")
		{
		  // tab 3 selected

                 $('img#imgTab4').attr({ src: "images/tab_payroll_dist_hover.png" });
				 
				  $('img#imgTab1').attr({ src: "images/tab_company_background4.png"});
                 $('img#imgTab2').attr({ src: "images/tab_payroll_process4.png"});
                 $('img#imgTab3').attr({  src: "images/tab_frequency4.png"});
             

		}

}
});





function combchange(ln)
{
var x = document.getElementById(ln).selectedIndex;
if(x == 0)
{
document.getElementById(ln+'1').checked=true;
}
else
{
document.getElementById(ln+'1').checked=false;
}
}

function rdochange(ln1)
{
document.getElementById(ln1).selectedIndex = 0;
}

function setvisibility()
{

 document.getElementById('pay_card1').style.display = "none";
 document.getElementById('pay_card2').style.display = "none";

}

function setvisibility1(this1)
{
	document.getElementById('pay_cards123').checked = true;
 document.getElementById('pay_card1').style.display = "block";
 document.getElementById('pay_card2').style.display = "block";
return hs.htmlExpand(this1, { contentId: 'info3' } );
}


function setvisibility21()
{
 document.getElementById('deposit_1').style.display = "block";
 document.getElementById('deposit_2').style.display = "block";

}

function setvisibility22()
{
 document.getElementById('deposit_1').style.display = "none";
 document.getElementById('deposit_2').style.display = "none";

}

<!--
if (document.images)
{
  pic1= new Image(150,37); 
  pic1.src="images/tab_company_background_hover.png"; 

  pic2= new Image(116,39); 
  pic2.src="images/tab_payroll_process_hover.png"; 

  pic3= new Image(92,37); 
  pic3.src="images/tab_frequency_hover.png"; 
  
  pic4 = new Image(86,37);
  pic4.src ="images/tab_payroll_dist_hover.png";
}
//-->
function finish_click()
{
	document.getElementById("tab_no").value="0";
	//var flg1 = validate4(); 
	
	/*if(flg1 == 1)
	{	
	
	// submit AJAX form 
	
document.form1.submit();
	
	}
	else
	{
		return false;
	
	}			*/
	
}
function function12(this1)
{
		return hs.htmlExpand(this1, { contentId: 'info_cap' } )
	}
	
function function13(this1)
{
	return hs.htmlExpand(this1, { contentId: 'info2' } )
}
function function14(this1)
{
return hs.htmlExpand(this1, { contentId: 'info1' } )
}
function closehs(this1)
{
hs.close('info_cap');
return hs.close(this1);
}