/*************************************************************************/
/** Functions Written For CS */
/************************************************************************* */

function checkQuantity(qty,flag) {
   var ret = true;
   for(var i=0;i<document.main.length;i++){
    var e = document.main.elements[i];
    if(e.type=="text" && e.name.indexOf("quantity") !=-1 && e.value > qty && productIsChecked(e.name,flag)){
 	       e.focus();
 	       alert('Maximum Quantity Allowed: '+6);
 	       ret = false;
 	       break;
     }
   }
  return ret;
}

function productIsChecked(fld,flg){
   if(flg=='false')
     return true;
   var id = fld.substr(8);
   if(document.main.product_id!=null){
       /* one row only */
       if(document.main.product_id.value!=null && document.main.product_id.checked==true
                    && document.main.product_id.value==id)
         return true;
       else{
         for (var i=0;i<document.main.product_id.length;i++){
         
           if(document.main.product_id[i].checked==true && document.main.product_id[i].value == id){

             return true;
           }
         }
       }
     }
   return false;
}

function addProductToCart(action_name,param){
	document.main.action.value = action_name;
	document.main.product_id.value = param;
	document.main.submit();
}

function popUPSmartFormMsg(){
  popUpMessage("Error","Smart Form Error","At Least One Product does not have smart form information")
}

function saveSmartform() {
    opener.location = "./transactive?action=VIEW_SHOPPING_CART";  
    self.close(); 
    opener.focus();
}

function popUpSmartForm(URL) {    
    var page = window.open(URL,'details', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=900,height=500,left=50,top=127');
    page.focus();
}
/*************************************************************************/
/** End of CSC Functions
/************************************************************************* */
  


