﻿
///month list
var monthname = new Array;
monthname[1] = "January";
monthname[2] = "February";
monthname[3] = "March";
monthname[4] = "April";
monthname[5] = "May";
monthname[6] = "June";
monthname[7] = "July";
monthname[8] = "August";
monthname[9] = "Septmeber";
monthname[10] = "October";
monthname[11] = "November";
monthname[12] = "December";

var countrycode = new Array("AF","AL","DZ","AS","AD","AO","AI","AQ","AG","AR","AM","AW","AU","AT","AZ","BS","BH","BD","BB","BY","BE","BZ","BJ","BM","BT","BO","BA","BW","BV","BR","IO","BN","BG","BF","BI","KH","CM","CA","CV","KY","CF","TD","CL","CN","CX","CC","CO","KM","CG","CK","CR","CI","HR","CU","CY","CZ","CD","DK","DJ","DM","DO","TP","EC","EG","SV","GQ","ER","EE","ET","FK","FO","FJ","FI","FR","GF","PF","TF","GA","GM","GE","DE","GH","GI","GR","GL","GD","GP","GU","GT","GW","GN","GY","HT","HM","HN","HK","HU","IS","IN","ID","IR","IQ","IE","IL","IT","JM","JP","JO","KZ","KE","KI","KR","KW","KG","LA","LV","LB","LS","LR","LY","LI","LT","LU","MO","MK","MG","MW","MY","MV","ML","MT","MH","MQ","MR","MU","YT","MX","FM","MD","MC","MN","MS","MA","MZ","MM","NA","NR","NP","NL","AN","NC","NZ","NI","NE","NG","NU","NF","MP","NO","OM","PK","PW","PA","PG","PY","PE","PH","PN","PL","PT","PR","QA","RE","RO","RU","RW","KN","LC","VC","WS","SM","ST","SA","SN","SC","SL","SG","SK","SI","SB","SO","ZA","GS","ES","LK","SH","PM","SD","SR","SJ","SZ","SE","CH","SY","TW","TJ","TZ","TH","TG","TK","TO","TT","TN","TR","TM","TC","TV","UG","UA","AE","UK","US","UM","UY","UZ","VU","VA","VE","VN","VG","VI","WF","EH","YE","YU","ZM","ZW");
var countryname = new Array("阿富汗","阿爾巴尼亞","阿爾及利亞 ","美洲薩摩亞","安道爾","安哥拉","鰻鱺屬","南極州","安地卡及巴布達","阿根廷 ","亞美尼亞","阿魯巴 ","澳洲","奧地利 ","阿塞拜疆","巴哈馬 ","巴林","孟加拉國 ","巴布達","白俄羅斯","比利時","伯利茲 ","比寧","百慕大 ","不丹","玻利維亞 ","波士尼亞和黑塞哥維那","博茨瓦納","布韋群島 ","巴西","英屬印度洋領地","英屬維爾斯群島 ","保加利亞","布荃納法索","布隆迪 ","柬埔寨","卡麥隆 ","加拿大","佛得角 ","開曼群島","中非共和國","乍得","智利","中國內地","聖誕島","椰樹海島","哥倫比亞","科摩羅","剛果","庫克群島","格斯達里加","科特迪瓦 ","克羅地亞","古巴 ","塞浦路斯","捷克 ","剛果民主共和國","丹麥 ","吉布地","多米尼克 ","多米尼加共和國","東帝汶","厄瓜多爾","埃及","薩爾瓦多","赤道幾內亞","厄立特里亞 ","愛沙尼亞","埃塞俄比亞","福克蘭群島 ","法羅島","斐濟 ","芬蘭","法國 ","法屬圭亞那","法屬波利尼西亞","法國屬地 ","加蓬","岡比亞 ","佐治亞","德國 ","迦納","直布羅陀 ","希臘","格陵蘭 ","格瑞那達","瓜德羅普島","關島","危地馬拉","幾內亞- 比紹","基尼","圭亞那 ","海地","聽見的海島和麥當勞海島","洪都拉斯 ","香港","匈牙利","冰島 ","印度","印度尼西亞 ","伊朗","伊拉克 ","愛爾蘭","以色列 ","意大利","牙買加 ","日本","喬丹 ","卡扎克斯坦","肯尼亞","基里巴斯","韓國","科威特","吉爾吉斯坦","老撾","拉脫維亞","黎巴嫩","賴索托","利比里亞","利比亞","列支敦斯登 ","立陶宛","盧森堡 ","澳門","馬其頓, 前南斯拉夫的共和國","馬達加斯加","馬拉維","馬來西亞","馬爾地夫","馬里","馬耳他","馬紹爾群島 ","馬提尼克島","毛里塔尼亞","毛里求斯 ","馬約特","墨西哥 ","密克羅西亞島","摩爾多瓦","摩納哥","蒙古","蒙的塞拉特","摩洛哥","莫桑比克","緬甸","納米比亞","瑙魯","尼泊爾","荷蘭","荷蘭屬地","新卡里多尼亞","紐西蘭 ","尼加拉瓜","尼日爾 ","尼日利亞","尼烏埃島","諾福克島 ","北馬力安那群島","挪威","阿曼","巴基斯坦","帛流","巴拿馬","巴布亞紐幾內亞 ","巴拉圭","秘魯 ","菲律賓","皮特克恩島","波蘭","葡萄牙","波多里哥","卡塔爾","留尼旺島","羅馬尼亞","俄國","盧安達","聖基茨和尼維斯 ","聖盧西亞","聖文森特和格林納丁斯","薩摩亞 ","聖馬利諾","聖多美島和普林西比島","沙地阿拉伯 ","塞內加爾","塞舌爾群島","塞阿里昂 ","新加坡","斯洛伐克 ","斯洛文尼亞","索羅門群島","索馬里 ","南非","南佐治亞和南桑威奇島","西班牙 ","斯里南卡","聖海倫娜","聖皮耳","蘇丹","蘇里南","凡帝","斯威士蘭","瑞典","瑞士","敘利亞","臺灣","塔吉克斯坦","坦桑尼亞 ","泰國","多哥 ","麻城","湯加 ","特立尼達和多巴哥","突尼斯","土耳其","土庫曼","特克斯和凱克斯群島 ","吐瓦魯","烏干達 ","烏克蘭","阿拉伯聯合酋長國","英國 ","美國","聯合國群島 ","烏拉圭","烏茲別克斯坦","萬那杜 ","焚蒂岡城","委內瑞拉","越南","唯爾京群島（英國）","唯爾京群島（美國）","未島 ","西薩哈拉","也門 ","南斯拉夫","贊比亞 "," 津巴布韋");

