// Start XmlHttp Object

function uzXmlHttp()
{
			var xmlhttp = false;
			try
			{
						xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch(e)
			{
						try
						{
								xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
						}
						catch(e)
						{
								xmlhttp = false;
						}
			}
		 
			if(!xmlhttp && document.createElement)
			{
					xmlhttp = new XMLHttpRequest();
			}
		
			return xmlhttp;
}
// End XmlHttp Object

function sponsor_retrieve(type) // type : 1 - check onBlur, 2 - check onSubmit
{ //alert('retrieve in');
			//alert(signmsgTxt);
			var sponsorcode 		= document.areaselect_form.inviter_code.value;

			var url = prefixNormalLink + 'sponsor_retrieve.php';
			xmlhttp = uzXmlHttp();
			xmlhttp.open("POST", url, true);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
			//alert(sponsorcode);
			//alert(xmlhttp.responseText);
			xmlhttp.onreadystatechange = function()
			{
				if(xmlhttp.readyState == 3)  // Loading Request
				{
						document.getElementById('sponsor_name').style.display = 'block';
						document.getElementById('sponsor_name').innerHTML = '<div align="center"><img src="' + preload_img + '" width="' + preloadSmallWidth + '" height="' + preloadSmallHeight + '" border="0"></div>';
				}
				if(xmlhttp.readyState == 4)  // Return Request
				{
						document.getElementById('sponsor_name').style.display = 'block';
						document.getElementById('sponsor_name').innerHTML = xmlhttp.responseText;
				}
			}
			xmlhttp.send("sponsorcode=" + sponsorcode + '&type=' + type);
			//document.getElementById('sponsor_name').style.display='block';
			//alert('Shop status saved');

			//eval(xmlhttp.responseText);
 //alert('delete out real');
}

function chat_period_refresh(isOnLoad) // isOnLoad = 1 load page first time must refresh all chat section
{
		//alert('in');
 		if (isOnLoad == 1)
			chat_message_manage(3);
		else
			chat_message_manage(2);
		//alert('in2');
		setTimeout("chat_period_refresh(0)",20000);
}

function chat_message_manage(type) // type : postmessage = 1, refresh = 2, onPageLoad refresh = 3
{			//alert(type);
			if (type == 1)
			{
				sname 		= document.chat_form.sendername.value;
				message  	= document.chat_form.sendermsg.value;
				//alert(sname);
				//alert(message);
				var url = prefixNormalLink + 'chat_message_management.php?sname=' + encodeURIComponent(sname) + '&message=' + encodeURIComponent(message) + '&type=' + type;
			}
			else if (type == 2)
			{
				//alert("in type 2");
				var url = prefixNormalLink + 'chat_message_management.php?type=' + type;
			}
			else if (type == 3)
			{
				//alert("in type 3");
				var url = prefixNormalLink + 'chat_message_management.php?type=' + type;
			}

			xmlhttp_chat = uzXmlHttp();
			xmlhttp_chat.open("GET", url, true);
			xmlhttp_chat.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );

			//alert(xmlhttp_chat.responseText);
			//eval(xmlhttp_chat.responseText);
			//document.getElementById('custshop_display').style.display='none';
			xmlhttp_chat.onreadystatechange = function()
			{
				if(xmlhttp_chat.readyState == 3)  // Loading Request
				{
						document.getElementById('send_msg_type2').innerHTML = '<div align="center"><br><br><br><img src="' + preload_img + '" width="' + preloadNormalWidth + '" height="' + preloadNormalHeight + '" border="0"></div>';
				}
				if(xmlhttp_chat.readyState == 4)  // Return Request
				{
						if (type == 1)
						{
							//alert(sname);
							//alert(message);
								document.getElementById('all_chatmsg_id').innerHTML = xmlhttp_chat.responseText;
						}
						else if (type == 2)
						{
								document.getElementById('send_msg_type2').innerHTML = xmlhttp_chat.responseText;
						}
						else if (type == 3)
						{
								document.getElementById('all_chatmsg_id').innerHTML = xmlhttp_chat.responseText;
						}
				}
			}
			xmlhttp_chat.send(null);
}

function product_stat_manage(type, prodid, oldvalue) // type : new = 3, update = 4, hot = 5
{			//alert("in");
			var url = prefixNormalLink + 'product_stat_management.php?type=' + type + '&prodid=' + prodid + '&oldvalue=' + oldvalue;

			xmlhttp = uzXmlHttp();
			xmlhttp.open("GET", url, false);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
			xmlhttp.send(null);

			//alert(xmlhttp.responseText);
			eval(xmlhttp.responseText);
			//document.getElementById('custshop_display').style.display='none';
			//document.getElementById('cont_shop').innerHTML = xmlhttp.responseText;
}

function group_stat_manage(type, groupid, oldvalue) // type : new = 3, update = 4, hot = 5
{			//alert("in");
			var url = prefixNormalLink + 'group_stat_management.php?type=' + type + '&groupid=' + groupid + '&oldvalue=' + oldvalue;

			xmlhttp = uzXmlHttp();
			xmlhttp.open("GET", url, false);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
			xmlhttp.send(null);

			//alert(xmlhttp.responseText);
			eval(xmlhttp.responseText);
			//document.getElementById('custshop_display').style.display='none';
			//document.getElementById('cont_shop').innerHTML = xmlhttp.responseText;
}

function contower_search_item_list(shopfloornow, shopdisplay, displaytype, type) // type = 2 --> display item
{			
			//alert("item list in");
			// displaytype search = 1, listall = 2;
			var searchkeyword = document.shopsearch_form.shopsearch_form_txt.value;

			if (displaytype == 1)
				var url = prefixNormalLink + 'control_towershop_display_aj.php?shopfloornow=' + shopfloornow + '&shopdisplay=' + shopdisplay + '&displaytype=' + displaytype + '&searchkeyword=' + searchkeyword + '&type=' + type;
			else if (displaytype == 2)
				var url = prefixNormalLink + 'control_towershop_display_aj.php?shopfloornow=' + shopfloornow + '&shopdisplay=' + shopdisplay + '&displaytype=' + displaytype + '&type=' + type;
			else if (displaytype == 3 || displaytype == 4 || displaytype == 5)
				var url = prefixNormalLink + 'control_towershop_display_aj.php?shopfloornow=' + shopfloornow + '&shopdisplay=' + shopdisplay + '&displaytype=' + displaytype + '&type=' + type;

			xmlhttp = uzXmlHttp();
			xmlhttp.open("GET", url, true);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
			//alert(xmlhttp.responseText);
			//document.getElementById('custshop_display').style.display='none';
			xmlhttp.onreadystatechange = function()
			{
				if(xmlhttp.readyState == 3)  // Loading Request
				{
						document.getElementById('cont_shop').innerHTML = '<div align="center"><br><br><br>' + spacepreload_store + '<img src="' + preload_img + '" width="' + preloadNormalWidth + '" height="' + preloadNormalHeight + '" border="0"></div>';
				}
				if(xmlhttp.readyState == 4)  // Return Request
				{
						document.getElementById('cont_shop').innerHTML = xmlhttp.responseText;
				}
			}
			xmlhttp.send(null);	
}

function cont_search_item_list(shopfloornow, shopdisplay, displaytype, type) // type = 2 --> display item
{			
			// alert("item list in");
			// displaytype search = 1, listall = 2, new = 3, update = 4, hot = 5
			var searchkeyword = document.shopsearch_form.shopsearch_form_txt.value;

			if (displaytype == 1)
				var url = prefixNormalLink + 'control_shop_display.php?shopfloornow=' + shopfloornow + '&shopdisplay=' + shopdisplay + '&displaytype=' + displaytype + '&searchkeyword=' + searchkeyword + '&type=' + type;
			else if (displaytype == 2)
				var url = prefixNormalLink + 'control_shop_display.php?shopfloornow=' + shopfloornow + '&shopdisplay=' + shopdisplay + '&displaytype=' + displaytype + '&type=' + type;
			else if (displaytype == 3 || displaytype == 4 || displaytype == 5)
				var url = prefixNormalLink + 'control_shop_display.php?shopfloornow=' + shopfloornow + '&shopdisplay=' + shopdisplay + '&displaytype=' + displaytype + '&type=' + type;

			xmlhttp = uzXmlHttp();
			xmlhttp.open("GET", url, true);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
			//alert(xmlhttp.responseText);
			//document.getElementById('custshop_display').style.display='none';
			xmlhttp.onreadystatechange = function()
			{
				if(xmlhttp.readyState == 3)  // Loading Request
				{
						document.getElementById('cont_shop').innerHTML = '<div align="center"><br><br><br>' + spacepreload_store + '<img src="' + preload_img + '" width="' + preloadNormalWidth + '" height="' + preloadNormalHeight + '" border="0"></div>';
				}
				if(xmlhttp.readyState == 4)  // Return Request
				{
						document.getElementById('cont_shop').innerHTML = xmlhttp.responseText;
				}
			}
			
			xmlhttp.send(null);
}

function cust_search_item_list(shopfloornow, shopdisplay, displaytype)
{			
			//alert("item list in");
			// displaytype search = 1, listall = 2;
			var searchkeyword = document.shopsearch_form.shopsearch_form_txt.value;

			if (displaytype == 1)
				var url = prefixNormalLink + 'shopping_towershop_itemgroupselect.php?shopfloornow=' + shopfloornow + '&shopdisplay=' + shopdisplay + '&displaytype=' + displaytype + '&searchkeyword=' + searchkeyword;
			else if (displaytype == 2)
				var url = prefixNormalLink + 'shopping_towershop_itemgroupselect.php?shopfloornow=' + shopfloornow + '&shopdisplay=' + shopdisplay + '&displaytype=' + displaytype;
			else if (displaytype == 3 || displaytype == 4 || displaytype == 5)
				var url = prefixNormalLink + 'shopping_towershop_itemgroupselect.php?shopfloornow=' + shopfloornow + '&shopdisplay=' + shopdisplay + '&displaytype=' + displaytype;

			xmlhttp = uzXmlHttp();
			xmlhttp.open("GET", url, true);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
			//alert(xmlhttp.responseText);
			//document.getElementById('custshop_display').style.display='none';
			
			xmlhttp.onreadystatechange = function()
			{
				if(xmlhttp.readyState == 3)  // Loading Request
				{
						document.getElementById('custshop_display').innerHTML = '<div align="center"><br><br><br>' + spacepreload_store + '<img src="' + preload_img + '" width="' + preloadNormalWidth + '" height="' + preloadNormalHeight + '" border="0"></div>';
				}
				if(xmlhttp.readyState == 4)  // Return Request
				{
						document.getElementById('custshop_display').innerHTML = xmlhttp.responseText;
				}
			}
			xmlhttp.send(null);
}

function update_article_view_onLoad(artid) // onClick currently not in use
{ //alert('update in' + artid);
			//alert(signmsgTxt);

			var url = prefixNormalLink + 'update_article_view.php';
			xmlhttp = uzXmlHttp();
			xmlhttp.open("POST", url, false);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
			xmlhttp.send("artid=" + artid);

			//alert('Shop status saved');
			//eval(xmlhttp.responseText);
 //alert('delete out real');
}

function update_article_view(artid) // onClick currently not in use
{ //alert('update in' + artid);
			//alert(signmsgTxt);
/*
			var url = prefixNormalLink + 'update_article_view.php';
			xmlhttp = uzXmlHttp();
			xmlhttp.open("POST", url, false);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
			xmlhttp.send("artid=" + artid);
*/
			//alert('Shop status saved');
			//eval(xmlhttp.responseText);
 //alert('delete out real');
}

function update_topic_view_onLoad(msgid)  // onPageLoad
{ //alert('update in' + msgid);
			//alert(signmsgTxt);

			var url = prefixNormalLink + 'update_topic_view.php';
			xmlhttp = uzXmlHttp();
			xmlhttp.open("POST", url, false);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
			xmlhttp.send("msgid=" + msgid);
			//alert('Shop status saved');
			//eval(xmlhttp.responseText);

 //alert('delete out real');
}

