    var sCopyTitle   = null;
    var oCurrToolTip = null;
    var oToolTipPos  = null;
    //
    function showTooltip(obj, blShow)
    {   if (blShow)
        {   sCopyTitle = obj.title;
            obj.title  = '';
            oCurrToolTip = document.createElement('span');
            oCurrToolTip.innerHTML  = sCopyTitle;
            oCurrToolTip.className  = 'tooltip';

            oToolTipPos = document.createElement('span');
            oToolTipPos.className  = 'tooltippos';
            oToolTipPos.appendChild(oCurrToolTip);
            
            obj.parentNode.insertBefore(oToolTipPos, obj);
        }
        else
        {   obj.title  = sCopyTitle;
            sCopytitle = '';
            if (oToolTipPos != null)
            {   obj.parentNode.removeChild(oToolTipPos);
                oToolTipPos = null;
            }
        }
    }
    
    
    function SetAllCheckBoxes(FormName, FieldName, CheckValue)
	{
		if(!document.forms[FormName])
			return;
		var objCheckBoxes = document.forms[FormName].elements[FieldName];
		if(!objCheckBoxes)
			return;
		var countCheckBoxes = objCheckBoxes.length;
		if(!countCheckBoxes)
			objCheckBoxes.checked = CheckValue;
		else
			// set the check value for all check boxes
			for(var i = 0; i < countCheckBoxes; i++)
				objCheckBoxes[i].checked = CheckValue;
	}

    function setSellList( oInObj)
    {
      //for module wlist
      var _wlist = document.getElementById("_wlist");
      if ( _wlist != null)
      {
        if ( '[{$urlsign}]' == '&')
          _wlist.href = _wlist.href + "&" + oInObj.name + "=" + oInObj.value;
        else
          _wlist.href = _wlist.href + "[{$urlsign}]" + oInObj.name + "[{$urlsign}]" + oInObj.value;
      }
      //for original selectlist
      var _wlist = document.getElementById("_slist");
      if ( _wlist != null)
      {
        if ( '[{$urlsign}]' == '&')
          _wlist.href = _wlist.href + "&" + oInObj.name + "=" + oInObj.value;
        else
          _wlist.href = _wlist.href + "[{$urlsign}]" + oInObj.name + "[{$urlsign}]" + oInObj.value;
      }
    }
    
    function anyArticlesSelected(oForm){
        var checkboxs = oForm.getElementsByTagName('input');
        for(var i = 0, inp; inp = checkboxs[i]; i++) 
            if( inp.type.toLowerCase() == 'checkbox'){ 
                if (inp.checked){
                    return true;
                }
            }
                    
        return false;                    
    }
    
     function printArticles(msg, baseURL){
//     	alert ( 'msg='+msg+'  baseURL='+baseURL );
     
        var sel = anyArticlesSelected(document.forms['articles_list']);
        
        if (!sel) {
			SetAllCheckBoxes('articles_list','selartids[]',true);
        }

        document.forms['articles_list'].cl.value='printsend';
        document.forms['articles_list'].fnc.value='printa';
        document.forms['articles_list'].target='_blank';
        document.forms['articles_list'].action=baseURL;
        document.forms['articles_list'].submit();
        return true;
            
    }
    
    /**
     * calls request that calls function that removes articles from notice list
     */
    function removeArticlesFromNoticelist(msg){
        var sel = anyArticlesSelected(document.forms['articles_list']);
        
        if (!sel) {
            alert(msg);
            return false;
        } else {
            document.forms['articles_list'].fnc.value='removeArticles';
            document.forms['articles_list'].cl.value='atmintine_detaliai';
            document.forms['articles_list'].target='_self';
            document.forms['articles_list'].submit();
            return true;
            
        }
    }
    
    
    /**
     * calls request that calls function that removes articles from notice list
     */
    function removeArticlesFromWishlist(msg){
        var sel = anyArticlesSelected(document.forms['articles_list']);

        if (!sel) {
            alert(msg);
            return false;
        } else {
            document.forms['articles_list'].fnc.value='removeWishlistArticles';
            document.forms['articles_list'].cl.value='account_wishlist';
            document.forms['articles_list'].target='_self';
            document.forms['articles_list'].submit();
            return true;
            
        }
    }
    
    /**
     * calls request that calls function that adds products to notice list
     */
    function articlesToNoticeList(msg, retclass) {
        var sel = anyArticlesSelected(document.forms['articles_list']);
        
        if (!sel) {
            alert(msg);
            return false;
        } else {
            document.forms['articles_list'].fnc.value='articlesToNoticeList';
            document.forms['articles_list'].cl.value=retclass;
            document.forms['articles_list'].target='_self';
            document.forms['articles_list'].submit();
            return true;
            
        }
    
    }
    
    
    function recomArticles(msg){
        var sel = anyArticlesSelected(document.forms['articles_list']);
        
        if (!sel) {
			SetAllCheckBoxes('articles_list','selartids[]',true);
        } 
        document.forms['articles_list'].cl.value='printsend';
        document.forms['articles_list'].fnc.value='recoma';
        document.forms['articles_list'].target='';
        document.forms['articles_list'].submit();
        return true;
    }
    
    function compareArticles(msg, retclass){
        var sel = anyArticlesSelected(document.forms['articles_list']);

        if (!sel) {
            alert(msg);
            return false;
        } else {
            newHiddenElement(document.forms['articles_list'], "addcompare", "1");
            newHiddenElement(document.forms['articles_list'], "addcompareaddonly", "1");
            document.forms['articles_list'].cl.value=retclass;
            document.forms['articles_list'].fnc.value='tocomparelistmult';
            if ( document.forms['articles_list'].pgNr ) {
                document.forms['articles_list'].pgNr.value='0';
            }
            document.forms['articles_list'].target='';
            document.forms['articles_list'].submit();
            return true;
        }
    }
    
    function newHiddenElement(elform, elname, elvalue){
            var newElem   = document.createElement("input");
            newElem.type  = "hidden";
            newElem.value = elvalue;
            newElem.name  = elname;
            return elform.appendChild(newElem);
    }
    
