jQuery.noConflict();

jQuery(document).ready(function($){
	//kill default blog feed:
	if ( $('body .blog-container link').length ) {
		$("body .blog-container link").remove();
	}
	//kill repeated blog post:
	$(".trim-blog li:first").remove();
	$("#newest-blog-post").show();
	$(function(){ $(".infield label").inFieldLabels(); });
	jQuery('#nav_533510').superfish();
	
	$("a.newsletterpop").fancybox({
				'padding'		: 20,
				'autoScale'		: false,
				'transitionIn'	: 'none',
				'transitionOut'	: 'none',
				'titleShow'		: false,
				'width'			: 320,
				'height'		: 160,
				'type'			: 'iframe'
			});

	//track affiliate clicks.
	$('.country a').click(function() {
	  _gaq.push(['_trackEvent', 'Link', 'Affiliate Click - ' + $(this).html(), 'Amazon']); 
	});
	
});

function jqsub() {
	//ajax nesletter sign up form
	var $form = jQuery('#newsletter-form'); // set your form ID
	var $messagebox = jQuery('#newsletter-message'); // set your message box ID
	var $successmessage = "<h2>You on the list!</h2>"; // replace with your own success message in HTML format
	var $errormessage = "<h2>Error - Please Try Again</h2>"; // replace with your own error message in HTML format
	
	jQuery.ajax({
		type: 'POST',
		url: $form.attr('action'),
		data: $form.serialize(), 
		cache: false,
		success: function (msg) { 
						 
						$messagebox.append($successmessage) 
						jQuery("#newsletter-form").hide();
						$messagebox.fadeIn();
						
						//log to google analytics:
						_gaq.push(['_trackEvent', 'Form', 'Sign up', 'Newsletter']); 
					    _gaq.push(['_trackPageview', '/CampaignProcess.aspx?ListID=22049']); 
				},
		error: function (msg) {
						$messagebox.append(msg) 
						$messagebox.fadeIn();
				}
		 });
}

function checkWholeForm47075(theForm){
	//newsletter validation script
	var why = "";
	if (theForm.EmailAddress) why += checkEmail(theForm.EmailAddress.value);
	if (theForm.CaptchaV2) why += isEmpty(theForm.CaptchaV2.value, "Enter Word Verification in box below"); 
	if (why != ""){alert(why);return false;};
	jqsub();
	return false;
}

//contact form validation:
var submitcount2811 = 0;
function checkWholeForm2811(theForm){
	var why = "";
	if (theForm.FirstName) why += isEmpty(theForm.FirstName.value, "First Name");
	if (theForm.LastName) why += isEmpty(theForm.LastName.value, "Last Name"); 
	if (theForm.EmailAddress) why += checkEmail(theForm.EmailAddress.value); 
	if(why != ""){
		alert(why);
		return false;
	};
	if(submitcount2811 == 0){
		submitcount2811++;theForm.submit();
		return false;
	}else{
		alert("Form submission is in progress.");
		return false;}
	}
