var cur_room = 0;
var new_num = 0;
var tt_new;
var promote_num = 0;
var t_promote;

function pkm_img(img){var p=window.createPopup();var pbody=p.document.body;pbody.style.backgroundcolor="#FFFFFF";pbody.style.border="3px ridge #7BBDEF";pbody.innerHTML='<img border="0" width="400" height="400" src="'+img+'">';p.show(180,80,400,400,document.body);}
function show_sec(sel_con, n_list){for(i = 0; i < n_list; i++){document.getElementById("content_"+i).style.display = 'none';document.getElementById("section_"+i).style.border = 'none';document.getElementById("section_"+i).style.background = 'none';}document.getElementById("content_"+sel_con).style.display = '';document.getElementById("section_"+sel_con).style.border = "1px solid #E0E0E0";document.getElementById("section_"+sel_con).style.background = "url('/images/grd1px.gif') repeat-x 0 -178px";}
function s_page(n_page){for(i = 0; i < n_page; i++){num = i+1;if(i == cur_room){num = '<font color="#FF0000"><b>'+num+'</b></font>';}document.getElementById("page_"+i).innerHTML = num;}}
function get_today_stone(wday){for(i = 0; i < 7; i++){document.getElementById("week_"+i).style.display = "none";}document.getElementById("week_"+wday).style.display = "";}
function prev_room(n_room, n_list){--cur_room;cur_room = cur_room < 0 ? (n_room - 1) : cur_room;for(i = 0; i < n_room; i++){document.getElementById("show_room_"+i).style.display = 'none';}document.getElementById("show_room_"+cur_room).style.display = '';show_con = cur_room*4;all_list = n_list;show_sec(show_con,all_list);all_room = n_room;s_page(all_room);}
function next_room(n_room, n_list){++cur_room;cur_room = cur_room == n_room ? 0 : cur_room;for(i = 0; i < n_room; i++){document.getElementById("show_room_"+i).style.display = 'none';}	document.getElementById("show_room_"+cur_room).style.display = '';show_con = cur_room*4;all_list = n_list;show_sec(show_con,all_list);all_room = n_room;s_page(all_room);}
function get_show_room(num_room, num_list){all_list = num_list;for(i = 0; i < num_room; i++){document.getElementById("show_room_"+i).style.display = 'none';}document.getElementById("show_room_0").style.display = '';show_sec(0,all_list);n_page = num_room;s_page(n_page);}
function file_open(num,n_file){for(i = 0; i < n_file; i++){document.getElementById("file_content_"+i).style.display = 'none';document.getElementById("file_"+i).style.borderBottomColor = '#A5C3DB';document.getElementById("file_"+i).style.borderLeftColor = '#D4E4F0';document.getElementById("file_"+i).style.borderTopColor = '#D4E4F0';document.getElementById("file_"+i).style.fontWeight = 'normal';document.getElementById("file_"+i).style.backgroundImage = "url('/images/grd1px.gif')";	document.getElementById("file_"+i).style.backgroundPosition = "0px -232px";document.getElementById("file_"+i).style.backgroundRepeat = "repeat-x";if(i == (n_file -1)){document.getElementById("file_"+i).style.borderRightColor = '#D4E4F0';}}document.getElementById("file_content_"+num).style.display = '';document.getElementById("file_"+num).style.borderBottomColor = '#FFFFFF';document.getElementById("file_"+num).style.borderLeftColor = '#A5C3DB';document.getElementById("file_"+num).style.borderTopColor = '#A5C3DB';if(num < (n_file - 1)){	document.getElementById("file_"+(num+1)).style.borderLeftColor = '#A5C3DB';}else{document.getElementById("file_"+num).style.borderRightColor = '#A5C3DB';}document.getElementById("file_"+num).style.fontWeight = 'Bold';document.getElementById("file_"+num).style.backgroundImage = "url('/images/grd1px.gif')";document.getElementById("file_"+num).style.backgroundPosition = "0px -178px";document.getElementById("file_"+num).style.backgroundRepeat = "repeat-x";}
function open_cart(request,num_code){if(!num_code){num_code='';}if(navigator.cookieEnabled){is_enable = 'xQCgvYLmPxmLBp6qE8';}else{is_enable = 'QcgvYmLpx';}if(request == 'view'){NewWin = window.open('/cgi-bin/cart.cgi?req=view&flg=1&ck='+is_enable, 'NewWin', 'width=450,height=450,scrollbars=yes');}else{window.location.href="/cgi-bin/cart.cgi?req="+request+"&ck="+is_enable+"&code="+num_code;}}
function get_stones(get_where){if(get_where > 0){window.location.href="http://www.pongkaam.com/cgi-bin/stone.cgi?type=stones&stone="+get_where;}}
function open_tab_prod(prod_num, all_prod){
	for(i = 1; i <= all_prod; i++){
		document.getElementById("content_prod"+i).style.display="none";
		document.getElementById("content_prod").style.marginTop = "0px";
		if(i == 2){
				document.getElementById("tab_prod"+i).style.borderRight = "1px  solid #a5c3db";
		}
		document.getElementById("tab_prod"+i).style.borderLeft = "1px  solid #a5c3db";
		document.getElementById("tab_prod"+i).style.borderTop = "1px  solid #a5c3db";
		document.getElementById("tab_prod"+i).style.borderBottom = "1px  solid #a5c3db";
		document.getElementById("tab_prod"+i).style.backgroundPosition = "0px -230px";
		document.getElementById("tab_prod"+i).style.fontWeight = "normal";
		document.getElementById("tab_prod"+i).style.paddingBottom = "4px";
	}
	document.getElementById("tab_prod"+prod_num).style.borderLeft = "1px solid #34688c";
	document.getElementById("tab_prod"+prod_num).style.borderTop = "1px solid #34688c";
	document.getElementById("tab_prod"+prod_num).style.borderBottom = "1px solid #ffffff";
	document.getElementById("tab_prod"+prod_num).style.backgroundPosition = "0px -178px";
	document.getElementById("tab_prod"+prod_num).style.fontWeight = "bold";
	if(prod_num == 2){
			document.getElementById("tab_prod"+prod_num).style.borderRight = "1px  solid #34688c";
	}else{
			document.getElementById("tab_prod"+(prod_num+1)).style.borderLeft = "1px  solid #34688c";
	}
	switch_tab = prod_num == 1 ? 2 : 1;
	document.getElementById("tab_prod"+switch_tab).style.borderBottom = "1px  solid #34688c";
	document.getElementById("tab_prod"+prod_num).style.paddingBottom = "5px";
	document.getElementById("content_prod").style.marginTop = "-1px";
	document.getElementById("content_prod"+prod_num).style.display="";	
}

