/*
Name  : common.js
Date  : 2010.11.29
Update: 2010.12.21
*/


/* google
----------------------------------------------- */
var _gaq = _gaq || [];
 _gaq.push(['_setAccount', 'UA-20357262-1']);
 _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);
 })();
 

/* jquery
----------------------------------------------- */

$(function() {
	$(window).bind("load", loadComplete);
	
	$("#pageTop a").bind("click", pageTop);
	
	$('a[href$=".pdf"]').bind("click", pdfOpen);
	
	$(".popup").bind("click", popUp);
	
	$("#products #listArea div:nth-child(5n)").css("padding-right", "0");
	$("#products #recipeArea div:nth-child(5n)").css("padding-right", "0");
	$("#recipe #newrecipeArea div:nth-child(2n)").css("padding-right", "0");
	$("#recipe #itemArea div:nth-child(5n)").css("padding-right", "0");
	$("#howto #listArea div:nth-child(2n)").css("margin-right", "0");
	$("#lesson #listArea div:nth-child(4n)").css("margin-right", "0");
	
});

function loadComplete() {
	$("#home #header").css({ opacity: 0 });
	$("#home #header").delay(50).animate({ opacity: 1.0 }, 500);
	return false;
}

function pageTop() {
	var targetOffset = $("#container").offset().top;
	$("html,body").animate({scrollTop: targetOffset}, 500);
	return false;
}

function pdfOpen() {
	window.open(this.href, '');
	return false;
}

function popUp() {
	window.open(this.href, "WindowName","width=520,height=500,resizable=no,scrollbars=no");
	return false;
}
