$(document).ready(function() {   
$('#dd1 ul, #dd2 ul, #dd3 ul, #dd4 ul').css('display', "none"); // so that FF and Safari load the dd state

$("#dd1").hoverIntent({
				sensitivity: 3, 
				interval: 50, 
				over: show_dd1, 
				timeout: 700, 
				out: hide_dd1
			});

$("#dd2").hoverIntent({
				sensitivity: 3, 
				interval: 50, 
				over: show_dd2, 
				timeout: 700, 
				out: hide_dd2
			});
$("#dd3").hoverIntent({
				sensitivity: 3, 
				interval: 50, 
				over: show_dd3, 
				timeout: 700, 
				out: hide_dd3
			});

$("#dd4").hoverIntent({
				sensitivity: 3, 
				interval: 50, 
				over: show_dd4, 
				timeout: 700, 
				out: hide_dd4
			});

function show_dd1(){ $("#dd1 ul").slideDown("fast"); $(this).addClass('menuhover'); }
function hide_dd1(){$("#dd1 ul").slideUp("fast"); $(this).removeClass('menuhover');}

function show_dd2(){  $("#dd2 ul").slideDown("fast"); $(this).addClass('menuhover'); }
function hide_dd2(){$("#dd2 ul").slideUp("fast"); $(this).removeClass('menuhover');}

function show_dd3(){  $("#dd3 ul").slideDown("fast"); $(this).addClass('menuhover'); }
function hide_dd3(){$("#dd3 ul").slideUp("fast"); $(this).removeClass('menuhover');}

function show_dd4(){  $("#dd4 ul").slideDown("fast");  $(this).addClass('menuhover');}
function hide_dd4(){$("#dd4 ul").slideUp("fast"); $(this).removeClass('menuhover');}

//$("#dd2").hover( 												
////				function() {  $("#dd2 ul").slideDown("fast"); $(this).addClass('menuhover');	 },     
// 				function() {  $("#dd2 ul").slideUp("fast"); $(this).removeClass('menuhover'); 		}
// 				);

//$("#dd3").hover(  												
//			    function() {  $("#dd3 ul").slideDown("fast"); $(this).addClass('menuhover');	 },     
// 				function() {  $("#dd3 ul").slideUp("fast"); $(this).removeClass('menuhover'); 		}
// 				);
//$("#dd4").hover(  												
//				function() {  $("#dd4 ul").slideDown("fast"); $(this).addClass('menuhover');	 },     
// 				function() {  $("#dd4 ul").slideUp("fast"); $(this).removeClass('menuhover'); 		}
//				);





$("a.closepopup").click(  
					   function() {
				  $("#popupbox").hide(); 
				  return false;
					   }
				);

$("a.popup").click(  
					   function() {
				  $("#popupbox").show(); 				 
				  var title = $(this).attr("title");
				  var id = $(this).attr("id");
				  $("div#popuphead").html(title);
				  
				  if (id=="formation_certificate") {
					  $("div#popupcontent").html("<p>At Start an American Company Ltd we will assist you in establishing your company in any American State. We combine cost effectiveness, rapid service and our wide range of experience to help you begin your new venture.</p>");
					  }
				  if (id=="apostille") {
					  $("div#popupcontent").html("<p>'Authenticating' a document may also be called 'flagging', 'verifying', 'certifying', or 'attaching a certificate of magistracy'. It means that an official certificate confirming the existence of a particular notary public or public officer, who has signed the document, must be attached to the document. An authentication certificate may be required when a document is sent to another state or to a foreign country. Business transactions, foreign adoptions, and high school and university transcripts are examples of documents that frequently require authentication.</p><p>An 'apostille' is a specific format of an authentication certificate that is required by certain countries. When requesting authentication certificates from the Secretary of State’s office, it is important to specify which foreign country is involved, so this Office can determine if an apostille or 'regular' authentication is necessary. Use of the wrong certificate can cause a document to be rejected by the foreign country</p>");
					  }
				if (id=="goodstanding") {
					  $("div#popupcontent").html("<p>A certificate issued by a state official as conclusive evidence that a corporation is in existence or authorized to transact business in the state.</p><p>The certificate generally sets forth the corporation's name; that it is duly incorporated or authorized to transact business; that all fees, taxes and penalties owed the state have been paid; that its most recent annual report has been filed; and, that articles of dissolution have not been filed. Also known as a certificate of existence or certificate of authorization.</p>");
					  }
				if (id=="boundcorporatekit") {
					  $("div#popupcontent").html("<p>A binder usually containing essential items for the routine maintenance and administration of a corporation or limited liability company. Corporate kits provided by The Company Corporation, Inc. include sample minutes and bylaws, stock certificates, a corporate seal and stock ledger.</p>");
					  }
				if (id=="virtualoffice") {
					  $("div#popupcontent").html("<p>You can run your US company from a virtual office using internet-based communication links and audio or video conferencing. A virtual office will enable you to be working in your office in your country of residence and answer your telephone or receive faxes as if you were in a US office yourself.</p><p>Alternatively, your &quot;reception&quot; can take messages on your behalf and forward them to you at your convenience. Post can also be received in this way. You will have your own US telephone and fax number which can be overlaid onto your existing telephone number which gives the impression of having a fully serviced office. </p><p>Our package price includes 12 months use of your virtual office plus 2 months deposit (refundable within 30 days of written termination of contract).</p>");
					  }
				
				
				  
				  
				  return false;
				  
				  //alert("popup:"+title);
					   }
					   
				);


	 
}); 


