
$(function(){
	if ($(".birthday3").size()>0) {
	$(".birthday3").datepicker();
	 $.datepicker.regional['zh-CN'] = {
	  closeText: '關閉',
	  prevText: '<上月',
	  nextText: '下月>',
	  currentText: '今天',
	  monthNames: ['一月','二月','三月','四月','五月','六月',
	  '七月','八月','九月','十月','十一月','十二月'],
	  monthNamesShort: ['一','二','三','四','五','六',
	  '七','八','九','十','十一','十二'],
	  dayNames: ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'],
	  dayNamesShort: ['周日','周一','周二','周三','周四','周五','周六'],
	  dayNamesMin: ['日','一','二','三','四','五','六'],
	  weekHeader: '周',
	  dateFormat: 'yy-mm-dd',
	  firstDay: 0,
	  isRTL: false,
	  showMonthAfterYear: true,
	  yearSuffix: '年'};
	 $.datepicker.setDefaults($.datepicker.regional['zh-CN']);
	}
	/**
	 *	滑鼠動作
	 */
	$(".JsMouseAction").mouseover(function(){
		$(this).removeClass('mouseout').addClass('mouseover');
	});
	$(".JsMouseAction").mouseout(function(){
		$(this).removeClass('mouseover').addClass('mouseout');
	});
	
	/**
	 *	簡繁切換
	 */
	if ($("#translateLink").size()>0) {
		var defaultEncoding = 1;
		var translateDelay = 0;
		var cookieDomain = $("#domainname").val();
		var msgToTraditionalChinese = "繁體";
		var msgToSimplifiedChinese = "簡體";
		var translateButtonId = "translateLink";
		translateInitilization();
	}
	
	/**
	 *	主功能標示
	 */
    var pathname=location.pathname.split('/');
	pathname=pathname[pathname.length-1];
	$(".jsddm > li").each(function(){
		var _href=$(this).find("a").attr("href").split('?');
		_href=_href[0];
		if (_href==pathname) {
			$(this).find("a").addClass("liched");
		}
		$(this).find("li").each(function(){
			var _href=$(this).find("a").attr("href").split('?');
			_href=_href[0];
			if (_href==pathname) {
				$(this).parent().parent().find("a").addClass("liched");
			}
		});
	});
	
	/**
	 *	自動把字串多出來的字元變成... 用法:class="truncate" length="10"
	 */
	$(".truncate").each(function(){
		var _len=$(this).attr("length");
		var _txt=$(this).text();
		var _txt2=_txt.substring(0,_len);
		if (_txt!=_txt2)
			$(this).text(_txt2+'...');
	});
	
	/**
	 *	點圖放大 用法: 在外層加上 class="chpic" param="target:'product_picture'"
	 */
	$(".chpic a").click(function(){
		var param;
		eval("param={"+$(".chpic").attr("param")+'}');
		var src=$(this).attr("href");
		$("#"+param.target).attr({src:src});
		return false;
	});
	
	/**
	 *	t2版型
	 */
	if ($(".body_l").css("position")=="absolute") {
		var _height=$(".body_l").height()
		+($(".body_l").css("padding-top").replace("px","")-0)
		+($(".body_l").css("padding-bottom").replace("px","")-0)
		+($(".body_l").css("margin-top").replace("px","")-0)
		+($(".body_l").css("margin-bottom").replace("px","")-0)
		-65
		-20;
		
		if ($(".body_r").height()<=_height)
			$(".body").css("height",_height);
	}
	
	/**
	 *	Flash呼叫 需載入swfobject，用法：在外層加上 id="flash_banner" param="target:'{$templates_dir}/flash/index.swf',width:990,height:297"
	 */
	
	var param;
	if ($("#flash_banner").size()>0) {
		eval("param={"+$("#flash_banner").attr("param")+'}');
		var flashvars = '';
		var params=new Object();
		params.wmode="transparent";
		var attributes = ''; 
		swfobject.embedSWF(param.target, "flash_banner", param.width, param.height, "9.0.0", "js/swfobject/expressInstall.swf", flashvars, params, attributes);
	}
	
	/**
	 *	加圖形卷軸
	 */
	//if (pathname!='contact_us.php' && pathname!='hair_style.php')
	//	$('#scrollbar1,#scrollbar2,#scrollbar_news,#scrollbar_recuit').tinyscrollbar();

	/**
	 *	啟用png24
	 */
	$('.f').ifixpng();
	
	/**
	 *	自動選擇select
	 */
	$(".auto_selected").each(function(){
		var val=$(this).attr('val');
		$(this).find("option").each(function(){
			if ($(this).val()==val) {
				$(this).attr({selected:true});
			}
		});
	});
	
	/**
	 *	區塊切換 用法:
	 *	<a href="" class="selectx" data-selectT="A" data-selectx="1">xxx</a>
	 *	<a href="" class="selectx" data-selectT="A" data-selectx="2">xxx</a>
	 *	<div class="selectxC" data-selectT="A" data-selectx="1">content</div>
	 *	<div class="selectxC" data-selectT="A" data-selectx="2">content</div>
	 */
	$(".selectx").click(function(){
		var selectT=$(this).attr('data-selectT');
		$(".selectxC[data-selectT="+selectT+"]").hide();
		var selectx=$(this).attr('data-selectx');
		$(".selectxC[data-selectT="+selectT+"][data-selectx="+selectx+"]").show();
		return false;
	});
	
	$('.slideshow').cycle({
		fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});
	
	/**
	 *	瞄點
	 */
	/*var t = $('#go').offset().top;
	$(window).scrollTop(t);*/
	if ($('#gallery').size()>0)
		$('#gallery a').lightBox();
});

$(window).load(function(){
	if ($.browser.msie) {
		document.execCommand("BackgroundImageCache",false,true);
	}
	
	/**
	 *	自動縮小圖片到一定尺寸內 用法: class="AutoImgSize" autosize="width:80,height:50"
	 */
	$(".AutoImgSize").each(function(){
		var _width=$(this).css("width").replace("px","");
		var _height=$(this).css("height").replace("px","");
		var autosize;
		eval("autosize={"+$(this).attr("autosize")+'}');
		var x = autosize.width/_width*100;
		var y = autosize.height/_height*100;
		if (y>x) y=x;
		if (x>100 && y>100) y=100;
		$(this).css("width",Math.floor(_width*y/100));
		$(this).css("height",Math.floor(_height*y/100));
	});
	
	$(".advancedpanorama").panorama({
		viewport_width: 672,
		auto_start: 10,
		start_position: 1,
		speed: 60000	        
	});

});
