// 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];}
}


/**
 * ========================================
 *
 * chLang
 * ----------------------------------------
 *
 */
 
function chLang(lang) {
	var currentPath=location.href.toString();
	var switchTc='/tc/';
	var switchEn='/en/';
	lang = '/'+lang+'/';

	switch (lang){
		case '/en/':
			currentPath=currentPath.replace(switchTc, switchEn);
			break;
		case '/tc/':
			currentPath=currentPath.replace(switchEn, switchTc);
			break;
		default:
	}

	document.location=currentPath;
}

/**
 * ========================================
 *
 * Ajax
 * ----------------------------------------
 *
 */
/*
$(document).ready(function(){
	$(".en .liketext").text("Like");
});
*/

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');

}



function post_feed(name, type, lang){

	var dd = document.domain;
	var caption		= "";
	var msg			= "";
	var title		= "";
	//var description = "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789";
	var description = "";
	var imgsrc		= "http://"+dd+"/images/fb/ghost"+type+".jpg";
	var hrefTitle	= "ophw2010";
	var hrefLink	= "http://"+dd;
	var userPrompt	= "";

	if(lang == "en"){
		switch(type){
			
			case 1:
				title		= name+" spooked some ghosts at the Halloween Bash website!";
				caption = "Rainy nights and scaredy cats are a bad mix. Beware of the fierce ghost that might tear you apart!";
				break;
			case 2:
				title		= name+" spooked some ghosts at the Halloween Bash website!";
				caption = "Wait for crazy funeral staff to cover your coffin and experience the last journey of your life!";
				break;				
			case 3:
				title		= name+" spooked some ghosts at the Halloween Bash website!";
				caption = "Vampire are dying to bite you this Halloween! Party up a storm with them till dawn!";
				break;
			case 4:
				title		= name+" spooked some ghosts at the Halloween Bash website!";
				caption = "Save lost souls in Terror Park!";
				break;
			case 5:
				title		= name+" spooked some ghosts at the Halloween Bash website!";
				caption = "Attacked by zombies? Come join the battle to exterminate them all!";
				break;
			case 6:
				title		= name+" spooked some ghosts at the Halloween Bash website!";
				caption = "Learn everything about curses at our wizard academy!";
				break;	
			case 7:
				title		= name+" spooked some ghosts at the Halloween Bash website!";
				caption = "Learn everything about curses at our wizard academy!";
				break;
			case 8:
				title		= name+" spooked some ghosts at the Halloween Bash website!";
				caption = "Visit the Horror Museum to review 10 years of classic ghost stories!";
				break;				
			default:
				title		= name+" spooked some ghosts at the Halloween Bash website!";
				caption = "Rainy nights and scaredy cats are a bad mix. Beware of the fierce ghost that might tear you apart!";
				break;

		}

	}else if(lang == "sc"){

		switch(type){
			
			case 1:
				title		= name+" 在海洋公园「十月全城哈罗喂」网站見鬼！";
				caption = "下雨夜，心慌慌，哈啰喂烈鬼给你碰上！！";
				break;
			case 2:
				title		= name+" 在海洋公园「十月全城哈罗喂」网站見鬼！";
				caption = "疯狂殓葬师会为您盖棺，讓您在哈囉喂感受人生最后一程！";
				break;				
			case 3:
				title		= name+" 在海洋公园「十月全城哈罗喂」网站見鬼！";
				caption = "嗜血僵尸蠢蠢欲动，在哈囉喂與你勁舞狂歡！";
				break;
			case 4:
				title		= name+" 在海洋公园「十月全城哈罗喂」网站見鬼！";
				caption = "哈囉喂誠邀您成為幽靈遊樂園的陰間守護者！";
				break;
			case 5:
				title		= name+" 在海洋公园「十月全城哈罗喂」网站見鬼！";
				caption = "被喪屍伏撃！立即來哈囉喂將喪屍逐一歼灭！";
				break;
			case 6:
				title		= name+" 在海洋公园「十月全城哈罗喂」网站見鬼！";
				caption = "巫术通晓，來哈囉喂您便會馬上通通知曉！";
				break;	
			case 7:
				title		= name+" 在海洋公园「十月全城哈罗喂」网站見鬼！";
				caption = "巫术通晓，來哈囉喂您便會馬上通通知曉！";
				break;
			case 8:
				title		= name+" 在海洋公园「十月全城哈罗喂」网站見鬼！";
				caption = "来哈啰喂博物馆看 “鬼展”，众多厉鬼将会延续过去10年的经典鬼故事！";
				break;				
			default:
				title		= name+" 在海洋公园「十月全城哈罗喂」网站見鬼！";
				caption = "下雨夜，心慌慌，哈啰喂烈鬼给你碰上！！";
				break;

		}

	}else{

		switch(type){
			
			case 1:
				title		= name+" 響哈囉喂網站撞鬼！";
				caption = "落雨夜，心慌慌，哈囉喂猛鬼等你撞！";
				break;
			case 2:
				title		= name+" 響哈囉喂網站撞鬼！";
				caption = "瘋狂殮葬員會為你蓋棺，比你喺哈囉喂感受人生最後一程！";
				break;				
			case 3:
				title		= name+" 響哈囉喂網站撞鬼！";
				caption = "嗜血彊屍蠢蠢欲動，喺哈囉喂同你勁舞狂歡！";
				break;
			case 4:
				title		= name+" 響哈囉喂網站撞鬼！";
				caption = "哈囉喂誠邀你成為幽靈遊樂園的陰間守護者！";
				break;
			case 5:
				title		= name+" 響哈囉喂網站撞鬼！";
				caption = "被喪屍伏撃！快啲嚟哈囉喂打返場反撃戰！";
				break;
			case 6:
				title		= name+" 響哈囉喂網站撞鬼！";
				caption = "巫術通識，嚟哈囉喂就可以好快通通學識！";
				break;	
			case 7:
				title		= name+" 響哈囉喂網站撞鬼！";
				caption = "巫術通識，嚟哈囉喂就可以好快通通學識！";
				break;
			case 8:
				title		= name+" 響哈囉喂網站撞鬼！";
				caption = "來哈囉喂博物館睇「鬼展」，一眾魔dol將會延續過去10年的經典鬼故！";
				break;				
			default:
				title		= name+" 響哈囉喂網站撞鬼！";
				caption = "落雨夜，心慌慌，哈囉喂猛鬼等你撞！";
				break;

		}

	}

	streamPublish(caption, msg, title, description, imgsrc, hrefTitle, hrefLink, userPrompt);

}


