// JavaScript Document
$(document).ready(function () {
	var subPageName = (window.location.hash)?window.location.hash:'';
	var initWidth = $(window).width();
	var flashClip = (document.URL.indexOf("/en") >= 0 || document.URL.indexOf("/zh") >= 0 || document.URL.indexOf("/ru") >= 0)? "../swf/"+pageName+".swf":"swf/"+pageName+".swf";
	if(pageName == "home"){
		$(".sarment-logo").hide().fadeIn(3000);
		$("#intro-wrap h1").hide().delay(2000).fadeIn(3000);
		$("#intro-wrap #lng-wrap").hide().delay(4000).fadeIn(3000);
	}
	if(initWidth>768){
		$("#bg-wrap").append('<div id="swf-wrap"></div>');
		if(subPageName && subPageName.indexOf("/")){
			var pageNameList = subPageName.split("#");
			pageName = pageNameList[1].substring(subPageName.indexOf("/"));
			subPageName = (pageNameList.length>2)?"#"+pageNameList[2]:'';
			$("#nav-menu a").removeClass("selected");
			$("#"+pageName).addClass("selected");
			$("#bg-wrap").removeClass("idea").addClass(pageName);
			$("#ajax-cntnt").load("_"+$("#"+pageName).attr("href"), function(){
							prevPageName = '';
							subPageName = pageInit(subPageName);
			})
		}else{
			if(pageName == "home"){
				$("#bg-wrap").css({background:'#fafafa'});
			setTimeout( function(){ 
				swfobject.embedSWF(flashClip, "swf-wrap", "1000", "600", "9.0.0", "expressInstall.swf",{},{wmode:"transparent"},{})
				}, 3000);
			}else{
				swfobject.embedSWF(flashClip, "swf-wrap", "1000", "600", "9.0.0", "expressInstall.swf",{},{wmode:"transparent"},{});
				var maskHeight = (document.URL.indexOf("/zh") >= 0)? 230:190;
				$("#cntnt-wrap "+subPageName+".cntnt").hide().fadeIn();
				//swappingMask("#cntnt-wrap .cntnt", 690, maskHeight, '#fafafa',10,0,500,1000);
			}
		}
		if(subPageName!='' && subPageName!='#'){
			$(".btn-thb a").each(function(idx, value){
				if($(this).attr("href") == subPageName){
					$(this).addClass("selected");
				}else{
					$(this).removeClass("selected");
				}
			});
		}
		$("#nav-menu a").click(function(e){
			$("#join-ft").animate({paddingTop:0}, function(){$(this).css('padding-top','');});
			$("#nav-menu a").removeClass("selected");
			$(this).addClass("selected");
			var href = $(this).attr("href");
			var loadHref = "#/"+$(this).attr("id");
			e.preventDefault();
			$("#cntnt-wrap .btn-thb").animate({opacity:'0'},1000);
			if(pageName=="mem" || pageName=="somm"){
				var maskWidth = ($.browser.msie)? 380:690;
			$("#cntnt-wrap .btn-thb").fadeOut(1000);
			//swappingMask("#cntnt-wrap .btn-thb", maskWidth, 50, '#fafafa',10,0,0,1000,"easeIn");
			}
			var maskWidth = (pageName=="cell" || pageName=="yacht" || pageName=="somm")?910:690;
			var maskHeight = (pageName == "idea")? 190:270;
				maskHeight = (pageName == "idea" && $.browser.msie)? 190:maskHeight;
				maskHeight = (document.URL.indexOf("/zh") >= 0)? 330:maskHeight;
			//maskHeight = (window.location.hash.indexOf("#price-table")>0)? 490:maskHeight;
			//maskWidth = (window.location.hash.indexOf("#price-table")>0)? 800:maskWidth;
			if(window.location.hash.indexOf("#price-table")>0){
				$("#cntnt-wrap #price-table.cntnt").animate({width:690, height:270});
				$("#cntnt-wrap #price-table.cntnt").animate({width:690, height:270, paddingLeft:0});
				$("#bg-wrap").animate({paddingTop:0});
				$("#cntnt-wrap").animate({height:600});
				$("#main-wrap").animate({height:600});
			}
				var pageNameList = window.location.hash.split("#");
				subPageName = (pageNameList.length>2)?"#"+pageNameList[2]:'';
			
				$("#cntnt-wrap .cntnt").animate({opacity:'0'},1000);
				$("#cntnt-wrap "+subPageName+".cntnt").fadeOut(1000);
				$("#bg-wrap").prepend('<div class="mask"></div>');
				$("#bg-wrap .mask").hide().css({ width:1000, height:600,background:'#fafafa',position:'absolute'}).fadeIn(1000);
				$("#cntnt-wrap "+subPageName+".cntnt:first").stop().fadeOut(1000,function(){
					window.location = loadHref; 
					prevPageName = pageName; 
					$("#bg-wrap").removeClass();
					pageName = $(this).attr("id");
					$("#ajax-cntnt").css({visibility:'hidden'});
					$("#ajax-cntnt").load("_"+href, function(){ 
						$("#bg-wrap .mask").remove();
						subPageName = pageInit(subPageName);
					})
				});
					
				/*swappingMask("#cntnt-wrap "+subPageName+".cntnt", maskWidth, maskHeight, '#fafafa',10,0,0,1000,"easeIn",function(){
					window.location = loadHref; 
					prevPageName = pageName; 
					$("#bg-wrap").removeClass();
					pageName = $(this).attr("id"); 
					$("#ajax-cntnt").css({visibility:'hidden'});
					$("#ajax-cntnt").load("_"+href, function(){ 
						subPageName = pageInit(subPageName);
					})
				});*/
				subPageName = '';
		});
		$(".btn-thb a").mouseenter(function() {
			if(!$(this).hasClass("selected")){
				$(this).stop().css('opacity','0.3').animate({opacity:'1'},1000);
				//$(this).find("span").stop().css('opacity','1').animate({opacity:'1'});
			}
		}).mouseleave(function(){
			if(!$(this).hasClass("selected")){
				$(this).stop().animate({opacity:'0.3'},1000);
				//$(this).find("span").stop().animate({opacity:'0'},1300);
			}
		});
		$(".btn-thb a").click(function(e){
			e.preventDefault();
			var nextPageName = $(this).attr("href").substring($(this).attr("href").indexOf("#"));
			window.location = "#/"+pageName+nextPageName;
			//addHashToHref('#lng-wrap a', subPageName);
			$(".btn-thb a").each(function(idx, value){
				if($(this).hasClass("selected") && subPageName != nextPageName){
					$(this).css('opacity','1').animate({opacity:'0.3'},1000);
					//$(this).find("span").css('opacity','1').animate({opacity:'0'},1300);
				}
			});
			if(subPageName != $(this).attr("href")){
				$(".btn-thb a").removeClass("selected");
				$(this).addClass("selected");
				var maskWidth = (pageName=="cell" || pageName=="yacht" || pageName=="somm")?910:690;
				var maskHeight = (nextPageName == "#price-table")? 505:270;
				//maskWidth = (window.location.hash == "#price-table")? 800:maskWidth;
				if(subPageName == "#price-table"){
					$("#cntnt-wrap "+nextPageName+".cntnt").animate({width:740, height:505, paddingLeft:60});
					$("#cntnt-wrap "+subPageName+".cntnt").animate({width:800, height:505});
					$("#bg-wrap").css('background','background:url(../images/member/bg-mem.jpg) left bottom no-repeat #fafafa');
					$("#bg-wrap").animate({height:600, paddingTop:220});
					$("#cntnt-wrap").animate({height:820});
					$("#main-wrap").animate({height:820});
				}
				if(subPageName == "#price-table"){
					$("#cntnt-wrap "+nextPageName+".cntnt").animate({width:690, height:270});
					$("#cntnt-wrap "+subPageName+".cntnt").animate({width:690, height:270, paddingLeft:0});
					$("#bg-wrap").animate({paddingTop:0});
					$("#cntnt-wrap").animate({height:600});
					$("#main-wrap").animate({height:600});
				}
				$("#cntnt-wrap "+subPageName+".cntnt").fadeOut(1000, function(){
					subPageName = nextPageName;
					if(subPageName == "#price-table")
						$("#bg-wrap").css('background','background:url(../images/member/bg-mem.jpg) left bottom no-repeat');
					$(".cntnt").css('display','none');
					$(subPageName).css('display','block');
					$(subPageName).hide().fadeIn(1000);
				});
				
				/*swappingMask("#cntnt-wrap "+subPageName+".cntnt", maskWidth, maskHeight, '#fafafa',10,0,0,1000,"easeIn", function(){
					subPageName = nextPageName;
					if(subPageName == "#price-table")
						$("#bg-wrap").css('background','background:url(../images/member/bg-mem.jpg) left bottom no-repeat');
					$(".cntnt").css('display','none');
					$(subPageName).css('display','block');
					var maskHeight = (subPageName == "#price-table")? 500:270;
					maskWidth = (subPageName == "#price-table")? 800:maskWidth;
					swappingMask(subPageName, maskWidth, maskHeight, '#fafafa',10,0,500,1000);
				});*/
			}
		});
		$("#btn-tbl").click(function(e){
			e.preventDefault();
			var nextPageName = $(this).attr("href").substring($(this).attr("href").indexOf("#"));
			window.location = "#/"+pageName+nextPageName;
			//addHashToHref('#lng-wrap a', subPageName);
			$("#join-ft").animate({paddingTop:210});
			$("#cntnt-wrap "+subPageName+".cntnt").animate({width:740, height:505, paddingLeft:60});
			$("#cntnt-wrap "+nextPageName+".cntnt").animate({width:800, height:505, paddingLeft:0});
			$("#bg-wrap").css('background','background:url(../images/member/bg-mem.jpg) left bottom no-repeat #fafafa');
			$("#bg-wrap").animate({height:600, paddingTop:220});
			$("#cntnt-wrap").animate({height:820});
			$("#main-wrap").animate({height:820});
			$("#cntnt-wrap "+subPageName+".cntnt:first").fadeOut(1000, function(){
					subPageName = nextPageName;
					$("#bg-wrap").css('background','background:url(../images/member/bg-mem.jpg) left bottom no-repeat');
					$(".cntnt").css('display','none');
					$(subPageName).css('display','block');
					$(subPageName).hide().fadeIn(1000);
				});
			/*swappingMask("#cntnt-wrap "+subPageName+".cntnt", 690, 500, '#fafafa',10,0,0,1000,"easeIn", function(){
				subPageName = nextPageName;
				$("#bg-wrap").css('background','background:url(../images/member/bg-mem.jpg) left bottom no-repeat');
				$(".cntnt").css('display','none');
				$(subPageName).css('display','block');
				swappingMask(subPageName, 800, 500, '#fafafa',10,0,500,1000);
			});*/
		});
	}else{
			if(pageName=="" || pageName=="idea"){
				$("#cntnt-wrap").append($("#foot-wrap"));
			}
			$("#cntnt-wrap .cntnt").css({width:'', height:'', paddingLeft:''});
			$('#guide-ft').css({marginTop:''});
			$("#bg-wrap").css({height:'', paddingTop:''});
			$("#cntnt-wrap").css({height:''});
			$("#main-wrap").css({height:''});
			$("#nav-menu a").unbind('click');
			$(".btn-thb a").unbind('click').unbind('mouseenter').unbind('mouseleave').css('opacity','');
			$(".btn-thb a span").css('opacity','');
			$(".btn-thb .mask").remove();
			$(".cntnt .mask").remove();
			$("#price-table").css({width:'', height:'',paddingLeft:''});
			$("#joining-sarment").css({width:'', height:'',paddingLeft:''});
		if(subPageName!='' && subPageName!='#')
			addHashToHref('#lng-wrap a', subPageName);
		if(subPageName == "#price-table"){
					$(".cntnt").css('display','none');
					$(subPageName).css('display','block');
		}
		$(".btn-thb a").click(function(e){
			e.preventDefault();
			var subPageName = $(this).attr("href");
			//addHashToHref('#lng-wrap a', subPageName);
			window.location.hash = subPageName;
			$(".btn-thb a").removeClass("selected");
			$(this).addClass("selected");
			$(".cntnt").css('display','none');
			$(subPageName).css('display','block');
		});
		$("#btn-tbl").click(function(e){
			var subPageName = $(this).attr("href");
				//addHashToHref('#lng-wrap a', subPageName);
					$("#bg-wrap").css('background','background:url(../images/member/bg-mem.jpg) left bottom no-repeat');
					$(".cntnt").css('display','none');
					$(subPageName).css('display','block');
		});
	}
	$(window).resize(function() {
		if($(window).width()> 768 && initWidth<=768){
			$('#guide-ft').css({marginTop:-44});
			if(!$("#bg-wrap div:first-child").is("#swf-wrap"))
				$("#bg-wrap").append('<div id="swf-wrap"></div>');
				swfobject.embedSWF(flashClip, "swf-wrap", "1000", "600", "9.0.0", "expressInstall.swf",{},{wmode:"transparent"},{})
				if(window.location.hash == "#price-table"){
					$("#cntnt-wrap .cntnt").css({width:800, height:505, paddingLeft:60});
					$("#cntnt-wrap "+window.location.hash+".cntnt").css({width:800, height:505, paddingLeft:0});
					$("#bg-wrap").css('background','background:url(../images/member/bg-mem.jpg) left bottom no-repeat #fafafa');
					$("#bg-wrap").css({height:600, paddingTop:220});
					$("#cntnt-wrap").css({height:820});
					$("#main-wrap").css({height:820});
				}
				$(".btn-thb a").unbind('click');
		$("#nav-menu a").click(function(e){
			$("#join-ft").animate({paddingTop:0}, function(){$(this).css('padding-top','');});
			$("#nav-menu a").removeClass("selected");
			$(this).addClass("selected");
			var href = $(this).attr("href");
			var loadHref = "#/"+$(this).attr("id");
			e.preventDefault();
			$("#cntnt-wrap .btn-thb").animate({opacity:'0'},1000);
			if(pageName=="mem" || pageName=="somm"){
				var maskWidth = ($.browser.msie)? 380:690;
			$("#cntnt-wrap .btn-thb").fadeOut(1000);
			//swappingMask("#cntnt-wrap .btn-thb", maskWidth, 50, '#fafafa',10,0,0,1000,"easeIn");
			}
			var maskWidth = (pageName=="cell" || pageName=="yacht" || pageName=="somm")?910:690;
			var maskHeight = (pageName == "idea")? 190:270;
				maskHeight = (pageName == "idea" && $.browser.msie)? 190:maskHeight;
				maskHeight = (document.URL.indexOf("/zh") >= 0)? 330:maskHeight;
			//maskHeight = (window.location.hash.indexOf("#price-table")>0)? 490:maskHeight;
			//maskWidth = (window.location.hash.indexOf("#price-table")>0)? 800:maskWidth;
			if(window.location.hash.indexOf("#price-table")>0){
				$("#cntnt-wrap #price-table.cntnt").animate({width:690, height:270});
				$("#cntnt-wrap #price-table.cntnt").animate({width:690, height:270, paddingLeft:0});
				$("#bg-wrap").animate({paddingTop:0});
				$("#cntnt-wrap").animate({height:600});
				$("#main-wrap").animate({height:600});
			}
				var pageNameList = window.location.hash.split("#");
				subPageName = (pageNameList.length>2)?"#"+pageNameList[2]:'';
			
				$("#cntnt-wrap .cntnt").animate({opacity:'0'},1000);
				$("#cntnt-wrap "+subPageName+".cntnt").fadeOut(1000);
				$("#bg-wrap").prepend('<div class="mask"></div>');
				$("#bg-wrap .mask").hide().css({ width:1000, height:600,background:'#fafafa',position:'absolute'}).fadeIn(1000);
				$("#cntnt-wrap "+subPageName+".cntnt:first").stop().fadeOut(1000,function(){
					window.location = loadHref; 
					prevPageName = pageName; 
					$("#bg-wrap").removeClass();
					pageName = $(this).attr("id");
					$("#ajax-cntnt").css({visibility:'hidden'});
					$("#ajax-cntnt").load("_"+href, function(){ 
						$("#bg-wrap .mask").remove();
						subPageName = pageInit(subPageName);
					})
				});
					
				/*swappingMask("#cntnt-wrap "+subPageName+".cntnt", maskWidth, maskHeight, '#fafafa',10,0,0,1000,"easeIn",function(){
					window.location = loadHref; 
					prevPageName = pageName; 
					$("#bg-wrap").removeClass();
					pageName = $(this).attr("id"); 
					$("#ajax-cntnt").css({visibility:'hidden'});
					$("#ajax-cntnt").load("_"+href, function(){ 
						subPageName = pageInit(subPageName);
					})
				});*/
				subPageName = '';
		});
		$(".btn-thb a").mouseenter(function() {
			if(!$(this).hasClass("selected")){
				$(this).stop().css('opacity','0.3').animate({opacity:'1'},1000);
				//$(this).find("span").stop().css('opacity','1').animate({opacity:'1'});
			}
		}).mouseleave(function(){
			if(!$(this).hasClass("selected")){
				$(this).stop().animate({opacity:'0.3'},1000);
				//$(this).find("span").stop().animate({opacity:'0'},1300);
			}
		});
		$(".btn-thb a").click(function(e){
			e.preventDefault();
			var nextPageName = $(this).attr("href").substring($(this).attr("href").indexOf("#"));
			window.location = "#/"+pageName+nextPageName;
			//addHashToHref('#lng-wrap a', subPageName);
			$(".btn-thb a").each(function(idx, value){
				if($(this).hasClass("selected") && subPageName != nextPageName){
					$(this).stop().css('opacity','1').animate({opacity:'0.3'},1000);
					//$(this).find("span").css('opacity','1').animate({opacity:'0'},1300);
				}
			});
			if(subPageName != $(this).attr("href")){
				$(".btn-thb a").removeClass("selected");
				$(this).addClass("selected");
				var maskWidth = (pageName=="cell" || pageName=="yacht" || pageName=="somm")?910:690;
				var maskHeight = (window.location.hash == "#price-table")? 505:270;
				//maskWidth = (window.location.hash == "#price-table")? 800:maskWidth;
				if(subPageName == "#price-table"){
					$("#cntnt-wrap "+window.location.hash+".cntnt").animate({width:740, height:505, paddingLeft:60});
					$("#cntnt-wrap "+subPageName+".cntnt").animate({width:800, height:505});
					$("#bg-wrap").css('background','background:url(../images/member/bg-mem.jpg) left bottom no-repeat #fafafa');
					$("#bg-wrap").animate({height:600, paddingTop:220});
					$("#cntnt-wrap").animate({height:820});
					$("#main-wrap").animate({height:820});
				}
				if(subPageName == "#price-table"){
					$("#cntnt-wrap "+window.location.hash+".cntnt").animate({width:690, height:270});
					$("#cntnt-wrap "+subPageName+".cntnt").animate({width:690, height:270, paddingLeft:0});
					$("#bg-wrap").animate({paddingTop:0});
					$("#cntnt-wrap").animate({height:600});
					$("#main-wrap").animate({height:600});
				}
				$("#cntnt-wrap "+subPageName+".cntnt").fadeOut(1000, function(){
					subPageName = nextPageName;
					if(subPageName == "#price-table")
						$("#bg-wrap").css('background','background:url(../images/member/bg-mem.jpg) left bottom no-repeat');
					$(".cntnt").css('display','none');
					$(subPageName).css('display','block');
					$(subPageName).hide().fadeIn(1000);
				});
				
				/*swappingMask("#cntnt-wrap "+subPageName+".cntnt", maskWidth, maskHeight, '#fafafa',10,0,0,1000,"easeIn", function(){
					subPageName = nextPageName;
					if(subPageName == "#price-table")
						$("#bg-wrap").css('background','background:url(../images/member/bg-mem.jpg) left bottom no-repeat');
					$(".cntnt").css('display','none');
					$(subPageName).css('display','block');
					var maskHeight = (subPageName == "#price-table")? 500:270;
					maskWidth = (subPageName == "#price-table")? 800:maskWidth;
					swappingMask(subPageName, maskWidth, maskHeight, '#fafafa',10,0,500,1000);
				});*/
			}
		});
		$("#btn-tbl").click(function(e){
			e.preventDefault();
			var nextPageName = $(this).attr("href").substring($(this).attr("href").indexOf("#"));
			window.location = "#/"+pageName+nextPageName;
			//addHashToHref('#lng-wrap a', subPageName);
			$("#join-ft").animate({paddingTop:210});
			$("#cntnt-wrap "+subPageName+".cntnt").animate({width:740, height:505, paddingLeft:60});
			$("#cntnt-wrap "+nextPageName+".cntnt").animate({width:800, height:505, paddingLeft:0});
			$("#bg-wrap").css('background','background:url(../images/member/bg-mem.jpg) left bottom no-repeat #fafafa');
			$("#bg-wrap").animate({height:600, paddingTop:220});
			$("#cntnt-wrap").animate({height:820});
			$("#main-wrap").animate({height:820});
			$("#cntnt-wrap "+subPageName+".cntnt:first").fadeOut(1000, function(){
					subPageName = nextPageName;
					$("#bg-wrap").css('background','background:url(../images/member/bg-mem.jpg) left bottom no-repeat');
					$(".cntnt").css('display','none');
					$(subPageName).css('display','block');
					$(subPageName).hide().fadeIn(1000);
				});
			/*swappingMask("#cntnt-wrap "+subPageName+".cntnt", 690, 500, '#fafafa',10,0,0,1000,"easeIn", function(){
				subPageName = nextPageName;
				$("#bg-wrap").css('background','background:url(../images/member/bg-mem.jpg) left bottom no-repeat');
				$(".cntnt").css('display','none');
				$(subPageName).css('display','block');
				swappingMask(subPageName, 800, 500, '#fafafa',10,0,500,1000);
			});*/
		});
			if(pageName=="" || pageName=="idea"){
				$("#join-ft").append($("#foot-wrap"));
			}
		}else if($(window).width()< 768 && initWidth >=768){
			if(subPageName!='' && subPageName!='#')
				//addHashToHref('#lng-wrap a', subPageName);
			if(pageName=="" || pageName=="idea"){
				$("#cntnt-wrap").append($("#foot-wrap"));
			}
			$('#guide-ft').css({marginTop:''});
			$("#cntnt-wrap .cntnt").css({width:'', height:'', paddingLeft:'', marginTop:''});
			$("#bg-wrap").css({height:'', paddingTop:''});
			$("#cntnt-wrap").css({height:''});
			$("#main-wrap").css({height:''});
			$("#nav-menu a").unbind('click');
			$(".btn-thb a").unbind('click').unbind('mouseenter').unbind('mouseleave').css('opacity','');
			$(".btn-thb a span").css('opacity','');
			$(".btn-thb .mask").remove();
			$(".cntnt .mask").remove();
			$("#price-table").css({width:'', height:'',paddingLeft:''});
			$("#joining-sarment").css({width:'', height:'',paddingLeft:''});
			$(".btn-thb a").bind('click', function(e){
			e.preventDefault();
			var subPageName = $(this).attr("href");
			addHashToHref('#lng-wrap a', subPageName);
			window.location.hash = subPageName;
			$(".btn-thb a").removeClass("selected");
			$(this).addClass("selected");
			$(".cntnt").css('display','none');
			$(subPageName).css('display','block');
			});
		$("#btn-tbl").click(function(e){
			var subPageName = $(this).attr("href");
				//addHashToHref('#lng-wrap a', subPageName);
					$("#bg-wrap").css('background','background:url(../images/member/bg-mem.jpg) left bottom no-repeat');
					$(".cntnt").css('display','none');
					$(subPageName).css('display','block');
		});
		}
		initWidth = $(window).width();
	});
});

