function removefromcartfrmbucket(isbn, qty){
    if (document.bucketCartform != null ) {
        document.bucketCartform.action.value = 'removefromcart';
        document.bucketCartform.isbn.value = isbn;
        document.bucketCartform.qty.value = qty;
        document.bucketCartform.submit();
    }
}
function addtocartfrmbucket(isbn, qty){
    if (document.bucketCartform != null ) {
        document.bucketCartform.action.value = 'addtocart';
        document.bucketCartform.isbn.value = isbn;
        document.bucketCartform.qty.value = qty;
        if (isbn.length == 8 )
		document.bucketCartform.type.value = 'ISSN';
        document.bucketCartform.submit();
    }
}
var a="";
function enableSubscrType(index) {
    a = index;
    var regionProdID = document.getElementById('region'+index).value;
    if(regionProdID == "-1") {
        document.getElementById('divSubscriptionType'+index).style.display='none';
        document.getElementById('divSubscriptionTerm'+index).style.display='none';
    }else{
        var URL = "../processrequestcatalog.jsp?action=subscriptionType&regionProdID=" + regionProdID + "&index=" + index + "&";
        makeRequest(URL, "a","doenableSubscrTypeOUT")
    }
}
function showprice(index) {
    a = index;
    var regionProdIDsubtype = document.getElementById('subtype'+index).value;
    if(regionProdIDsubtype == "-1") {
        document.getElementById('divSubscriptionTerm'+index).style.display='none';
    }else{
        var URL = "../processrequestcatalog.jsp?action=showprice&index=" + index + "&";
        makeRequest(URL, "a","showpriceOUT")
    }
}
function showpriceterm(index) {
    var strarray;
    var regionProdIDsubtypePrice = document.getElementById('subtype'+index).value;
    var subscrTerm = document.getElementById('subterm'+index).value;
    //alert("regionProdIDsubtypePrice::"+regionProdIDsubtypePrice);
    //alert("subscrTerm::"+subscrTerm);
    var region,prodid,subtype,price;
    strarray = regionProdIDsubtypePrice.split(":");
    region = strarray[0];
    prodid = strarray[1];
    subtype = strarray[2];
    price = strarray[3];
    document.getElementById('origprice'+index).value = price;
    //alert("origprice::"+document.getElementById('origprice'+index).value);
    var subtotal = "";
    var total = "";
    if(subscrTerm != "0") {
        subtotal = price*subscrTerm+"";
        if(subtotal.indexOf(".") == -1)
            total = subtotal + ".00";
        else if(subtotal.substring(subtotal.indexOf(".")+1,subtotal.length).length==1)
            total = subtotal + "0";
        else
            total = subtotal;
        document.getElementById('subprice'+index).value = "$"+total;        //currency symbol needs to be updated
    }else{
        document.getElementById('subprice'+index).value = "";
    }
}
//Ajax Calls
function makeRequest(url, parameters,callback) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      http_request.onreadystatechange = eval(callback);
      http_request.open('GET', url + parameters, true);
      http_request.send(null);
 }
function doenableSubscrTypeOUT() {
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                //alert(http_request.responseText);
                document.getElementById('divSubscriptionType'+a).style.display='block';
                document.getElementById('divSubscriptionType'+a).innerHTML = http_request.responseText;
             }
        }
}
function showpriceOUT() {
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                //alert(http_request.responseText);
                document.getElementById('divSubscriptionTerm'+a).style.display='block';
                document.getElementById('divSubscriptionTerm'+a).innerHTML = http_request.responseText;
             }
        }
}