function update_topic_view(msgid) // onClick currently not in use
{ //alert('update in' + msgid);
			//alert(signmsgTxt);
/*
			var url = prefixNormalLink + 'update_topic_view.php';
			xmlhttp = uzXmlHttp();
			xmlhttp.open("POST", url, false);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
			xmlhttp.send("msgid=" + msgid);
			//alert('Shop status saved');
			//eval(xmlhttp.responseText);
*/
 //alert('delete out real');
}

function file_banner_remove(fieldType)
{ //alert('delete in');
			//alert(signmsgTxt);
			var url = prefixNormalLink + 'file_banner_remove.php';
			xmlhttp = uzXmlHttp();
			xmlhttp.open("POST", url, false);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
			xmlhttp.send("fieldType=" + fieldType);
			//alert('Shop status saved');
			eval(xmlhttp.responseText);
 //alert('delete out real');
}

function file_trust_remove(accUrl, filepathname, fieldType)
{ //alert('delete in');
			//alert(signmsgTxt);
			var url = prefixNormalLink + 'file_trust_remove.php';
			xmlhttp = uzXmlHttp();
			xmlhttp.open("POST", url, false);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
			xmlhttp.send("accUrl=" + accUrl + "&filepathname=" + filepathname + "&fieldType=" + fieldType);
			//alert('Shop status saved');
			eval(xmlhttp.responseText);
 //alert('delete out real');
}

function file_cpn_remove(userId, filepathname, fieldType)
{ //alert('delete in');
			//alert(signmsgTxt);
			var url = prefixNormalLink + 'file_cpn_remove.php';
			xmlhttp = uzXmlHttp();
			xmlhttp.open("POST", url, false);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
			xmlhttp.send("userId=" + userId + "&filepathname=" + filepathname + "&fieldType=" + fieldType);
			//alert('Shop status saved');
			eval(xmlhttp.responseText);
 //alert('delete out real');
}

function update_shopstatusmsg(userId, type)
{ //alert('delete in');
			if (type == 1)
					var signmsgTxt = document.getElementById('signmsgTxt').value;
			else
					var signmsgTxt = document.getElementById('signmsgTxt2').value;
			//alert(signmsgTxt);
			var url = prefixNormalLink + 'shopstatupdate.php';
			xmlhttp = uzXmlHttp();
			xmlhttp.open("POST", url, false);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
			xmlhttp.send("signmsgTxt=" + signmsgTxt + "&userId=" + userId);

			alert('Shop status saved');
			//alert(xmlhttp.responseText);
 //alert('delete out real');
}

// ######################## Search item ############################ //

function consprod_delete(cspid)
{ //alert('delete in');
			var passcode = document.getElementById('passcode_ent').value;
			var url = prefixNormalLink + 'index_consprod_management.php';
			xmlhttp = uzXmlHttp();
			xmlhttp.open("POST", url, false);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
			xmlhttp.send("cspid=" + cspid + "&passcode=" + passcode);
 //alert('delete out');
			//alert(xmlhttp.responseText);
			eval(xmlhttp.responseText);
 //alert('delete out real');
}

function passcode_form_display(cspid)
{
			document.getElementById('passcode_check_delete_form').innerHTML = '<table border="0" width="400" cellspacing="0" cellpadding="0" style="border-color:#CCCCCC;border-width:0px;border-spacing:0px;"><tr><td valign="middle" width="30%" style="border-top:1px solid #CCCCCC;background-color:#FFFFFF;border-left:1px solid #CCCCCC;border-right:0px solid #CCCCCC;border-bottom:1px solid #CCCCCC;"><div align="left" id="consprod_confpasscode_label" style="font-family: Tahoma,\'MS Sans Serif\',CordiaUPC;font-size: 12px;font-weight: bold;padding-top: 3px;padding-bottom: 3px;padding-left: 5px;">enter passcode</div></td><td valign="middle" width="40%" style="border-top:1px solid #CCCCCC;background-color:#FFFFFF;border-left:1px solid #CCCCCC;border-right:1px solid #CCCCCC;border-bottom:1px solid #CCCCCC;"><div align="left" id="consprod_confpasscode" style="font-family: Tahoma,\'MS Sans Serif\',CordiaUPC;font-size: 12px;font-weight: normal;padding-top: 3px;padding-bottom: 3px;padding-left: 5px;"><input name="passcode_ent" id="passcode_ent" type="password" class="" style="" maxlength="15" onKeyUp="return false;"></div></td><td valign="middle" width="30%" style="border-top:1px solid #CCCCCC;border-bottom:1px solid #CCCCCC;background-color:#FFFFFF;border-left:0px solid #CCCCCC;border-right:1px solid #CCCCCC;"><div align="center" id="consprod_img_label" style="font-family: Tahoma,\'MS Sans Serif\',CordiaUPC;font-size: 12px;font-weight: bold;padding-top: 3px;padding-bottom: 3px;padding-left: 5px;"><input type="submit" name="passcode_ent_sub" id="passcode_ent_sub" value="Submit" onClick="consprod_delete(\'' + cspid + '\');" style="font-family: Tahoma,\'MS Sans Serif\',CordiaUPC;font-size: 12px;font-weight: bold;"></div></td></tr></table>';
}

function search_consproduct_dropdownlist(isAll, maxRecPerPage)
{
			//alert('search IN : ');
			var search_keywords = document.search_consprod_form.search_keywords_consprod.value;
			var dropdownPageSelect	= document.consproduct_pageselect_form.page_product.value;
			var startRec	= (dropdownPageSelect-1) * maxRecPerPage;

			if (isAll == 'true')
						document.search_consprod_form.search_keywords_consprod.value = "";
			var url = prefixNormalLink + 'index_search_consproduct.php';
			xmlhttp = uzXmlHttp();
			xmlhttp.open("POST", url, true);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
			
		    //alert(xmlhttp.responseText);
			//alert(search_type);
			//alert(search_table);
			//alert(document.getElementById('search_res').innerHTML);
			xmlhttp.onreadystatechange = function()
			{
				if(xmlhttp.readyState == 3)  // Loading Request
				{
						document.getElementById('search_consprod_list').innerHTML = '<div align="center"><br><br><br><img src="' + preload_img + '" width="' + preloadNormalWidth + '" height="' + preloadNormalHeight + '" border="0"></div>';
				}
				if(xmlhttp.readyState == 4)  // Return Request
				{
						document.getElementById('search_consprod_list').innerHTML = xmlhttp.responseText;
						document.consproduct_pageselect_form.page_product.value = dropdownPageSelect;
				}
			}
			xmlhttp.send("isAll=" + isAll + "&startRec=" + startRec + "&search_keywords=" + search_keywords + "&pageSelect=" + dropdownPageSelect);
			//alert('search IN : '+ search_type);
}

function search_consproduct_list(isAll, startRec, pageSelect)
{ 
			//alert('search IN : '+ search_type);
			var search_keywords = document.search_consprod_form.search_keywords_consprod.value;
			if (isAll == 'true')
						document.search_consprod_form.search_keywords_consprod.value = "";

			var url = prefixNormalLink + 'index_search_consproduct.php';
			xmlhttp = uzXmlHttp();
			xmlhttp.open("POST", url, true);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );

		    //alert(xmlhttp.responseText);
			//alert(search_type);
			//alert(search_table);
			//alert(document.getElementById('search_res').innerHTML);
			xmlhttp.onreadystatechange = function()
			{
				if(xmlhttp.readyState == 3)  // Loading Request
				{
						document.getElementById('search_consprod_list').innerHTML = '<div align="center"><br><br><br><img src="' + preload_img + '" width="' + preloadNormalWidth + '" height="' + preloadNormalHeight + '" border="0"></div>';
				}
				if(xmlhttp.readyState == 4)  // Return Request
				{
						document.getElementById('search_consprod_list').innerHTML = xmlhttp.responseText;
						document.consproduct_pageselect_form.page_product.value = pageSelect;
				}
			}
			xmlhttp.send("isAll=" + isAll + "&startRec=" + startRec + "&search_keywords=" + search_keywords + "&pageSelect=" + pageSelect);
			//alert('search IN : '+ search_type);
}

function search_product_dropdownlist(isAll, maxRecPerPage)
{
			//alert('search IN : ');
			var search_keywords = document.search_product_form.search_keywords.value;
			var dropdownPageSelect	= document.product_pageselect_form.page_product.value;
			var startRec	= (dropdownPageSelect-1) * maxRecPerPage;

			if (isAll == 'true')
						document.search_product_form.search_keywords.value = "";
			var url = prefixNormalLink + 'index_search_product.php';
			xmlhttp1 = uzXmlHttp();
			xmlhttp1.open("POST", url, true);
			xmlhttp1.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
			
		    //alert(xmlhttp1.responseText);
			//alert(search_type);
			//alert(search_table);
			//alert(document.getElementById('search_res').innerHTML);
			xmlhttp1.onreadystatechange = function()
			{
				if(xmlhttp1.readyState == 3)  // Loading Request
				{
						document.getElementById('search_product_list').innerHTML = '<div align="center"><br><br><br><img src="' + preload_img + '" width="' + preloadNormalWidth + '" height="' + preloadNormalHeight + '" border="0"></div>';

				}
				if(xmlhttp1.readyState == 4)  // Return Request
				{
						document.getElementById('search_product_list').innerHTML = xmlhttp1.responseText;
						document.product_pageselect_form.page_product.value = dropdownPageSelect;
				}
			}
			xmlhttp1.send("isAll=" + isAll + "&startRec=" + startRec + "&search_keywords=" + search_keywords + "&pageSelect=" + dropdownPageSelect);
			//alert('search IN : '+ search_type);
}

function search_product_list(isAll, startRec, pageSelect)
{
			//alert('search IN : '+ search_type);
			var search_keywords = document.search_product_form.search_keywords.value;
			if (isAll == 'true')
						document.search_product_form.search_keywords.value = "";
			var url = prefixNormalLink + 'index_search_product.php';
			xmlhttp1 = uzXmlHttp();
			xmlhttp1.open("POST", url, true);
			xmlhttp1.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
			
		    //alert(xmlhttp.responseText);
			//alert(search_type);
			//alert(search_table);
			//alert(document.getElementById('search_res').innerHTML);
			xmlhttp1.onreadystatechange = function()
			{
				if(xmlhttp1.readyState == 3)  // Loading Request
				{
						document.getElementById('search_product_list').innerHTML = '<div align="center"><br><br><br><img src="' + preload_img + '" width="' + preloadNormalWidth + '" height="' + preloadNormalHeight + '" border="0"></div>';

				}
				if(xmlhttp1.readyState == 4)  // Return Request
				{
						document.getElementById('search_product_list').innerHTML = xmlhttp1.responseText;
						document.product_pageselect_form.page_product.value = pageSelect;
				}
			}
			xmlhttp1.send("isAll=" + isAll + "&startRec=" + startRec + "&search_keywords=" + search_keywords + "&pageSelect=" + pageSelect);
			//alert('search IN : '+ search_type);
}

