function viewportHeight() {
	var viewportheight;
	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	if (typeof window.innerHeight != 'undefined'){ viewportheight = window.innerHeight; }
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientHeight != 'undefined' && document.documentElement.clientHeight != 0)
	{ viewportheight = document.documentElement.clientHeight; }
	// older versions of IE
	else {	viewportheight = document.getElementsByTagName('body')[0].clientHeight;	 }
	return viewportheight;
}
function viewportWidth() {
	var viewportwidth;
	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	if (typeof window.innerWidth != 'undefined'){ viewportwidth = window.innerWidth; }
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0)
	{ viewportwidth = document.documentElement.clientWidth; }
	 // older versions of IE
	 else { viewportwidth = document.getElementsByTagName('body')[0].clientWidth; }
	 return viewportwidth;	
}

/* 
 	Messaging popups 
*/
function messageService(msgTitle,msgTxt,msgLen)
{
	// create msg containers
	var curDate = new Date();
	var msgID = "msg-"+curDate.getTime();		
	
	$("body").append("<div id=\""+msgID+"\" class=\"message-service\" style=\"display: none;\"></div>");
	$("#"+msgID).append("<div class=\"message-content\"><a href=\"#\" class=\"close\">close</a><div class=\"inner-msg clearfix\"></div></div>");
	
	// assign close button action
	$("#"+msgID+" .message-content a.close").click(function() {
		$("#"+msgID).remove();
		return false;
	});
	
	// write msg
	$("#"+msgID+" .message-content .inner-msg").html("<h3>"+msgTitle+"</h3><p>"+msgTxt+"</p>");
	
	// center the message box
	
	// animate
	$("#"+msgID).fadeTo("fast", 0, function() { $("#"+msgID).css("display","block"); });
	$("#"+msgID).fadeTo("slow", 1);
	//$("#"+msgID+" .message-content .inner-msg").animate({opacity: 1});
	
	// remove item
}


$(document).ready(function(){
	$(".add-to-cart-button").click(function(){
		try {
			var pageTracker = _gat._getTracker("UA-19219063-1");
			pageTracker._setDomainName("freshfinds.com");
			pageTracker._initData();
			pageTracker._trackPageview('/AddToCart');
			} catch(err) {}
	});
	$(".quickorder-button").click(function(){
		try {
			var pageTracker = _gat._getTracker("UA-19219063-1");
			pageTracker._setDomainName("freshfinds.com");
			pageTracker._initData();
			pageTracker._trackPageview('/QuickOrderAdd');
			} catch(err) {}
	});
	
	$('p.paypalMessageLink a').click(function(e){
		e.preventDefault();
		$('div.paypal-message').show();
	});
	$('div.paypal-message p.close-paypalMessage a').click(function(e){
		e.preventDefault();
		$('div.paypal-message').hide();
	});
	
	$('p.aboutpaypal a').click(function(e){
		window.open('https://www.paypal.com/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside','olcwhatispaypal','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=400, height=350, left='+(200+document.getElementById('logo-container').offsetLeft));
	});
	
	$('#body-container div.paypal-message p.paypal-link a').click(function(e){
		e.preventDefault();
		window.open('https://www.paypal.com/us/cgi-bin/webscr?cmd=_home-general&nav=0','whatispaypal','width=672, height=672, scrollbars=yes, left='+(200+document.getElementById('logo-container').offsetLeft));
	});
});

