	
	
	function DetailModal(Qid,path){
		//styles = 'dialogWidth=488px;dialogHeight=500px;dialogTop=20;dialogLeft=20px;status=no;help=no;';
	
		src = path+"product_detail.asp?Qid="+Qid;
		//window.showModalDialog(src,window,styles); 
		winstyle = "resizable=yes,height=500,width=500,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,top=20,left=20";
		window.open(src,'detail',winstyle);

	}
	
		function DetailModal2(Qid,path){
		//styles = 'dialogWidth=488px;dialogHeight=500px;dialogTop=20;dialogLeft=20px;status=no;help=no;';
	
		src = path+"product_detail2.asp?Qid="+Qid;
		//window.showModalDialog(src,window,styles); 
		winstyle = "resizable=yes,height=500,width=500,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,top=20,left=20";
		window.open(src,'detail',winstyle);

	}


	function PopColor(id,path){
		styles = 'dialogWidth=110px;dialogHeight=130px;dialogTop=150;dialogLeft=400px;status=no;help=no;';
		src = path+"popcolor.asp?id="+id;
		window.showModalDialog(src,'dialog',styles); 
		//winstyle = "height=500,width=482,status=yes,toolbar=no,menubar=no,location=no,scrollbars=no,top=20,left=20";
		//window.open(src,'detail',winstyle);
	}
	
	
	function chk_blank()
	{
		f = document.forms(0);
				if(Trim(f.Data.value))
				{
					WarnInput(f.Data," Data ")
				}
				else
				{
					f.submit();
				}
	}
	
		function chk_blank1()
	{
		f = document.formsearch;
				if(Trim(f.DataSearch.value))
				{
					WarnInput(f.DataSearch," Data Search ")
				}
				else
				{
					f.submit();
				}
	}

	
			function Trim(key)
		{
			sp =key.split(" ");
				ch = 0
			 	for (st = 0;st<sp.length;st++){
					if (sp[st] == ""){
						ch++;
					}
				}
				if (eval(sp.length) ==eval(ch)){
							return true;}
				else{
							return false;}
		}
  
  function check_email(e) {
			ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
			for(i=0; i < e.length ;i++){
			if(ok.indexOf(e.charAt(i))<0){ 
			return (false);
			}	
			} 
			if (document.images) {
			re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
			re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
			if (!e.match(re) && e.match(re_two)) {
			return (-1);		
			} 
			}
			}

  
  	function WarnInput(key,name)
	{
			alert(" Please Insert "+ name +"")
			key.focus();
	}		
	
	function Warncheck(key,name)
	{
			alert(" Please check "+ name +" again !! ")
			key.focus();
	}		
	
	function Warnselbox(key,name)
	{
			alert(" Please select "+ name +"  ")
			key.focus();
	}		


	
		function chk_shipping(f,id)
	{
				var str_name,str_address,str_state,str_zipcode;
				var Name,address,State,Zipcode
				
				ff = document.form;
				Name 		=  	ff.Name.value;
				Address 	= 		ff.Address.value;
				State 			=  	ff.State.value;
				Zipcode 	= 		ff.Zipcode.value;
				
				sp_Name = Name.split(",")
				sp_Address = Address.split(",")
				sp_State = State.split(",")
				sp_Zipcode =Zipcode.split(",")
				
				
				if(id == "")
				{
					str_name				= "";
					str_address			= "";
					str_state				= "";
					str_zipcode 		= "";
				}
				else
				{
						Pos = parseFloat(id-1)
						str_name				= sp_Name[Pos];
						str_address			= sp_Address[Pos];
						str_state				= sp_State[Pos];
						str_zipcode 		= sp_Zipcode[Pos];
				}
				
				f.shipname.value			=str_name;
				f.shipaddress.value		=str_address;
				f.shipstate.value			=str_state;
				f.shipzipcode.value		=str_zipcode;
	}
	
		
	
	
