	
	
	function DetailModal(qid,path){
		styles = 'dialogWidth=600px;dialogHeight=500px;dialogTop=20;dialogLeft=100px;status=no;help=no;';
		src = path+"sdbsdetail.asp?Gid="+qid;
		window.showModalDialog(src,window,styles); 
	}
	
	
	function chk_blank()
	{
		f = document.forms(0);
				if(Trim(f.Data.value))
				{
					WarnInput(f.Data," คำที่คุณต้องการค้นหา ")
				}
				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 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 Selected "+ name +" ")
			key.focus();
	}		

		function openWin(win_src,win_name,width,height)
		{
		 window.open(win_src,win_name,"status=yes,toolbar=no,location=no,scrollbars=yes,left=1,top=1,width="+width+",height="+height);
		}

function shwCus()
{
	var numberseat = document.all.numberseat.value;
	var numtotal= document.all.numtotal.value;
		if(numberseat != "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(numberseat);i++){
			eval("document.all.row"+i+".style.display ='' ") 
		     }
			 document.all.numtotal.value=eval(numberseat)
}

		
	function chk_step2(f)
		{
								f.action="?p=ship1"
								f.method="post"
								f.submit();
		}


	
	
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 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 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 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_mailcontact()
{
		f = document.form;
		if(Trim(f.str_sender.value)){
				WarnInput(f.str_sender ," Sender ")
		}
		else if(!check_email(f.str_email.value)){
				Warncheck(f.str_email," 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;
			str_email = f.str_email.value;
			id = "str_email="+str_email+"&sender="+senders+"&suject="+subjects+"&comment="+comments
			popup('2',id)
		}
}

function chk_maillist(f)
{
		if(f.maillist.value.length <4){
				Warncheck(f.maillist," อีเมลล์ ")
		}
		else if(!check_email(f.maillist.value)){
				Warncheck(f.maillist," อีเมลล์ ")
		}
		else
		{
			maillist = f.maillist.value;
			popup('1',maillist)
		}
}
	
		function popup(mode,id)
	{

			if(mode == 1)
			{
			 src = "Sdbsmaillist.asp?maillist="+id;
			 }
			 else
			 {
			 src="Sdbsmailcontact.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 chk_reserve()
{
	f = document.form;
	 if(f.numberseat.value != "")
		{
			var submit=false;
			count = 0
			var numtotal = eval(document.all.numberseat.value)
			for(k=1;k<=eval(document.all.numberseat.value);k++)
				{
					if  (eval("f.res_name"+k+".value")  ==  ""  ||   eval("f.res_address"+k+".value")  ==  "")
					{
						if  (eval("f.res_name"+k+".value") == "")
						{
						alert("Please Insert Name  "+k+"")
						eval("f.res_name"+k+".focus()")
						submit = true
						return 0
						}
						else if (eval("f.res_address"+k+".value")  ==  "")
						{
						alert("Please Insert Address "+k+" ")
						eval("f.res_address"+k+".focus()")
						submit = true
						return 0
						}
					}
					else
					submit=false
					if (submit == false)
					{
					count = (eval(count)+1)
						if (eval(count) == eval(numtotal))
						{
							con = confirm(" Confirm Reserving")
							if(con)
							{
							f.submit()
							}
						} 
					}
				}
			}

}

	function dmy(str_day,str_month,str_year)
	{
	f = document.form;
    var cday=eval("f."+str_day+".value");
	var cmonth=eval("f."+str_month+".value");
	var cyear=eval("f."+str_year+".value");
	if((cmonth == 'Apr')||(cmonth == 'Jun')||(cmonth == 'Jun')||(cmonth == 'Nov'))
	{
		if(cday > 30)
		{
		alert ('Please Check Day Again  ( This month have 30days )');
		eval("f."+str_day+".value = 30 ");
		eval("f."+str_day+".focus");
		}
	}
	else if(cmonth =='Feb')
		{
		var nyear = eval((cyear - 543)%4);
		if( nyear > 0 && cday > 28)
			{
		//	alert(nyear);
			alert('Please Check Day Again  ( This month have 28 days )');
			eval("f."+str_day+".value = 28 ");
			eval("f."+str_day+".focus");
			}
		else if( nyear == 0 && cday > 29)
			{
			//alert(nyear);
			alert(' Please Check Day Again  ( This month have 29 days )');
			eval("f."+str_day+".value = 29 ");
			eval("f."+str_day+".focus");
			}
		}
	}

	