function search_contproduct_catalog_dropdownlist(isAll, maxRecPerPage, shopdisplay, package, contside_page) // contside_page 1 = shopma, 2 = contshop
{
			//alert('search IN : ');
			var search_keywords 	= document.search_product_form.search_keywords.value;
			var dropdownPageSelect	= document.product_pageselect_form.page_product.value;
			var startRec	= (dropdownPageSelect-1) * maxRecPerPage;
			var contside_page = contside_page;

			if (isAll == 'true')
					document.search_product_form.search_keywords.value = "";
			var url = prefixNormalLink + 'control_req_catalog.php';
			xmlhttp_catalog = uzXmlHttp();
			xmlhttp_catalog.open("POST", url, true);
			xmlhttp_catalog.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
			
		    //alert(xmlhttp1.responseText);
			//alert(search_type);
			//alert(search_table);
			//alert(document.getElementById('search_res').innerHTML);
			xmlhttp_catalog.onreadystatechange = function()
			{
				if(xmlhttp_catalog.readyState == 3)  // Loading Request
				{
						document.getElementById('search_product_list').innerHTML = '<div align="center"><br><br><br><img src="' + preload_img + '" width="' + preloadNormalWidth + '" height="' + preloadNormalHeight + '" border="0"></div>';

				}
				if(xmlhttp_catalog.readyState == 4)  // Return Request
				{
						document.getElementById('search_product_list').innerHTML = xmlhttp_catalog.responseText;
						document.product_pageselect_form.page_product.value = dropdownPageSelect;
				}
			}
			xmlhttp_catalog.send("isAll=" + isAll + "&startRec=" + startRec + "&search_keywords=" + search_keywords + "&pageSelect=" + dropdownPageSelect + "&shopdisplay=" + shopdisplay + "&contside_page=" + contside_page);
			//alert('search IN : '+ search_type);
}

function search_contproduct_catalog_list(isAll, startRec, pageSelect, shopdisplay, contside_page) // contside_page 1 = shopma, 2 = contshop
{
			//alert('search IN : '+ search_type);
			var search_keywords = document.search_product_form.search_keywords.value;
			var contside_page = contside_page;
			if (isAll == 'true')
						document.search_product_form.search_keywords.value = "";
			var url = prefixNormalLink + 'control_req_catalog.php';
			xmlhttp_catalog = uzXmlHttp();
			xmlhttp_catalog.open("POST", url, true);
			xmlhttp_catalog.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
			
		    //alert(xmlhttp.responseText);
			//alert(search_type);
			//alert(search_table);
			//alert(document.getElementById('search_res').innerHTML);
			xmlhttp_catalog.onreadystatechange = function()
			{
				if(xmlhttp_catalog.readyState == 3)  // Loading Request
				{
						document.getElementById('search_product_list').innerHTML = '<div align="center"><br><br><br><img src="' + preload_img + '" width="' + preloadNormalWidth + '" height="' + preloadNormalHeight + '" border="0"></div>';

				}
				if(xmlhttp_catalog.readyState == 4)  // Return Request
				{
						document.getElementById('search_product_list').innerHTML = xmlhttp_catalog.responseText;
						document.product_pageselect_form.page_product.value = pageSelect;
				}
			}
			xmlhttp_catalog.send("isAll=" + isAll + "&startRec=" + startRec + "&search_keywords=" + search_keywords + "&pageSelect=" + pageSelect + "&shopdisplay=" + shopdisplay + "&contside_page=" + contside_page);
			//alert('search IN : '+ search_type);
}

function search_product_catalog_dropdownlist(isAll, maxRecPerPage, shopdisplay, package)
{
			//alert('search IN : ');
			var search_keywords 	= document.search_product_form.search_keywords.value;
			var dropdownPageSelect	= document.product_pageselect_form.page_product.value;
			var startRec	= (dropdownPageSelect-1) * maxRecPerPage;

			if (isAll == 'true')
					document.search_product_form.search_keywords.value = "";
			var url = prefixNormalLink + 'shopping_req_catalog.php';
			xmlhttp_catalog = uzXmlHttp();
			xmlhttp_catalog.open("POST", url, true);
			xmlhttp_catalog.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
			
		    //alert(xmlhttp1.responseText);
			//alert(search_type);
			//alert(search_table);
			//alert(document.getElementById('search_res').innerHTML);
			xmlhttp_catalog.onreadystatechange = function()
			{
				if(xmlhttp_catalog.readyState == 3)  // Loading Request
				{
						document.getElementById('search_product_list').innerHTML = '<div align="center"><br><br><br><img src="' + preload_img + '" width="' + preloadNormalWidth + '" height="' + preloadNormalHeight + '" border="0"></div>';

				}
				if(xmlhttp_catalog.readyState == 4)  // Return Request
				{
						document.getElementById('search_product_list').innerHTML = xmlhttp_catalog.responseText;
						document.product_pageselect_form.page_product.value = dropdownPageSelect;
				}
			}
			xmlhttp_catalog.send("isAll=" + isAll + "&startRec=" + startRec + "&search_keywords=" + search_keywords + "&pageSelect=" + dropdownPageSelect + "&shopdisplay=" + shopdisplay);
			//alert('search IN : '+ search_type);
}

function search_product_catalog_list(isAll, startRec, pageSelect, shopdisplay)
{
			//alert('search IN : '+ search_type);
			var search_keywords = document.search_product_form.search_keywords.value;
			if (isAll == 'true')
						document.search_product_form.search_keywords.value = "";
			var url = prefixNormalLink + 'shopping_req_catalog.php';
			xmlhttp_catalog = uzXmlHttp();
			xmlhttp_catalog.open("POST", url, true);
			xmlhttp_catalog.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
			
		    //alert(xmlhttp_catalog.responseText);
			//alert(search_type);
			//alert(search_table);
			//alert(document.getElementById('search_res').innerHTML);
			xmlhttp_catalog.onreadystatechange = function()
			{
				if(xmlhttp_catalog.readyState == 3)  // Loading Request
				{
						document.getElementById('search_product_list').innerHTML = '<div align="center"><br><br><br><img src="' + preload_img + '" width="' + preloadNormalWidth + '" height="' + preloadNormalHeight + '" border="0"></div>';

				}
				if(xmlhttp_catalog.readyState == 4)  // Return Request
				{
		    			//alert(xmlhttp_catalog.responseText);
						document.getElementById('search_product_list').innerHTML = xmlhttp_catalog.responseText;
						document.product_pageselect_form.page_product.value = pageSelect;
				}
			}
			xmlhttp_catalog.send("isAll=" + isAll + "&startRec=" + startRec + "&search_keywords=" + search_keywords + "&pageSelect=" + pageSelect + "&shopdisplay=" + shopdisplay);
			//alert('search IN : '+ search_type);
}
// ######################## Search item ############################ //

// ######################## menu button ############################ //
function auto_tutorial_onoff(type)
{
		var url = prefixNormalLink + 'tutorial_onoff_aj.php';
		xmlhttp_tutorialbtn = uzXmlHttp();
		xmlhttp_tutorialbtn.open("POST", url, true);
		xmlhttp_tutorialbtn.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
		
		xmlhttp_tutorialbtn.onreadystatechange = function()
		{
			if(xmlhttp_tutorialbtn.readyState == 3)  // Loading Request
			{
					document.getElementById('tutorial_btn').innerHTML = '<div align="left"><img src="' + preload_img + '" width="' + preloadSmallWidth + '" height="' + preloadSmallHeight + '" border="0"></div>';
			}
			if(xmlhttp_tutorialbtn.readyState == 4)  // Return Request
			{
					document.getElementById('tutorial_btn').innerHTML = xmlhttp_tutorialbtn.responseText;
			}
		}
		xmlhttp_tutorialbtn.send("type=" + type);
}
// ######################## menu button ############################ //

// ######################## character page - beg ########################### //
function costume_dynamic()
{ 		
		var hairstyle_select 			= document.character_costume_form.hairstyle_select;
		var hairstyle_selectBuffer						= "";
		for(var i=0;hairstyle_selectCounter=hairstyle_select[i];i++) 
		{
				hairstyle_selectBuffer = (hairstyle_selectCounter.checked) ? (hairstyle_selectCounter.value) : (hairstyle_selectBuffer);
		}
		hairstyle_select = hairstyle_selectBuffer;

		var face_select 			= document.character_costume_form.face_select;
		var face_selectBuffer						= "";
		for(var i=0;face_selectCounter=face_select[i];i++) 
		{
				face_selectBuffer = (face_selectCounter.checked) ? (face_selectCounter.value) : (face_selectBuffer);
		}
		face_select = face_selectBuffer;

		var clothes_select 			= document.character_costume_form.clothes_select;
		var clothes_selectBuffer						= "";
		for(var i=0;clothes_selectCounter=clothes_select[i];i++) 
		{
				clothes_selectBuffer = (clothes_selectCounter.checked) ? (clothes_selectCounter.value) : (clothes_selectBuffer);
		}
		clothes_select = clothes_selectBuffer;

		var pants_select 			= document.character_costume_form.pants_select;
		var pants_selectBuffer						= "";
		for(var i=0;pants_selectCounter=pants_select[i];i++) 
		{
				pants_selectBuffer = (pants_selectCounter.checked) ? (pants_selectCounter.value) : (pants_selectBuffer);
		}
		pants_select = pants_selectBuffer;

		var shoes_select 			= document.character_costume_form.shoes_select;
		var shoes_selectBuffer						= "";
		for(var i=0;shoes_selectCounter=shoes_select[i];i++) 
		{
				shoes_selectBuffer = (shoes_selectCounter.checked) ? (shoes_selectCounter.value) : (shoes_selectBuffer);
		}
		shoes_select = shoes_selectBuffer;

		var url = prefixNormalLink + 'control_character_aj.php';
		xmlhttp = uzXmlHttp();
		xmlhttp.open("POST", url, false);
		xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
		xmlhttp.send("hairstyle_select=" + hairstyle_select + "&face_select=" + face_select + "&clothes_select=" + clothes_select + "&pants_select=" + pants_select + "&shoes_select=" + shoes_select);

		document.getElementById('char_img').innerHTML = xmlhttp.responseText;
}
// ######################## character page - end ########################### //

// ######################## company information - beg ########################### //
// # control
function shopinfo_form(saveClick, timecountLoc)
{//alert("cpn IN form");
		if(timecountLoc == timecount || saveClick)
		{      //alert("cpn IN form time");
					timecount = 0;
					var pagetitle					= document.cpn_form.pagetitle.value;			
					var companyName		= document.cpn_form.companyName.value;			
					var description  			= document.cpn_form.description1.value;
					var contactEmail 			= document.cpn_form.contactEmail.value;
					var contactAddr 			= document.cpn_form.contactAddr.value;			
					var postalCode				= document.cpn_form.postalCode.value;
					var phoneNum				= document.cpn_form.phoneNum.value;
					var fax 							= document.cpn_form.fax.value;
					var welcomemsg			= document.cpn_form.welcomemsg1.value;
					var shopnews				= document.cpn_form.shopnews1.value;

					//var logoImage				= document.cpn_form.logoImage.value; //alert(logoImage);
					//var indexImage				= document.cpn_form.indexImage.value; //alert(indexImage);
					//var otherAttach				= document.cpn_form.otherAttach.value; //alert(otherAttach);
					//var saveBtn					= saveClick;
					var url = prefixNormalLink + 'control_form_cpn_aj.php';
					xmlhttp = uzXmlHttp();
					xmlhttp.open("POST", url, false);
					xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
					xmlhttp.send("pagetitle=" + pagetitle + "companyName=" + companyName + "&description=" + description + "&contactEmail=" + contactEmail + "&contactAddr=" + contactAddr + "&postalCode=" + postalCode + "&phoneNum=" + phoneNum + "&fax=" + fax + "&welcomemsg=" + welcomemsg + "&shopnews=" + shopnews);
//alert(xmlhttp.responseText);
					eval(xmlhttp.responseText); 
					//alert(xmlhttp.responseText);
		}
}

function shopinfo_keydelay(saveClick)
{ 
		timecount = timecount+1; 
		setTimeout("shopinfo_form("+saveClick+","+timecount+")",700);
}
// ######################## company information - end ########################### //

