// JavaScript Document
/*dreamweaver js function*/

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

/**
 * ========================================
 *
 * chLang
 * ----------------------------------------
 *
 */

function chLang(lang) {
	var currentPath=location.href.toString();
	var switchTc='/tc/';
	var switchEn='/en/';
	var switchSc='/sc/';
	lang = '/'+lang+'/';

	switch (lang){
		case '/en/':
			currentPath=currentPath.replace(switchTc, switchEn);
			currentPath=currentPath.replace(switchSc, switchEn);
			break;
		case '/tc/':
			currentPath=currentPath.replace(switchEn, switchTc);
			currentPath=currentPath.replace(switchSc, switchTc);
			break;
		case '/sc/':
			currentPath=currentPath.replace(switchEn, switchSc);
			currentPath=currentPath.replace(switchTc, switchSc);
			break;
		default:
	}

	document.location=currentPath;
}

/**
 * ========================================
 *
 * ajax
 * ----------------------------------------
 *
 */

$(window).load(function(){
	$(".preload").fadeOut(500,function(){
		$(this).remove();
		}
	);
	$("#fakeBox").css("visibility","visible");
});

$(function(){
	topMenu();
	
});


function topMenu(){	
	$('menu li').each(function(){
		var subObj = $(this).children('ul');
		subObj.hide();
		
		// Select Internet Explorer 8 or below
		if (jQuery.browser.msie && jQuery.browser.version <= '8.0') {
			$(this).hover(		
				function(){
					subObj.stop(true, true).css({'padding-left':0}).show();
					menuShadow(subObj);
				},
				function(){
					subObj.stop(true, true).hide();
					$(this).find('span').remove();
				}
			);
		}else{
			$(this).hover(		
				function(){
					subObj.stop(true, true).show().animate({'padding-left':0, 'opacity':1},300);
					//subObj.stop(true, true).show('drop',{'direction':'right'},'');
					menuShadow(subObj);
				},
				function(){
					subObj.stop(true, true).hide().css({'padding-left':25, 'opacity':0},300);;
					$(this).find('span').remove();
				}
			);
		}
	})
	
	//	$('menu li li').mouseOver(function(e){
//		e.stopPropagation()
//	})
	
	$('menu li a').bind('click', function(e) {
		e.preventDefault();
	});
	
	$('menu li ul').find('li:eq(0) a').css("borderWidth",0 );
	
	navActiviate();

}

function navActiviate(){
		
	$('.n01').click(function(){
		$('.menu-bar .hl').removeClass('hl');
		$(this).children('a').addClass('hl');
		$('.n01').css('backgroundImage','none');	
		$('.headline.a1').removeClass('a1');
		$('.headline.g1').removeClass('g1');
		$('.headline.h1').removeClass('h1');
		$('.headline.s1').removeClass('s1');
		$('.headline.t1').removeClass('t1');
		$('.headline.v1').removeClass('v1');	
		$('.headline').addClass('a1');
		$('num').html('A1');
	})
	$('.n02').click(function(){
		$('.menu-bar .hl').removeClass('hl');
		$(this).children('a').addClass('hl');
		$('.n01').css('backgroundImage','none');
		$('.headline.a1').removeClass('a1');
		$('.headline.g1').removeClass('g1');
		$('.headline.h1').removeClass('h1');
		$('.headline.s1').removeClass('s1');
		$('.headline.t1').removeClass('t1');
		$('.headline.v1').removeClass('v1');
		$('.headline').addClass('g1');
		$('.num').html('G1');
	})
	$('.n03').click(function(){
		$('.menu-bar .hl').removeClass('hl');
		$(this).children('a').addClass('hl');
		$('.n01').css('backgroundImage','none');
		$('.headline.a1').removeClass('a1');
		$('.headline.g1').removeClass('g1');
		$('.headline.h1').removeClass('h1');
		$('.headline.s1').removeClass('s1');
		$('.headline.t1').removeClass('t1');
		$('.headline.v1').removeClass('v1');
		$('.headline').addClass('h1');
		$('.num').html('H1');
	})
	$('.n04').click(function(){
		$('.menu-bar .hl').removeClass('hl');
		$(this).children('a').addClass('hl');
		$('.n01').css('backgroundImage','none');
		$('.headline.a1').removeClass('a1');
		$('.headline.g1').removeClass('g1');
		$('.headline.h1').removeClass('h1');
		$('.headline.s1').removeClass('s1');
		$('.headline.t1').removeClass('t1');
		$('.headline.v1').removeClass('v1');
		$('.headline').addClass('s1');
		$('.num').html('S1');
	})
	$('.n05').click(function(){
		$('.menu-bar .hl').removeClass('hl');
		$(this).children('a').addClass('hl');
		$('.n01').css('backgroundImage','none');
		$('.headline.a1').removeClass('a1');
		$('.headline.g1').removeClass('g1');
		$('.headline.h1').removeClass('h1');
		$('.headline.s1').removeClass('s1');
		$('.headline.t1').removeClass('t1');
		$('.headline.v1').removeClass('v1');
		$('.headline').addClass('t1');
		$('.num').html('T1');
	})
	$('.n06').click(function(){
		$('.menu-bar .hl').removeClass('hl');
		$(this).children('a').addClass('hl');
		$('.n01').css('backgroundImage','none');
		$('.headline.a1').removeClass('a1');
		$('.headline.g1').removeClass('g1');
		$('.headline.h1').removeClass('h1');
		$('.headline.s1').removeClass('s1');
		$('.headline.t1').removeClass('t1');
		$('.headline.v1').removeClass('v1');
		$('.headline').addClass('v1');
		$('.num').html('V1');
	})
	
	return false;
}

