﻿
// 按鈕 onMouseOver 更換圖片的功能
function MM_swapImgRestore() 
	{ //v3.0
			var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}

function MM_swapImage() 
	{ //v3.0
  			var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   			if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}

function MM_findObj(n, d) 
	{ //v4.01
  			var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) 
  			{
    		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
    		}
  			if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  			for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  			if(!x && d.getElementById) x=d.getElementById(n); return x;
	}



// 共用搜尋的功能
function search1() 
    {     
	if(document.main.ddl_otherweb.value=="")
	{
	    	window.alert("請選擇網站!");
	    	document.main.ddl_otherweb.focus();
	}
	else
	{
	    	window.location.href=document.main.ddl_otherweb.value
	}
    } 

function search2() 
    {     
	if(document.main.ddl_countryid.value=="" && document.main.ddl_cityid.value=="" && document.main.ddl_areaid.value=="" && document.main.ddl_sltptype.value=="")
	{
	    	window.alert("請選擇搜尋條件.");
	    	document.main.ddl_countryid.focus();
	}
	else
	{
    		var vcountryid=document.main.ddl_countryid.value;
    		var vcityid=document.main.ddl_cityid.value;        
        	var vareaid=document.main.ddl_areaid.value;
   			var vltptype=document.main.ddl_sltptype.value;
   			var vfromdatey=document.main.ddl_fromdatey.value;
   			var vfromdatem=document.main.ddl_fromdatem.value;
   			var vfromdated=document.main.ddl_fromdated.value;
   			var vfromdate=vfromdatey + "/" + vfromdatem + "/" + vfromdated;
    		window.location.href="ltp_main.aspx?sltptype=" + vltptype + "&countryid=" + vcountryid + "&cityid=" + vcityid + "&areaid=" + vareaid + "&fromdate=" + vfromdate
    }
    } 

function search3() 
    {     
	if(document.main.tb_sltpname.value=="")
	{
	    	window.alert("請輸入關鍵字.");
	    	document.main.tb_sltpname.focus();
	}
	else
	{
    		var vltpname=document.main.tb_sltpname.value;
    		window.location.href="ltp_main.aspx?sltpname=" + vltpname
    }
    } 

// 共用搜尋的功能 - 訂購說明專用    
function search4() 
    {     
	if(document.main.ddl_countryid.value=="" && document.main.ddl_cityid.value=="" && document.main.ddl_areaid.value=="" && document.main.ddl_sltptype.value=="")
	{
	    	window.alert("請選擇搜尋條件.");
	    	document.main.ddl_countryid.focus();
	}
	else
	{
    		var vcountryid=document.main.ddl_countryid.value;
    		var vcityid=document.main.ddl_cityid.value;        
        	var vareaid=document.main.ddl_areaid.value;
   			var vltptype=document.main.ddl_sltptype.value;
   			var vfromdatey=document.main.ddl_fromdatey.value;
   			var vfromdatem=document.main.ddl_fromdatem.value;
   			var vfromdated=document.main.ddl_fromdated.value;
   			var vfromdate=vfromdatey + "/" + vfromdatem + "/" + vfromdated;
    		window.location.href="../ltp_main.aspx?sltptype=" + vltptype + "&countryid=" + vcountryid + "&cityid=" + vcityid + "&areaid=" + vareaid + "&fromdate=" + vfromdate
    }
    } 

function search5() 
    {     
	if(document.main.tb_sltpname.value=="")
	{
	    	window.alert("請輸入關鍵字.");
	    	document.main.tb_sltpname.focus();
	}
	else
	{
    		var vltpname=document.main.tb_sltpname.value;
    		window.location.href="../ltp_main.aspx?sltpname=" + vltpname
    }
    } 
    

function searchHatoBus() 
    {     
   
	if(document.getElementById("HH_tb_sltpname2").value=="")
	{
	    	window.alert("請輸入關鍵字.");
	    	document.getElementById("HH_tb_sltpname2").focus();
	}
	else
	{
	
    		var vltpname=document.getElementById("HH_tb_sltpname2").value;
    		window.location.href="/List.aspx?sltpname=" + vltpname
    }
    } 


// ltp_reserve2.aspx - 檢查"旅客資料"
function check_TrData()
{
    	for (i = 0; i < document.main.elements.length; i++) 
    	{
        	if (document.main.elements[i].name.indexOf('tb_cname') == 0) 
			{
        		if (document.main.elements[i].value == '') 
        		{
        			window.alert('請輸入中文姓名!');
        			document.main.elements[i].focus();
        			return false;
        		}
        	}
        	else if (document.main.elements[i].name.indexOf('tb_efname') == 0) 
			{
        		if (document.main.elements[i].value == '') 
        		{
        			window.alert('請輸入英文姓名 ~ First Name!');
        			document.main.elements[i].focus();
        			return false;
        		}
        	}
        	else if (document.main.elements[i].name.indexOf('tb_elname') == 0) 
			{
        		if (document.main.elements[i].value == '') 
        		{
        			window.alert('請輸入英文姓名 ~ Last Name!');
        			document.main.elements[i].focus();
        			return false;
        		}
        	}
        	else if (document.main.elements[i].name.indexOf('ddl_birthy') == 0) 
			{
        		if (document.main.elements[i].value == 0) 
        		{
        			window.alert('請選擇出生日期 ~ 年 !');
        			document.main.elements[i].focus();
        			return false;
        		}
        	}
        	else if (document.main.elements[i].name.indexOf('ddl_birthm') == 0) 
			{
        		if (document.main.elements[i].value == 0) 
        		{
        			window.alert('請選擇出生日期 ~ 月 !');
        			document.main.elements[i].focus();
        			return false;
        		}
        	}
        	else if (document.main.elements[i].name.indexOf('ddl_birthd') == 0) 
			{
        		if (document.main.elements[i].value == 0) 
        		{
        			window.alert('請選擇出生日期 ~ 日 !');
        			document.main.elements[i].focus();
        			return false;
        		}
        	}
    	}
    	return true;
}



// ltp_reserve3.aspx - "列印訂單"
function prtord()
	{
	vltpremid=document.main.hi_ltpremid.value;
	window.open("ltp_prt_reserve.aspx?ltpremid=" + vltpremid);
	}



// 分期付款特惠專案
/*
function opengepu() 
	{
			window.open("http://www.leonpkg.com.tw/gepu.htm","分期付款特惠專案","width=412,height=316");
	}
*/
//輸入檢查
function chkinput(obj,typ){
	var s = obj.value
	switch (typ)
	{
	case "EN": 
		var first = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(s.charAt(s.length-1))
		if (first >= 0)
		{
			obj.value = s.toUpperCase();
		}else{
			obj.value = s.slice(0,s.length-1)
		}
		break;
	case "NUM": 
		var first = "0123456789".indexOf(s.charAt(s.length-1))
		if (first < 0)
		{
			obj.value = s.slice(0,s.length-1)
		}
		break;
	case "TEL":
		var first = "0123456789-X".indexOf(s.charAt(s.length-1))
		if (first < 0)
		{
			obj.value = s.slice(0,s.length-1)
		}
		break;
	case "CH":
		var first = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/*-+.~!@#%^&*()_+<>?;:\"'$|\\[]{}`".indexOf(s.charAt(s.length-1))
		if (first >= 0)
		{
			obj.value = s.slice(0,s.length-1)
		}
		break;
	case "IdNo": 
		var first = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(s.charAt(s.length-1))
		if (first >= 0)
		{
			obj.value = s.toUpperCase();
		}else{
			obj.value = s.slice(0,s.length-1)
		}
		break;
	}
}
//-->

