$(document).ready(function(){
	
	$("#quickLinksDMSBT a").each(function(){
		
		$(this).hover(function(){
			oldImage = $(this).children("img").attr("src");
			$(this).children("img").attr("src", $(this).children("img").attr("class"));
		},function(){
			$(this).children("img").attr("src", oldImage);
		});

		//alert($(this).children("img").attr("class"));
	});

	
	
		$(".linkIcon").hover(function(){
			//alert($(this).children("div").html());
				
				$(this).children("div").children("div").fadeIn();
			}, function(){
				$(this).children("div").children("div").fadeOut();
			}
		);
		$(".linkIcon").eq(0).css("margin-left", "0px");
	
	
	$("#edit-submit").click(function(){
		$("#edit-submitted-message").val("account");
		$("#webform-client-form-320").attr("action", "/google-earth-pro-buy");
		$("#webform-client-form-320").submit();
	});
	
	
	$("#paypalButton").click(function(){
		if($("#edit-submitted-name").val() == "" ) {
			$("#webform-client-form-320").attr("action", "/google-earth-pro-buy");
			$("#webform-client-form-320").submit();
		}
		else if($("#edit-submitted-phone").val() == "" ) {
			$("#webform-client-form-320").attr("action", "/google-earth-pro-buy");
			$("#webform-client-form-320").submit();
		}
		else if($("#edit-submitted-email").val() == "" ) {
			$("#webform-client-form-320").attr("action", "/google-earth-pro-buy");
			$("#webform-client-form-320").submit();
		}
		else if($("#edit-submitted-terms-and-conditions-1").attr("checked")== false) {
			$("#webform-client-form-320").attr("action", "/google-earth-pro-buy");
			$("#webform-client-form-320").submit();
		}
		else {
			
			   if ($("#numlicen").length == 0) 
			      {
			      alert("Please enter a value.");
			      return false;
			      } 
			   else if (IsNumeric($("#numlicen").val()) == false) 
			      {
			      alert("Please check - non numeric value!");
			      return false;
			      }
			
			$("#webform-client-form-320").attr("action", "/checkout/ReviewOrder.php");
			$("#webform-client-form-320").submit();
			
		}
	
	});
	
	
	$("#numlicen").keyup(function(){
		//alert(parseInt($(this).val()));
		if(parseInt($(this).val()) < 11 ) {
			$("#mapAmount").val("399.00");
			$("#mapAmountDisplay").text("399.00");
			totalAmoutWithoutGST = (399 * parseInt($(this).val()));
			totalAmoutWithoutGSTComma = addCommas(roundNumber(totalAmoutWithoutGST, 2));
			$("#totalAmount").text(totalAmoutWithoutGSTComma);
			GST = totalAmoutWithoutGST/10;
			$("#gstAmount").text(GST);
			totalWithGST = totalAmoutWithoutGST + GST;
			totalGSTcommaRound = addCommas(roundNumber(totalWithGST, 2));
			$("#totalGST").text(totalGSTcommaRound);				

			
		}
		if((parseInt($(this).val()) < 26 ) & (parseInt($(this).val()) > 10 ))  {
			$("#mapAmount").val("350.00");
			$("#mapAmountDisplay").text("350.00");
			totalAmoutWithoutGST = (350 * parseInt($(this).val()));
			totalAmoutWithoutGSTComma = addCommas(roundNumber(totalAmoutWithoutGST, 2));
			$("#totalAmount").text(totalAmoutWithoutGSTComma);
			GST = totalAmoutWithoutGST/10;
			$("#gstAmount").text(GST);
			totalWithGST = totalAmoutWithoutGST + GST;
			totalGSTcommaRound = addCommas(roundNumber(totalWithGST, 2));
			$("#totalGST").text(totalGSTcommaRound);				
		}
		if(parseInt($(this).val()) > 25 ) {
			$("#mapAmount").val("300.00");
			$("#mapAmountDisplay").text("300.00");
			totalAmoutWithoutGST = (300 * parseInt($(this).val()));
			totalAmoutWithoutGSTComma = addCommas(roundNumber(totalAmoutWithoutGST, 2));
			$("#totalAmount").text(totalAmoutWithoutGSTComma);
			GST = totalAmoutWithoutGST/10;
			$("#gstAmount").text(GST);
			totalWithGST = totalAmoutWithoutGST + GST;
			totalGSTcommaRound = addCommas(roundNumber(totalWithGST, 2));
			$("#totalGST").text(totalGSTcommaRound);
			
		}
	});
	
       
$('#simpleSlideshow img').show();
 $('#simpleSlideshow').cycle({
        fx:     'fade',
        timeout: 6000,
        random: 1
    });
 
 $("#homeFeatureMarket div:first-child").css("margin-left", "0px");
 
 //alert($(document).height());
 
 //alert($(document).height() - 200);
 $(".inner").eq(1).height($(document).height() - 90);
 
$("#gmap-blocks-1").height($(document).height() - 75);
 //$("#gmap-blocks-1").corner("15px");

$(".bottomLeft").css("top", $(document).height() - 95);
$(".bottomRight").css("top", $(document).height() - 95);

});


$(".quote").show();

 $('#quoteContainer').cycle({
        fx:     'fade',
        timeout: 5000,
        random: 1
    });


	function addCommas(nStr)
	{
		nStr += '';
		x = nStr.split('.');
		x1 = x[0];
		x2 = x.length > 1 ? '.' + x[1] : '';
		var rgx = /(\d+)(\d{3})/;
		while (rgx.test(x1)) {
			x1 = x1.replace(rgx, '$1' + ',' + '$2');
		}
		return x1 + x2;
	}
	function roundNumber(num, dec) {
		var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
		return result;
	}

	function IsNumeric(strString)
	   //  check for valid numeric strings	
	   {
	   var strValidChars = "1234567890";
	   var strChar;
	   var blnResult = true;

	   if (strString.length == 0) return false;

	   //  test strString consists of valid characters listed above
	   for (i = 0; i < strString.length && blnResult == true; i++)
	      {
	      strChar = strString.charAt(i);
	      if (strValidChars.indexOf(strChar) == -1)
	         {
	         blnResult = false;
	         }
	      }
	   return blnResult;
	   }