function open_tab(tab_num, all_tab){
	num_tab = all_tab;
	close_tab_now(num_tab);
	document.getElementById("tab"+tab_num).style.borderLeft = "1px solid #34688c";
	document.getElementById("tab"+tab_num).style.borderTop = "1px solid #34688c";
	document.getElementById("tab"+tab_num).style.borderBottom = "1px solid #ffffff";
	document.getElementById("tab"+tab_num).style.backgroundPosition = "0px -178px";
	document.getElementById("tab"+tab_num).style.fontWeight = "bold";
	if(tab_num == 3 || tab_num == 6){
		document.getElementById("tab"+tab_num).style.borderRight = "1px  solid #34688c";
	}else{
		document.getElementById("tab"+(tab_num+1)).style.borderLeft = "1px  solid #34688c";
	}
	min_tab = 4;
	max_tab = 6;
	if(tab_num <= 3){
		min_tab = 1;
		max_tab = 3;
	}
	for(i = min_tab; i <= max_tab; i++){
		if(i < tab_num || i > tab_num){
			document.getElementById("tab"+i).style.borderBottom = "1px  solid #34688c";
		}
	}
		
	this_content = "contentbot";
	if(tab_num <= 3){
		this_content = "contenttop";
	}
	document.getElementById("tab"+tab_num).style.paddingBottom = "5px";
	document.getElementById(this_content).style.marginTop = "-1px";
	document.getElementById("content"+tab_num).style.display="";
}

	var enable_close = 0;

	function set_close(){
		if(enable_close == 1){
			clearTimeout(t);
			enable_close = 0;
		}
	}

	function close_tab(){
		t = setTimeout("close_tab_now(6);", 4000);
		enable_close = 1;
	}

	function close_tab_now(num){
		for(i = 1; i <= num; i++){
			document.getElementById("content"+i).style.display="none";
			document.getElementById("contenttop").style.marginTop = "0px";
			document.getElementById("contentbot").style.marginTop = "0px";
			if(i == 3 || i == 6){
				document.getElementById("tab"+i).style.borderRight = "1px  solid #a5c3db";
			}
			document.getElementById("tab"+i).style.borderLeft = "1px  solid #a5c3db";
			document.getElementById("tab"+i).style.borderTop = "1px  solid #a5c3db";
			document.getElementById("tab"+i).style.borderBottom = "1px  solid #a5c3db";
			document.getElementById("tab"+i).style.backgroundPosition = "0px -230px";
			document.getElementById("tab"+i).style.fontWeight = "normal";
			document.getElementById("tab"+i).style.paddingBottom = "4px";
		}		
	}


