/*
Name	:common.js
Date	:2011.08.04
Update	:2012.01.26
*/


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

$(function(){
	$("#pageTop a").bind("click", pageUp);
	$(".rollover a img").opOver(1.0,0.6);
	$("#coordinate #photoList li:nth-child(4n)").css("margin-right", "0");
	$("#newitem #photoList li:nth-child(4n)").css("margin-right", "0");
	
	// fadeIn
	$("#newsArea,#photoList,#detailArea,#catalogArea,#shoplistArea").fadeIn(200);
	
	// target _blank
	$('a[href^="http"]').not('[href*="www.miel-c.com"]').click(function() {
		window.open(this.href, '');
		return false;
	});
	$('a[href$=".pdf"]').click(function() {
		window.open(this.href, '');
		return false;
	});

	// slides
	$("#slides").slides({
		effect: "slide",
		generateNextPrev: false,
		generatePagination: false,
		slideSpeed: 600,
		play: 6000
	});

	// innerfade
	$("#image ul").innerfade({
		speed: 2000,
		timeout: 6000,
		type: "sequence",
		containerheight: "420px"
	});
	$(".newitemBox01").innerfade({
		speed: 1000,
		timeout: 5000,
		type: "random_start",
		containerheight: '124px'
	});
	$(".newitemBox02").innerfade({
		speed: 1100,
		timeout: 5000,
		type: "random_start",
		containerheight: "124px"
	});
	$(".newitemBox03").innerfade({
		speed: 1200,
		timeout: 5000,
		type: "random_start",
		containerheight: "124px"
	});
	
	$("html").css("background", "#fff url(/common/bg_footer.png) repeat 0 0");
});

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


/* smartphone
----------------------------------------------- */
function smtPhone() {
	var nav = navigator.userAgent;
	var ref = document.referrer;
	if (ref.indexOf("www.miel-c.com") == -1 && nav.indexOf("iPad") == -1 && (nav.indexOf("iPhone") > 0 || nav.indexOf("Android") > 0 || nav.indexOf("iPod") > 0)) {
		location.href = "http://www.miel-c.com/smt/";
	}
}


/* Google Analytics
----------------------------------------------- */
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-25708430-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);
})();