// ######################## cart - beg ########################### //
function custorderdetail_form(placeClick, timecountLoc, shopdisplay)
{ 
	//alert("order IN");
	if(timecountLoc == timecount || placeClick)
	{      
			timecount = 0;
			var custName		 		= document.custorder_form.custName.value;			
			var contactEmail 			= document.custorder_form.contactEmail.value;
			var contactAddr 			= document.custorder_form.contactAddr.value;
			var postalCode 			= document.custorder_form.postalCode.value;			
			var MPhoneNum			= document.custorder_form.MPhoneNum.value;
			var phoneNum				= document.custorder_form.phoneNum.value;
			var fax 							= document.custorder_form.fax.value;
			var description 				= document.custorder_form.description.value;
			var passcode 					= document.custorder_form.passcode.value;
			var confpasscode 			= document.custorder_form.confpasscode.value;
			var placeBtn					= placeClick;
			var url = prefixNormalLink + 'shopping_cart_display.php';

			xmlhttp = uzXmlHttp();
			xmlhttp.open("POST", url, false);			
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );			
			xmlhttp.send("custName=" + custName + "&contactEmail=" + contactEmail + "&contactAddr=" + contactAddr + "&postalCode=" + postalCode + "&MPhoneNum=" + MPhoneNum + "&phoneNum=" + phoneNum + "&fax=" + fax + "&description=" + description + "&placeBtn=" + placeBtn + "&type=4" + "&shopdisplay=" + shopdisplay + "&passcode=" + passcode + "&confpasscode=" + confpasscode); 
			//if(placeClick)
			//		alert(xmlhttp.responseText);
			eval(xmlhttp.responseText);
			if (success)
			{
						url = prefixNormalLink + 'shopping_cart_display.php';
						//''alert("success IN");

						xmlhttp_placeorder = uzXmlHttp();
						xmlhttp_placeorder.open("POST", url, true);			
						xmlhttp_placeorder.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );			
						
						xmlhttp_placeorder.onreadystatechange = function()
						{
							if(xmlhttp_placeorder.readyState == 3)  // Loading Request
							{
									document.getElementById('customer_cart').innerHTML = '<div align="center"><br><br><br><img src="' + preload_img + '" width="' + preloadNormalWidth + '" height="' + preloadNormalHeight + '" border="0"></div>';
							}
							if(xmlhttp_placeorder.readyState == 4)  // Return Request
							{
									document.getElementById('customer_cart').innerHTML = xmlhttp_placeorder.responseText;
							}
						}
						xmlhttp_placeorder.send("type=1" + "&shopdisplay=" + shopdisplay);
			}
	}

}

function custorder_keydelay(placeClick)
{   
		timecount = timecount+1; 
		setTimeout("custorderdetail_form("+placeClick+","+timecount+")",500);
}

function cart_process(type, shopdisplay, areaTypeForShopStore)
{
			var url = prefixNormalLink + 'shopping_cart_display.php';
			xmlhttp = uzXmlHttp();
			xmlhttp.open("POST", url, false);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
			xmlhttp.send("type=" + type + "&shopdisplay=" + shopdisplay + "&areaTypeForShopStore=" + areaTypeForShopStore); // type 3 : customer details form
			//alert(xmlhttp.responseText);
			document.getElementById('customer_cart').innerHTML = xmlhttp.responseText;
			if (type == 2) // cancel order back to display item
			{
				document.getElementById('editsuccess').style.display = 'none';
				document.getElementById('editfailed').style.display = 'none';
				document.getElementById('deletesuccess').style.display = 'none';
			}
}

function add2cart_catalog_manage(cart_type, customerId, itemId, unitpriceTHB, unitpriceCUR, cartItemQty, itemImg, itemName, itemGroupId, shopdisplay, shopfloornow, displaycurcode, form_name, areaTypeForShopStore)
{ //alert('IN');
			//var form_name = form_name;
			//var areaTypeForShopStore = areaTypeForShopStore;
			//var getQtyString = "document."+ form_name + ".cartItemQty.value;";
			var cartItemQty = 1;
 //alert('CHECK');
			if (cart_type == "edit" || cart_type == "delete")
			{
					var cart_nameString = "document."+ form_name + ".cart_name.value;";
					var cart_name = eval(cart_nameString);
			}
			var url = prefixNormalLink + 'shopping_catalog_add2cart.php';
			xmlhttp = uzXmlHttp();
			xmlhttp.open("POST", url, false);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
 //alert('CHECK2');
			xmlhttp.send("cart_type=" + cart_type + "&customerId=" + customerId + "&itemId=" + itemId + "&unitpriceTHB=" + unitpriceTHB + "&unitpriceCUR=" + unitpriceCUR + "&cartItemQty=" + cartItemQty + "&itemImg=" + itemImg + "&itemName=" + itemName + "&itemGroupId=" + itemGroupId+ "&shopdisplay=" + shopdisplay + "&shopfloornow=" + shopfloornow + "&displaycurcode=" + displaycurcode + "&areaTypeForShopStore=" + areaTypeForShopStore);
			//alert(xmlhttp.responseText);
			eval(xmlhttp.responseText);
}

function add2cart_manage(cart_type, customerId, itemId, unitpriceTHB, unitpriceCUR, cartItemQty, itemImg, itemName, itemGroupId, shopdisplay, shopfloornow, displaycurcode, form_name, areaTypeForShopStore)
{ //alert('IN');
			var form_name = form_name;
			var areaTypeForShopStore = areaTypeForShopStore;
			var getQtyString = "document."+ form_name + ".cartItemQty.value;";
			var cartItemQty = eval(getQtyString);
 //alert('CHECK');
			if (cart_type == "edit" || cart_type == "delete")
			{
					var cart_nameString = "document."+ form_name + ".cart_name.value;";
					var cart_name = eval(cart_nameString);
			}
			var url = prefixNormalLink + 'add2cart.php';
			xmlhttp = uzXmlHttp();
			xmlhttp.open("POST", url, false);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
			if (cart_type == "edit" || cart_type == "delete")
			{
						xmlhttp.send("cart_type=" + cart_type + "&customerId=" + customerId + "&itemId=" + itemId + "&unitpriceTHB=" + unitpriceTHB + "&unitpriceCUR=" + unitpriceCUR + "&cartItemQty=" + cartItemQty + "&itemImg=" + itemImg + "&itemName=" + itemName + "&itemGroupId=" + itemGroupId+ "&shopdisplay=" + shopdisplay + "&shopfloornow=" + shopfloornow + "&displaycurcode=" + displaycurcode + "&cart_name=" + cart_name);
						var add2cartEval = xmlhttp.responseText;

						var url = prefixNormalLink + 'shopping_cart_display.php';
						xmlhttp = uzXmlHttp();
						xmlhttp.open("POST", url, false);
						xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
						xmlhttp.send("type=2" + "&shopdisplay=" + shopdisplay + "&areaTypeForShopStore=" + areaTypeForShopStore);
			
						document.getElementById('customer_cart').innerHTML = xmlhttp.responseText;
						eval(add2cartEval);
			}
			else // case of add item
			{
						xmlhttp.send("cart_type=" + cart_type + "&customerId=" + customerId + "&itemId=" + itemId + "&unitpriceTHB=" + unitpriceTHB + "&unitpriceCUR=" + unitpriceCUR + "&cartItemQty=" + cartItemQty + "&itemImg=" + itemImg + "&itemName=" + itemName + "&itemGroupId=" + itemGroupId+ "&shopdisplay=" + shopdisplay + "&shopfloornow=" + shopfloornow + "&displaycurcode=" + displaycurcode + "&areaTypeForShopStore=" + areaTypeForShopStore);
						eval(xmlhttp.responseText);
			}			
}
// ######################## cart - end ########################### //

// ######################## shop store - beg ############################### //
// # control tower shop display
function contower_shopstore_ladder(shopdisplay, shopfloor, type)
{
			var url = prefixNormalLink + 'control_towershop_display_aj.php?shopdisplay=' + shopdisplay + '&shopfloor=' + shopfloor + '&type=' + type;
			xmlhttp = uzXmlHttp();
			xmlhttp.open("GET", url, true);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );

			xmlhttp.onreadystatechange = function()
			{
				if(xmlhttp.readyState == 3)  // Loading Request
				{
						document.getElementById('cont_shop').innerHTML = '<div align="center"><br><br><br>' + spacepreload_store + '<img src="' + preload_img + '" width="' + preloadNormalWidth + '" height="' + preloadNormalHeight + '" border="0"></div>';
				}
				if(xmlhttp.readyState == 4)  // Return Request
				{
						document.getElementById('cont_shop').innerHTML = xmlhttp.responseText;
						document.getElementById('sampleProductDisplay').style.display = 'none';
				}
			}
			xmlhttp.send(null);
}

function contowerback_to_shopstore(shopdisplay, shopfloor, type)
{
			var shopfloor = shopfloor; //alert(shopdisplay + shopfloor + type)
			var url = prefixNormalLink + 'control_towershop_display_aj.php?shopfloor=' + shopfloor + '&type=' + type + '&shopdisplay=' + shopdisplay;
			xmlhttp = uzXmlHttp();
			xmlhttp.open("GET", url, true);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
//alert(xmlhttp.responseText);
			xmlhttp.onreadystatechange = function()
			{
				if(xmlhttp.readyState == 3)  // Loading Request
				{
						document.getElementById('cont_shop').innerHTML = '<div align="center"><br><br><br>' + spacepreload_store + '<img src="' + preload_img + '" width="' + preloadNormalWidth + '" height="' + preloadNormalHeight + '" border="0"></div>';
				}
				if(xmlhttp.readyState == 4)  // Return Request
				{
						document.getElementById('cont_shop').innerHTML = xmlhttp.responseText;
						document.getElementById('sampleProductDisplay').style.display='none';
				}
			}
			xmlhttp.send(null);						
}

function contower_item_list(itemGroupId, itemGroupName, itemGroupImgDisp, shopfloornow, shopdisplay, type)
{			
			//alert("item list in " + type);
			var itemGroupId = itemGroupId;
			var url = prefixNormalLink + 'control_towershop_display_aj.php?itemGroupId=' + itemGroupId + '&itemGroupName=' + itemGroupName + '&itemGroupImgDisp=' + itemGroupImgDisp + '&shopfloornow=' + shopfloornow + '&shopdisplay=' + shopdisplay + '&type=' + type;
			xmlhttp = uzXmlHttp();
			xmlhttp.open("GET", url, true);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );

			//alert(xmlhttp.responseText);
			xmlhttp.onreadystatechange = function()
			{
				if(xmlhttp.readyState == 3)  // Loading Request
				{
						document.getElementById('cont_shop').innerHTML = '<div align="center"><br><br><br>' + spacepreload_store + '<img src="' + preload_img + '" width="' + preloadNormalWidth + '" height="' + preloadNormalHeight + '" border="0"></div>';
				}
				if(xmlhttp.readyState == 4)  // Return Request
				{
						document.getElementById('cont_shop').innerHTML = xmlhttp.responseText;
				}
			}
			xmlhttp.send(null);
}

// # control
function cont_shopstore_ladder(shopdisplay, shopfloor, type)
{
			var url = prefixNormalLink + 'control_shop_display.php?shopdisplay=' + shopdisplay + '&shopfloor=' + shopfloor + '&type=' + type;
			xmlhttp = uzXmlHttp();
			xmlhttp.open("GET", url, true);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );

			xmlhttp.onreadystatechange = function()
			{
				if(xmlhttp.readyState == 3)  // Loading Request
				{
						document.getElementById('cont_shop').innerHTML = '<div align="center"><br><br><br>' + spacepreload_store + '<img src="' + preload_img + '" width="' + preloadNormalWidth + '" height="' + preloadNormalHeight + '" border="0"></div>';
				}
				if(xmlhttp.readyState == 4)  // Return Request
				{
						document.getElementById('cont_shop').innerHTML = xmlhttp.responseText;
						document.getElementById('sampleProductDisplay').style.display = 'none';
				}
			}
			xmlhttp.send(null);
}

