/**
 * @author Hardy
 */
var body_height;
var Client;

	//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();

	$(".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;

	});

	//populate aid_link after page has drawn
	$("a[rel=aid_link]").each(function() {

		var hr=$(this).attr("href");

		if(hr.indexOf("?")>0) {

			$(this).attr({"href":hr+"&aid="+_aid});

		} else {

			$(this).attr({"href":hr+"?aid="+_aid});

		}



	});



});

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=400,height=350,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);



}