/**
 * ========================================
 *
 * redirect link to #hash at URL
 * ----------------------------------------
 *
 */
  
function updateURL() {

	var url = location.href.toString();
	var hash = location.hash.toString();

	var lang = new Array("/tc", "/sc", "/en");
	var validPath = new Array("main", "admission", "event-period", "food", "gift", "house-burned", "house-guangzhou", "house-magic", "house-museum", "house-pang", "house-park", "house-show", "house-vampire", "house-zombie", "index", "intro", "opening", "ticket-price", "ticket-type");

	if(hash) {

		for(var i=0; i<lang.length; i++) {
			if(url.match(lang[i])) {
				var n = url.indexOf(lang[i]);
				var urlPath = url.substring(0, n+3) + "/";
				break;
			} else {
				urlPath = "http://" + location.hostname + "/tc/";
			}
		}
		for(var j=0; j<validPath.length; j++) {
			if(hash.match(validPath[j])) {
				var urlPage = validPath[j] + ".php#/"+validPath[j];
				break;
			} else {
				var urlPage = "";
			}
		}

		location.replace(urlPath + urlPage);

		return false;
	}else{
		var urlPage = "";
		for(var i=0; i<lang.length; i++) {
			if(url.match(lang[i])) {
				var n = url.indexOf(lang[i]);
				var urlPath = url.substring(0, n+3) + "/";
				break;
			} else {
				urlPath = "http://" + location.hostname + "/tc/";
			}
		}

		for(var j=0; j<validPath.length; j++) {

			if(url.match(validPath[j])) {
				urlPage += validPath[j] + ".php#/"+validPath[j];
				break;
			}

		}	

		if(urlPage == ""){
			urlPage = "index.php";
		}

		location.replace(urlPath + urlPage);

		return false;
	}
	return true;
}
if (location.href.toString() != "http://www.halloweenbash.com.hk/" && location.href.toString() != "http://halloweenbash.com.hk/")
{
	updateURL();
}