var ELE_NAME_ARRAY = new Array('chkBuyOfferIds','chkSellOfferIds','chkProductIds','chkCompanyIds');	
var MY_WEB_SERVER = "http://my.alibaba.com";
var US_MY_ALIBABA = "http://us.my.alibaba.com";
var WWW_SERVER    = "http://www.alibaba.com" ;


function check(checked){
  setCheckedFlag(document.form,ELE_NAME_ARRAY,checked);
}



function inquiryNow(){
    var checkedNum = getCheckedNum();
    var basketItemNum = parseInt(document.form.basketItemNum.value);
    var urlString = document.location+""; 
    
    if(checkedNum == 0) {
      if(basketItemNum == 0){
          alert("No item(s) selected.")
          return;    	
      }else{
          document.form.action=US_MY_ALIBABA+"/mcweb/inquiry_basket.htm";
          document.form.target="_blank";
          document.form.submit();    	
      }
    }

    if(checkedNum > 0) {
        document.form.action=US_MY_ALIBABA +"/mcweb/contact.htm?action=mcweb:contact_action";
        document.form.target="_blank";
        document.form.submit();
    }
}

function addBasket(){
    var basketItemMax = parseInt(document.form.basketItemMax.value);
    var basketItemNum = parseInt(document.form.basketItemNum.value);
    var num = getCheckedNum();
    var urlString = document.location+"";
    if(num == 0) {
        alert("No item(s) selected.")
        return;
    }

    if(basketItemMax < (basketItemNum + num)) {
        var alertMessage = "Your Inquiry Basket is full. It can store a maximum of " + basketItemMax + " inquiries.";
        alert(alertMessage);
        return;
    }
    
    document.form.action=window.location.href;
    document.form.target="";
    document.form.submit();
}

function getCheckedNum(){
  return getCheckedRecordNum(document.form,ELE_NAME_ARRAY);
}

function getBuyOfferCheckedNum(){
  return getCheckedItemNum('chkBuyOfferIds'); 	
}

function getSellOfferCheckedNum(){
  return getCheckedItemNum('chkSellOfferIds'); 	
}

function getCompanyCheckedNum(){
  return getCheckedItemNum('chkCompanyIds'); 	
}

function getProductCheckedNum(){
  return getCheckedItemNum('chkProductIds'); 	
}

function getCheckedItemNum(item){
  return getCheckedRecordNum(document.form,new Array(item)); 	
}

function uncheckQuote(){
  setCheckedFlag(document.form,new Array('chkBuyOfferIds'),false);
}

function uncheckRFQ(){
  setCheckedFlag(document.form,new Array('chkSellOfferIds','chkProductIds','chkCompanyIds'),false);	
}

function singleInquiryNow(inquiryType,id){
	var chkbox=document.getElementById("chk"+id);
	if (chkbox && chkbox.checked)
	{
	  document.form.action=US_MY_ALIBABA +"/mcweb/contact.htm?action=mcweb:contact_action";
    }
    else{
       document.form.action=US_MY_ALIBABA +"/mcweb/contact.htm?action=mcweb:contact_action&"+inquiryType+"="+id;
    }
    document.form.target="_blank";
    document.form.submit();
  
}



 function fixTextOverflowY(casingId,detailId,pointsId)
{
	var casingObject = document.getElementById(casingId);
	var detailObject = document.getElementById(detailId);
	var potinsObject = document.getElementById(pointsId);
if(casingObject.offsetHeight<detailObject.offsetHeight){
	potinsObject.style.display="block";
	
}else{
potinsObject.style.display="none";
}
}

function openGsIcon(){
	win=open(globalImgServer+'/hermes/goldsuppliers.html', 'forbuyerchina', 'width=600,height=450,location=no,toolbar=no,status=no,resizable=yes,scrollbars=yes'); 
	win.focus();
}



