var bName = navigator.appName;
var bVer = parseInt(navigator.appVersion);
var bet = new Date;
var cardWindow = false;
var pcWindow = false;

pcgo = 0;

gbimagdir = "/images/guestbook/";

image1= new Image();
image1.src = gbimagdir + "00.gif";
image2= new Image();
image2.src = gbimagdir + "01.gif";
image3= new Image();
image3.src = gbimagdir + "02.gif";
image4= new Image();
image4.src = gbimagdir + "03.gif";
image5= new Image();
image5.src = gbimagdir + "04.gif";
image6= new Image();
image6.src = gbimagdir + "05.gif";
image7= new Image();
image7.src = gbimagdir + "06.gif";
image8= new Image();
image8.src = gbimagdir + "07.gif";
image9= new Image();
image9.src = gbimagdir + "08.gif";
image10= new Image();
image10.src = gbimagdir + "09.gif";
image11= new Image();
image11.src = gbimagdir + "10.gif";

function checkBrowser() {
	//if (bName == "Microsoft Internet Explorer" && bVer >= 4) { bCond = 0; }
	//else if (bName == "Netscape" && bVer >= 5) { bCond = 0; }
	//else  { bCond = 1; }
	//if (bCond == 1) { top.location = "/browser.shtml"; }
}

function showTime() {
	var NDate = new Date;
	bet.setTime(NDate.getTime() - now.getTime());
	RLTime();
}

function addZero(num) {
	if (num < 10) {
	num = "0" + num;
	}
	return num;
}

function addFavorite(url, name) {
	window.external.AddFavorite(url, name);
}

function navigate(form)	{
	var go = (form.linkList.options[form.linkList.selectedIndex].value);
	document.location.href = go;
}

function imgchange() {
	var imageNum = document.gbform.gbimage.selectedIndex + 1;
	document.img.src = eval("image" + imageNum + ".src");
}