var Cgoto = "";
var ourInterval = "";
var pagegoto = "top";

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];}
}

// for tch only
function changeLang(newlang) {
 var lang="tch";
 var currURL = ""+document.location;
 var newURL = currURL;
 var match = baseurl;
 var match2 = "lang="+lang;
 if (currURL.match(match2)) {
	newURL = eval("currURL.replace(/" + match2 + "/, \"lang=" + newlang + "\")");
  }
  else if (currURL.match(match)) {
	newURL = currURL.replace(match, baseurl +  "\/" +  newlang);
  }
  document.location = newURL;
}

function digitoption(start, end, defaultdigit) {
	var out = "";
	var i,j;
	for(i = start; i <= end; i++) {
		j = i;
		if(j < 10) {
			j = '0' + j;
		}
		if(i == defaultdigit) {
			out += "<option value='" + j  + "' selected>" + i + "</option>";
		}
		else {
			out += "<option value='" + j  + "'>" + i + "</option>";
		}
	}
	return out;
}

function changebackwin(url) {

	if (opener && !opener.closed) {
		opener.location.href = url;
		opener.focus();
	}
	else {
		homewin = window.open(url,'homewin','top=0, left=0,width=800,toolbar=yes,location=yes,menubar=yes,scrollbars=yes,status=yes,resizable=yes');
		homewin.focus();
	}
	return;
}

