// JavaScript Document
function langEn() {

var url=document.URL;
url =(url).replace('#1','');
countstr=url.length;
data=url.substr(countstr-1);

if(data=='/'){
url=url+'index.php';
}

sp_url=url.split("."); 
pointtype=(sp_url.length)-1;

type=sp_url[pointtype];
newurl =url.replace('.'+type,'-en.'+type);
window.location=newurl;
//alert(newurl);
}
function langTh() {
		var url=document.URL;
			url =(url).replace('#1','');
			newurl =(url).replace('-en','');
			window.location=newurl;
}

function showMenu(id,hid){
	hideMenu();
	$('#submenu'+id).show();
}
function hideMenu(){
	//alert('a')
	$('#submenu1').hide();
	$('#submenu2').hide();
}
function fnProduct(id,name){
	$('#pContent').html('');
		 queryStr="id="+id+"&name="+name;				  	
   //alert(queryStr);
  
				  $.ajax({
					   type: "POST",
					   url: "ajax-product.php",
					   cache: false,
					   data: queryStr,
					   success: function(response){
						 setTimeout("finishAjax('pContent', '"+escape(response)+"')", 500);
					   }
					 });
}
function finishAjax(id, response) {
  //$('#AjaxLoading').hide();
  $('#'+id).html(unescape(response));
  $('#'+id).fadeIn();
}
function fnCar(id,name){
	$('#pContent').html('');
		 queryStr="id="+id+"&name="+name;				  	
   //alert(queryStr);
  
				  $.ajax({
					   type: "POST",
					   url: "ajax-car.php",
					   cache: false,
					   data: queryStr,
					   success: function(response){
						 setTimeout("finishAjax2('pContent', '"+escape(response)+"')", 500);
					   }
					 });
}
function finishAjax2(id, response) {
  //$('#AjaxLoading').hide();
  $('#pContent').html('');
  $('#'+id).html(unescape(response));
  $('#'+id).fadeIn();
  
}

function fnShowLMenu(id,num){
	$(".lmenu").css("display","none");
	$('#lcat'+id).show();
	$('#lpro'+id).show();
	$('#lcar'+id).show();
}

function showBoxNews(id){
	$(".imgNews").attr('src',"engine/icon-off.gif");
	$(".boxNews").css("display","none");
	$('#boxNews'+id).show();
	$('#imgNews'+id).attr('src',"engine/icon-on.gif");
}
function showBoxPro(id){
	$(".imgPro").attr('src',"engine/icon-off.gif");
	$(".boxPro").css("display","none");
	$('#boxPro'+id).show();
	$('#imgPro'+id).attr('src',"engine/icon-on.gif");
}
function showBoxGallery(id){
	$(".imgGallery").attr('src',"engine/icon-off.gif");
	$(".boxGallery").css("display","none");
	$('#boxGallery'+id).show();
	$('#imgGallery'+id).attr('src',"engine/icon-on.gif");
}
function showTVC(name,tvc){
	var s1 = new SWFObject("player.swf","player","320","259","8");
	s1.addParam("allowfullscreen","true");
	s1.addParam("allowscriptaccess","always");
	s1.addParam("wmode", "transparent");
	s1.addVariable("autostart","true");
	s1.addVariable("width","320");
	s1.addVariable("height","259");
	s1.addVariable("file",tvc);	
	s1.write("containertvc2");
	
	$('#bottomName').html(name);
	$('#topName').html(name);
}

function showMap(region,where,province,district,startrow){
	var queryStr="region="+region+"&where="+where+"&province="+province+"&district="+district+"&startrow="+startrow;
	//alert(queryStr)
					$.ajax({
					   type: "POST",
					   url: "distri-list.php",
					   cache: false,
					   data: queryStr,
					   success: function(response){
						 setTimeout("finishAjaxMap('boxContent', '"+escape(response)+"')", 100);
					   }
					 });
}

function showMapInter(where,country,startrow){
	var queryStr="where="+where+"&country="+country+"&startrow="+startrow;
	//alert(queryStr)
					$.ajax({
					   type: "POST",
					   url: "distri-inter-list.php",
					   cache: false,
					   data: queryStr,
					   success: function(response){
						 setTimeout("finishAjaxMap('boxContent', '"+escape(response)+"')", 100);
					   }
					 });
}

function showNews(id,startrow){
	var queryStr="id="+id+"&startrow="+startrow;
	//alert(queryStr)
					$.ajax({
					   type: "POST",
					   url: "news-list.php",
					   cache: false,
					   data: queryStr,
					   success: function(response){
						 setTimeout("finishAjaxMap('boxContent', '"+escape(response)+"')", 100);
					   }
					 });
}

function finishAjaxMap(id, response) {
	//alert(unescape(response))
  $('#'+id).html(unescape(response));
  $('#'+id).fadeIn();
}

function showImage(type,id,img){
	//alert(id)
	if(type!='product'){
		tb_show('', 'boxshow.php?type='+type+'&simg='+img+'&height=640&width=770', '') ;
	}else{
		tb_show('', 'boxshow.php?type='+type+'&id='+id+'&height=640&width=770', '') ;
	}
	$('#TB_title').hide();
}

function showImageEn(type,id,img){
	//alert(id)
	if(type!='product'){
		tb_show('', 'boxshow-en.php?type='+type+'&simg='+img+'&height=640&width=770', '') ;
	}else{
		tb_show('', 'boxshow-en.php?type='+type+'&id='+id+'&height=640&width=770', '') ;
	}
	$('#TB_title').hide();
}

function addeNews(){
	var eMail=$('#enews-email').val();
	var queryStr="email="+eMail;
	//alert(queryStr)
					$.ajax({
					   type: "POST",
					   url: "add-enews.php",
					   cache: false,
					   data: queryStr,
					   success: function(response){
						  // alert(response)
						 //setTimeout("finishAjaxMap('boxContent', '"+escape(response)+"')", 100);
						 $('#enews-email').val('บันทึกข้อมูลเรียบร้อย');
						 //alert('บันทึกข้อมูลเรียบร้อย')
					   }
					 });
}