function menuShadow(el){	
	var targetObj = el;
	var subW = targetObj.width();
	var subH = targetObj.height();
	
	targetObj.prepend('<span></span>');
	targetObj.children('span').css({width: subW, height: subH});
	
	return false;	
}


/* Facebook Function */
function fbs_click() {
	u=location.href;
	t=document.title;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}
/* Lung part */
function fb_init(){
	FB.init({
		appId  : '143778822346734',
		status : true, // check login status
		cookie : true, // enable cookies to allow the server to access the session
		xfbml  : true  // parse XFBML
	});
}


function fb_send(name,link,picture,description){

	FB.ui({
		method : 'send',
		display : 'popup',
		app_id : '214994671880352',
		'name' : name,
		'link' : link,
		'picture' : picture,
		'description' : description
	});
}

function register_fb_send(name,link,picture,description){
	$('#display .sharePlay').click(function(e){
		e.preventDefault();
		fb_send(name,link,picture,description);

		$.ajax({ url: "/sharebtn_count.php", type: "GET",  data: "type=house_friend&lang=tc", success: function(msg){
			//Success
		}});	
	});

	$('#display .sharePlay-en').click(function(e){
		e.preventDefault();
		fb_send(name,link,picture,description);

		$.ajax({ url: "/sharebtn_count.php", type: "GET",  data: "type=house_friend&lang=en", success: function(msg){
			//Success
		}});	
	});
}

function si_send(house_name){


	$.ajax({ url: "/sharebtn_count.php", type: "GET",  data: "type=house_friend&lang=sc", success: function(msg){
		//Success
	}});	

	var dd = document.domain;
	//window.open('http://v.t.sina.com.cn/share/share.php?url='+encodeURI('http://'+dd+'/fb_feed/si_'+house_name+'.php','si_sharer','toolbar=0,status=0,width=600,height=400');
	window.open ('http://v.t.sina.com.cn/share/share.php?url='+encodeURI('http://'+dd+'/fb_feed/si_'+house_name+'.php'), 'fb_window', 'height=600, width=900, top=0, left=0, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no');


}

function register_si_send(house_name){

	$('#display .sharePlay-sc').click(function(e){
		e.preventDefault();
		si_send(house_name);
	});
}



function share_to_fb_footer(lang) {

	$.ajax({ url: "/sharebtn_count.php", type: "GET",  data: "type=footer_share&lang="+lang, success: function(msg){
			//Success
		}});
	var dd = document.domain;
	window.open ('http://www.facebook.com/share.php?u=http://'+dd+'/'+lang+'/index.php?hw=2011', 'fb_window', 'height=400, width=400, top=0, left=0, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no');

}

function share_to_fb(lang) {

	var dd = document.domain;
	//window.open ('http://www.facebook.com/share.php?u=http://'+dd+'/'+lang+'/feed/fb_feed.html', 'fb_window', 'height=600, width=900, top=0, left=0, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no');
	window.open ('/share_count.php?type=fb&lang='+lang, 'fb_window', 'height=600, width=900, top=0, left=0, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no');

}
 
function share_to_rr(lang) {
 
	var dd = document.domain;
	//window.open ('http://share.renren.com/share/buttonshare.do?link=http://'+dd+'/'+lang+'/feed/ren_feed.html', 'rr_window', 'height=600, width=900, top=0, left=0, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no');
	window.open ('/share_count.php?type=ren&lang='+lang, 'rr_window', 'height=600, width=900, top=0, left=0, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no');

}
 