function checkvaliddate(chkyear, chkmth, chkday) {
	var chkdate = chkyear + "" + chkmth  + "" + chkday;
	var nowdate   = new Date();
	var nowmth = nowdate.getMonth() + 1;

	if(nowmth < 10) {
		nowmth = "0" + nowmth;
	}
	var nowday = nowdate.getDate();
	if(nowday < 10) {
		nowday = "0" + nowday;
	}
	var fullnowdate = nowdate.getFullYear() + "" + nowmth + "" + nowday;
	if(chkdate > fullnowdate) {
		return false;
	}
	else {
		var validdate = new Date(chkyear, chkmth - 1, chkday ,0 ,0 ,0 ,0);
		var validmth = validdate.getMonth() + 1;
		if(validmth < 10) {
			validmth = "0" + validmth;
		}
		var validday = validdate.getDate();
		if(validday < 10) {
			validday = "0" + validday;
		}
		var fullvaliddate = validdate.getFullYear() + "" + validmth + "" + validday;
		if(fullvaliddate != chkdate) {
			return false;
		}
	}
	return true;
}

function opentandc() {
	var mypage = "realpeople_tnc.html"
	var myname="winpop";
	var w=420;
	var h=500;
	var scroll = 'YES';

	if(document.all){
		// IE
		winl = self.screenLeft+170;
		wint = self.screenTop;
	}else{
		// NN
		winl = self.screenX+175;
		wint = self.screenY;
	}


	winprops = 'screenX='+winl+',screenY='+wint+',left='+winl+',top='+wint+',height='+h+',width='+w+',scrollbars='+scroll+',status=YES';
	if(document.all)
  	   win = window.open(mypage, myname, winprops)
	else
  	   win = window.open(mypage, myname, winprops)

        if ( self.name == '' )
           self.name = 'hoinpa';

        win.openerName = self.name;

	if (parseInt(navigator.appVersion) >= 4) { win.focus(); }

	return;
}


function showpagelist(curpage) {

    var prevbut = "";
    var nextbut = "";
    var out = "";
    var nextlist = 5;
    var prevpage, nextpage = 0;
	
    var endpage = 0;
	var showpageid = 0;
    for(i = totalpage; i >= 1; i = i - nextlist) {
    	if(curpage <= i && curpage > i - nextlist) {	
    		prevpage = i + 1;
    		prevbut = "<a href='javascript:gotopage("+ prevpage +")'><img src='images/realpeople/re_left_arrow.gif' width=6 height=10 border=0></a>";

    		nextpage = i - nextlist;
    		nextbut = "<a href='javascript:gotopage("+ nextpage +")'><img src='images/realpeople/re_right_arrow.gif' width=6 height=10 border=0></a>";
    		
			endpage = nextpage +  1;
    		for(j = i; j >= endpage; j--) {
				showpageid = totalpage - j + 1;
    			if(j ==  curpage) {
    				 out += "<B>" + showpageid + "</b>&nbsp;&nbsp;";
    			}
				else if(j < 1) {
    				 out += "&nbsp;&nbsp;&nbsp;&nbsp;";
				}
    			else {
    				 out += "<a href='javascript:gotopage("+j+")' class=toptxt>" + showpageid + "</a>&nbsp;&nbsp;";
    			}
    		}
    		i = 1;
    	}
    }
    if(prevpage > totalpage) {
	   prevbut = "<img src='images/shim.gif' width=6 height=10 border=0>";
    }
    if(nextpage <= 0) {
    	nextbut = "<img src='images/shim.gif' width=6 height=10 border=0>";
    }
	showpageid = totalpage - curpage + 1;
    var pdiv = document.getElementById("pagelist");
    pdiv.innerHTML = "";
	pdiv.innerHTML += "第 " + showpageid + " 頁，共 " + totalpage + " 頁";
    pdiv.innerHTML += "&nbsp;&nbsp;&nbsp;&nbsp;" + prevbut;
    pdiv.innerHTML += "&nbsp;&nbsp;" + out;
    pdiv.innerHTML += "&nbsp;&nbsp;" + nextbut;
    return;
}

function curpagehtml(pageid) {
	var temp = eval("page" + pageid);
	var out = "<table cellpadding=2 cellspacing=0 border=0 width=475>";
	for(i=0; i < temp.length; i++) {
		out += "<tr>";
		out += storylisthtml(temp[i]);
		out += "</tr>";
		out += "<tr><td colspan=2><img src='images/shim.gif' height=5 border=0></td></tr>";
		out += "<tr><td colspan=2 background='images/realpeople/re_purple_dotline.gif' height=2 border=0></td></tr>";
		out += "<tr><td colspan=2><img src='images/shim.gif' height=5 border=0></td></tr>";
	}
	out += "</table>";
	return out;
}

