var pageNum = 1;		//分頁
var proclass = ""; //產品類別
var orderby = "";		//產品排序
var count = 0;

if (top.location != self.location)top.location=self.location;

//圖片抓取失敗時讀取的圖片
function getError(s){
   s.src="./img/RCNOPHOTOS.gif";
   return false;
}
//--  購物車 start ---------------------------------------
function addShopCar(i){
   var s = "&" + addRow(i);

   ifr_shopCar.location = "./shoppingcart/shoppingCar.jsp?show=add" + s;
}

function addRow(addindex){
  var s = "";

  s = "idkey="   + idkey.value +
      "&idno="   + idno.value +
      "&idname=" + idname.value +
      "&idprice="+ idprice.value +
      "&idnum="  + idnum.value;

  return s;
}

function showShoppingCar(){
   carlist.innerHTML =
      "<IFRAME name=\"ifr_shopCar\" src=\"\" width=\"100%\" height=\"150px\" frameborder=\"NO\" border=\"0\" framespacing=\"0\">請使用ie5.0以上的版本，否則看不到這裏的內容</IFRAME>";
   ifr_shopCar.location = "./shoppingcart/shoppingCar.jsp?show=y";

   addShopCar();

   return false;
}

//rc active
function activeType(actid,type){
   location = "activefra.jsp?tag="+ type +"&actid="+ actid;
}
//--  購物車 end  ---------------------------------------

function proIndex(s){
  location= "./index.jsp";
  return false;
}
//<!-- 點選左邊產品表單 表單 -->
function proClass(s,pag){
  //if(proclass=="")proclass="newpro";
  location= "./profra.jsp?tag=prolist&id="+ s +"&pageNum="+ pag;
  return false;
}
//<!-- 選擇品牌 (品牌, 產品分類) -->
function proTypeClick(brandno){
  if(brandno!="")location="./profra.jsp?tag=prolist&brandno="+ brandno;
  return false;
}
//<!-- Production Information -->
function ProInf(s,proid){
   location = "./profra.jsp?tag=proInf&id="+ s +"&proid="+ proid +"&proclass="+ proclass;
   return false;
}
function proType(proclass){
  location="./profra.jsp?tag=prolist&proclass="+ proclass;
  return false;
}
function proActive(proclass){
  location="./activefra.jsp?tag=&proclass="+ proclass;
  return false;
}

