
function productSearchSubmit(){
  var tag = document.getElementById("keyword").value;
  if(tag==null || trim(tag)==''){
  //alert('Please input a search term.');
  return false;
  }
  if(tag.length > 100){
  //alert('Please input a search term less than 100 characters.');
  return false;
  }
  return true;
}


function productSearchSubmit2(){
  var tag = document.getElementById("keyword2").value;
  if(tag==null || trim(tag)==''){
  //alert('Please input a search term.');
  return false;
  }
  if(tag.length > 100){
  //alert('Please input a search term less than 100 characters.');
  return false;
  }
  return true;
}


// for popup tips
var timer = new Array();
var tip = new Array();

function showCookieTip(tipId, showSwitch, targetURL, targetWin) {
    if (showSwitch == true)
    {
        var cookieValue;
        cookieValue = AE.bom.getCookie(tipId);
        var isLogin;
        isLogin = AE.bom.getCookie('ali_non_s_ever');
        if (cookieValue == 'N' || isLogin != '') {
            openWin(targetURL, targetWin, (tipId+'Win'));
        } else {
            showTip(tipId, true, targetURL, targetWin);
        }
    } else {
        var tipForm;
        tipForm = get(tipId + 'Form');
        if (tipForm != null) {
            if (tipForm.elements['showAgain'].checked == true) {
                AE.bom.setCookie(tipId, 'N', 12);
            }
            showTip(tipId, false, targetURL, targetWin);
        }
    }
}

function showTip(tipId, showSwitch, targetURL, targetWin) {
    tip[tipId] = get(tipId);
    if (tip[tipId] != null && showSwitch == true) {
        tip[tipId].style.display = '';
        timer[tipId] = window.setTimeout(function(){tip[tipId].style.display = 'none'; openWin(targetURL, targetWin, (tipId+'Win'));}, 5000);
    } else if (tip != null && showSwitch == false) {
        clearTimeout(timer[tipId]);
        tip[tipId].style.display = 'none';
        openWin(targetURL, targetWin, (tipId+'Win'));
    }
}

function openWin(targetURL, targetWin, winName) {
    winName = (winName == "") ? "newWin" : winName;
    if (targetWin == 'blank') {
        window.open(targetURL, winName, '');
    } else {
        document.location = targetURL;
    }
}

function clearCookie(cookieName) {
    AE.bom.setCookie(cookieName, '', -1);
}



function inquiryNow(tips){
    tips = tips || 'No item(s) selected.';
    var checkedNum = getCheckedNum();
    var basketItemNum = parseInt(document.form.basketItemNum.value);
    var urlString = document.location+""; 
    
    if(checkedNum == 0) {
      if(basketItemNum == 0){
          alert(tips)
          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();
    }
}