function storylisthtml(storyid) {
	var out = "";
	var showphoto = "";
	var colspantd = "colspan=2";
	var temp = eval(storyid);
	if(temp[6]) {
		showphoto = "<td valign=top align=right><img src='" + baseurl + "/realpeople/photo/" + temp[6] + "' width=196 border=0 hspace=2></td>";
		colspantd = "";
	}
	out += "<td valign=top " + colspantd + " >";
	if(Cgoto == temp[9]) {
		out += "<a name=gohere></a>";
		pagegoto = "gohere";
	}
	out += "<b>" + temp[0] + "</b>";
	if(temp[5]) {
		for(var x = 0; x < countrycode.length; x++) {
			if(temp[5] == countrycode[x]) {
				out += " 來自<b>" + countryname[x] + "</b>";
				x = countrycode.length;
			}
		}
	}
	out += "<br>";
	out += "於 <b>" + temp[1] + "年" + temp[2] + "月" + temp[3] + "日</b> 暢遊樂園";
	out += "<br><img src='images/shim.gif' width=1 height=3 border=0><br>";
	out += temp[4];
	out += "</td>";
	out += showphoto;
	return out;
}

function gotopage(curpage) {
	var currURL = ""+document.location;
	pagegoto = "top";
	var tempary = new Array;
	var tempstoryary = new Array;
	if(Cgoto == "") {
		var result = currURL.match(/\?(\w+)$/);
		if(result != null) {
			//check what page
			for(p = 1; p <= totalpage; p++) {
				tempary = eval("page" + p);
				for(s = 0; s < tempary.length; s++) {
					//alert(tempary[s]);
					tempstoryary = eval(tempary[s]);
					if(tempstoryary[9] == result[1]) {
						Cgoto = result[1];
						curpage = p;
						s = tempary.length + 1;
						p = totalpage + 1;
					}
				}
			}
		}
	}
	else {
		Cgoto = "-";
	}
	showpagelist(curpage);
	if(viewframe.baseurl == baseurl) {
	var out = curpagehtml(curpage);
    		var sdiv = viewframe.document.getElementById("storylist");
		sdiv.innerHTML = out;
		viewframe.location = "realpeople_view_content.html#" + pagegoto;
	}
	else {
		ourInterval = setInterval("viewframegoto('" + curpage + "')", 1000);
	}
}


function viewframegoto(curpage) {
	//for first time loading
	if(viewframe.baseurl == baseurl) {
		var out = curpagehtml(curpage);
    		var sdiv = viewframe.document.getElementById("storylist");
		sdiv.innerHTML = out;
		viewframe.location = "realpeople_view_content.html#" + pagegoto;
		clearInterval(ourInterval);
	}
}

function openWPsample() {
	WPsamplewin = window.open(baseurl + '/discover/realpeople_wallpaper_sample.html','WPsamplewin','width=529,height=494,toolbar=false,scrollbars=no,menubar=no,status=false,location=no,resizable=no');
	return;
}

function openwallpaper(url) {
	WPwin = window.open(url,'WPwin','width=800,height=600,toolbar=false,scrollbars=yes,menubar=no,status=false,location=no,resizable=no');
	return;
}


