/**
 * @author Hardy
 */
var body_height;
var Client;
var img_error=Array();
var img_error_page='';
var img_error_count=1;
var show_backout=true;

	//get the window dimensions
	Client = {
	  viewportWidth: function() {
	    return self.innerWidth || (document.documentElement.clientWidth || document.body.clientWidth);
	  },

	  viewportHeight: function() {
	    return self.innerHeight || (document.documentElement.clientHeight || document.body.clientHeight);
	  },

	  viewportSize: function() {
	    return { width: this.viewportWidth(), height: this.viewportHeight() };
	  }
	};

	//MAIN PRELOADING METHOD
$(document).ready(function() {

	body_height=$("#body_container").height();
	
	$("a[rel=aid_link]").each(function() {
		
		//alert("here i am");
		var href=$(this).attr("href");
		
		$(this).attr({"href":href+"?aid="+_aid+"&api_opt1="+_api_opt1+"&api_opt2="+_api_opt2+"&api_opt3="+_api_opt3});
		
	});

	$(".main_nav_list li").hover(
		function() {
			$(this).addClass("main_nav_list_over");
		},
		function() {
			$(this).removeClass("main_nav_list_over");
		}
	).click(function() {
		var ref=$(this).find("a").attr("href");
		document.location.href=ref;
	});

	//sub navigation rollovers

	$(".sub_nav_list li").hover(
		function() {
			$(this).addClass("sub_nav_list_over");
		},
		function() {
			$(this).removeClass("sub_nav_list_over");
		}
	).click(function() {
		var ref=$(this).find("a").attr("href");
		document.location.href=ref;
	});



	//super nav rollovers

	$(".left_col_supernav").hover(
		function() {
			$(this).addClass("left_col_supernav_over");
		},
		function() {
			$(this).removeClass("left_col_supernav_over");
		}
	).click(function() {
		var ref=$(this).find("a").attr("href");
		document.location.href=ref;

	});




	// Top nav hovers
	$(".top_nav_list li").hover(
		function() {
			$(this).addClass("top_nav_list_over");
		},
		function() {
			$(this).removeClass("top_nav_list_over");
		}
	).click(function() {

		var ref=$(this).find("a").attr("href");
		document.location.href=ref;
	});


	$("#testimonial_comment_form").submit(function() {  
	
	var name=$("#testimonial_comment_form input[name=name]").val();
	var comment=$("#testimonial_comment_form textarea").val();
	
			if(name.length<3 || comment<10) {
				
				alert("Please make sure you enter a title, your name and that your comment is over 10 characters");
				return false;
				
			} else {
			
				return true;
				
			}
			
	
	});
	
	//CHECK FOR THE FRONT_FORM HASH AND SHOW THE BUBBLE
	if(document.location.hash=='#front_form') {
		
		//append the bubble to the front page
		$("#frontpage_form_name_label").append("<div id='frontpage_form_bubble'></div>");
		$("#frontpage_form_bubble,#mailofferform").click(function() {    
			
			$("#frontpage_form_bubble").remove();
			
			
		});
	}

});

function sendFreeNewsletter() {

	var fn=$("input[name=fn]").val();
	var em=$("input[name=em]").val();
	var msg='';
	if(fn=='' || fn=='Name') {

		msg+="You must enter your first name \n";

	}
	if(!isValidEmail(em) || em=='Email') {

		msg+="You must enter a valid email address";

	}
	if(msg.length<1) {

		window.open("/newsletter.php?aid="+_aid+"&fn="+fn+"&em="+em,"","width=450,height=350,toolbars=no");

	} else {

		alert(msg);

	}



}

function newsletterFocus(e,m) {

	var val=$(e).val();

	if(val==m) {

		$(e).val('');

	}

}
function newsletterBlur(e,m) {

	var val=$(e).val();
	if(val=='') {

		$(e).val(m);

	}


}

function tosPopUp() {

	window.open("tos.php","","width=600,height=400,scrollbars=yes,resizable=yes");

}

function privacyPolicy() {

	window.open("tos.php#pp","","width=600,height=400,scrollbars=yes,resizable=yes");

}

function intPhoneNumbers() {

	window.open("http://www.securebiller.com/phone/index.php?aid="+_aid,"","width=400,height=350,scrollbars=yes,resizable=yes");

}

function isValidEmail(str) {

   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);



}

function lifeTimePopup(pid) {

	window.open("?p=lifetime_terms&product_id="+pid,"","height=200,width=650,toolbars=no,resizable=yes,scrollbars=yes");

}


function splashPop(page) {


	window.open(page,'','width=900,height=450,resizable=yes,toolbars=no,scrollbars=yes');



}
function stopBackout() {

	show_backout=false;

}

function fudgeDate(add) {
	
	var d = new Date();
	
	d.setDate(d.getDate()-add);
	
	document.write(d.toLocaleDateString());
	
}