function contback_to_shopstore(shopfloor, type)
{
			var shopfloor = shopfloor;
			var url = prefixNormalLink + 'control_shop_display.php?shopfloor=' + shopfloor + '&type=' + type;
			xmlhttp = uzXmlHttp();
			xmlhttp.open("GET", url, true);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );

			xmlhttp.onreadystatechange = function()
			{
				if(xmlhttp.readyState == 3)  // Loading Request
				{
						document.getElementById('cont_shop').innerHTML = '<div align="center"><br><br><br>' + spacepreload_store + '<img src="' + preload_img + '" width="' + preloadNormalWidth + '" height="' + preloadNormalHeight + '" border="0"></div>';
				}
				if(xmlhttp.readyState == 4)  // Return Request
				{
						document.getElementById('cont_shop').innerHTML = xmlhttp.responseText;
						document.getElementById('sampleProductDisplay').style.display='none';
				}
			}
			xmlhttp.send(null);
}

function cont_item_list(itemGroupId, itemGroupName, itemGroupImgDisp, shopfloornow, shopdisplay, type)
{			
			//alert("item list in " + type);
			var itemGroupId = itemGroupId;
			var url = prefixNormalLink + 'control_shop_display.php?itemGroupId=' + itemGroupId + '&itemGroupName=' + itemGroupName + '&itemGroupImgDisp=' + itemGroupImgDisp + '&shopfloornow=' + shopfloornow + '&shopdisplay=' + shopdisplay + '&type=' + type;
			xmlhttp = uzXmlHttp();
			xmlhttp.open("GET", url, true);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );

			xmlhttp.onreadystatechange = function()
			{
				if(xmlhttp.readyState == 3)  // Loading Request
				{
						document.getElementById('cont_shop').innerHTML = '<div align="center"><br><br><br>' + spacepreload_store + '<img src="' + preload_img + '" width="' + preloadNormalWidth + '" height="' + preloadNormalHeight + '" border="0"></div>';
				}
				if(xmlhttp.readyState == 4)  // Return Request
				{
						document.getElementById('cont_shop').innerHTML = xmlhttp.responseText;
				}
			}
			xmlhttp.send(null);
			//alert(xmlhttp.responseText);
}

// # customer
function shopstore_ladder(shopdisplay, shopfloor)
{
			var url = prefixNormalLink + 'shopping_towershop_display.php?shopdisplay=' + shopdisplay + '&shopfloor=' + shopfloor;
			xmlhttp = uzXmlHttp();
			xmlhttp.open("GET", url, true);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );

			xmlhttp.onreadystatechange = function()
			{
				if(xmlhttp.readyState == 3)  // Loading Request
				{
						document.getElementById('custshop_display').innerHTML = '<div align="center"><br><br><br>' + spacepreload_store + '<img src="' + preload_img + '" width="' + preloadNormalWidth + '" height="' + preloadNormalHeight + '" border="0"></div>';
				}
				if(xmlhttp.readyState == 4)  // Return Request
				{
						document.getElementById('custshop_display').innerHTML = xmlhttp.responseText;
						document.getElementById('sampleProductDisplay').style.display = 'none';
				}
			}
			xmlhttp.send(null);
}

function custback_to_shopstore(shopdisplay, shopfloor)
{
			var shopfloor = shopfloor; //alert(shopfloor);
			var url = prefixNormalLink + 'shopping_towershop_display.php?shopdisplay=' + shopdisplay + '&shopfloor=' + shopfloor;
			xmlhttp = uzXmlHttp();
			xmlhttp.open("GET", url, true);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );

			xmlhttp.onreadystatechange = function()
			{
				if(xmlhttp.readyState == 3)  // Loading Request
				{
						document.getElementById('custshop_display').innerHTML = '<div align="center"><br><br><br>' + spacepreload_store + '<img src="' + preload_img + '" width="' + preloadNormalWidth + '" height="' + preloadNormalHeight + '" border="0"></div>';
				}
				if(xmlhttp.readyState == 4)  // Return Request
				{
						document.getElementById('custshop_display').innerHTML = xmlhttp.responseText;
						document.getElementById('sampleProductDisplay').style.display='none';
				}
			}
			xmlhttp.send(null);
}

function cust_item_list(itemGroupId, itemGroupName, itemGroupImgDisp, shopfloornow, shopdisplay)
{			
			//alert("item list in");
			var itemGroupId = itemGroupId;
			var url = prefixNormalLink + 'shopping_towershop_itemgroupselect.php?itemGroupId=' + itemGroupId + '&itemGroupName=' + itemGroupName + '&itemGroupImgDisp=' + itemGroupImgDisp + '&shopfloornow=' + shopfloornow + '&shopdisplay=' + shopdisplay;
			xmlhttp = uzXmlHttp();
			xmlhttp.open("GET", url, true);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );

			xmlhttp.onreadystatechange = function()
			{
				if(xmlhttp.readyState == 3)  // Loading Request
				{
						document.getElementById('custshop_display').innerHTML = '<div align="center"><br><br><br>' + spacepreload_store + '<img src="' + preload_img + '" width="' + preloadNormalWidth + '" height="' + preloadNormalHeight + '" border="0"></div>';
				}
				if(xmlhttp.readyState == 4)  // Return Request
				{
						//alert(xmlhttp.responseText);
						//document.getElementById('sampleProductDisplay').style.display='none';
						document.getElementById('custshop_display').innerHTML = xmlhttp.responseText;
				}
			}
			xmlhttp.send(null);
			//alert(xmlhttp.responseText);
			//document.getElementById('custshop_display').style.display='none';
}
// ######################## shop store - end ############################### //

// ######################## cont side towermap - beg ####################################//
function cont_form_floor_area(floor_ar, zone_ar)
{//alert(floor_ar);alert(zone_ar);
			var floor_ar = floor_ar;
			var zone_ar = zone_ar;
			var url = prefixNormalLink + 'control_towermap_form.php?floor_ar=' + floor_ar + '&zone_ar=' + zone_ar + '&type_select=1';
			xmlhttp_contarea = uzXmlHttp();
			xmlhttp_contarea.open("GET", url, true);
			xmlhttp_contarea.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );

			//alert(floor_ar);alert(zone_ar);
			//document.getElementById('cont_floor_select').innerHTML = xmlhttp_contarea.responseText;
			xmlhttp_contarea.onreadystatechange = function()
			{ //alert('in cont_floor_select');
				if(xmlhttp_contarea.readyState == 3)  // Loading Request
				{
						document.getElementById('cont_floor_select').innerHTML = '<div align="center"><img src="' + preload_img + '" width="' + preloadSmallWidth + '" height="' + preloadSmallHeight + '" border="0"></div>';
				}
				if(xmlhttp_contarea.readyState == 4)  // Return Request
				{
						document.getElementById('cont_floor_select').innerHTML = xmlhttp_contarea.responseText;
				}
			}
			xmlhttp_contarea.send(null);
			//alert(xmlhttp_contarea.responseText);
			//alert(document.getElementById('cust_floor_select').innerHTML);

			url = prefixNormalLink + 'control_towermap_form.php?floor_ar=' + floor_ar + '&zone_ar=' + zone_ar + '&type_select=2';
			xmlhttp_contarea2 = uzXmlHttp();
			xmlhttp_contarea2.open("GET", url, true);
			xmlhttp_contarea2.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );

			//document.getElementById('cont_zone_select').innerHTML = xmlhttp_contarea2.responseText;
			xmlhttp_contarea2.onreadystatechange = function()
			{ //alert('in cont_zone_select');
				if(xmlhttp_contarea2.readyState == 3)  // Loading Request
				{
						document.getElementById('cont_zone_select').innerHTML = '<div align="center"><img src="' + preload_img + '" width="' + preloadSmallWidth + '" height="' + preloadSmallHeight + '" border="0"></div>';
				}
				if(xmlhttp_contarea2.readyState == 4)  // Return Request
				{
						document.getElementById('cont_zone_select').innerHTML = xmlhttp_contarea2.responseText;
				}
			}
			xmlhttp_contarea2.send(null);
			//alert(xmlhttp_contarea2.responseText);
			//alert(document.getElementById('cust_zone_select').innerHTML);
}

function contmap_display(floor_ar, zone_ar)
{			
			var floor_ar = floor_ar;
			var zone_ar = zone_ar;
			var url = prefixNormalLink + 'control_towermap_display.php?floor_ar=' + floor_ar + '&zone_ar=' + zone_ar;
			xmlhttp = uzXmlHttp();
			xmlhttp.open("GET", url, true);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
			//alert(floor_ar);alert(zone_ar);
			//alert(xmlhttp.responseText);
			//alert(document.getElementById('map_display').innerHTML);
			xmlhttp.onreadystatechange = function()
			{
				if(xmlhttp.readyState == 3)  // Loading Request
				{
						document.getElementById('map_display').innerHTML = '<div align="center"><br><br><br><br><br><br><br><br><br><br><img src="' + preload_img + '" width="' + preloadNormalWidth + '" height="' + preloadNormalHeight + '" border="0"></div>';
				}
				if(xmlhttp.readyState == 4)  // Return Request
				{
						document.getElementById('map_display').innerHTML = "";
						document.getElementById('map_display').innerHTML = xmlhttp.responseText;
						document.getElementById('sampleProductDisplay').style.display='none';
						document.getElementById('ownerImageDisplay').style.display='none';
				}
			}
			xmlhttp.send(null);
			//alert(document.getElementById('map_display').innerHTML);
}

function cont_calc_floor_zone(type, lift_floor, direction,timecountLoc)
{
	if(timecountLoc == timecount)
	{
			timecount = 0;
			var type = type;
			var lift_floor = lift_floor;
			if (type == 1) // form select
			{
						var floor_ar = document.floor_zone_form.floor_select.value;
						var zone_ar = document.floor_zone_form.zone_select.value;
			}
			else if (type == 2) // arrow direction
			{						
						var floor_ar = lift_floor;
						var zone_ar = direction;
			}
			else if (type == 3) // lift
			{
						var floor_ar = lift_floor;
						var zone_ar = direction;
			}
			else
			{
						var floor_ar = 1;
						var zone_ar = "CENTER";
			}
			//alert(floor_ar);alert(zone_ar);
			contmap_display(floor_ar, zone_ar);
			cont_form_floor_area(floor_ar, zone_ar);
	}
}

function map_clickdelay_cont(type, lift_floor, direction)
{   
		timecount = timecount+1; 
		setTimeout("cont_calc_floor_zone('"+type+"','"+lift_floor+"','"+direction+"','"+timecount+"')", 0);
}
// ######################## cont side towermap - end ####################################//
// ######################## cust side towermap - beg ####################################//
function form_floor_area(floor_ar, zone_ar)
{//alert(floor_ar);alert(zone_ar);
			var floor_ar = floor_ar;
			var zone_ar = zone_ar;
			var url = prefixNormalLink + 'shopping_towermap_form.php?floor_ar=' + floor_ar + '&zone_ar=' + zone_ar + '&type_select=1';
			xmlhttp_custarea = uzXmlHttp();
			xmlhttp_custarea.open("GET", url, true);
			xmlhttp_custarea.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );

			//alert(floor_ar);alert(zone_ar);
			//document.getElementById('cust_floor_select').innerHTML = xmlhttp_custarea.responseText;
			xmlhttp_custarea.onreadystatechange = function()
			{ //alert('in cont_floor_select');
				if(xmlhttp_custarea.readyState == 3)  // Loading Request
				{
						document.getElementById('cust_floor_select').innerHTML = '<div align="center"><img src="' + preload_img + '" width="' + preloadSmallWidth + '" height="' + preloadSmallHeight + '" border="0"></div>';
				}
				if(xmlhttp_custarea.readyState == 4)  // Return Request
				{
						document.getElementById('cust_floor_select').innerHTML = xmlhttp_custarea.responseText;
				}
			}
			xmlhttp_custarea.send(null);
			//alert(xmlhttp_custarea.responseText);
			//alert(document.getElementById('cust_floor_select').innerHTML);

			url = prefixNormalLink + 'shopping_towermap_form.php?floor_ar=' + floor_ar + '&zone_ar=' + zone_ar + '&type_select=2';
			xmlhttp_custarea2 = uzXmlHttp();
			xmlhttp_custarea2.open("GET", url, true);
			xmlhttp_custarea2.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );

			//document.getElementById('cust_zone_select').innerHTML = xmlhttp_custarea2.responseText;
			xmlhttp_custarea2.onreadystatechange = function()
			{ //alert('in cont_floor_select');
				if(xmlhttp_custarea2.readyState == 3)  // Loading Request
				{
						document.getElementById('cust_zone_select').innerHTML = '<div align="center"><img src="' + preload_img + '" width="' + preloadSmallWidth + '" height="' + preloadSmallHeight + '" border="0"></div>';
				}
				if(xmlhttp_custarea2.readyState == 4)  // Return Request
				{
						document.getElementById('cust_zone_select').innerHTML = xmlhttp_custarea2.responseText;
				}
			}
			xmlhttp_custarea2.send(null);
			//alert(xmlhttp_custarea2.responseText);
			//alert(document.getElementById('cust_zone_select').innerHTML);
}

