var servlet_path = 'http://www.myweb2s.com/tool/servlet/';
var guestbook_path = 'http://www.myweb2s.com/tool/';

function showHide(id, act) {
	(act == 'H') ? act = 'none' : act = 'block';
	if (document.all) {
		document.all['reply'+id].style.display = act;
	} else {
		//document.getElementById(element).style.visibility="hidden";
		document.getElementById('reply'+id).style.display = act;
	}
}

function popUp(url) {
	aWindow = window.open(url, '', 'toolbar=no,width=250,height=150,status=no,scrollbars=no,resizable=no,menubar=no');
	aWindow.focus();
}

function popUp2(url) {
	aWindow = window.open(url,'','toolbar=no,width=250,height=250,status=no,scrollbars=yes,resizable=yes,menubar=no');
	aWindow.focus();
}

function popUp3(url,w,h) {
	aWindow = window.open(url,'','toolbar=no,width='+w+',height='+h+',status=no,scrollbars=yes,resizable=yes,menubar=no');
	aWindow.focus();
}

function showUserField(type) {
	popUp3(servlet_path + 'ShowUserField?id=' + guestbook_id + '&type=' + type, 250, 250);
}

function showMessageAmount() {
	popUp3(servlet_path + 'ShowAmount?id=' + guestbook_id, 600, 450);
}

function administration() {
	var url = servlet_path + 'MemLogin?did=GUESTBOOK-' + guestbook_id;
	aWindow = window.open(url, '', '');
	aWindow.focus();
}

function login() {
	popUp3(servlet_path + 'GbAdmin?act=login&id=' + guestbook_id, 475, 170);
}

function logout() {
	location.href = servlet_path + 'GuestbookAdd?act=logout&id=' + guestbook_id;
}

function deleteMessage() {
	popUp3(servlet_path + 'GbAdmin?act=delete&id=' + guestbook_id, 475, 170);
}

function reply(parent_id) {
	location.href = guestbook_path + 'Guestbook?id=' + guestbook_id + '&parent_id=' + parent_id;
}

function setCookie() {
	gb = document.InputForm;
	var expire = new Date();
	expire.setTime(expire.getTime() + 31536000000);
	for (count = 0; count < field.length; count++) {	
		document.cookie = field[count] + "=" + escape(gb[field[count]].value) + "; path=/; expires=" + expire.toGMTString();
	}
}

function getCookie() {
//	alert(document.cookie);
	gb = document.InputForm;
	var coco = document.cookie;
	for (count = 0; count < field.length; count++) {
		begin = coco.indexOf(field[count] + "=");
		if (begin > -1) {
			begin += field[count].length + 1;
			end = coco.indexOf(";", begin);
			if (end < 0) end = coco.length;
			val = unescape(coco.substring(begin, end));
			if (gb[field[count]]) {
				if (field[count] == "photo" || field[count] == "font_color" || 
				    field[count] == "frame_color" || field[count] == "bg_image") {
					// select field
					for (i = 0; i < gb[field[count]].options.length; i++) {
						if (gb[field[count]].options[i].value == val) {
							gb[field[count]].options[i].selected = true;
						}
					}
				} else {
					gb[field[count]].value = val;
				}
			}
		}
	}
}

function copyright() {
	//document.write('<p>Powered by <a href="http://www.myweb2s.com" target="_blank">MyWeb2s</a>');
	document.write('Powered by <a href="http://www.myweb2s.com" target="_blank">MyWeb2s</a>');
}