function showhide(id) {
  var i=1;
  while (document.getElementById('additional_tab_content_'+i)) {
  	if (id!=i) {
			document.getElementById('additional_tab_content_'+i).style.display='none';
		} else {
			document.getElementById('additional_tab_content_'+i).style.display='block';
		}
		i++;
  }
	return false;
}


function fillvalue(field) {
	document.getElementById('v_servis_vklucheno').className="";
	document.getElementById('dop_uslugi').className="";
	document.getElementById('opisanie').className="";
	document.getElementById('oborudovanie').className="";
	document.getElementById('mesto_raspolozhenia').className="";
	document.getElementById(field).className="active";
	var field2 = field+'_text';
	document.getElementById('additionaltext').innerHTML=document.getElementById(field2).innerHTML;
}


function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}





function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ' ' + '$2');
	}
	return x1 + x2;
}


this.tooltip = function(){	
	/* CONFIG */		
		xOffset = 10;
		yOffset = 20;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	$("ul.kvint a").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    },
	function(){
		this.title = this.t;		
		$("#tooltip").remove();
    });	
	$("ul.kvint a").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};



// starting the script on page load
$(document).ready(function(){
	tooltip();
});