﻿/**
 * @author Riaz Missaghi
 */

/*
 * Jonathan Howard
 *
 * jQuery Pause
 * version 0.2
 *
 * Requires: jQuery 1.0 (tested with svn as of 7/20/2006)
 *
 * Feel free to do whatever you'd like with this, just please give credit where
 * credit is do.
 *
 *
 *
 * pause() will hold everything in the queue for a given number of milliseconds,
 * or 1000 milliseconds if none is given.
 *
 *
 *
 * unpause() will clear the queue of everything of a given type, or 'fx' if no
 * type is given.
 */
$.fn.pause = function(milli,type) {
	milli = milli || 1000;
	type = type || "fx";
	return this.queue(type,function(){
		var self = this;
		setTimeout(function(){
			$.dequeue(self);
		},milli);
	});
};

$.fn.clearQueue = $.fn.unpause = function(type) {
	return this.each(function(){
		type = type || "fx";
		if(this.queue && this.queue[type]) {
			this.queue[type].length = 0;
		}
	});
};

jQuery.fn.checkbox = function (opt) {
			jQuery("input[@type='checkbox']", this).hide().each( function () {
				jQuery("<img>")
					.attr( {src: this.checked ? opt.checked : opt.unchecked } )
					.click( function() {
						var check = jQuery(this).next()[0].checked == true;
						if (jQuery(this).next()[0].className.length > 0){
							jQuery("."+jQuery(this).next()[0].className)
								.each(function () {
										this.checked = false;
										jQuery(this).prev().attr( { src: opt.unchecked } )
								})					
						}
						jQuery(this)
							.attr( { src: check ? opt.unchecked : opt.checked } )
							.next()[0].checked = !check;
						
						
						fCalculate();
						
					})
					.insertBefore(this);
			});
		}
		
		var filingFeeNotRequired = false;
		
		var promocode = ''; 
		var promoamount = ''; 
		var promopercentage = ''; 
		var promodescription = ''; 
		
		$(document).ready(function(){ 
		//function docReady() {
				
				$().checkbox({checked: "images/checked.gif", unchecked: "images/unchecked.gif"});
				
				$('form').submit(function() {
					if ($('input[@name=promo_code]').attr('value') != null && $('input[@name=promo_code]').attr('value').length > 0)
						 {	
							if (promocode == $('input[@name=promo_code]').attr('value'))
							{
								return checkComplete();
							}
							else
							{
								$('#btnPromo').click();
								return false;
							}
						  }
						  else
						  {				
							return	checkComplete();
						  }
				});
				
			
				$("input[@name=chkSeal]").prev().one("click", function() {
					//$('#trKit').css({background});
					$('#sealDeal').fadeIn('fast', function() {
							$('#sealDeal').pause(2000).fadeOut('slow')
						});
				})
				
				$('.state').html($('#selectState').attr("value"));
				//$('#txtState')[0].options[0].selected = true;
				$('#txtState').change( function() { 
				    changeState( this.value ); 				    
			        $("#fillingFeeStd input[@checked]").prev().click();
			        $(".fillingFeeExp input[@checked]").prev().click();
			        $(".fillingFee24hr input[@checked]").prev().click();    
				    });
				    
				$('#btnPromo').click(function() { $.getScript("promocode.asp?code="+ $("input[@name=promo_code]").attr('value')); return false;   } );
				
				$("#notice").hide();
				$("#NHnotice").hide();
				
				$("input[@name=packageType]").click(function() {
					SelectCol(this);
				}); 			
				
				
				//$(".chkAgent]").change(function() { alert("regagent"); gotStateInfo(); })
				
				$("#entityType")
					.change(function() { 
					    typeChange(this); 
					    $("#fillingFeeStd input[@checked]").prev().click();
			            $(".fillingFeeExp input[@checked]").prev().click();
			            $(".fillingFee24hr input[@checked]").prev().click();
					});
					//.each(function() {if (this.value == "scorp" || this.value == null) {$("#trSCorp td").show();} else {$("#trSCorp td").hide();} });
				
				  
				$('#completebtn').click(function() {
					//alert("wtf");
					return checkComplete();
					 //false; 
				});
				
				$("#fillingFeeStd").hide();
				$(".fillingFeeExp").hide();
				$(".fillingFee24hr").hide();
				
				//$("#np501c3").hide();

				
				//$("#quotetable, #FilingFee").show()
				$(".astate").text(" A ");
		//}
		});
		
		
		
function formatAsMoney(mnt) {
    mnt -= 0;
    mnt = (Math.round(mnt*100))/100;
    return (mnt == Math.floor(mnt)) ? mnt + '.00' 
              : ( (mnt*10 == Math.floor(mnt*10)) ? 
                       mnt + '0' : mnt);
}
		