/*
Name:	common.js
Date:	2011.03.03
Update:	2011.04.22
*/


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

	$("#pageTop a").bind("click", pageUp);
	$('a[href$=".pdf"]').bind("click", pdfOpen);
	$("#products #itemArea div:nth-child(2n)").css("margin-right", "0");
	$("#recruit .tableType01 td p:nth-child(1)").css("margin-top", "0");
	
	$(".popup").bind("click", popUp);
	$(".popup2").bind("click", popUp2);
	
	$(".english").css("display","none");
	$(".btn_english").bind("click", engOpen);

	$(".parentlink").bind("click", parentLink);
});


/* pageUp
----------------------------------------------- */
function pageUp() {
	var targetOffset = $("#container").offset().top;
	$("html,body").animate({scrollTop: targetOffset}, 1000);
	return false;
}

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

/* popUp
----------------------------------------------- */
function popUp() {
	window.open(this.href, "WindowName","width=600,height=750,resizable=no,scrollbars=yes");
	return false;
}

/* popUp2
----------------------------------------------- */
function popUp2() {
	window.open(this.href, "WindowName","width=600,height=450,resizable=no,scrollbars=yes");
	return false;
}

/* engOpen
----------------------------------------------- */
function engOpen() {
	$(".english").each(function(){
		$(this).css("height",$(this).height()+"px");
	});
	
	var toggleElm = $(this).next(".english");
	if (toggleElm.css('display') == 'none') {
		toggleElm.animate({height: 'show', opacity: 'show'}, 500, 'linear');
	} else {
		toggleElm.animate({height: 'hide', opacity: 'hide'}, 500, 'swing');
	}
	return false;
}

/* parentLink
----------------------------------------------- */
function parentLink() {
	var url = $(this).attr("href");
	window.opener.location.href = url;
	window.close();
	return false;
}
