$j=jQuery.noConflict();
jQuery.easing.quart = function (x, t, b, c, d) {
    return -c * ((t=t/d-1)*t*t*t - 1) + b;
};
$j(function(){
	$j('#cf_btn').click(function(){
		var yourNameVal = $j('#cf_yourName').val();
		var yourEmailVal = $j('#cf_yourEmail').val();
		var yourEmailText = $j('#cf_yourText').val();
		var errorEmail = 0;
		if (!yourEmailVal.match(/^[A-Za-z0-9]+[\w-]+@[\w\.-]+\.\w{2,}$/) || yourEmailVal.length == 0){
			var errorEmail = 1;
		}
		if (yourNameVal.length == 0 || errorEmail == 1 || yourEmailText.length == 0){
			if (yourNameVal.length == 0){
				if ($j('#errorName').size() == 0){
					$j('#cf_yourName').parent().append('<span id="errorName" class="alert">※ お名前を入力してください</span>');
					$j('#cf_yourName').focus(function(){
						$j('#errorName').remove();
					});
				}
			}
			if (errorEmail == 1){
				if ($j('#errorEmail').size() == 0){
					$j('#cf_yourEmail').parent().append('<span id="errorEmail" class="alert">※正しい形式で入力してください</span>');
					$j('#cf_yourEmail').focus(function(){
						$j('#errorEmail').remove();
					});
				}
			}
			if (yourEmailText.length == 0){
				if ($j('#errorContent').size() == 0){
					$j('#cf_yourText').parent().append('<br /><span id="errorContent" class="alertText">※内容を入力してください</span>');
					$j('#cf_yourText').focus(function(){
						$j('#errorContent').remove();
					});
				}
			}
			return false;
		}
	});
	$j("#naviBlog").hover(
		function(){$j("#blogSubNavi").fadeIn();},
		function(){$j("#blogSubNavi").hide();}
	);
	var sTxt = $j("#s").val();
	if (sTxt.length != 0){
		$j("#s").css("backgroundColor","#FFF");
	} else {
		$j("#s").css("backgroundColor","transparent");
	}
	$j("#naviArchive").hover(
		function(){$j("#archiveSubNavi").fadeIn();},
		function(){$j("#archiveSubNavi").hide();}
	);
	$j("#s").focus(
		function(){
			$j("#searchform").toggleClass("focus");
			var sTxt = $j("#s").val();
			if (sTxt.length != 0){
				$j("#s").css("backgroundColor","#FFF");
			} else {
				$j("#s").css("backgroundColor","transparent");
			}
		}
	);
	$j("#s").blur(
		function(){
			$j("#searchform").toggleClass("focus");
			var sTxt = $j("#s").val();
			if (sTxt.length != 0){
				$j("#s").css("backgroundColor","#FFF");
			} else {
				$j("#s").css("backgroundColor","transparent");
			}
		}
	);
	$j('#slidePhoto').coinslider({
		width: 590, //画像幅
		height: 260, //画像高
		delay:8000,
		titleSpeed:1000,
		spw: 7, //画像切替時の横四角数
		sph: 5, //画像切替時の縦四角数
		effect: 'rain' // エフェクト（random, swirl, rain, straight）
	});
	$j('#link_to_top').click(function () {
		$j('html,body').animate({ scrollTop: 0 }, 300, 'quart');
    });
	$j('<img>').attr('src', 'http://sweet-sweet-sweden.com/wp/wp-content/themes/sss_theme_2/images/loader.gif');
	var parentHeight = $j('#select').height();
	var parentHeightHalf = parentHeight / 2;
	$j('#photoGallery').children('li').children('a').click(function () {
		$j('#select').append('<div style="position: absolute; top: 0px; left: 0px; z-index: 999; background: #FFF; width: 100%; height: '+parentHeight+'px; opacity: 0.75; "><img src="http://sweet-sweet-sweden.com/wp/wp-content/themes/sss_theme_2/images/loader.gif" width="32" height="32" style="position: absolute; top: '+(parentHeightHalf - 32)+'px; left: 279px;"/></div>');
	});
});