function addpulldown(mthid) {
	var arcidary = ["latest","201111","201110","201109","201108","201107","201106","201105","201104","201103","201102","201101","201012","201011","201010","201009","201008","201007","201006","201005","201004","201003","201002","201001","200912","200911","200910","200909","200908","200907","200906","200905","200904","200903","200902","200901","200812","200811","200810","200809","200808","200807","200806","200805","200804","200803","200802","200801","200712","200711","200710","200709","200708","200707","200706","200705","200704","200703","200702","200701","200612","200611","200610","200609","200608","200607","200606","200605","200604","200603","200602","200601","200512","200511","200510"];
	var arcnameary = ["最近上載的分享","2011年11月的分享","2011年10月的分享","2011年9月的分享","2011年8月的分享","2011年7月的分享","2011年6月的分享","2011年5月的分享","2011年4月的分享","2011年3月的分享","2011年2月的分享","2011年1月的分享","2010年12月的分享","2010年11月的分享","2010年10月的分享","2010年9月的分享","2010年8月的分享","2010年7月的分享","2010年6月的分享","2010年5月的分享","2010年4月的分享","2010年3月的分享","2010年2月的分享","2010年1月的分享","2009年12月的分享","2009年11月的分享","2009年10月的分享","2009年9月的分享","2009年8月的分享","2009年7月的分享","2009年6月的分享","2009年5月的分享","2009年4月的分享","2009年3月的分享","2009年2月的分享","2009年1月的分享","2008年12月的分享","2008年11月的分享","2008年10月的分享","2008年9月的分享","2008年8月的分享","2008年7月的分享","2008年6月的分享","2008年5月的分享","2008年4月的分享","2008年3月的分享","2008年2月的分享","2008年1月的分享","2007年12月的分享","2007年11月的分享","2007年10月的分享","2007年9月的分享","2007年8月的分享","2007年7月的分享","2007年6月的分享","2007年5月的分享","2007年4月的分享","2007年3月的分享","2007年2月的分享","2007年1月的分享","2006年12月的分享","2006年11月的分享","2006年10月的分享","2006年9月的分享","2006年8月的分享","2006年7月的分享","2006年6月的分享","2006年5月的分享","2006年4月的分享","2006年3月的分享","2006年2月的分享","2006年1月的分享","2005年12月的分享","2005年11月的分享","2005年10月的分享"];
	var arcurlary = ["realpeople_view.html","realpeople_view_201111.html","realpeople_view_201110.html","realpeople_view_201109.html","realpeople_view_201108.html","realpeople_view_201107.html","realpeople_view_201106.html","realpeople_view_201105.html","realpeople_view_201104.html","realpeople_view_201103.html","realpeople_view_201102.html","realpeople_view_201101.html","realpeople_view_201012.html","realpeople_view_201011.html","realpeople_view_201010.html","realpeople_view_201009.html","realpeople_view_201008.html","realpeople_view_201007.html","realpeople_view_201006.html","realpeople_view_201005.html","realpeople_view_201004.html","realpeople_view_201003.html","realpeople_view_201002.html","realpeople_view_201001.html","realpeople_view_200912.html","realpeople_view_200911.html","realpeople_view_200910.html","realpeople_view_200909.html","realpeople_view_200908.html","realpeople_view_200907.html","realpeople_view_200906.html","realpeople_view_200905.html","realpeople_view_200904.html","realpeople_view_200903.html","realpeople_view_200902.html","realpeople_view_200901.html","realpeople_view_200812.html","realpeople_view_200811.html","realpeople_view_200810.html","realpeople_view_200809.html","realpeople_view_200808.html","realpeople_view_200807.html","realpeople_view_200806.html","realpeople_view_200805.html","realpeople_view_200804.html","realpeople_view_200803.html","realpeople_view_200802.html","realpeople_view_200801.html","realpeople_view_200712.html","realpeople_view_200711.html","realpeople_view_200710.html","realpeople_view_200709.html","realpeople_view_200708.html","realpeople_view_200707.html","realpeople_view_200706.html","realpeople_view_200705.html","realpeople_view_200704.html","realpeople_view_200703.html","realpeople_view_200702.html","realpeople_view_200701.html","realpeople_view_200612.html","realpeople_view_200611.html","realpeople_view_200610.html","realpeople_view_200609.html","realpeople_view_200608.html","realpeople_view_200607.html","realpeople_view_200606.html","realpeople_view_200605.html","realpeople_view_200604.html","realpeople_view_200603.html","realpeople_view_200602.html","realpeople_view_200601.html","realpeople_view_200512.html","realpeople_view_200511.html","realpeople_view_200510.html"];

	var i,j =0;
	//document.clipform.moreclip.options[0] = new Option("更多回覆","",true,true);
	for(i=0; i <= arcidary.length;i++) {
		document.clipform.moreclip.options[i] = new Option(arcnameary[i],arcurlary[i],true,true);
		if (arcidary[i] == mthid) {
			j = i;
		}

	}
	document.clipform.moreclip.options.length= i - 1;
	document.clipform.moreclip.selectedIndex = j;
	//document.clipform.moreclip.selectedIndex = 0;
}
