/* var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-17203036-10']);
  _gaq.push(['_setDomainName', 'none']);
  _gaq.push(['_setAllowLinker', true]);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();*/
var delay = 700;
$(function(){


$("#navcontainer").delay(delay).fadeIn(500); 
$("#navcontainerTop").delay(delay).fadeIn(500);
$("#navcontainerTopRight").delay(delay).fadeIn(500); 
$("#navcontainerSide").delay(delay).fadeIn(500); 
$("#cmsimage").one("load",function(){
			$(this).delay(0).fadeIn(2000); 
			
//do something
})
.each(function(){
	if(this.complete || (jQuery.browser.msie && parseInt(jQuery.browser.version) == 6))
		$(this).trigger("load");
	}); 

	//use nice select boxes
	$("select").selectbox();
	//when shipping changes	
	if ($('#default-usage-select').length > 0 ){
	$("#default-usage-select").selectbox().bind('change', function(){
				GetStuff();
			});
	}		
	//when quantity change		
	$("#JqPostForm").change(function(){
	//$("input").blur(function(){
				GetStuff();
	
        return false;
    });
	
function GetStuff(){
if (URL != ""){
		//alert($("#postCodeData").val());
		//$('#postCodeData').val(data);
$.post(URL, $("#JqPostForm").serialize(),
	
        function(data){
				//alert(data.pkey+" "+data.price);
				if(data.pkey != 0 && data.price != 0 ){
					$("#price_post_"+data.pkey).html(data.price);
				}
				$("#subtotal_post").html(data.subtotal);
				//alert(":"+data.delivery+":");
				//($1.00)
				//alert("jsstuff: "+data.delivery);
				if(data.delivery == "($1.00)") {
					$("#delivery_post").html("TBA");
				} else {
					$("#delivery_post").html(data.delivery);
				}
				$("#gst_post").html(data.gst);
				$("#total_post").html("<b>"+data.total+"</b>");
				$("#TopCartTotal").html(data.size);
        },"json");
	}
	}
});
$(document).ready(function() {

			/*
			*   Show - image
			*/
			
			$("a.productIframe1").fancybox({
					'width'				: 650,
					'height'			: 550,
			        'autoScale'     	: true,
					'overlayShow'		: false,
					'type'				: 'iframe',
					'margin' : 30,
					'titleShow'		: false
				});
		
		$("a.productIframe2").fancybox({
					'width'				: 650,
					'height'			: 680,
			        'autoScale'     	: true,
					'overlayShow'		: false,
					'type'				: 'iframe',
					'margin' : 30,
					'titleShow'		: false
				});
		$("a.productIframe3").fancybox({
					'width'				: 650,
					'height'			: 730,
			        'autoScale'     	: true,
					'overlayShow'		: false,
					'type'				: 'iframe',
					'margin' : 30,
					'titleShow'		: false
				});
		
			$("#postcodewarning").fancybox({
				'titleShow'		: false,
				'overlayShow'		: false,
				
							'margin' : 30
				});
			
			$("#referralcode").fancybox({
				'titleShow'		: false,
				'overlayShow'		: false,
				
							'margin' : 30
				});
			
			$("a.example1").fancybox({
				'titleShow'		: false,
				'overlayShow'		: false,
				'margin' : 1,
				'padding' : 1
			});
			$("#various1").fancybox({
				'titleShow'		: false,
				'overlayShow'		: false
				
			});
			
			$("a.faq").fancybox({
				'width'				: 650,
				'height'			: 800,
			    'autoScale'     	: true,
				'titleShow'		: false,
				'overlayShow'		: false,
				'type'				: 'iframe',
				'margin' : 1,
				'padding' : 1
			});
			
			$("#contactus").fancybox({
				'titleShow'		: false,
				'overlayShow'		: false
				
			});
			
			$("#video").fancybox({
				'type'				: 'iframe',
				'padding'			: 10,
				'width'				: 330,
				'height'			: 290,
				'autoScale'			: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none'
			});
			
			
			$("#various2").fancybox({
				'titleShow'		: false,
				'overlayShow'		: false,
				'onClosed'		: function() {
				$('#result').html('Send Enquiry');
				
	    		$("input[name='cname']").val("");
				$("input[name='cemail']").val("");
				$("input[name='cph']").val("");
				$("input[name='ccomment']").val("");
					} 
				
			});
			
			$("#checkouttermsIframe").fancybox({
					'width'				: '70%',
					'height'			: '100%',
			        'autoScale'     	: true,
					'overlayShow'		: false,
					'type'				: 'iframe',
					'margin' : 30,
					'titleShow'		: false
				});
			$("#termsIframe").fancybox({
					'width'				: '70%',
					'height'			: '100%',
			        'autoScale'     	: true,
					'overlayShow'		: false,
					'type'				: 'iframe',
					'margin' : 30,
					'titleShow'		: false
				});
				
				$("#ptermsIframe").fancybox({
					'width'				: '70%',
					'height'			: '70%',
			        'autoScale'     	: true,
					'overlayShow'		: false,
					'type'				: 'iframe',
					'margin' : 30,
					'titleShow'		: false
				});
				$("#disclaimerIframe").fancybox({
					'width'				: '70%',
					'height'			: '70%',
			        'autoScale'     	: true,
					'overlayShow'		: false,
					'type'				: 'iframe',
					'margin' : 30,
					'titleShow'		: false
				});
				
			$("#various3").fancybox({
				'titleShow'		: false,
				'overlayShow'		: false,
				'onClosed'		: function() {
				$('#result').html('Send Request');
				/*
	    		$("input[name='cname']").val("");
				$("input[name='cemail']").val("");
				$("input[name='cph']").val("");
				$("input[name='ccomment']").val("");
				*/
					} 
				
			});
			
			 $("#requestForm").validate({
			
			 submitHandler: function(){ 
			 
				$.post('/cf/AjaxSendEmail.cfm',$("#requestForm").serialize(), function(data) {
				//  alert($('#result').html());
				  $('#resultRequest').html(data);
				});

				return false;
					
        		}		
			 });
			
			
			 $("#commentForm").validate({
			
			 submitHandler: function(){ 
			 
				$.post('/cf/AjaxSendEmail.cfm',$("#commentForm").serialize(), function(data) {
				//  alert($('#result').html());
				  $('#result').html(data);
				});

				return false;
					
        		}		
			 });
		});  
//});