function openWin_ors(url, width, height) {
	gWindow = window.open("http://www.ferryhalim.com/orisinal/games/" + url + ".htm", "", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=" + width + ", height=" + height);
	gWindow.focus();
}

function openWin_fh(url, width, height) {
	gWindow = window.open("http://www.ferryhalim.com/" + url, "", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=" + width + ", height=" + height);
	gWindow.focus();
}

function openWin_wp64(title, url) {
	if ((screen.availWidth > 640) && (screen.availHeight > 480)) {
	winWidth = 640;
	winHeight = 480;
	condt = "no";
	}
	else {
	winWidth = screen.availWidth - 50;
	winHeight = screen.availHeight - 50;
	condt = "yes";
	}
	wpWindow = window.open("/wallpaper/loading.html", "", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=" + condt + ", resizable=no, left=0, top=0, width=" + winWidth + ", height=" + winHeight);
	wpWindow.document.write("<html><head><title>CM Zone - Wallpaper - 640 x 480</title></head><body style='margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px;'><img src='/wallpaper/640_480/" + title + "/" + url + ".jpg'></body></html>");
	wpWindow.focus();
}

function openWin_wp86(title, url) {
	if ((screen.availWidth > 800) && (screen.availHeight > 600)) {
	winWidth = 800;
	winHeight = 600;
	condt = "no";
	}
	else {
	winWidth = screen.availWidth - 50;
	winHeight = screen.availHeight - 50;
	condt = "yes";
	}
	wpWindow = window.open("/wallpaper/loading.html", "", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=" + condt + ", resizable=no, left=0, top=0, width=" + winWidth + ", height=" + winHeight);
	wpWindow.document.write("<html><head><title>CM Zone - Wallpaper - 800 x 600</title></head><body style='margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px;'><img src='/wallpaper/800_600/" + title + "/" + url + ".jpg'></body></html>");
	wpWindow.focus();
}

function openWin_wp17(title, url) {
	if ((screen.availWidth > 1024) && (screen.availHeight > 768)) {
	winWidth = 1024;
	winHeight = 768;
	condt = "no";
	}
	else {
	winWidth = screen.availWidth - 50;
	winHeight = screen.availHeight - 50;
	condt = "yes";
	}
	wpWindow = window.open("/wallpaper/loading.html", "", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=" + condt + ", resizable=no, left=0, top=0, width=" + winWidth + ", height=" + winHeight);
	wpWindow.document.write("<html><head><title>CM Zone - Wallpaper - 1024 x 768</title></head><body style='margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px;'><img src='/wallpaper/1024_768/" + title + "/" + url + ".jpg'></body></html>");
	wpWindow.focus();
}

function openWin_wp11(title, url) {
	if ((screen.availWidth > 1280) && (screen.availHeight > 1024)) {
	winWidth = 1280;
	winHeight = 1024;
	condt = "no";
	}
	else {
	winWidth = screen.availWidth - 50;
	winHeight = screen.availHeight - 50;
	condt = "yes";
	}
	wpWindow = window.open("/wallpaper/loading.html", "", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=" + condt + ", resizable=no, left=0, top=0, width=" + winWidth + ", height=" + winHeight);
	wpWindow.document.write("<html><head><title>CM Zone - Wallpaper - 1280 x 1024</title></head><body style='margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px;'><img src='/wallpaper/1280_1024/" + title + "/" + url + ".jpg'></body></html>");
	wpWindow.focus();
}

function openWin_pcj(title, card) {
	cardWindow = window.open("/postcard/card.html", "", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=400, height=300");
	cardWindow.document.write("<html><head><title>CM Zone - Card</title></head><body style='margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px;'><a onClick='self.close()'><img src='/postcard/cards/jpg/" + title + "/" + card + ".jpg'></a></body></html>");
	cardWindow.focus();
}

function openWin_pcg(title, card) {
	cardWindow = window.open("/postcard/card.html", "", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=400, height=300");
	cardWindow.document.write("<html><head><title>CM Zone - Card</title></head><body style='margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px;'><a onClick='self.close()'><img src='/postcard/cards/gif/" + title + "/"  + card + ".gif'></a></body></html>");
	cardWindow.focus();
}

function openWin_pcf(title, card) {
	cardWindow = window.open("/postcard/card.html", "", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=400, height=300");
	cardWindow.document.write("<html><head><title>CM Zone - Card</title></head><body style='margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px;'><OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0' ID=intro WIDTH=770 HEIGHT=400><PARAM NAME=movie VALUE='/postcard/cards/swf/" + title + "/"  + card + ".swf'> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#0066CC> <EMBED src='/postcard/cards/swf/" + title + "/"  + card + ".swf' quality=high bgcolor=#0066CC WIDTH=770 HEIGHT=400 TYPE='application/x-shockwave-flash' PLUGINSPAGE='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'></EMBED></OBJECT></body></html>");
	cardWindow.focus();
}

function postcard(form)	{
	var go = (form.pcmidi.options[form.pcmidi.selectedIndex].value);
	pcgo = go;
}

function ignore_error() {
	cardWindow=false;
	pcWindow=false;
	return true;
}

function close_pcWin() {
	if (cardWindow) {
	cardWindow.close();
	cardWindow=false;
	}
	if (pcWindow) {
	pcWindow.close();
	pcWindow=false;
	}
}

function pcplay() {
	if (pcgo == '0') {
	alert('¨S ¦³ ­µ ¼Ö');
	}
	else {
	pcWindow = window.open("/postcard/loading.html", "playmidi", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=130, height=30");
	pcWindow.document.write("<html><head><title>CM Zone</title></head><body><embed src='/postcard/midi/" + pcgo + ".mid' type='audio/midi' loop='0' autostart='true' height='0' width='0'><noembed><bgsound src='/postcard/midi/" + pcgo + ".mid' loop='infinite'></noembed><font face='Arial' size='2'>Playing ...... <br><br><a href='javascript:self.close()'>Stop</a></font></body></html>");
	}
	pcWindow.focus();
}

function pcdl() {
	if (pcgo == '0') {
	alert('¨S ¦³ ­µ ¼Ö');
	}
	else {
	self.location = "/postcard/midi/" + pcgo + ".mid";
	}
}

function RLTime() {
	var NDate = new Date;
	now.setTime(NDate.getTime() - bet.getTime());

	if (now.getHours() == 0 && now.getMinutes() == 0 && now.getSeconds() == 0) {
	realTime = addZero(now.getHours() + 12) + ":" + addZero(now.getMinutes()) + ":" + addZero(now.getSeconds()) + " AM" ;
	location.reload();
	}

	else if (now.getHours() > 12) {
	realTime = addZero(now.getHours() - 12) + ":" + addZero(now.getMinutes()) + ":" + addZero(now.getSeconds()) + " PM";
	}

	else if (now.getHours() == 12) {
	realTime = addZero(now.getHours()) + ":" + addZero(now.getMinutes()) + ":" + addZero(now.getSeconds()) + " PM";
	}

	else if (now.getHours() == 0) {
	realTime = addZero(now.getHours() + 12) + ":" + addZero(now.getMinutes()) + ":" + addZero(now.getSeconds()) + " AM";
	}

	else {
	realTime = addZero(now.getHours()) + ":" + addZero(now.getMinutes()) + ":" + addZero(now.getSeconds()) + " AM";
	}
	document.all["liveTime"].innerHTML = realTime;
	setTimeout("RLTime()",1000);
}

function searchcheck() {
	if(document.searchengine.query.value=='') {
	alert('½Ð ¿é ¤J ·j ´M ¦r ¦ê !');
	return false;
	}
}

function pcdatacheck() {
	if(document.pcform.fridname.value=='') {
	alert('½Ð ¿é ¤J ¦¬ ¥ó ªÌ ªº ¦W ¦r !');
	return false;
	}
	else if(document.pcform.fridemail.value=='') {
	alert('½Ð ¿é ¤J ¦¬ ¥ó ªÌ ªº ¹q ¶l ¦a §} !');
	return false;
	}
	else if(document.pcform.fridemail.value!='' && (document.pcform.fridemail.value.indexOf('@',1)<0 || document.pcform.fridemail.value.indexOf('.',3)<0)) {
	alert('½Ð ¿é ¤J ¦³ ®Ä ªº ¹q ¶l ¦a §} !');
	return false;
	}
	else if(document.pcform.name.value=='') {
	alert('½Ð ¿é ¤J §A ªº ¦W ¦r !');
	return false;
	}
	else if(document.pcform.email.value=='') {
	alert('½Ð ¿é ¤J §A ªº ¹q ¶l ¦a §} !');
	return false;
	}
	else if(document.pcform.email.value!='' && (document.pcform.email.value.indexOf('@',1)<0 || document.pcform.email.value.indexOf('.',3)<0)) {
	alert('½Ð ¿é ¤J ¦³ ®Ä ªº ¹q ¶l ¦a §} !');
	return false;
	}
	else if(document.pcform.content.value=='') {
	alert('½Ð ¿é ¤J ¶P ¥d ¤º ®e !');
	return false;
	}
}

function pcreaddatacheck() {
	if(document.pcreadform.pcnum.value=='' || isNaN(document.pcreadform.pcnum.value)){
	alert('½Ð ¿é ¤J ¥¿ ½T ªº ¶P ¥d ¥N ½X ¡C');
	return false;
	}
}

function gbdatacheck() {
	if(document.gbform.name.value=='') {
	alert('½Ð ¿é ¤J §A ªº ¦W ¦r !');
	return false;
	}
	else if(document.gbform.age.value!='' && (isNaN(document.gbform.age.value) || (document.gbform.age.value<0 || document.gbform.age.value>100))){
	alert('½Ð ¿é ¤J ¥¿ ½T ªº ¦~ ÄÖ !\n\n¦p ªG ¤£ ·Q §i ª¾ ¡A ½Ð ¯d ªÅ ¦¹ ¶µ ¡C');
	return false;
	}
	else if(document.gbform.comefrom.value=='') {
	alert('½Ð ¿é ¤J §A ¬O ¨Ó ¦Û ­þ ùØ !');
	return false;
	}
	else if((document.gbform.url.value!='http://' && document.gbform.url.value!='') && (document.gbform.url.value.indexOf('http://',0)<0 || document.gbform.url.value.indexOf('.',8)<0)) {
	alert('½Ð ¿é ¤J ¦³ ®Ä ªº ºô ­¶ URL !\n\n¦p ªG ¨S ¦³ ¡A ½Ð ¯d ªÅ ¦¹ ¶µ ¡C');
	return false;
	}
	else if(document.gbform.email.value!='' && (document.gbform.email.value.indexOf('@',1)<0 || document.gbform.email.value.indexOf('.',3)<0)) {
	alert('½Ð ¿é ¤J ¦³ ®Ä ªº ¹q ¶l ¦a §} !\n\n¦p ªG ¨S ¦³ ¡A ½Ð ¯d ªÅ ¦¹ ¶µ ¡C');
	return false;
	}
	else if(document.gbform.icquin.value!='' && (isNaN(document.gbform.icquin.value) || document.gbform.icquin.value<1001)){
	alert('½Ð ¿é ¤J ¥¿ ½T ªº ICQ UIN !\n\n¦p ªG ¨S ¦³ ¡A ½Ð ¯d ªÅ ¦¹ ¶µ ¡C');
	return false;
	}
	else if(gbform.gbmark.options[gbform.gbmark.selectedIndex].value=='0') {
	alert('½Ð µ¹ ¥» ºô ¯¸ µû ¤À !');
	return false;
	}
	else if(document.gbform.comment.value=='') {
	alert('½Ð ¿é ¤J §A ªº ¯d ¨¥ !');
	return false;
	}
}

function cmdatacheck() {
	if(document.cmform.name.value=='') {
	alert('½Ð ¿é ¤J §A ªº ¦W ¦r !');
	return false;
	}
	else if(document.cmform.email.value=='') {
	alert('½Ð ¿é ¤J §A ªº ¹q ¶l ¦a §} !');
	return false;
	}
	else if(document.cmform.email.value!='' && (document.cmform.email.value.indexOf('@',1)<0 || document.cmform.email.value.indexOf('.',3)<0)) {
	alert('½Ð ¿é ¤J ¦³ ®Ä ªº ¹q ¶l ¦a §} !');
	return false;
	}
	else if(document.cmform.icquin.value!='' && (isNaN(document.cmform.icquin.value) || document.cmform.icquin.value<1001)){
	alert('½Ð ¿é ¤J ¥¿ ½T ªº ICQ UIN !\n\n¦p ªG ¨S ¦³ ¡A ½Ð ¯d ªÅ ¦¹ ¶µ ¡C');
	return false;
	}
	else if(document.cmform.suggestion.value=='') {
	alert('½Ð ¿é ¤J §A ªº ·N ¨£ !');
	return false;
	}
}

function friddatacheck() {
	if(document.fridform.fridname.value=='') {
	alert('½Ð ¿é ¤J ¦n ¤Í ªº ¦W ¦r !');
	return false;
	}
	else if(document.fridform.fridemail.value=='') {
	alert('½Ð ¿é ¤J ¦n ¤Í ªº ¹q ¶l ¦a §} !');
	return false;
	}
	else if(document.fridform.fridemail.value!='' && (document.fridform.fridemail.value.indexOf('@',1)<0 || document.fridform.fridemail.value.indexOf('.',3)<0)) {
	alert('½Ð ¿é ¤J ¦³ ®Ä ªº ¹q ¶l ¦a §} !');
	return false;
	}
	else if(document.fridform.name.value=='') {
	alert('½Ð ¿é ¤J §A ªº ¦W ¦r !');
	return false;
	}
	else if(document.fridform.email.value=='') {
	alert('½Ð ¿é ¤J §A ªº ¹q ¶l ¦a §} !');
	return false;
	}
	else if(document.fridform.email.value!='' && (document.fridform.email.value.indexOf('@',1)<0 || document.fridform.email.value.indexOf('.',3)<0)) {
	alert('½Ð ¿é ¤J ¦³ ®Ä ªº ¹q ¶l ¦a §} !');
	return false;
	}
}

function showFill() {
	if(document.all) {
		msgfridname=document.fridform.fridname.value;
		msgname=document.fridform.name.value;
		document.fridform.content.value="<" + msgfridname + "> §A¦n¡A§Ú¬O <" + msgname + ">¡C§Ú­n§iª¾§A¤@­Óºô¯¸ - CM Zone (http://cmzone.mcy.info)¡C³o­Óºô¯¸¦³®à¥¬¤U¸ü¡B°Q½×²á¤Ñ¡B¹q¤l¶P¥d¡Bºô¯¸·j´M¡B§K¶O¸ê·½...(ÁÙ¦³«Ü¦h³á!)¯uªº«Ü¥¿°Ú! §ÖÂI¨ì CM Zone - http://cmzone.mcy.info ¬Ý¬Ý§a!";
	}
	var timer=setTimeout("showFill()",300);
}