function custmap_display(floor_ar, zone_ar)
{			
			var floor_ar = floor_ar;
			var zone_ar = zone_ar;
			var url = prefixNormalLink + 'shopping_towermap_display.php?floor_ar=' + floor_ar + '&zone_ar=' + zone_ar;
			xmlhttp = uzXmlHttp();
			xmlhttp.open("GET", url, true);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
			//alert(floor_ar);alert(zone_ar);
			//alert(xmlhttp.responseText);
			//alert(document.getElementById('map_display').innerHTML);

			xmlhttp.onreadystatechange = function()
			{
				if(xmlhttp.readyState == 3)  // Loading Request
				{
						document.getElementById('map_display').innerHTML = '<div align="center"><br><br><br><br><br><br><br><br><br><br><img src="' + preload_img + '" width="' + preloadNormalWidth + '" height="' + preloadNormalHeight + '" border="0"></div>';
				}
				if(xmlhttp.readyState == 4)  // Return Request
				{
						document.getElementById('map_display').innerHTML = xmlhttp.responseText;
						document.getElementById('sampleProductDisplay').style.display='none';
						document.getElementById('ownerImageDisplay').style.display='none';
				}
			}
			xmlhttp.send(null);
			//alert(document.getElementById('map_display').innerHTML);
}

function calc_floor_zone(type, lift_floor, direction, timecountLoc)
{
	if (timecountLoc == timecount)
	{
			timecount = 0;
			var type = type;
			var lift_floor = lift_floor;
			if (type == 1) // form select
			{
						var floor_ar = document.floor_zone_form.floor_ar.value;
						var zone_ar = document.floor_zone_form.zone_ar.value;
			}
			else if (type == 2) // arrow direction
			{						
						var floor_ar = lift_floor;
						var zone_ar = direction;
			}
			else if (type == 3) // lift
			{
						var floor_ar = lift_floor;
						var zone_ar = direction;
			}
			else
			{
						var floor_ar = 1;
						var zone_ar = "CENTER";
			}
			//alert(floor_ar);alert(zone_ar);
			document.getElementById('map_display').innerHTML = "";
			custmap_display(floor_ar, zone_ar);
			form_floor_area(floor_ar, zone_ar);
	}
}

function map_clickdelay_cust(type, lift_floor, direction)
{   
		timecount = timecount+1;  
		setTimeout("calc_floor_zone('"+type+"','"+lift_floor+"','"+direction+"','"+timecount+"')", 0);
}
// ######################## cust side towermap - end ####################################//

function paym_inf_success()
{
			document.getElementById('paym_inf_msg').innerHTML = "Payment informed<br><br>";
}

function orderchecker_display(paym_inf)
{
			document.getElementById('paym_inf_msg').innerHTML = "";
			var ordercode = document.order_checker_form.ordercode.value;
			var passcode = document.order_checker_form.passcode.value;
			var paym_inform_text = "";
			var paym_inform = paym_inf;			
			if (paym_inform == 1)
			{
						paym_inf_success();
						paym_inform_text = document.payminform_form.paym_inform_text.value;
			}
			var url = prefixNormalLink + 'shopping_orderchecker_display.php';
			xmlhttp = uzXmlHttp();
			xmlhttp.open("POST", url, true);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );

			//alert(xmlhttp.responseText);			
			xmlhttp.onreadystatechange = function()
			{
				if(xmlhttp.readyState == 3)  // Loading Request
				{
						document.getElementById('orderchecker_res').innerHTML = '<div align="left"><img src="' + preload_img + '" width="' + preloadNormalWidth + '" height="' + preloadNormalHeight + '" border="0"></div>';
				}
				if(xmlhttp.readyState == 4)  // Return Request
				{
						document.getElementById('orderchecker_res').innerHTML = xmlhttp.responseText;
				}
			}
			xmlhttp.send("ordercode=" + ordercode + "&paym_inform=" + paym_inform + "&paym_inform_text=" + paym_inform_text + "&passcode=" + passcode);
			//alert(document.getElementById('orderchecker_res').innerHTML);
}

function search_type_select_dropdownlist(search_type, isAll, maxRecPerPage)
{
			//alert('search IN : '+ search_type);
			var search_keywords = document.search_swap_form.search_keywords.value;
			var dropdownPageSelect	= document.getElementById('page_shop').value;
			var startRec	= (dropdownPageSelect-1) * maxRecPerPage;
			//alert("search type : " + search_type + " isAll : " + isAll + " startRec : " + startRec + " pageSelect : " + pageSelect);
			if (isAll == 'true')
						document.search_swap_form.search_keywords.value = "";
			if (isAll == true)
						document.search_swap_form.search_keywords.value = "";
			var url = prefixNormalLink + 'search_type.php';
			xmlhttp = uzXmlHttp();
			xmlhttp.open("POST", url, true);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
			
		    //alert(xmlhttp.responseText);
			//alert(search_type);
			//alert(search_table);
			//alert(document.getElementById('search_res').innerHTML);
			xmlhttp.onreadystatechange = function()
			{
				if(xmlhttp.readyState == 3)  // Loading Request
				{
						document.getElementById('search_res').innerHTML = '<div align="center"><br><br><br><img src="' + preload_img + '" width="' + preloadNormalWidth + '" height="' + preloadNormalHeight + '" border="0"></div>';
				}
				if(xmlhttp.readyState == 4)  // Return Request
				{
						document.getElementById('search_res').innerHTML = xmlhttp.responseText;
						document.getElementById('page_shop').value = dropdownPageSelect;
				}
			}
			xmlhttp.send("search_type=" + search_type + "&search_keywords=" + search_keywords + "&isAll=" + isAll + "&startRec=" + startRec + "&pageSelect=" + dropdownPageSelect);

			//alert('search IN : '+ search_type);
} 

function search_type_select(search_type, isAll, startRec, pageSelect)
{
			//alert('search IN : '+ search_type);
			var search_keywords = document.search_swap_form.search_keywords.value;
			//alert("search type : " + search_type + " isAll : " + isAll + " startRec : " + startRec + " pageSelect : " + pageSelect);
			if (isAll == 'true')
						document.search_swap_form.search_keywords.value = "";
			if (isAll == true)
						document.search_swap_form.search_keywords.value = "";
			var url = prefixNormalLink + 'search_type.php';
			xmlhttp = uzXmlHttp();
			xmlhttp.open("POST", url, true);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
			//alert('search IN : '+ search_type);
		    //alert(xmlhttp.responseText);
			//alert(xmlhttp.responseText);
			//alert(search_table);
			//alert(document.getElementById('search_res').innerHTML);
			xmlhttp.onreadystatechange = function()
			{
				if(xmlhttp.readyState == 3)  // Loading Request
				{
						document.getElementById('search_res').innerHTML = '<div align="center"><br><br><br><img src="' + preload_img + '" width="' + preloadNormalWidth + '" height="' + preloadNormalHeight + '" border="0"></div>';
				}
				if(xmlhttp.readyState == 4)  // Return Request
				{
						document.getElementById('search_res').innerHTML = xmlhttp.responseText;
						document.getElementById('page_shop').value = pageSelect;
				}
			}
			xmlhttp.send("search_type=" + search_type + "&search_keywords=" + search_keywords + "&isAll=" + isAll + "&startRec=" + startRec + "&pageSelect=" + pageSelect);
			//alert('search IN : '+ search_type);
}