function imgsize()
		{
			f = document.all;
			TotalRecord = f.TotalRecord.value;
			numberColumns = f.numberColumns.value;
			start_i = 1;
			k =  parseFloat(numberColumns);
			var img_obj = new Image();
			for (i=start_i ; i<=TotalRecord;i++)
			{
							eval("f.img"+i+k+".style.display=''")
							img_obj = eval("f.img"+i+k+".src")
							str_price = eval("f.Price"+i+k+".value")
							eval("document.getElementById('L_Price"+i+k+"').innerHTML ='"+ formatCurrency(str_price,'1')+" บาท&nbsp;&nbsp;'")
							w =eval("f.img"+i+k+".width")
							eval("f.img"+i+k+".width ="+eval(w*0.55)+"")
							
					if ( i % parseFloat(numberColumns) == 0)
						{
						k = k+parseFloat(numberColumns);
						}
 				}
		}
		
		function shwCus()
{
	var Pack = document.all.Pack.value;
	var numtotal= document.all.numtotal.value;
	//	if(Pack != "0"){
	//		document.all.rows.style.display = '';
	//		document.all.rowcon.style.display = '';
	//	}
	//	else{
	//		document.all.rows.style.display = 'none';
	//		document.all.rowcon.style.display = 'none';
	//	}
		
		for ( j=1;j<=eval(numtotal);j++){
			eval("document.all.row"+j+".style.display ='none' ") 
		     }
			for ( i=1;i<=eval(Pack);i++){
			eval("document.all.row"+i+".style.display ='' ") 
		     }
			 document.all.numtotal.value=eval(Pack)
}


	function ccolor(th_chk,Value,Name,Count){
		countitem(th_chk)
		var f = document.form;
		for(i=1;i<Count;i++){
			if(eval("f.c"+i+".checked")){
				chk = true;
				break;
			}else{chk=false;}
		}
			if(eval("f."+Name+".checked")){
				eval("t"+Value+".style.backgroundColor='#F4F4F4'");
			}else{
				eval("t"+Value+".style.backgroundColor=''");
			}
			
	}
	
	function TableClick(id,number,Count){
		var f = document.form;
		TableId = eval("f.c"+number+".checked");
		if(TableId)
		{
			eval("f.c"+number+".checked=false");
						ccolor(false,id,'c'+number,Count);
			}
			else
			{
				eval("f.c"+number+".checked=true");
								ccolor(true,id,'c'+number,Count);
			}
	}
	
	
	function countitem(value)
				{
						f=document.form;
						CountTotal =parseFloat(f.CountTotal.value);
						if  (value == true)
						{
							CountTotal = CountTotal +1 ;
						}
						else
						{
							CountTotal= CountTotal - 1;	
						}
						f.CountTotal.value = eval(CountTotal)
				}

	function shop(path)
	{
					var f= document.form;
					var Str_val;
					TotalRecord = f.TotalRecord.value;
					var Str_Item ="";
					if (f.CountTotal.value == 0)
					{
						alert("กรุณาเลือกรายการสินค้าด้วยครับ")
					}
					else
					{
						for (var h =1 ; h <= TotalRecord ; h++)
						{
							if (eval("f.c"+h+".checked") == true)
							{
								Str_val = eval("f.c"+h+".value")
								Str_Item = Str_Item+Str_val+","
							}
						}
						Str_Item = Str_Item.substring(0,Str_Item.lastIndexOf(","))
						f.Str_Item.value = Str_Item;
						f.action = path;
						f.method="post"
						f.submit();
					}
	}


function view(name,num) 
{
	for(i=0;i<document.all[name].length;i++)	
		{
		if(i==parseInt(num-1)) 
		document.all[name][i].style.visibility="visible";
	else
		document.all[name][i].style.visibility="hidden";
		}
}

function init() 
{
	if(document.all["layer"]!=null)	
		{
		for(i=0;i<document.all["layer"].length;i++)
			document.all["layer"][i].style.visibility="hidden";
		}
}


function chk_position()
{
			for(i=0;i<document.all["layer"].length;i++)
			{
				screen_width  = screen.width;
				if(screen_width== 1024)
				{
					document.all["layer"][i].style.left = "230px"
				}
			}
		//	imgsize();
}

