function showUnderline(id){
	id="underline"+id;
	if(document.getElementById(id)){
		document.getElementById(id).style.visibility="visible";
	}
}
function hideUnderline(id){
	id="underline"+id;
	if(document.getElementById(id)){
		document.getElementById(id).style.visibility="hidden";
	}
}
function showTooltip(id){
	this.ver=navigator.appVersion;
	this.agent=navigator.userAgent;
	this.dom=document.getElementById?1:0;
	this.opera5=this.agent.indexOf("Opera 5")>-1;
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
	this.ie55=(this.ver.indexOf("MSIE 5.5")>-1 && this.dom && !this.opera5)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie7=(this.ver.indexOf("MSIE 7")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6;
	this.mac=this.agent.indexOf("Mac")>-1;
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera5);
	
	var ballon = document.getElementById(id);
	var ballonArrow = ballon.getElementsByTagName("p")[0];
	if(ballon){
		ballon.style.display = "block";
		
		if(!ballon.style.marginLeft || ballon.style.marginLeft == ""){
			if((getClientWidth() - getElementPosition(id).left) < 450){
				ballon.style.marginLeft = "-230px";				
				if(getElementPosition(id).top <= 400){
					ballon.style.marginTop = "-100px";
					ballonArrow.className = "ballonArrow_TR";
				}
				else if(getElementPosition(id).top > 400 && getElementPosition(id).top < 600){
					ballon.style.marginTop = "-200px";
					ballonArrow.className = "ballonArrow_MR";
				}
				else{
					ballon.style.marginTop = "-320px";
					ballonArrow.className = "ballonArrow_BR";
				}				
			}
			else{
				ballon.style.marginLeft = "150px";
				if(getElementPosition(id).top <= 400){
					ballon.style.marginTop = "-100px";
					ballonArrow.className = "ballonArrow_TL";
				}
				else if(getElementPosition(id).top > 400 && getElementPosition(id).top < 600){
					ballon.style.marginTop = "-200px";
					ballonArrow.className = "ballonArrow_ML";
				}
				else{
					ballon.style.marginTop = "-320px";
					ballonArrow.className = "ballonArrow_BL";
				}
			}			
		}		
	}
}
function hideTooltip(id){
	if(document.getElementById(id)){
		document.getElementById(id).style.display = "none";
	}
}
function changeSearchIcon(tag, num){
	tag.getElementsByTagName("img")[0].src = "/images/iconSearch"+num+"_on.jpg";
}
function backSearchIcon(tag, num){
	tag.getElementsByTagName("img")[0].src = "/images/iconSearch"+num+".jpg";
}

function changePicture(id){
	var img = document.getElementById(id);
	var isBlack;
	if(img){
		if(img.src.substr(img.src.length-7).substr(0,3) == "_bw"){
			img.src = img.src.split("_bw")[0]+img.src.split("_bw")[1];
		}
		else{
			img.src = img.src.split(".jpg")[0]+"_bw.jpg";
		}
	}
}
function clearAllMargin(){
	for(i=0;i<30;i++){
		if(document.getElementById("tooltip"+i)){
			document.getElementById("tooltip"+i).style.marginLeft = "";
		}
	}
}

/* standart functions */
function getClientWidth(){
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

function getClientHeight(){
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}
function getDocumentHeight(){
	return (document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight;
}
function getDocumentWidth(){
	return (document.body.scrollWidth > document.body.offsetWidth)?document.body.scrollWidth:document.body.offsetWidth;
}
function getElementPosition(elemId){
    var elem = document.getElementById(elemId);
	
    var w = elem.offsetWidth;
    var h = elem.offsetHeight;
	
    var l = 0;
    var t = 0;
	
    while (elem)
    {
        l += elem.offsetLeft;
        t += elem.offsetTop;
        elem = elem.offsetParent;
    }

    return {"left":l, "top":t, "width": w, "height":h};
}
function getElementPosition2(elem){
    var elem = elem;
	
    var w = elem.offsetWidth;
    var h = elem.offsetHeight;
	
    var l = 0;
    var t = 0;
	
    while (elem)
    {
        l += elem.offsetLeft;
        t += elem.offsetTop;
        elem = elem.offsetParent;
    }

    return {"left":l, "top":t, "width": w, "height":h};
}
function getElementComputedStyle(elem, prop)
{
  if (typeof elem!="object") elem = document.getElementById(elem);
  
  // external stylesheet for Mozilla, Opera 7+ and Safari 1.3+
  if (document.defaultView && document.defaultView.getComputedStyle)
  {
    if (prop.match(/[A-Z]/)) prop = prop.replace(/([A-Z])/g, "-$1").toLowerCase();
    return document.defaultView.getComputedStyle(elem, "").getPropertyValue(prop);
  }
  
  // external stylesheet for Explorer and Opera 9
  if (elem.currentStyle)
  {
    var i;
    while ((i=prop.indexOf("-"))!=-1) prop = prop.substr(0, i) + prop.substr(i+1,1).toUpperCase() + prop.substr(i+2);
    return elem.currentStyle[prop];
  }
  
  return "";
}
/* end of standart functions */

function tableLinesSeparator(id){
	var table = document.getElementById(id);
	if(table){
		for(i=1;i<table.getElementsByTagName("tr").length;i++){
			if(i%2 == 0){
				table.getElementsByTagName("tr")[i].style.backgroundColor = "#FFFEF7";
			}
		}
	}
}
function tableLinesSeparatorColor(id,color){
	var table = document.getElementById(id);
	if(table){
		for(i=0;i<table.getElementsByTagName("tr").length;i++){
			if(i%2 == 0){
				table.getElementsByTagName("tr")[i].style.backgroundColor = color;
			}			
		}
	}
}
var idInterval, idTimeout;
function showAddAlert(checkBox){
	var id, otherId;
	if(checkBox.checked){
		id = "productAddedAlert";
		otherId = "productDeletedAlert";
	}
	else{
		id = "productDeletedAlert";
		otherId = "productAddedAlert";
	}
	var block = document.getElementById(id);
	var pos = getElementPosition2(checkBox);
	var step = 0.2;
	var alpha = 0;
	setElementOpacity(id, alpha);
	setElementOpacity(otherId, alpha);
	block.style.display = "none";
	document.getElementById(id).style.display = "none";
	clearInterval(idInterval);
	clearTimeout(idTimeout);
	
	block.style.display = "block";
	block.style.top = pos.top + "px";
	idInterval = setInterval(doShowing, 100);
	function doShowing(){
		alpha += step;
		setElementOpacity(id, alpha);
		if(alpha >= 1){
			clearInterval(idInterval);
			idTimeout = setTimeout(doHide, 1000);
		}
	}
	function doHide(){
		block.style.display = "none";
	}
}