function custsearch_form(btnClick)
{ // shopping_search.php
			//alert("custsearchIN");

			var menu_select 		= btnClick;
			//alert(menu_select);

			if (menu_select == 1) // cate type
			{
						catesearch_input.innerHTML = "<input type=\"image\" src=\"" + catetype_search2 + "\" name=\"catetype_search\" width=\"" + catetype_search2Width + "\" height=\"" + catetype_search2Height + "\" onClick=\"custsearch_form(1);return false;\">";
						shopnamesearch_input.innerHTML = "<input type=\"image\" src=\"" + shopname_search + "\" name=\"shopname_search\" width=\"" + shopname_searchWidth + "\" height=\"" + shopname_searchHeight + "\" onClick=\"custsearch_form(2);return false;\">";
						shopurlsearch_input.innerHTML = "<input type=\"image\" src=\"" + shopurl_search + "\" name=\"shopurl_search\" width=\"" + shopurl_searchWidth + "\" height=\"" + shopurl_searchHeight + "\" onClick=\"custsearch_form(3);return false;\">";
						shopownersearch_input.innerHTML = "<input type=\"image\" src=\"" + shopowner_search + "\" name=\"shopowner_search\" width=\"" + shopowner_searchWidth + "\" height=\"" + shopowner_searchHeight + "\" onClick=\"custsearch_form(4);return false;\">";
						search_form.innerHTML = '<div style="' + normalStyle + '">ใส่คำค้นหาประเภทสินค้าที่คุณต้องการ<br>ตัวอย่าง โทรศัพท์มือถือ, เสื้อผ้า, เกมส์, เครื่องใช้ไฟฟ้า<br><br>Enter a keyword to search for shops which have type of goods that you want to buy<br>EX. mobile phone, dress, clothes, games, furniture, Etc.</div><br>'
						+ '<input type="text" name="search_keywords"  class="style5" style="' + formShopInfoStyle + '">'
						+ '<input type="submit" name="catetype_search_sub" value="Search" class="labelBold" style="' + formBtnStyle + '" onClick=\"search_type_select(1, false, 0, 1);return false;\">'
						+ '<input type="submit" name="search_all_sub" value="List all" class="labelBold" style="' + formBtnStyle + '" onClick=\"search_type_select(1, true, 0, 1);return false;\">'; 
			}
			else if (menu_select == 2) // shopname
			{
						catesearch_input.innerHTML = "<input type=\"image\" src=\"" + catetype_search + "\" name=\"catetype_search\" width=\"" + catetype_searchWidth + "\" height=\"" + catetype_searchHeight + "\" onClick=\"custsearch_form(1);return false;\">";						
						shopnamesearch_input.innerHTML = "<input type=\"image\" src=\"" + shopname_search2 + "\" name=\"shopname_search\" width=\"" + shopname_search2Width + "\" height=\"" + shopname_search2Height + "\" onClick=\"custsearch_form(2);return false;\">";
						shopurlsearch_input.innerHTML = "<input type=\"image\" src=\"" + shopurl_search + "\" name=\"shopurl_search\" width=\"" + shopurl_searchWidth + "\" height=\"" + shopurl_searchHeight + "\" onClick=\"custsearch_form(3);return false;\">";
						shopownersearch_input.innerHTML = "<input type=\"image\" src=\"" + shopowner_search + "\" name=\"shopowner_search\" width=\"" + shopowner_searchWidth + "\" height=\"" + shopowner_searchHeight + "\" onClick=\"custsearch_form(4);return false;\">";
						search_form.innerHTML = '<div style="' + normalStyle + '">ใส่ชื่อร้านค้าที่คุณต้องการเข้าชม<br>ตัวอย่าง beauty shop, chocolate shop, lady cosmetic, คลับเกมเมอร์, แฟชั่นนิสต้า <br><br>Find your favorite shop by shop name<br>EX. BJTOWER, etc.</div><br>'
						+ '<input type="text" name="search_keywords" class="style5" style="' + formShopInfoStyle + '">'
						+ '<input type="submit" name="shopname_search_sub" value="Search" class="labelBold" style="' + formBtnStyle + '" onClick=\"search_type_select(2, false, 0, 1);return false;\">'
						+ '<input type="submit" name="search_all_sub" value="List all" class="labelBold" style="' + formBtnStyle + '" onClick=\"search_type_select(2, true, 0, 1);return false;\">';						
			}
			else if (menu_select == 3) // shop url
			{
						catesearch_input.innerHTML = "<input type=\"image\" src=\"" + catetype_search + "\" name=\"catetype_search\" width=\"" + catetype_searchWidth + "\" height=\"" + catetype_searchHeight + "\" onClick=\"custsearch_form(1);return false;\">";
						shopnamesearch_input.innerHTML = "<input type=\"image\" src=\"" + shopname_search + "\" name=\"shopname_search\" width=\"" + shopname_searchWidth + "\" height=\"" + shopname_searchHeight + "\" onClick=\"custsearch_form(2);return false;\">";
						shopurlsearch_input.innerHTML = "<input type=\"image\" src=\"" + shopurl_search2 + "\" name=\"shopurl_search\" width=\"" + shopurl_search2Width + "\" height=\"" + shopurl_search2Height + "\" onClick=\"custsearch_form(3);return false;\">";
						shopownersearch_input.innerHTML = "<input type=\"image\" src=\"" + shopowner_search + "\" name=\"shopowner_search\" width=\"" + shopowner_searchWidth + "\" height=\"" + shopowner_searchHeight + "\" onClick=\"custsearch_form(4);return false;\">";
						search_form.innerHTML = '<div style="' + normalStyle + '">ใส่ URL ของร้านค้าที่คุณต้องการเข้าชม<br>ตัวอย่าง URL : http://<b>shopurl</b>.bjtower.com | ใส่ <b>shopurl</b> ในการค้นหา <br><br>Find your favorite shop by shop URL<br>EX. URL : http://<b>shopurl</b>.bjtower.com | use only <b>shopurl</b> in searching</div><br>'
						+ '<input type="text" name="search_keywords"  class="style5" style="' + formShopInfoStyle + '">'
						+ '<input type="submit" name="shopurl_search_sub" value="Search" class="labelBold" style="' + formBtnStyle + '" onClick=\"search_type_select(3, false, 0, 1);return false;\">'
						+ '<input type="submit" name="search_all_sub" value="List all" class="labelBold" style="' + formBtnStyle + '" onClick=\"search_type_select(3, true, 0, 1);return false;\">';
			}
			else if (menu_select == 4) // shop owner
			{
						catesearch_input.innerHTML = "<input type=\"image\" src=\"" + catetype_search + "\" name=\"catetype_search\" width=\"" + catetype_searchWidth + "\" height=\"" + catetype_searchHeight + "\" onClick=\"custsearch_form(1);return false;\">";
						shopnamesearch_input.innerHTML = "<input type=\"image\" src=\"" + shopname_search + "\" name=\"shopname_search\" width=\"" + shopname_searchWidth + "\" height=\"" + shopname_searchHeight + "\" onClick=\"custsearch_form(2);return false;\">";
						shopurlsearch_input.innerHTML = "<input type=\"image\" src=\"" + shopurl_search + "\" name=\"shopurl_search\" width=\"" + shopurl_searchWidth + "\" height=\"" + shopurl_searchHeight + "\" onClick=\"custsearch_form(3);return false;\">";
						shopownersearch_input.innerHTML = "<input type=\"image\" src=\"" + shopowner_search2 + "\" name=\"shopowner_search\" width=\"" + shopowner_search2Width + "\" height=\"" + shopowner_search2Height + "\" onClick=\"custsearch_form(4);return false;\">";
						search_form.innerHTML = '<div style="' + normalStyle + '">ใส่ชื่อเจ้าของร้านค้าที่คุณต้องการเข้าชม<br>ตัวอย่าง วาสนา, พงษกร, นาตาลี, อื่นๆ <br><br>Find your favorite shop by owner name<br>EX. wasna, pongsagorn, angelica,Etc.</div><br>'
						+ '<input type="text" name="search_keywords" class="style5" style="' + formShopInfoStyle + '">'
						+ '<input type="submit" name="shopowner_search_sub" value="Search" class="labelBold" style="' + formBtnStyle + '" onClick=\"search_type_select(4, false, 0, 1);return false;\">'
						+ '<input type="submit" name="search_all_sub" value="List all" class="labelBold" style="' + formBtnStyle + '" onClick=\"search_type_select(4, true, 0, 1);return false;\">';
			}
}

function accma_menu_button(btnClick)
{ // accma.php						
			var menu_select 		= btnClick;
			var cpwd_msg 	= "";
			var cprf_msg 		= "";
			var accst_msg 	= "";
			var menu_detail_msg 	= "";

			if (menu_select == 1)
			{
						text_header = "<br>CHANGE PASSWORD";						
						cpwd_msg 	= '<img src="' + changepwd2 + '" border=\"0\">';
						cprf_msg 		= '<input type="image" src="' + changeprofile + '" name="changeprofile" id="changeprofile" value="2" onClick="accma_menu_button(2);return false;">';
						accst_msg 	= '<input type="image" src="' + acc_ma_status_txt + '" name="account_status" id="account_status" value="3" onClick="accma_menu_button(3);return false;">';
						var url = prefixNormalLink + 'control_acc_ma_cpwd.php';
						xmlhttp = uzXmlHttp();
						xmlhttp.open("POST", url, true);
						xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
						xmlhttp.onreadystatechange = function()
						{
							if(xmlhttp.readyState == 3)  // Loading Request
							{
									document.getElementById('menu_detail_main').innerHTML = '<div align="center"><br><br><br><img src="' + preload_img + '" width="' + preloadNormalWidth + '" height="' + preloadNormalHeight + '" border="0"></div>';
							}
							if(xmlhttp.readyState == 4)  // Return Request
							{
									menu_detail_msg = xmlhttp.responseText;
									document.getElementById('menu_detail_main').innerHTML		= menu_detail_msg;
									document.getElementById('upd_success').innerHTML = '';
							}
						}
						xmlhttp.send('');
			}
			else if (menu_select == 2)
			{
						text_header = "<br>PERSONAL PROFILE";
						cpwd_msg 	= '<input type="image" src="' + changepwd + '" name="changepwd" id="changepwd" value="1" onClick="accma_menu_button(1);return false;">';
						cprf_msg 		= '<img src="' + changeprofile2 + '" border="0">';
						accst_msg 	= '<input type="image" src="' + acc_ma_status_txt + '" name="account_status" id="account_status" value="3" onClick="accma_menu_button(3);return false;">';

						var url = prefixNormalLink + 'control_acc_ma_cprof.php';
						xmlhttp = uzXmlHttp();
						xmlhttp.open("POST", url, true);
						xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
						xmlhttp.onreadystatechange = function()
						{
							if(xmlhttp.readyState == 3)  // Loading Request
							{
									document.getElementById('menu_detail_main').innerHTML = '<div align="center"><br><br><br><img src="' + preload_img + '" width="' + preloadNormalWidth + '" height="' + preloadNormalHeight + '" border="0"></div>';
							}
							if(xmlhttp.readyState == 4)  // Return Request
							{
									menu_detail_msg = xmlhttp.responseText;
									document.getElementById('menu_detail_main').innerHTML		= menu_detail_msg;
									document.getElementById('savesuccess_res').innerHTML = '';
							}
						}
						xmlhttp.send('');
			}
			else if (menu_select == 3)
			{
						text_header = "<br>ACCOUNT STATUS";
						cpwd_msg 	= '<input type="image" src="' + changepwd + '" name="changepwd" id="changepwd" value="1" onClick="accma_menu_button(1);return false;">';
						cprf_msg 		= '<input type="image" src="' + changeprofile + '" name="changeprofile" id="changeprofile" value="2" onClick="accma_menu_button(2);return false;">';
						accst_msg 	= '<img src="' + acc_ma_status_txt2 + '" border="0">';

						var url = prefixNormalLink + 'control_acc_ma_status.php';
						xmlhttp = uzXmlHttp();
						xmlhttp.open("POST", url, true);
						xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
						xmlhttp.onreadystatechange = function()
						{
							if(xmlhttp.readyState == 3)  // Loading Request
							{
									document.getElementById('menu_detail_main').innerHTML = '<div align="center"><br><br><br><img src="' + preload_img + '" width="' + preloadNormalWidth + '" height="' + preloadNormalHeight + '" border="0"></div>';
							}
							if(xmlhttp.readyState == 4)  // Return Request
							{
									menu_detail_msg = xmlhttp.responseText;
									document.getElementById('menu_detail_main').innerHTML		= menu_detail_msg;
							}
						}
						xmlhttp.send('');
			}
			else if (menu_select == 5) // save password
			{
						text_header = "<br>CHANGE PASSWORD";						
						cpwd_msg 	= '<img src="' + changepwd2 + '" border=\"0\">';
						cprf_msg 		= '<input type="image" src="' + changeprofile + '" name="changeprofile" id="changeprofile" value="2" onClick="accma_menu_button(2);return false;">';
						accst_msg 	= '<input type="image" src="' + acc_ma_status_txt + '" name="account_status" id="account_status" value="3" onClick="accma_menu_button(3);return false;">';
						var url = prefixNormalLink + 'control_acc_ma_cpwd.php';
						xmlhttp = uzXmlHttp();
						xmlhttp.open("POST", url, false);
						xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
						xmlhttp.send('');

						menu_detail_msg = xmlhttp.responseText;
						document.getElementById('menu_detail_main').innerHTML		= menu_detail_msg;
						document.getElementById('upd_success').innerHTML = '';
			}
			else if (menu_select == 6) // save profile
			{
						text_header = "<br>PERSONAL PROFILE";
						cpwd_msg 	= '<input type="image" src="' + changepwd + '" name="changepwd" id="changepwd" value="1" onClick="accma_menu_button(1);return false;">';
						cprf_msg 		= '<img src="' + changeprofile2 + '" border="0">';
						accst_msg 	= '<input type="image" src="' + acc_ma_status_txt + '" name="account_status" id="account_status" value="3" onClick="accma_menu_button(3);return false;">';

						var url = prefixNormalLink + 'control_acc_ma_cprof.php';
						xmlhttp = uzXmlHttp();
						xmlhttp.open("POST", url, false);
						xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
						xmlhttp.send('');

						menu_detail_msg = xmlhttp.responseText;
						document.getElementById('menu_detail_main').innerHTML		= menu_detail_msg;
						document.getElementById('savesuccess_res').innerHTML = '';
			}

			document.getElementById('menu_text_header').innerHTML				= text_header;			
			document.getElementById('cpwd_res').innerHTML 						= cpwd_msg; 
			document.getElementById('cprf_res').innerHTML 						= cprf_msg;
			document.getElementById('accst_res').innerHTML 						= accst_msg; //alert(menu_detail_msg);			 
			//alert(menu_detail_msg);
			//alert(menu_detail_main.innerHTML);
			//document.accma_swap_form.oldpasswd.value = "";
			//document.accma_swap_form.newpasswd.value = "";
			//document.accma_swap_form.newconfirmpasswd.value = "";			
			//accma_swap_form.reset();
}

