﻿var tsearch=false;
function Checksearch(txtsearch,ErrorMessage,Url,ddlC,cxname){
    var search=trim(document.getElementById(txtsearch).value);  
    var cid="";
    
    if (ddlC!=""){
    cid=trim(document.getElementById(ddlC).value); 
    if (cid==""){
	alert("Please Select Catagragory");
	document.getElementById(ddlC).focus();     
	return false;
	}
    }
    
	if (search==""){
	alert(ErrorMessage);
	document.getElementById(txtsearch).focus();     
	return false;
	}
		
window.location.href=Url+'?search='+encodeURI(search)+'&cid='+cid+'&cxname=' + cxname ;
return false;
}

function Checksearch2(txtsearch,ErrorMessage,Url,ddlC,cxname){
    var search=trim(document.getElementById(txtsearch).value);  
    var cid="";
    
    if (ddlC!=""){
    cid=trim(document.getElementById(ddlC).value); 
    if (cid==""){
	alert("Please Select Catagragory");
	document.getElementById(ddlC).focus();     
	return false;
	}
    }
    
	if (search==""){
	alert(ErrorMessage);
	document.getElementById(txtsearch).focus();     
	return false;
	}
		
window.location.href=Url+'?search='+encodeURI(search)+'&cid='+cid+'&cxname=' + cxname ;
return false;
}




function testNu2m(){
if ( !(window.event.keyCode>=48 && window.event.keyCode<=57 ))
      window.event.keyCode = 0;
}

function trim(instr){
  return instr.replace(/^[\s]*/gi,"").replace(/[\s]*$/gi,"");
}

function beginsearch() {
   var cid=document.getElementById("ddlC").value;
   var y1 = document.getElementById("ddlyear1").value;
   var m1 = document.getElementById("ddlmonth1").value;
   var y2 = document.getElementById("ddlyear2").value;
   var m2 = document.getElementById("ddlmonth2").value;
	
  window.location.href='news_list.aspx?cid='+ cid +'&y1='+encodeURI(y1)+'&m1='+encodeURI(m1)+'&y2='+encodeURI(y2)+'&m2='+encodeURI(m2);
	
}

function products_beginsearch() {
   var search=document.getElementById("Products_search1_txtsearch").value;  
if (search==""){
alert("請輸入關鍵字");
return false;
}
  window.location.href='products_list.aspx?search='+encodeURI(search);
	
}

function beginsearch_media() {
   var y1 = document.getElementById("ddlyear").value;
   var m1 = document.getElementById("ddlmonth").value;
	
  window.location.href='media.aspx?y1='+encodeURI(y1)+'&m1='+encodeURI(m1);
	
}