/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
\                                                                                              \
\           libraries/function.js                                                              \
\                                                                                              \
\                This file is part of online shopping cart system                              \
\                                                                                              \
\                                                                                              \
\        (C) Copyright 2004                                                                    \
\                                                                                              \
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
/*******************************************************************************************

        AUTHOR: Priya Saliya Wijesinghe <priyasaliya@yahoo.com>
        FILE:   libraries/function.js
        PURPOSE:
                1.  javascript functions
        COMMENT:
******************************************************************************************/
  /*==================================================================
       function con_del use for get confirmed request on delete a,
               1. category.
               2. product
       variables :
             getId --> id of removeing
             msg   --> warning massage
             path  --> path for delete code
  */
  function con_del(getId,msg,path,flag,pg)
   {
     if(flag=="c"){
        var link=path+"&use=delc&id=" + getId;
     }else if(flag=="l"){
        var link=path+"&use=dell&id=" + getId + "&pgNo=" + pg;
     }else if(flag=="p"){
        var link=path+"&use=delp&id=" + getId + "&pgNo=" + pg;
     }

            if(confirm(msg)){
            document.location.href=link;
            }
   }
  /*==================================================================
       function for desable
       or for enabled shipping objects in billing info
  */

   function shipHand(thisVal){
       if(thisVal=="Y"){
              document.frmBillNShip.billCountry[0].disabled=true;
             alert("ssss");
           }
   }


  /*==================================================================
       function billNship use for disabled
       or for enabled some objects in billing info
  */
  function billNship()
   {
       if (document.frmBillNShip.bill_s_ship.checked==true)
       {
           document.frmBillNShip.shipCompany.disabled=true;
           document.frmBillNShip.shipName.disabled=true;
           document.frmBillNShip.shipAddress.disabled=true;
           document.frmBillNShip.shipStreet.disabled=true;
           document.frmBillNShip.shipCity.disabled=true;
           document.frmBillNShip.shipState.disabled=true;
           document.frmBillNShip.shipZip.disabled=true;
           document.frmBillNShip.shipCountry.disabled=true;
           document.frmBillNShip.shipTel.disabled=true;
       }else{
           document.frmBillNShip.shipCompany.disabled=false;
           document.frmBillNShip.shipName.disabled=false;
           document.frmBillNShip.shipAddress.disabled=false;
           document.frmBillNShip.shipStreet.disabled=false;
           document.frmBillNShip.shipCity.disabled=false;
           document.frmBillNShip.shipState.disabled=false;
           document.frmBillNShip.shipZip.disabled=false;
           document.frmBillNShip.shipCountry.disabled=false;
           document.frmBillNShip.shipTel.disabled=false;
       }
   }
  /*==================================================================
       function validate_bill use for validate user inputs
       on billing information window
  */
  function validate_bill()
   {
       if (document.frmBillNShip.bill_s_ship.checked==true)
       {
           document.frmBillNShip.shipName.disabled=true;
           document.frmBillNShip.shipAddress.disabled=true;
           document.frmBillNShip.shipState.disabled=true;
           document.frmBillNShip.shipZip.disabled=true;
           document.frmBillNShip.shipCountry.disabled=true;
       }else{
           document.frmBillNShip.shipName.disabled=false;
           document.frmBillNShip.shipAddress.disabled=false;
           document.frmBillNShip.shipState.disabled=false;
           document.frmBillNShip.shipZip.disabled=false;
           document.frmBillNShip.shipCountry.disabled=false;
       }
   }
  /*==================================================================*/

   function del_alt()
   {
     var msg="WARNING! Sorry, You can not delete this catagory " ;
     alert(msg);
   }
  /*==================================================================*/

   function show_code(item,shop){
        args="width="+300+",height="+400+",resizable=no,scrollbars=yes,status=0";
        myUrl="inc/prod_code.php?shop="+shop +"&myItem="+ item;
        window.open(myUrl,"procode",args);
   }

  /*==================================================================*/
   function show_zoom(item,shop){
        args="width="+600+",height="+500+",resizable=no,scrollbars=yes,status=0";
        myUrl="img_zoom.php?shop="+shop +"&myItem="+ item;
        window.open(myUrl,"zoom",args);
   }
  /*==================================================================*/

   function img_up(item,shop,varify){
        args="width="+400+",height="+250+",resizable=no,scrollbars=yes,status=0";
        myUrl="../img_ftp/img_upload.php?shop="+shop +"&myItem="+ item +"&varify="+ varify;
        window.open(myUrl,"imgup",args);
   }     /*==================================================================*/

   function show_cat_code(item,shop){
        args="width="+300+",height="+200+",resizable=no,scrollbars=yes,status=0";
        myUrl="inc/cat_code.php?shop="+shop +"&myCat="+ item;
        window.open(myUrl,"catcode",args);
   }



   /**
 * Checks/unchecks all tables
 *
 * @param   string   the form name
 * @param   boolean  whether to check or to uncheck the element
 *
 * @return  boolean  always true
 */
function setCheckboxes(the_form, do_check)
{
    var elts      = document.forms[the_form].elements['selected_types[]'];
    var elts_cnt  = (typeof(elts.length) != 'undefined')
                  ? elts.length
                  : 0;

    if (elts_cnt) {
        for (var i = 0; i < elts_cnt; i++) {
            elts[i].checked = do_check;
        } // end for
    } else {
        elts.checked        = do_check;
    } // end if... else

    return true;
} // end of the 'setCheckboxes()' function