﻿function CheckAll(checked) {
  len = document.mlist.elements.length;
  var i=0;
  for( i=0; i<len; i++) {
    if (document.mlist.elements[i].name=='ProductID') {
      document.mlist.elements[i].checked=(checked==true?true:false);
    }
  }
}

function putinbasket(){
    var basketItemMax = parseInt(document.mlist.basketItemMax.value);
    var basketItemNum = parseInt(document.mlist.basketItemNum.value);
    var num = getCheckedNum();    
    //var urlString = document.location+"";
    if(num == 0) {
        alert("No Product(s) selected! Please select one or more Products!")
        return;
    }

    if(basketItemMax < (basketItemNum+num)) {
//    var alertMessage="Your Inquiry Basket is full. It can store a maximum of "+basketItemMax+" inquiries.";
    var alertMessage="Your Inquiry Basket is full. It can store a maximum of "+basketItemMax+" inquiries.\n\n"+basketItemNum+" inquiries In Your Basket, You can Select "+(basketItemMax-basketItemNum)+" inquiries now. But you selected "+num+".";
        alert(alertMessage);
        return;
    }
    document.mlist.action="PutInBasket.asp";
    //document.mlist.target="";
    document.mlist.submit();
    }

function Basket(action){
if (action=="Basket_View")
location.href="Basket_View.asp";
}

function Basket_Inquiry(){
  var flag,i,len;
  flag = false;
  i = 0;
  len = document.mlist.elements.length;
  for( i=0; i<len; i++) {
    if ((document.mlist.elements[i].name=='ProductID') && (document.mlist.elements[i].checked==true)){
        document.mlist.action="Basket_Inquiry.asp";
        document.mlist.submit();
	 flag = true;
	 }
  }
    if (flag == true)
     document.mlist.submit();
      else
        document.mlist.action="Basket_Inquiry.asp";
        document.mlist.submit();
}

function getCheckedNum()
{
    var num = 0;                
    for(var i=0;i<document.mlist.elements.length;i++)
    {  
        var e = document.mlist.elements[i];
        if (e.name == 'OpportunitiesID'||e.name == 'ProductID'||e.name == 'CorpID') {
            if(e.checked)
                num++;
        }
    }
    return num;
}
function openScript(url, width, height ,isbars) {
        window.open(url,"",'width=' + width + ',height=' + height + ',resizable=no,scrollbars='+ isbars + ',status=no,toolbar=no,menubar=no,location=no ');
}
