﻿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_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}
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 checkstic(){
if(document.frmAction.ckFlodlevel.checked==true)
 {
 document.frmAction.sequence.disabled=false;
 document.frmAction.foldlevl.disabled=false;
 }
 else{
 document.frmAction.sequence.disabled=true;
 document.frmAction.foldlevl.disabled=true;
 }
}

function searchByChoice() {
   // if (document.frmAction.rbType[0].checked == true) {
   //if (document.frmAction.rbType.checked == true) {
   //     document.frmAction.action="/product/ProductSearch.jsp";
   // } else {
   //     document.frmAction.action="/customer/CustomerSearch.jsp";
   // }
    if(document.frmAction.selectSearchChang.selectedIndex==0){
       document.frmAction.action="/product/ProductSearch.jsp";
   }
   else if(document.frmAction.selectSearchChang.selectedIndex==1){
   	document.frmAction.action="/customer/CustomerSearch.jsp";
   }
    document.frmAction.submit();
}

function searchByComboBox() {
    if (document.frmAction.fldSearch.value == "") {
        alert("Please enter the key word you wanna search !");
        document.frmAction.fldSearch.focus();
    } else {
        if (document.frmAction.rbType.value == "product") {
            document.frmAction.action="/product/ProductSearch.jsp?DISTINTYPE=PS";
        } else if (document.frmAction.rbType.value == "supplier") {
            document.frmAction.action="/customer/CustomerSearch.jsp?DISTINTYPE=FS";
        }
        document.frmAction.submit();
    }
}
function searchByComboBox1(seqt,superseqt,foldlevl) {
    if (document.frmAction.fldSearch.value == "") {
        alert("Please enter the key word you wanna search !");
        document.frmAction.fldSearch.focus();
    } else {
        if (document.frmAction.rbType.value == "product") {
            document.frmAction.action="/product/ProductSearch.jsp?DISTINTYPE=PS&sequence="+superseqt+"&superseqt="+superseqt+"&foldlevl="+foldlevl;
        } else if (document.frmAction.rbType.value == "supplier") {
            document.frmAction.action="/customer/CustomerSearch.jsp?DISTINTYPE=FS&sequence="+superseqt+"&superseqt="+superseqt+"&foldlevl="+foldlevl;
        }
        document.frmAction.submit();
    }
}

function getJSDate() {
    today = new Date()
    var theyear = today.getYear()
    var themonth = today.getMonth()+1
    var thedate = today.getDate()
    var theday = today.getDay()
    switch(themonth){
    	case 1 : themonth="Jan";break;
    	case 2 : themonth="Feb";break;
    	case 3 : themonth="Mar";break;
    	case 4 : themonth="Apr";break;
    	case 5 : themonth="May";break;
    	case 6 : themonth="Jun";break;
    	case 7 : themonth="Jul";break;
    	case 8 : themonth="Aug";break;
    	case 9 : themonth="Sep";break;
    	case 10 : themonth="Oct";break;
    	case 11 : themonth="Nov";break;
    	case 12 : themonth="Dec";break;
    }
    switch(theday){
    	case 1 : theday="Monday";break;
    	case 2 : theday="Tuesday";break;
    	case 3 : theday="Wednesday";break;
    	case 4 : theday="Thursday";break;
    	case 5 : theday="Friday";break;
    	case 6 : theday="Saturday";break;
    	case 7 : theday="Sunday";break;
    }
    document.write(theday,"&nbsp;",".","&nbsp;",themonth,"&nbsp;",thedate,"&nbsp;",".","&nbsp;",theyear);
}