function accma_pwd_form()
{ // change_pwd.php			
			var oldpasswd = document.accma_swap_form.oldpasswd.value;
			var newpasswd = document.accma_swap_form.newpasswd.value;
			var newconfirmpasswd = document.accma_swap_form.newconfirmpasswd.value;
			var url = prefixNormalLink + 'change_password.php';
			xmlhttp = uzXmlHttp();
			xmlhttp.open("POST", url, false);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
			xmlhttp.send("oldpasswd=" + oldpasswd + "&newpasswd=" + newpasswd + "&newconfirmpasswd=" + newconfirmpasswd);
			
		    eval(xmlhttp.responseText);
}

function accma_prof_form(saveClick, timecountLoc)
{ // change_profile.php
	if(timecountLoc == timecount || saveClick)
	{      
			timecount = 0;
			var title		 					= document.accma_swap_form.title;
			var titleBuffer					= "";
			for(var i=0;titleCounter=title[i];i++) 
			{
					titleBuffer = (titleCounter.checked) ? (titleCounter.value) : (titleBuffer);
			}
			title = titleBuffer;
			var name 						= document.accma_swap_form.name.value;
			var surname 					= document.accma_swap_form.surname.value;
			var sex 							= document.accma_swap_form.sex;
			var sexBuffer					= "";
			for(var i=0;sexCounter=sex[i];i++) 
			{
					sexBuffer = (sexCounter.checked) ? (sexCounter.value) : (sexBuffer);
			}
			sex = sexBuffer;
			var date		 					= document.accma_swap_form.date.value;
			var month 						= document.accma_swap_form.month.value;
			var year 							= document.accma_swap_form.year.value;
			var email		 				= document.accma_swap_form.email.value;
			var province 					= document.accma_swap_form.province.value;
			var address		 			= document.accma_swap_form.address.value;
			var postalCode 			= document.accma_swap_form.postalCode.value;
			var phone 						= document.accma_swap_form.phone.value;
			var mPhone		 			= document.accma_swap_form.mPhone.value;
			var fax 							= document.accma_swap_form.fax.value;
			var cateType		 			= document.accma_swap_form.cateType.value;
			var curdisplay	 			= document.accma_swap_form.curdisplay.value;
			var saveBtn					= saveClick;
			var url = prefixNormalLink + 'change_profile.php';

			xmlhttp = uzXmlHttp();
			xmlhttp.open("POST", url, true);			
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
			//alert(xmlhttp.responseText);
			xmlhttp.onreadystatechange = function()
			{
				if(xmlhttp.readyState == 4)  // Return Request
				{ //alert(xmlhttp.responseText);
						eval(xmlhttp.responseText);	
				}
			}
			xmlhttp.send("title=" + title + "&name=" + name + "&surname=" + surname + "&sex=" + sex + "&date=" + date + "&month=" + month + "&year=" + year + "&email=" + email + "&province=" + province + "&address=" + address + "&postalCode=" + postalCode + "&phone=" + phone + "&mPhone=" + mPhone + "&fax=" + fax + "&cateType=" + cateType + "&curdisplay=" + curdisplay + "&saveBtn=" + saveBtn); 
	}
}

function accma_prof_keydelay(saveClick)
{   
		timecount = timecount+1; 
		setTimeout("accma_prof_form("+saveClick+","+timecount+")",700);
}

function checkname_form()
{ // cname_search.php			
			var userNameCheck = document.checkname.userNameCheck.value;
			var shopNameCheck = document.checkname.shopNameCheck.value;
			var result;
			var url = prefixNormalLink + 'cname_search.php';
			xmlhttp = uzXmlHttp();
			xmlhttp.open("POST", url, false);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
			xmlhttp.send("userNameCheck=" + userNameCheck + "&shopNameCheck=" + shopNameCheck); 

			//document.checkname.userNameCheck.value =	userNameCheck;
			//document.checkname.shopNameCheck.value = shopNameCheck;
		    eval(xmlhttp.responseText);
			//document.checkname.userNameCheck.value = result;
}

function ownerlogin_form()
{ // authentication.php					
			var userId = document.login_form.userId.value;
			var userPwd = document.login_form.userPwd.value;
			var result;
			var url = prefixNormalLink + 'authentication.php';
			xmlhttp = uzXmlHttp();
			xmlhttp.open("POST", url, false);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
			xmlhttp.send("userId=" + userId + "&userPwd=" + userPwd); 
			//document.checkname.userNameCheck.value =	userNameCheck;
			//document.checkname.shopNameCheck.value = shopNameCheck;
			//alert(xmlhttp.responseText);
		    eval(xmlhttp.responseText);
			//document.checkname.userNameCheck.value = result;
}

function forgotpwd_process(type)
{ // forgotpwd_process
			var userId = document.login_form.userId.value;
			var url = prefixNormalLink + 'pwd_regen.php';
			xmlhttp = uzXmlHttp();
			xmlhttp.open("POST", url, false);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
			xmlhttp.send("userId=" + userId + "&type=" + type); 
			//alert(xmlhttp.responseText);
			//document.checkname.userNameCheck.value =	userNameCheck;
			//document.checkname.shopNameCheck.value = shopNameCheck;
			//alert(xmlhttp.responseText);
		    eval(xmlhttp.responseText);
			//document.checkname.userNameCheck.value = result;
}

function ownerareaselect_form()
{ // control_area_submit.php						
			var floor_select		 			= document.areaselect_form.floor_select.value;
			var area_select		 				= document.areaselect_form.area_select;
			var sponsorcode		 			= document.areaselect_form.inviter_code.value;
			var area_selectBuffer				= "";
			for(var i=0;area_selectCounter=area_select[i];i++) 
			{
					area_selectBuffer = (area_selectCounter.checked) ? (area_selectCounter.value) : (area_selectBuffer);
			}
			area_select = area_selectBuffer;

			var char_select		 		= document.areaselect_form.char_select
			var char_selectBuffer					= "";
			for(var i=0;char_selectCounter=char_select[i];i++) 
			{
					char_selectBuffer = (char_selectCounter.checked) ? (char_selectCounter.value) : (char_selectBuffer);
			}
			char_select = char_selectBuffer;

			//alert(floor_select);
			//alert(area_select);
			//alert(char_select);
			
			var result;
			var url = prefixNormalLink + 'control_area_submit.php';
			xmlhttp = uzXmlHttp();
			xmlhttp.open("POST", url, false);
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
			xmlhttp.send("floor_select=" + floor_select + "&area_select=" + area_select  + "&char_select=" + char_select  + "&sponsorcode=" + sponsorcode); 

			//document.checkname.userNameCheck.value =	userNameCheck;
			//document.checkname.shopNameCheck.value = shopNameCheck;
			//alert(xmlhttp.responseText);
		    eval(xmlhttp.responseText);
			//document.checkname.userNameCheck.value = result;
			
}


function paymentinform_keydelay(paymentClick)
{   
		timecount = timecount+1; 
		setTimeout("paymentinform_form("+paymentClick+","+timecount+")",700);
}

function paymentinform_form(paymentClick, timecountLoc)
{ // bj_payment_management.php			
// // shop_url bank_select date month year time_hour time_min paid_amount ps_text inform_submit randNumFull randNumBox
	if(timecountLoc == timecount || paymentClick == 1)
	{      
			timecount = 0;
			var shop_url		 	= document.payment_form.shop_url.value;
			var bank_select			= document.payment_form.bank_select.value;
			var date		 		= document.payment_form.date.value;
			var month 				= document.payment_form.month.value;
			var year 				= document.payment_form.year.value;
			var time_hour		 	= document.payment_form.time_hour.value;
			var time_min 			= document.payment_form.time_min.value;
			var paid_amount		 	= document.payment_form.paid_amount.value;
			var ps_text		 		= document.payment_form.ps_text.value;
			var randNumFull		 	= document.payment_form.randNumFull.value;
			var randNumBox		 	= document.payment_form.randNumBox.value;
			var paymentClick		= paymentClick;
			var url = prefixNormalLink + 'bj_payment_management.php';
			//alert(bank_select);
			//alert(domainnameURL);
			xmlhttp = uzXmlHttp();
			xmlhttp.open("POST", url, false);			
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );			
			xmlhttp.send("shop_url=" + shop_url + "&bank_select=" + bank_select + "&date=" + date + "&month=" + month + "&year=" + year + "&time_hour=" + time_hour + "&time_min=" + time_min + "&paid_amount=" + paid_amount + "&ps_text=" + ps_text + "&paymentClick=" + paymentClick + "&randNumFull=" + randNumFull + "&randNumBox=" + randNumBox);
			eval(xmlhttp.responseText);
			//alert(xmlhttp.responseText);	
	}
}

function registration_form(registClick, timecountLoc)
{ // registration.php			
	if(timecountLoc == timecount || registClick == 1)
	{      
			timecount = 0;
			var userId 						= document.regist_form.userId.value;
			var passwd 					= document.regist_form.passwd.value;
			var confirmPasswd 		= document.regist_form.confirmPasswd.value;
			var title		 					= document.regist_form.title;
			var titleBuffer					= "";
			for(var i=0;titleCounter=title[i];i++) 
			{
					titleBuffer = (titleCounter.checked) ? (titleCounter.value) : (titleBuffer);
			}
			title = titleBuffer;
			var name 						= document.regist_form.name.value;
			var surname 					= document.regist_form.surname.value;
			var sex 							= document.regist_form.sex;
			var sexBuffer					= "";
			for(var i=0;sexCounter=sex[i];i++) 
			{
					sexBuffer = (sexCounter.checked) ? (sexCounter.value) : (sexBuffer);
			}
			sex = sexBuffer;
			var date		 					= document.regist_form.date.value;
			var month 						= document.regist_form.month.value;
			var year 							= document.regist_form.year.value;
			var email		 				= document.regist_form.email.value;
			var personalId 				= document.regist_form.personalId.value;
			var province 					= document.regist_form.province.value;
			var address		 			= document.regist_form.address.value;
			var postalCode 			= document.regist_form.postalCode.value;
			var phone 						= document.regist_form.phone.value;
			var mPhone		 			= document.regist_form.mPhone.value;
			var fax 							= document.regist_form.fax.value;
			var accountURL		 	= document.regist_form.accountURL.value;
			var domainnameURL		 	= document.regist_form.domainnameURL.value;
			var cateType		 			= document.regist_form.cateType.value;
			var package 					= document.regist_form.package.value;
			var randNumFull		 	= document.regist_form.randNumFull.value;
			var randNumBox		 	= document.regist_form.randNumBox.value;
			var registerBtn				= registClick;
			var url = prefixNormalLink + 'registration.php';
			//alert(title);
			//alert(domainnameURL);
			xmlhttp = uzXmlHttp();
			xmlhttp.open("POST", url, false);			
			xmlhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );			
			xmlhttp.send("userId=" + userId + "&passwd=" + passwd + "&confirmPasswd=" + confirmPasswd + "&title=" + title + "&name=" + name + "&surname=" + surname + "&sex=" + sex + "&date=" + date + "&month=" + month + "&year=" + year + "&email=" + email + "&personalId=" + personalId + "&province=" + province + "&address=" + address + "&postalCode=" + postalCode + "&phone=" + phone + "&mPhone=" + mPhone + "&fax=" + fax + "&accountURL=" + accountURL + "&cateType=" + cateType + "&package=" + package + "&randNumBox=" + randNumBox + "&randNumFull=" + randNumFull + "&registerBtn=" + registerBtn + "&domainnameURL=" + domainnameURL);
			eval(xmlhttp.responseText);
			//alert(xmlhttp.responseText);	
	}
}

function registration_keydelay(registClick)
{   
		timecount = timecount+1; 
		setTimeout("registration_form("+registClick+","+timecount+")",700);
}