function swappingMask(obj,w, h, bg, shdw_h, shdw_v, d, s, m, callback, z){
	m =(m)?m:"easeOut";
	z =(z)?z:'10';
	complete = callback;
	$(obj+" .mask").remove();
	$(obj+":first").prepend('<div class="mask"></div>');
	if(m=="easeOut"){
		$(obj+':first .mask').css({'z-index':z, width:w, height:h,background:bg,position:'absolute','box-shadow':'0 0 '+shdw_h+'px '+shdw_v+'px '+bg}).delay(d).animate({width:0,marginLeft:w},s, function(){
			if(complete){ 
				complete();
			}
			$(this).remove();
		});
	}else if(m=="easeIn"){
		$(obj+":first .mask").css({'z-index':z, width:0, height:h,background:bg,position:'absolute','box-shadow':'0 0 '+shdw_h+'px '+shdw_v+'px '+bg}).animate({width:w},1000, function(){ 
			if(complete){ 
				complete();
			}
		});
	}
}
function addHashToHref(obj, hash){
	$(obj).each(function(idx, value){
		if($(this).attr('href').indexOf('#')>0)
			$(this).attr('href',$(this).attr('href').substr(0, $(this).attr('href').indexOf('#'))+hash);
		else
			$(this).attr('href',$(this).attr('href')+hash);
	});
}
function pageInit(subPageName){
	var initWidth = $(window).width();
	var flashClip = (document.URL.indexOf("/en") >= 0 || document.URL.indexOf("/zh") >= 0 || document.URL.indexOf("/ru") >= 0)? "../swf/"+pageName+".swf":"swf/"+pageName+".swf";
	$("#ajax-cntnt").css({visibility:''});
	//$(".btn-thb a").css('opacity','');
	//$(".btn-thb a span").css('opacity','');
	$("#price-table").css({width:'', height:'',paddingLeft:''});
	$("#joining-sarment").css({width:'', height:'',paddingLeft:''});
	$("#cntnt-wrap .cntnt").css({width:'', height:'', paddingLeft:''});
	$("#bg-wrap").css({height:'', paddingTop:''});
	$("#cntnt-wrap").css({height:''});
	$("#main-wrap").css({height:''});
	$(".btn-thb a").unbind('click').unbind('mouseenter').unbind('mouseleave');
	$(".btn-thb .mask").remove();
	$(".cntnt .mask").remove();
	if(initWidth>768){
		if(prevPageName != pageName){
			var flashClip = (document.URL.indexOf("/en") >= 0 || document.URL.indexOf("/zh") >= 0 || document.URL.indexOf("/ru") >= 0)? "../swf/"+pageName+".swf":"swf/"+pageName+".swf";
			swfobject.embedSWF(flashClip, "swf-wrap", "1000", "600", "9.0.0", "expressInstall.swf",{},{wmode:"transparent"},{});
			$("object").ready(function(e) {
              // $("#bg-wrap").addClass(pageName); 
            });
		}
		if(subPageName!='' && subPageName!='#'){
			$(".btn-thb a").each(function(idx, value){
				if($(this).attr("href").substring($(this).attr("href").indexOf("#")) == subPageName){
					$(this).addClass("selected");
				}else{
					$(this).removeClass("selected");
				}
			});
			//alert(pageName);
			var maskWidth = (pageName=="cell" || pageName=="yacht" || pageName=="somm")?910:690;
			var maskHeight = (subPageName == "#price-table")? 505:270;
			maskWidth = (subPageName == "#price-table")? 800:maskWidth;
			$(".cntnt").css('display','none');
			if(subPageName!='' && subPageName!='#')
			$(subPageName).css('display','block');
			if(window.location.hash.indexOf("#price-table")>0){
				$("#join-ft").css({paddingTop:210});
				$("#cntnt-wrap .cntnt").css({width:800, height:505, paddingLeft:60});
				$("#cntnt-wrap "+window.location.hash+".cntnt").css({width:800, height:505, paddingLeft:0});
				$("#bg-wrap").css('background','background:url(../images/member/bg-mem.jpg) left bottom no-repeat #fafafa');
				$("#bg-wrap").css({height:600, paddingTop:220});
				$("#cntnt-wrap").css({height:820});
				$("#main-wrap").css({height:820});
			}
			$("#cntnt-wrap "+subPageName+".cntnt").hide().fadeIn(1000);
			//swappingMask(subPageName, maskWidth, maskHeight, '#fafafa',10,0,500,1000);
		}else{
			if(pageName=="mem" || pageName=="somm"){
				var maskWidth = ($.browser.msie)? 380:690;
				$("#cntnt-wrap .btn-thb").hide().fadeIn(1000);
				//swappingMask("#cntnt-wrap .btn-thb", maskWidth, 50, '#fafafa',10,0,0,1000);
			}
			var maskWidth = (pageName=="cell" || pageName=="yacht" || pageName=="somm")? 910:690;
			var maskHeight = (pageName == "idea")? 190:270;
				maskHeight = (pageName == "idea" && $.browser.msie)? 190:maskHeight;
			maskHeight = (subPageName == "#price-table")? 500:maskHeight;
			maskWidth = (subPageName == "#price-table")? 800:maskWidth;
			maskHeight = (document.URL.indexOf("/zh") >= 0)? 330:maskHeight;
			$("#cntnt-wrap .cntnt:first").hide().fadeIn(1000);
			//swappingMask("#cntnt-wrap .cntnt", maskWidth, maskHeight, '#fafafa',10,0,500,1000);
		}
		$(".btn-thb a").mouseenter(function() {
			if(!$(this).hasClass("selected")){
				$(this).stop().css('opacity','0.3').animate({opacity:'1'},1000);
				//$(this).find("span").stop().css('opacity','1').animate({opacity:'1'});
			}
		}).mouseleave(function(){
			if(!$(this).hasClass("selected")){
				$(this).stop().animate({opacity:'0.3'},1000);
				//$(this).find("span").stop().animate({opacity:'0'},1300);
			}
		});
		$(".btn-thb a").click(function(e){
			e.preventDefault();
			var nextPageName = $(this).attr("href").substring($(this).attr("href").indexOf("#"));
			window.location = "#/"+pageName+nextPageName;
			//addHashToHref('#lng-wrap a', subPageName);
			$(".btn-thb a").each(function(idx, value){
				if($(this).hasClass("selected") && subPageName != nextPageName){
					$(this).stop().css('opacity','1').animate({opacity:'0.3'},1000);
					//$(this).find("span").css('opacity','1').animate({opacity:'0'},1300);
				}
			});
			if(subPageName != $(this).attr("href")){
				$(".btn-thb a").removeClass("selected");
				$(this).addClass("selected");
				var maskWidth = (pageName=="cell" || pageName=="yacht" || pageName=="somm")?910:690;
				var maskHeight = (window.location.hash == "#price-table")? 505:270;
				//maskWidth = (window.location.hash == "#price-table")? 800:maskWidth;
				if(subPageName == "#price-table"){
					$("#cntnt-wrap "+nextPageName+".cntnt").animate({width:740, height:505, paddingLeft:60});
					$("#cntnt-wrap "+subPageName+".cntnt").animate({width:800, height:505});
					$("#bg-wrap").css('background','background:url(../images/member/bg-mem.jpg) left bottom no-repeat #fafafa');
					$("#bg-wrap").animate({height:600, paddingTop:220});
					$("#cntnt-wrap").animate({height:820});
					$("#main-wrap").animate({height:820});
				}
				if(subPageName == "#price-table"){
					$("#cntnt-wrap "+nextPageName+".cntnt").animate({width:690, height:270});
					$("#cntnt-wrap "+subPageName+".cntnt").animate({width:690, height:270, paddingLeft:0});
					$("#bg-wrap").animate({paddingTop:0});
					$("#cntnt-wrap").animate({height:600});
					$("#main-wrap").animate({height:600});
				}
				$("#cntnt-wrap "+subPageName+".cntnt:first").fadeOut(1000, function(){
					subPageName = nextPageName;
					if(subPageName == "#price-table")
						$("#bg-wrap").css('background','background:url(../images/member/bg-mem.jpg) left bottom no-repeat');
					$(".cntnt").css('display','none');
					$(subPageName).css('display','block');
					$(subPageName).hide().fadeIn(1000);
				});
				
				/*swappingMask("#cntnt-wrap "+subPageName+".cntnt", maskWidth, maskHeight, '#fafafa',10,0,0,1000,"easeIn", function(){
					subPageName = nextPageName;
					if(subPageName == "#price-table")
						$("#bg-wrap").css('background','background:url(../images/member/bg-mem.jpg) left bottom no-repeat');
					$(".cntnt").css('display','none');
					$(subPageName).css('display','block');
					var maskHeight = (subPageName == "#price-table")? 500:270;
					maskWidth = (subPageName == "#price-table")? 800:maskWidth;
					swappingMask(subPageName, maskWidth, maskHeight, '#fafafa',10,0,500,1000);
				});*/
			}
		});
		$("#btn-tbl").click(function(e){
			e.preventDefault();
			var nextPageName = $(this).attr("href").substring($(this).attr("href").indexOf("#"));
			window.location = "#/"+pageName+nextPageName;
			//addHashToHref('#lng-wrap a', subPageName);
			$("#join-ft").animate({paddingTop:210});
			$("#cntnt-wrap "+subPageName+".cntnt").animate({width:740, height:505, paddingLeft:60});
			$("#cntnt-wrap "+nextPageName+".cntnt").animate({width:800, height:505, paddingLeft:0});
			$("#bg-wrap").css('background','background:url(../images/member/bg-mem.jpg) left bottom no-repeat #fafafa');
			$("#bg-wrap").animate({height:600, paddingTop:220});
			$("#cntnt-wrap").animate({height:820});
			$("#main-wrap").animate({height:820});
			$("#cntnt-wrap "+subPageName+".cntnt:first").fadeOut(1000, function(){
					subPageName = nextPageName;
					$("#bg-wrap").css('background','background:url(../images/member/bg-mem.jpg) left bottom no-repeat');
					$(".cntnt").css('display','none');
					$(subPageName).css('display','block');
					$(subPageName).hide().fadeIn(1000);
				});
			/*swappingMask("#cntnt-wrap "+subPageName+".cntnt", 690, 500, '#fafafa',10,0,0,1000,"easeIn", function(){
				subPageName = nextPageName;
				$("#bg-wrap").css('background','background:url(../images/member/bg-mem.jpg) left bottom no-repeat');
				$(".cntnt").css('display','none');
				$(subPageName).css('display','block');
				swappingMask(subPageName, 800, 500, '#fafafa',10,0,500,1000);
			});*/
		});
	}else{
	if(subPageName!='' && subPageName!='#')
		//addHashToHref('#lng-wrap a', subPageName);
		$(".btn-thb a").click(function(e){
			e.preventDefault();
			var subPageName = $(this).attr("href");
			addHashToHref('#lng-wrap a', subPageName);
			window.location.hash = subPageName;
			if(pageName=="" || pageName=="idea"){
				$("#cntnt-wrap").append($("#foot-wrap"));
			}
			$(".btn-thb a").removeClass("selected");
			$(this).addClass("selected");
			$(".cntnt").css('display','none');
			$(subPageName).css('display','block');
		});
		$("#btn-tbl").click(function(e){
			var subPageName = $(this).attr("href");
				//addHashToHref('#lng-wrap a', subPageName);
					$("#bg-wrap").css('background','background:url(../images/member/bg-mem.jpg) left bottom no-repeat');
					$(".cntnt").css('display','none');
					$(subPageName).css('display','block');
		});
	}
	return subPageName;
}