//前台  mail check
function submitcheck(){
    trimAllElements();
   obj=document.sendMailForm;
   if ( obj.fldSubject.value.length ==0 )
	  alert("please specify your Subject before submiting!");
   else if  ( obj.txtMessage.value.length ==0 )
	   alert("please specify your Message before submiting!");
   else if  ( obj.fldCompname.value.length ==0 )
	   alert("please specify your Company Name before submiting!");
   else if  ( obj.fldFrstname.value.length ==0 )
	   alert("please specify your First Name before submiting!");
   else if  ( obj.fldLastname.value.length ==0 )
	   alert("please specify your Last Name before submiting!");
   else if  (obj.fldCompmail.value.length ==0 )
	   alert("please specify your Major E-mail: before submiting!");
   else if  ( obj.fldTel1.value.length ==0 )
	   alert("please specify your Business Tel No. before submiting!");
   else if  ( obj.fldTel2.value.length ==0 )
	   alert("please specify your Business Tel No. before submiting!");
   else if  (obj.fldTel3.value.length ==0 )
	   alert("please specify your Business Tel No. before submiting!");
   else if (isNaN(obj.fldTel1.value))
	     alert("please specify your Business Tel No. before submiting!");
   else if (isNaN(obj.fldTel2.value))
	     alert("please specify your Business Tel No. before submiting!");
   else if (isNaN(obj.fldTel3.value))
        alert("please specify your Business Tel No. before submiting!");
   else if (isNaN(obj.fldFax1.value))
	     alert("please specify your Business FAX No. before submiting!");
   else if (isNaN(obj.fldFax2.value))
	     alert("please specify your Business FAX No. before submiting!");
   else if (isNaN(obj.fldFax3.value))
	     alert("please specify your Business FAX No. before submiting!");
   else if (!isEmailValidedf(obj.fldCompmail))
	     alert("please specify your MAIL before submiting!");
   else if (!isEmailValidedf(obj.backmail) && !obj.backmail.value.length ==0)
	     alert("please specify your MAIL before submiting!");
   else if (!isCheckboxSelected(obj.cbCustxxid))
	     alert("please specify your Selected before submiting!");
   else {
    obj.submit();
   }
}
function submitcheckbigpic(){
    trimAllElements();
   obj=document.sendMailForm;
   if ( obj.fldSubject.value.length ==0 )
	  alert("please specify your Subject before submiting!");
   else if  ( obj.txtMessage.value.length ==0 )
	   alert("please specify your Message before submiting!");
   else if  ( obj.fldCompname.value.length ==0 )
	   alert("please specify your Company Name before submiting!");
   else if  ( obj.fldFrstname.value.length ==0 )
	   alert("please specify your First Name before submiting!");
   else if  ( obj.fldLastname.value.length ==0 )
	   alert("please specify your Last Name before submiting!");
   else if  (obj.fldCompmail.value.length ==0 )
	   alert("please specify your Major E-mail: before submiting!");
   else if  ( obj.fldTel1.value.length ==0 )
	   alert("please specify your Business Tel No. before submiting!");
   else if  ( obj.fldTel2.value.length ==0 )
	   alert("please specify your Business Tel No. before submiting!");
   else if  (obj.fldTel3.value.length ==0 )
	   alert("please specify your Business Tel No. before submiting!");
   else if (isNaN(obj.fldTel1.value))
	     alert("please specify your Business Tel No. before submiting!");
   else if (isNaN(obj.fldTel2.value))
	     alert("please specify your Business Tel No. before submiting!");
   else if (isNaN(obj.fldTel3.value))
        alert("please specify your Business Tel No. before submiting!");
   else if (isNaN(obj.fldFax1.value))
	     alert("please specify your Business FAX No. before submiting!");
   else if (isNaN(obj.fldFax2.value))
	     alert("please specify your Business FAX No. before submiting!");
   else if (isNaN(obj.fldFax3.value))
	     alert("please specify your Business FAX No. before submiting!");
   else if (!isEmailValidedf(obj.fldCompmail))
	     alert("please specify your MAIL before submiting!");
   else if (!isEmailValidedf(obj.backmail) && !obj.backmail.value.length ==0)
	     alert("please specify your MAIL before submiting!");

   else {
    obj.submit();
   }
}

function countwd(){
 if (document.sendMailForm.txtMessage.value.length>2000)
    alert("Not more 2000");
    document.sendMailForm.fldCount.value=document.sendMailForm.txtMessage.value.length;
}

function setNextWeekDate(){
var today = new Date();

today.setDate(today.getDate()+7);

var year;
var month;
var day;
year = today.getYear();
month = today.getMonth()+1;
day = today.getDate();
document.sendMailForm.listMonth.selectedIndex=month-1;
document.sendMailForm.listYear.selectedIndex=year-2003;
document.sendMailForm.listDay.selectedIndex=day-1;
}

function setRequestURL() {
    document.sendMailForm.RqstURL.value = document.URL;
    //alert(document.URL);
}
//前台  mail check

// Buyer Login
function jsBuyerLogin() {
    var id = document.BuyerLoginForm.BuyerLoginID;
    var pw = document.BuyerLoginForm.BuyerLoginPW;
    if (id.value == "") {
        alert("Please Enter Your ID !!");
        id.focus();
        return ;
    } else if (pw.value == "") {
        alert("Please Enter Your Password !!");
        pw.focus();
        return;
    } else {
        document.BuyerLoginForm.submit();
    }
}