function theRotator() {
	//Set the opacity of all images to 0
	$('div#rotator ul li').css({opacity: 0.0});
	
	//Get the first image and display it (gets set to full opacity)
	$('div#rotator ul li:first').css({opacity: 1.0});
	
		
	//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('rotate()',8000);
	
}

function rotate() {	
	//Get the first image
	var current = ($('div#rotator ul li.show')?  $('div#rotator ul li.show') : $('div#rotator ul li:first'));

	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div#rotator ul li:first') :current.next()) : $('div#rotator ul li:first'));	
	
	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
};

function pricelist_total(){
	i=0;poa_warning=0; total=0;
	var price1 = $("#txtPrice_nominee_director").attr('value') * parseFloat($("#txtPrice_nominee_director").attr('price'));
	var price2 = $("#txtPrice_costperdocsig").attr('value') * parseFloat($("#txtPrice_costperdocsig").attr('price'));
	var price3 = $("#txtPrice_nominee_notarisation").attr('value') * parseFloat($("#txtPrice_nominee_notarisation").attr('price'));
	var price4 = $("#txtPrice_nominee_sig").attr('value') * parseFloat($("#txtPrice_nominee_sig").attr('price'));
var textboxes = price1+price2+price3+price4;
$("input[type=checkbox]:checked").each(
					function() {   i++;
														 
								var id = $(this).attr('id');
								var price = $(this).attr('price');
								if (price=="POA"){ poa_warning++; } 
								else {price = parseFloat(price); total=total + price;}
								  } );



grand_total = textboxes + total;
//alert("Total: "+grand_total);
if (poa_warning >0){$("#POA").show();} else {$("#POA").hide();}
$("div#pkg_total").html("&pound"+grand_total);
$("#form_total").val(grand_total);
		
		}

$(document).ready(function() {		
	//Load the slideshow
	theRotator();
	
	$("input[type=checkbox]").click(     
						function() {   
									var id = $(this).attr('id');
									var price = $(this).attr('price');
									//if ( $(this).attr('checked')) {alert("checked - price:"+price); } 														 									if (price=="POA"){ $("#POA").show(); } 
									//alert("ok: "+id);     
									pricelist_total();
									//chk_boxes(id);
									return true;
									 } );
// Check the text boxes and check if there are numerics, if not then display alert box and do not allow entry 
$("#txtPrice_nominee_director, #txtPrice_costperdocsig, #txtPrice_nominee_notarisation, #txtPrice_nominee_sig").keypress(function (e)
{
	if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
  { var value = $(this).val(); alert("ERROR! Please only enter numeric values ");   
  return false;  	
  }
   
});


$(":input").change(function() {	pricelist_total();  });

	
	function chk_boxes(id){
		//alert("function worked: "+id);
		i=0;poa_warning=0; total=0;
		$("input[type=checkbox]:checked").each(
							function() {   i++;
														 
										var id = $(this).attr('id');
										var price = $(this).attr('price');
										if (price=="POA"){ poa_warning++; } 
										else {price = parseFloat(price); total=total + price;}
														 
														
														  } );
	alert("there were"+i+" checkboxes checked and POA="+poa_warning+" the total was="+total);
	if (poa_warning >0){$("#POA").show();} else {$("#POA").hide();}
	
	$("div#pkg_total").html(total);
	$("#form_total").val(total);
		
		};


	
	
	
});