function open_promote(win,all_win){
	for(i = 0; i < all_win; i++){
		document.getElementById("promote"+i).style.display = "none";
	}
	document.getElementById("promote"+win).style.display = "";
	++promote_num;
	win_all = all_win;
	if(promote_num >= all_win){
		promote_num = 0;
	}
	if(win_all > 1){
		cur_show = win+1;
		document.getElementById("current_show").innerHTML = cur_show;
		for(i = 0; i < win_all; i++){
			cur_win = i+1;
			if(i == win){
				cur_win = '<font color="#ff0000">' + cur_win + '</font>';
			}
			document.getElementById("page"+i).innerHTML = cur_win;
		}
		t_promote = setTimeout("open_promote(promote_num,win_all);", 10000);
	}
}

function stop_promote(num){
	if(num > 1){
		clearTimeout(t_promote);
	}
}

function start_promote(num){
	if(num > 1){
		all_win = num;
		t_promote = setTimeout("open_promote(promote_num,all_win);", 10000);
	}
}

function prev_promote(num){
	clearTimeout(t_promote);
	cur_num = parseInt(document.getElementById("current_show").innerHTML);
	num_win = num;
	--cur_num;
	if(cur_num < 1){
		cur_num = num;
	}
	promote_num = cur_num - 1;
	open_promote(promote_num,num_win);
}

function next_promote(num){
	clearTimeout(t_promote);
	num_win = num;
	open_promote(promote_num,num_win);
}



function open_new(win,all_win2){
	for(i = 0; i < all_win2; i++){
		document.getElementById("new_prod"+i).style.display = "none";
	}
	document.getElementById("new_prod"+win).style.display = "";
	++new_num;
	win_all2 = all_win2;
	if(new_num >= all_win2){
		new_num = 0;
	}
	if(win_all2 > 1){
		cur_shows = win+1;
		document.getElementById("current_new").innerHTML = cur_shows;
		for(i = 0; i < win_all2; i++){
			cur_wins = i+1;
			if(i == win){
				cur_wins = '<font color="#ff0000">' + cur_wins + '</font>';
			}
			document.getElementById("new_page"+i).innerHTML = cur_wins;
		}
		tt_new = setTimeout("open_new(new_num,win_all2);", 10000);
	}
}

function stop_new(num){
	if(num > 1){
		clearTimeout(tt_new);
	}
}

function start_new(num){
	if(num > 1){
		all_win1 = num;
		tt_new = setTimeout("open_new(new_num,all_win1);", 10000);
	}
}

function prev_new(num){
	clearTimeout(tt_new);
	cur_num = parseInt(document.getElementById("current_new").innerHTML);
	num_win = num;
	--cur_num;
	if(cur_num < 1){
		cur_num = num;
	}
	new_num = cur_num - 1;
	open_new(new_num,num_win);
}

function next_new(num){
	clearTimeout(tt_new);
	num_win1 = num;
	open_new(new_num,num_win1);
}

function show_help(this_help){
	document.getElementById(this_help).style.position="absolute";
	document.getElementById(this_help).style.left=event.clientX+20;
	document.getElementById(this_help).style.top=event.clientY;
	document.getElementById(this_help).style.display="";
}
	
function hide_help(last_help){
	document.getElementById(last_help).style.display="none";
}