// ------  跳視窗抓取大圖  -----------
function getBigPic(sValue){
   var w=600;
   var h=480;
   sysWin = window.open('./showBigPic.jsp?showphoto='+ sValue,'member','scrollbars=yes,resizable=yes,width='+w+',height='+h+',top='+ (screen.height - h)/2 +',left='+(screen.width - w)/2 +',',true);
   sysWin.focus();
   sysWin.opener = window;
   return false;
}
function checkID(sId,temp,LangType){
  if(sId != ""){
    var w=170;
    var h=50;
    var x = (screen.width-w)/2;
    var y = (screen.height-h)/2;
    var ckid = window.showModalDialog('./member/CheckId.jsp?sId='+ sId +'&temp='+ temp+'&LangType='+LangType,false,"dialogWidth:"+ w +"px;dialogHeight:"+ h +"px;status:0;");
  }
  return ckid;
}
function checkMail(eMail,temp,LangType){
  if(eMail != ""){
    var w=170;
    var h=50;
    var x = (screen.width-w)/2;
    var y = (screen.height-h)/2;
    showModalDialog('./member/CheckId.jsp?ckmail='+ eMail+'&temp='+ temp+'&LangType='+LangType,false,"dialogWidth:"+ w +"px;dialogHeight:"+ h +"px;status:0;");
  }
}
function firstOrder(){
  location = "./orderfra.jsp?tag=list";
  return false;
}
function doPrint(){
  window.document.execCommand('Print');
}
//---- cart -----------------------------------------------------------------------------
function orderProducts(id ,s ,msg ){
    if (s.value < 0 || s.value== "" || !isInt(s.value))
       return false;

    var w=170;
    var h=50;
    //var w=570;
    //var h=550;

    var x = (screen.width-w)/2;
    var y = (screen.height-h)/2;
    //sysWin = window.open('./shoppingcart/addItem.jsp?id='+ id +'&idnum='+ s.value +'&show=add&msg='+ msg,'member','scrollbars=yes,resizable=yes,width='+w+',height='+h+',top='+ (screen.height - h)/2 +',left='+(screen.width - w)/2 +',',true);
    
    load_s();
    var inum = showModalDialog('./shoppingcart/addItem.jsp?id='+ id +'&idnum='+ s.value +'&show=add&msg='+ msg,false,"dialogWidth:"+ w +"px;dialogHeight:"+ h +"px;status:0;");
    load_end();
    
    if (inum != undefined && inum != "")
        s.value = inum;
}
//act03
function getItemNum(s, showNum){
    if (s.value== "" || s.value < 0)
       return false;

    var w=170;
    var h=50;

    var x = (screen.width-w)/2;
    var y = (screen.height-h)/2;
    
    var showUrl = "./shoppingcart/getItemNum.jsp?id="+ s.value;

    if ( (typeof actid) != "undefined" ){
       showUrl += "&actid="+ actid;
    }
    
    load_s();
    var inum = showModalDialog(showUrl,false,"dialogWidth:"+ w +"px;dialogHeight:"+ h +"px;status:0;");
    load_end();
    
    if ( (typeof inum) != "undefined" && inum != "")
        showNum.value = inum;
}
// act01 04 used
function addShopping(k){
  if(eval('addShop'+k).idkey.value == ""){
     alert("Please add the item.");
     return false;
  }else if(eval('addShop'+k).idnum.value==""){
    alert("Please Select Quantity.");
    return false;
  }

  orderActProducts(eval('addShop'+k).idkey.value ,eval('addShop'+k).idnum ,'y');
  return false;
}
//act01 . act05
//msg : 是否要顯示訊息 y/n
function orderActProducts(id ,s ,msg ){
    if (s.value < 0 || s.value== "" || !isInt(s.value))
       return false;

    var w=170;
    var h=50;
    //var w=570;
    //var h=550;

    var x = (screen.width-w)/2;
    var y = (screen.height-h)/2;
    
    load_s();
    var inum = showModalDialog('./shoppingcart/addItem.jsp?id='+ id +'&actid='+ actid +'&acttype='+ acttype +'&idnum='+ s.value +'&show=add&msg='+ msg,false,"dialogWidth:"+ w +"px;dialogHeight:"+ h +"px;status:0;");
    load_end();
    
    if (acttype == "03" || acttype == "04") {
      var finalnum = new Array();
      if (inum == undefined || inum == "") {
         window.top.location.reload();
         return;
      }
    }
    
    if (inum != undefined && inum != "")
      s.value = inum;
}
//act02
function orderAct02Products(s ,msg ){
    if (s.value < 0 || s.value== "" || !isInt(s.value))
       return false;

    var w=170;
    var h=50;
    //var w=570;
    //var h=550;

    var x = (screen.width-w)/2;
    var y = (screen.height-h)/2;
    
    load_s();
    var inum = showModalDialog('./shoppingcart/addItem.jsp?actid='+ actid +'&acttype='+ acttype +'&idnum='+ s.value +'&show=add&msg='+ msg,false,"dialogWidth:"+ w +"px;dialogHeight:"+ h +"px;status:0;");
    load_end();
    
    if (inum != undefined && inum != "")
        s.value = inum;
    else
    	window.top.location.reload();
}

//讀取檔案
function load_s(){
  MM_showHideLayers('LayerLoad','','show');
}
function load_end(){
  MM_showHideLayers('LayerLoad','','hide');
}

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 MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}