$(document).ready(function(){
	
	/***************************************
	 * jQuery.blend
	 * When using fade effects to alpha channel PNG, abort this process on MSIE.
	 
	if(!$.browser.msie){
		$("#global_navi a").blend({speed:350,opacity:1});	
	}else{
		//4 IE
	}
	 ***************************************/
	
	/***************************************
	 * searchBar
	 ***************************************/
	 $.fn.extend({
		 inputFocusTexSwap: function() {
			 var $searchInput = this
			 var searchInputColorDef = $searchInput.css('color')
			 var searchWordsDef = $searchInput.attr('value')
			 
			 $searchInput.bind('focus',function(e){
				var v =$searchInput.attr('value')
				if(v == searchWordsDef ) $searchInput.attr('value',"");
				$searchInput.addClass('focus');
			})
			 $searchInput.bind('blur',function(e){
				var v =$searchInput.attr('value')
				if(v == "") $searchInput.attr('value',searchWordsDef);
				$searchInput.removeClass('focus');
			})
			 return this;
		 }
	 });
	 
	 //set after
	 //$('#search_input').inputFocusTexSwap();
	 
	
	/***************************************
	 * Add DropShadow!
	 ***************************************/
	$(".dropsdw2x2_190, .dropsdw2x2_484, .dropsdw2x2_304").prepend('<span class="after" />');
	
	/***************************************
	 *twoColumnList  AND thumbList_MH  - height - Fix , and smallBtn
	 ***************************************/
	var smlBtnPref  = "a.button_more, a.button_buy, a.button_dl, a.button_playnow, a.button_community, a.button_campaign, a.button_official, a.button_itunes, a.button_relation"
	var fixSmlBtnHeight = function($p,mDiff){
		$p.find(smlBtnPref).each(function(i,elm){
			var defmt = $(elm).css('margin-top')
			defmt = parseInt(defmt.replace(/px(;*)|em(;*)|\%(;*)$/,''))
			//alert(mDiff+defmt);
			$(elm).css('margin-top',mDiff+defmt)
		})
	},
	threeColumnHeightFix = function(tPref){
		$(tPref).each(function(i,elm){
			var maxH,$n1,$n2,$n3
			if(i%3 != 0) return;
			//gusu nomi
			$n1 = $(elm)
			$n2 = $(tPref+":eq("+(i+1)+")");
			$n3 = $(tPref+":eq("+(i+2)+")");
			if(!$n2){
				return;
			}else if(!$n3){
				maxH = Math.max($n1.height(),$n2.height())
				fixSmlBtnHeight($n1,maxH-$n1.height())
				fixSmlBtnHeight($n2,maxH-$n2.height())
				//$n1.height(maxH)
				//$n2.height(maxH)
				$n1.css('minHeight',maxH)
				$n2.css('minHeight',maxH)
			}else{
				maxH = Math.max($n3.height(),Math.max($n1.height(),$n2.height()))
				fixSmlBtnHeight($n1, maxH-$n1.height())
				fixSmlBtnHeight($n2, maxH-$n2.height())
				fixSmlBtnHeight($n3, maxH-$n3.height())
				//$n1.height(maxH)
				//$n2.height(maxH)
				//$n3.height(maxH)
				$n1.css('minHeight',maxH)
				$n2.css('minHeight',maxH)
				$n3.css('minHeight',maxH)
			}
		})
	},
	twoColumnHeightFix = function(tPref){
		$(tPref).each(function(i,elm){
			var maxH,$next
			if(i%2 != 0)return;
			//gusu nomi
			$n1 = $(elm)
			$n2 = $(tPref+":eq("+(i+1)+")");
			if(!$n2) return;
			maxH = Math.max($n1.height(),$n2.height())
			fixSmlBtnHeight($n2,maxH-$n2.height())
			fixSmlBtnHeight($n1,maxH-$n1.height())
			//$n1.height(maxH)
			//$n2.height(maxH)
			$n1.css('minHeight',maxH)
			$n2.css('minHeight',maxH)
		})
	};
	
	//first-child(s)  only.
	twoColumnHeightFix(".twoColumnList > li")
	//$(".thumbList_LH li").each(function(i,elm){alert($(elm).html())})
	threeColumnHeightFix(".thumbList_LH > li")
	threeColumnHeightFix(".thumbList_MH > li")
	
	
	/***************************************
	 * QR Code enlarge Effect.
	 ***************************************/
	if(typeof($.fn.fancybox)!="undefined"){
	$("a.enlarge").fancybox({
		'hideOnContentClick' : true,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'onStart'	:function(){$("object").css('visibility','hidden')},
		'onClosed'	:function(){$("object").css('visibility','visible')},
		'padding':20,
		'titleShow'		: false
	});
	}
	
	
});