/**
 * This function is responsible for rounding required amount of the product to buy.
 * This function works in the same way as recalculateBuyAmount in oxutils.php.
 *
 * Parameters:
 * sourceID - is an id of input field where user imputs the product amount he wants to buy.
 * minimumAmount - minimum amount of the product, customer must buy.
 * destinationID - is an id of a label where required amount of the product is displayed, rounded by minimumAmount.
 */
function displayBuyAmount (sourceID, minimumAmount, destinationID ) {

    inputAmountStr = document.getElementById(sourceID).value;
    inputAmountStr = inputAmountStr.replace(',', '.' );
    inputAmount = parseFloat(inputAmountStr );
    
//    alert ( 'inputAmount='+inputAmount );
    if ( inputAmount == 0 || isNaN(inputAmount) ) {
	    inputAmount = minimumAmount;
    }
    
    countOfMinimumAmounts = inputAmount / minimumAmount;
    countOfMinimumAmountsInt = Math.floor( countOfMinimumAmounts );
    
    precision = 0.001;
    if ( countOfMinimumAmounts - countOfMinimumAmountsInt > precision ) {
    	countOfMinimumAmountsInt = countOfMinimumAmountsInt + 1;
    }
    
    newAmount = Math.round( countOfMinimumAmountsInt  * minimumAmount * 1000 ) / 1000; // take only 3 digits
    
	document.getElementById(destinationID).innerHTML=newAmount;
	return true;
}

function alertBuyAmount(sourceID, destinationID, sAlertMsg )
{
	if ($(sourceID).attr('value') != $(destinationID).html())
	{
		var sAmount = $(destinationID).html();
		sAlertMsg = sAlertMsg.replace(/@amount@/i, sAmount);
		return confirm(sAlertMsg);
	}
	else
		return true;
}

/**
 * This function is responsible of handling buttons of putting products to basket, where the buttons are out of the form.
 *
 */
function putProductToBasket ( productID, formID, sPrefix ) {
	// construct id of the html item where the product amount is stored
	// put amount to the form whose id is given
	// put product id to the form whose id is given
	// submit the form
	
	if (sPrefix == undefined) sPrefix = "";
	var amountHolderID = 'am'+sPrefix+productID;
	
	var amount = document.getElementById(amountHolderID).value;
	
	document.forms[formID].am.value  = amount;
	document.forms[formID].aid.value = productID;
	document.forms[formID].submit();
	
	return false;
}
  function changeImg(sImageSrc)  {
    if(oObj = document.getElementById("product_img")){
      oObj.src=sImageSrc;
	}
    return false;
  }    