function share_to_kx(lang) {

	var dd = document.domain;
	/*
	if(lang == "tc"){
		window.open ('http://www.kaixin001.com/repaste/share.php?rtitle='+encodeURIComponent('海洋公園十月全城哈囉喂2010 - 嚇足你十年 - 十周年全城哈囉喂，十月嚇破膽回歸﹗恐怖地獄之門經已打開，各路遊魂野鬼速速上路﹗')+'&rurl=http://'+dd+'/&rcontent='+encodeURIComponent('十周年全城哈囉喂，十月嚇破膽回歸﹗恐怖地獄之門經已打開，各路遊魂野鬼速速上路﹗'), 'kx_window', 'height=600, width=900, top=0, left=0, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no');
	}else if(lang == "sc"){
		window.open ('http://www.kaixin001.com/repaste/share.php?rtitle='+encodeURIComponent('海洋公园十月全城哈啰喂2010 - 吓您惊心十年 - 十周年全城哈啰喂，十月吓破胆回归！恐怖地域之门已经打开，孤魂野鬼齐出动！')+'&rurl=http://'+dd+'/&rcontent='+encodeURIComponent('十周年全城哈囉喂，十月嚇破膽回歸﹗恐怖地獄之門經已打開，各路遊魂野鬼速速上路﹗'), 'kx_window', 'height=600, width=900, top=0, left=0, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no');
	}else{
		window.open ('http://www.kaixin001.com/repaste/share.php?rtitle='+encodeURIComponent('A Decade of Frights: Ocean Park Halloween Bash 2010 - Frights and misfortune continue for their tenth year at Ocean Park\'s Halloween Bash, where no one can escape the scares and tears! Are you ready to be spooked?')+'&rurl=http://'+dd+'/&rcontent='+encodeURIComponent('十周年全城哈囉喂，十月嚇破膽回歸﹗恐怖地獄之門經已打開，各路遊魂野鬼速速上路﹗'), 'kx_window', 'height=600, width=900, top=0, left=0, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no');
	}
	*/
	window.open ('/share_count.php?type=kx&lang='+lang, 'kx_window', 'height=600, width=900, top=0, left=0, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no');

}

function share_to_tw(lang) {
	/*
	if(lang == "tc"){
		window.open ('http://twitter.com/home?status='+encodeURI('海洋公園十月全城哈囉喂2010 - 嚇足你十年 - 十周年全城哈囉喂，十月嚇破膽回歸﹗恐怖地獄之門經已打開，各路遊魂野鬼速速上路﹗'), 'tw_window', 'height=600, width=900, top=0, left=0, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no');
	}else if(lang == "sc"){
		window.open ('http://twitter.com/home?status='+encodeURI('海洋公园十月全城哈啰喂2010 - 吓您惊心十年 - 十周年全城哈啰喂，十月吓破胆回归！恐怖地域之门已经打开，孤魂野鬼齐出动！'), 'tw_window', 'height=600, width=900, top=0, left=0, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no');
	}else{
		window.open ('http://twitter.com/home?status='+encodeURI('A Decade of Frights: Ocean Park Halloween Bash 2010 - Frights and misfortune continue for their tenth year at Ocean Park\'s Halloween Bash, where no one can escape the scares and tears! Are you ready to be spooked?'), 'tw_window', 'height=600, width=900, top=0, left=0, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no');
	}
	*/
	window.open ('/share_count.php?type=tw&lang='+lang, 'tw_window', 'height=600, width=900, top=0, left=0, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no');

}


function share_to_si(lang) {
 
	var dd = document.domain;
	//window.open ('http://v.t.sina.com.cn/share/share.php?url='+encodeURI('http://'+dd+'/'+lang+'/feed/si_feed.html'), 'si_window', 'height=600, width=900, top=0, left=0, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no');
	window.open ('/share_count.php?type=si&lang='+lang, 'si_window', 'height=600, width=900, top=0, left=0, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no');

}



/* Lung part */







/*       Cookies Control       */
function setCookie(c_name,value,exdays){
	var exdate=new Date();
	exdate.setDate(exdate.getDate() + exdays);
	var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
	document.cookie=c_name + "=" + c_value;
}

function getCookie(c_name){
	var i,x,y,ARRcookies=document.cookie.split(";");
	for (i=0;i<ARRcookies.length;i++){
		x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
		y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
		x=x.replace(/^\s+|\s+$/g,"");
		if (x==c_name){
			return unescape(y);
		}
	}
}












var GoogleAnalytics='UA-24382069-1';
