﻿var tsearch=false;
function Checksearch(txtsearch){
	if (trim(document.getElementById(txtsearch).value)==""){
	alert("請輸入關鍵字");
	return false;
	}
}


function trim(instr){
  return instr.replace(/^[\s]*/gi,"").replace(/[\s]*$/gi,"");
}

function checkmama_class(ddlyear1,ddlmonth1,cid){
 var txt;	
 
	  if (document.getElementById(ddlyear1).value=="請選擇"){
		txt=document.getElementById(ddlyear1);
		alert('請選擇(年)');
		//txt.focus();       
		return false;
	    }
	    
	     if (document.getElementById(ddlmonth1).value=="請選擇"){
		txt=document.getElementById(ddlmonth1);
		alert('請輸入(月)');
		//txt.focus();       
		return false;
	    }	    
	 	
	    
	var urls ="?year1="+document.getElementById(ddlyear1).value+"&month1="+document.getElementById(ddlmonth1).value+"&cid="+cid;
	
	location.href='mama_class.aspx'+urls;
	return false;
		
}

function checksearchdate_video(ddlyear1,ddlyear2,ddlmonth1,ddlmonth2){
 var txt;	
	  if (document.getElementById(ddlyear1).value=="請選擇"){
		txt=document.getElementById(ddlyear1);
		alert('請選擇(起始)年');
		txt.focus();       
		return false;
	    }
	    
	     if (document.getElementById(ddlmonth1).value=="請選擇"){
		txt=document.getElementById(ddlmonth1);
		alert('請輸入(起始)月');
		txt.focus();       
		return false;
	    }
	    
	 	    if (document.getElementById(ddlyear2).value=="請選擇"){
		txt=document.getElementById(ddlyear2);
		alert('請輸入(至)年');
		txt.focus();       
		return false;
	    }
	    
	     if (document.getElementById(ddlmonth2).value=="請選擇"){
		txt=document.getElementById(ddlmonth2);
		alert('請輸入(至)月');
		txt.focus();       
		return false;
	    }
	
	var urls ="?year1="+document.getElementById(ddlyear1).value+"&year2="+document.getElementById(ddlyear2).value+"&month1="+document.getElementById(ddlmonth1).value+"&month2="+document.getElementById(ddlmonth2).value;
	
	location.href='video_center.aspx'+urls;
	return false;
		
}

function checksearchdate(ddlyear1,ddlyear2,ddlmonth1,ddlmonth2,murl){
 var txt;	
	  if (document.getElementById(ddlyear1).value=="請選擇"){
		txt=document.getElementById(ddlyear1);
		alert('請選擇(起始)年');
		txt.focus();       
		return false;
	    }
	    
	     if (document.getElementById(ddlmonth1).value=="請選擇"){
		txt=document.getElementById(ddlmonth1);
		alert('請輸入(起始)月');
		txt.focus();       
		return false;
	    }
	    
	 	    if (document.getElementById(ddlyear2).value=="請選擇"){
		txt=document.getElementById(ddlyear2);
		alert('請輸入(至)年');
		txt.focus();       
		return false;
	    }
	    
	     if (document.getElementById(ddlmonth2).value=="請選擇"){
		txt=document.getElementById(ddlmonth2);
		alert('請輸入(至)月');
		txt.focus();       
		return false;
	    }
	
	var urls ="?year1="+document.getElementById(ddlyear1).value+"&year2="+document.getElementById(ddlyear2).value+"&month1="+document.getElementById(ddlmonth1).value+"&month2="+document.getElementById(ddlmonth2).value;
	
	location.href=murl+urls;
	return false;
		
}

function beginsearch() {
var msearch=trim(document.all.q.value);
	if (msearch != "")
	{
	  if (msearch == "紅十字"&&tsearch==false){
	    alert("請輸入關鍵字");
		return false;
	  }	  
	  window.location.href='product_catagory2.aspx?msearch='+encodeURI(msearch);
	}else{
	alert("請輸入關鍵字");
	return false;
	}

}