function chk_maillist(f)
{
		var maillista;
		
		f = document.all;
		if(f.maillist.value.length <4){
				Warncheck(f.maillist," Email ")
		}
		else if(!check_email(f.maillist.value)){
				Warncheck(f.maillist," Email ")
		}
		else
		{
			maillista = f.maillist.value;
			popup('1',maillista)
		}
}

function cls_value(f)
{
	f.maillist.value = '';
}

	function chk_itm(id)
	{
		f = document.formpro;
		f.Str_Item.value = id;
		f.submit();
	}

function chk_mailcontact()
{
		f = document.form;
		if(f.str_sender.value.length <4){
				Warncheck(f.str_sender ," Email ")
		}
		else if(!check_email(f.str_sender.value)){
				Warncheck(f.str_sender," Email ")
		}
		else if(Trim(f.str_subject.value))
		{
						WarnInput(f.str_subject," Subject ")
		}
		else if(Trim(f.str_comment.value))
		{
				WarnInput(f.str_comment," comment ")
		}
		else
		{
			senders = f.str_sender.value;
			subjects= f.str_subject.value;
			comments = f.str_comment.value;
			id = "sender="+senders+"&suject="+subjects+"&comment="+comments
			popup('2',id)
		}
}

	function Get_Group(f,val,sid)
	{
		f = document.form;
		fa = document.all;
		var str_style,str_mnr,sumval;
		sumval = 0;
		if(sid == 1)
		{
			Get_Group1("","")
		}
		f.Group.value = '';
		str_mnr = f.s_mnr.value;
		countmain = f.Cut_Countrecord.value;
		spmnr = str_mnr.split(",");
		spcountmain = countmain.split(",");
		
		for(i=0  ;i < spmnr.length; i++){
				if(spcountmain[i] > 0)
				{
					if(parseFloat(spmnr[i]) == parseFloat(val))
						{
						eval("fa.main"+spmnr[i]+".style.display=''");
						sumval = parseFloat(sumval) +1
						}
						else
						{
						eval("fa.main"+spmnr[i]+".style.display='none'");
						}
				}
			}
			if(sumval > 0)
			{
				fa.cols.style.display = '';
			}
			else
			{
				fa.cols.style.display = 'none';
			}
	}

	function Get_Group1(f,val)
	{	
		f = document.form;
		fa = document.all;
		var str_style,str_mnr,sumval;
		sumval=0;
		f.Group1.value = '';		
		f.Group.value = val;
		str_mnr = f.s_mnr1.value;
		c_count = f.s_count.value;
		spmnr = str_mnr.split(",");
		spcount = c_count.split(",");
		for(i=0  ;i < spmnr.length; i++){
			eval("f.Group1"+spmnr[i]+".value=''");
			if(spcount[i] > 0)
				{
						if(parseFloat(spmnr[i]) == parseFloat(val))
							{
							sumval = parseFloat(sumval) +1
							eval("fa.main1"+spmnr[i]+".style.display=''");
							}
							else
							{
							eval("fa.main1"+spmnr[i]+".style.display='none'");
							}
				}	
		}
		if(sumval > 0)
			{
				fa.cols1.style.display = '';
			}
			else
			{
				fa.cols1.style.display = 'none';
			}

	}


	function popup(mode,id)
	{
			if(mode == 1)
			{
			 src = "maillist.asp?maillist="+id;
			 }
			 else
			 {
			 src="mailcontact.asp?"+id
			 }
			winstyle = "height=200,width=400,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,top=250,left=250";
			window.open(src,null,winstyle);
	}

	function Fill_val(f,val,id)
	{
			f = document.form;
			if (id == 1)
			{
			f.Group.value = val;
			}
			else
			{
			f.Group1.value = val;
			}
	}
	
	function set_val(id,val)
	{
		f= document.form;
		eval("f.Group1"+id+".value = "+val+"")
	}
	function IsDigits(Temp,f,name){
		var v = Temp.value
		var m = v.match(/[0-9]+/)
		var n = v.match(/0/)
		if(null != m){
			if (m[0].length==v.length){
			return true;
			}
		}
		alert(" Please Check  Amonut again !!")
		eval("f."+name+".value = 1")
		return false;
}
//window.onerror = handle_error; function handle_error(){return true;}

	



