/** --- TOOLTIP --- **/
var OP=(navigator.userAgent.indexOf('Opera')!=-1)?true:false;var IE=(navigator.userAgent.indexOf('MSIE')!=-1 && !OP)?true:false;var GK=(navigator.userAgent.indexOf('Gecko')!=-1)?true:false;var NN4=document.layers;var DOM=document.getElementById;
function tooltipReplace(txt){var delka=txt.length;var ntxt='';for(var i=0;i<delka;i++){if(txt.charAt(i)=='\ufffd'){ntxt+='"';}else{ntxt+=txt.charAt(i);}}return ntxt;}
function TOOLTIP(){
this.width=200;this.bgColor='#FFFFC0';this.textColor='#A00000';this.borderColor='#D00000';this.opacity=80;this.cursorDistance=5;this.classname='';this.text='';this.height=0;this.obj=0;this.sobj=0;this.active=false;
this.create=function(){if(!this.sobj) this.init();if(this.classname!=''){var classik=' class='+this.classname;var cpad='0';}else{classik='';cpad='4';}var t='<table border=0 cellspacing=0 cellpadding='+cpad+classik+' width='+this.width+' bgcolor='+this.bgColor+'><tr>'+'<td align=center><font color=' + this.textColor + '>' + tooltipReplace(this.text) + '</font></td></tr></table>';
if(NN4){t='<table border=0 cellspacing=0'+classik+' cellpadding=1><tr><td bgcolor='+this.borderColor+'>'+t+'</td></tr></table>';this.sobj.document.write(t);this.sobj.document.close();}else {this.sobj.border='1px solid '+this.borderColor;this.setOpacity();if(document.getElementById)document.getElementById('ToolTip').innerHTML=t;else document.all.ToolTip.innerHTML=t;}if(DOM)this.height=this.obj.offsetHeight;else if(IE)this.height=this.sobj.pixelHeight;else if(NN4)this.height=this.obj.clip.bottom;this.show();}
this.init=function(){if(DOM){this.obj=document.getElementById('ToolTip');this.sobj=this.obj.style;}else if(IE){this.obj=document.all.ToolTip;this.sobj=this.obj.style;}else if(NN4){this.obj=document.ToolTip;this.sobj=this.obj;}}
this.show=function(){var ext=(document.layers?'':'px');var left=mouseX;var top=mouseY;if(left+this.width+this.cursorDistance>winX)left-=this.width+this.cursorDistance;else left+=this.cursorDistance;if(top+this.height+this.cursorDistance-scrTop>winY)top-=this.height;else top+=this.cursorDistance;this.sobj.left=left+ext;this.sobj.top=top+ext;if(!this.active){this.sobj.visibility='visible';this.active=true;}}
this.hide=function(){if(this.sobj)this.sobj.visibility='hidden';this.active=false;}
this.setOpacity=function(){this.sobj.filter='alpha(opacity='+this.opacity+')';this.sobj.mozOpacity='.1';if(this.obj.filters)this.obj.filters.alpha.opacity=this.opacity;if(!document.all && this.sobj.setProperty)this.sobj.setProperty('-moz-opacity',this.opacity/100,'');}
}
var tooltip=mouseX=mouseY=winX=winY=scrTop=0;if(document.layers){document.write('<layer id="ToolTip"></layer>');document.captureEvents(Event.MOUSEMOVE);}else document.write('<div id="ToolTip" style="position:absolute; z-index:69"></div>');document.onmousemove=getMouseXY;
function getMouseXY(e){if(document.body && document.body.scrollTop+document.documentElement.scrollTop>=0)scrTop=document.body.scrollTop+document.documentElement.scrollTop;else if(window.pageYOffset>=0)scrTop=window.pageYOffset;
if(IE){if(document.body){mouseX=event.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;}else{mouseX=event.clientX+document.documentElement.scrollLeft;}if(document.body){mouseY=event.clientY+document.body.scrollTop+document.documentElement.scrollTop;}else{mouseY=event.clientY+document.documentElement.scrollTop;}}
else{mouseX=e.pageX;mouseY=e.pageY;}if(mouseX<0)mouseX=0;if(mouseY<0)mouseY=0;if(GK || NN4){winX=window.innerWidth-25;winY=window.innerHeight;}else if(DOM){if(document.body){winX=document.body.offsetWidth-25;}else{winX=document.documentElement.offsetWidth-25;}
if(document.body){winY=document.body.offsetHeight;}else{winY=document.documentElement.offsetHeight;}}else{winX=screen.width-25;winY=screen.height;}if(tooltip && tooltip.active)tooltip.show();}
function toolTip(text,width,opacity,classname){if(text){tooltip=new TOOLTIP();tooltip.text=text;if(width)tooltip.width=width;if(opacity)tooltip.opacity=opacity;if(classname)tooltip.classname=classname;tooltip.create();}else if(tooltip)tooltip.hide();}
function autohideInputText(obj,txt,focused){if(focused){if(obj.value == txt) obj.value = '';}else{if(obj.value == '') obj.value = txt;}}

$(document).ready(function(){$("a[rel=tooltip]").tooltip();$('img.ixformhelp[title]').tooltip({position: "center right", opacity: 0.8});});

wasIXFWConfirmed = false;

function ixfwConfirm(header,text,funcOK,funcCancel){
	wasIXFWConfirmed = false;
	$.fancybox('<br /><h2>'+header+'</h2><table class="ixconfirmquestion"><tr><td>'+text+'</td></tr></table><table class="ixconfirmactions"><tr><td><a class="button" href="javascript:;" onclick="wasIXFWConfirmed = true;'+funcOK+';$.fancybox.close();">ANO</a></td><td><a class="button" href="javascript:$.fancybox.close();'+funcCancel+'">NE</a></td></tr></table>',{
				'modal'		: true,
				'overlayColor' : '#000',
				'plusClass': 'ixfwconfirmfancy',
				'onClosed': function(){
					if(funcCancel){
						if(!wasIXFWConfirmed) eval(funcCancel);
					}
				}
			});
			/*
	$.fancybox(
//		'<div class="ixfwconfirm"><h2>'+header+'</h2><div class="xcontent"><p>'+text+'</p><table class="actions"><tr><td><a class="button" href="javascript:;" onclick="wasIXFWConfirmed = true;'+funcOK+';$.fancybox.close();">ANO</a></td><td><a class="button" href="javascript:$.fancybox.close();'+funcCancel+'">NE</a></td></tr></table></div></div>',
'<br /><h2>'+header+'</h2><table><tr><td>Vyberte provedení zboží</td></tr></table><div class="buttons"><a href="javascript:;" onclick="$.fancybox.close();">OK</a></div><br />',
		{
			'model'		: true,
			'plusClass'			: 'ixfwconfirmfancy',
			'onClosed': function(){
				if(funcCancel){
					if(!wasIXFWConfirmed) eval(funcCancel);
				}
			}
		}
	);
	*/
}

function number_format(number, decimals, dec_point, thousands_sep){
    number = (number + '').replace(/[^0-9+\-Ee.]/g, '');
    var n = !isFinite(+number) ? 0 : +number,
	prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
	sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,
	dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
	s = '',
	toFixedFix = function (n, prec) {
		var k = Math.pow(10, prec);
		return '' + Math.round(n * k) / k;
	};
    s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
    if (s[0].length > 3) {
        s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
    }
    if ((s[1] || '').length < prec) {
        s[1] = s[1] || '';
        s[1] += new Array(prec - s[1].length + 1).join('0');
    }
    return s.join(dec);
}

IX_PRICE_ROUND_2_UP = 0;
IX_PRICE_ROUND_2_DOWN = 1;
IX_PRICE_ROUND_2_AUTO = 2;
IX_PRICE_ROUND_1_UP = 3;
IX_PRICE_ROUND_1_DOWN = 4;
IX_PRICE_ROUND_1_AUTO = 5;
IX_PRICE_ROUND_0_IP = 6;
IX_PRICE_ROUND_0_DOWN = 7;
IX_PRICE_ROUND_0_AUTO = 8;
IX_PRICE_CENT_DIGITS_0 = 0;
IX_PRICE_CENT_DIGITS_1 = 1;
IX_PRICE_CENT_DIGITS_2 = 2;

function setFormatPrice(digitsSplitter,centSplitter,mena,showMinusInsteadZeros,roundType,centDigits){
	priceDigitsSplitter = digitsSplitter;
	priceCentSplitter = centSplitter;
	priceMena = mena;
	priceShowMinusInsteadZeros = showMinusInsteadZeros;
	priceRoundType = roundType;
	priceCentDigits = centDigits;
}

function formatPrice(price){
	var s;
	var desetinna = 0;
	if(price < 1000000){
		var f = 1;
		var rounded;
		if(priceRoundType == IX_PRICE_ROUND_1_AUTO || priceRoundType == IX_PRICE_ROUND_1_UP || priceRoundType == IX_PRICE_ROUND_1_DOWN) f = 10;
		else if(priceRoundType == IX_PRICE_ROUND_2_AUTO || priceRoundType == IX_PRICE_ROUND_2_UP || priceRoundType == IX_PRICE_ROUND_2_DOWN) f = 100;
		if(priceRoundType == IX_PRICE_ROUND_0_AUTO || priceRoundType == IX_PRICE_ROUND_1_AUTO || priceRoundType == IX_PRICE_ROUND_2_AUTO) rounded = Math.round(price*f)/f;
		else if(priceRoundType == IX_PRICE_ROUND_0_UP || priceRoundType == IX_PRICE_ROUND_1_UP || priceRoundType == IX_PRICE_ROUND_2_UP) rounded = Math.floor(price*f+0.9999)/f;
		else rounded = Math.floor(price*f)/f;
		var cela = Math.floor(rounded);
		desetinna = rounded - cela;
		s = '';
		if(priceDigitsSplitter == '') s = ''+cela;
		else{
			s = '';
			var p = ''+cela;
			var delka = p.length;
			var zb = 3-(delka % 3);
			if(zb == 3) zb = 0;
			for(var i=0;i<delka;i++){
				if(i > 0 && zb == 0) s+= priceDigitsSplitter;
				s+= p.charAt(i);
				zb++;
				if(zb >= 3) zb = 0;
			}
		}
		
	}
	else{
		s = number_format(price,0,priceCentSplitter,priceDigitsSplitter);
	}
	if(priceCentDigits != IX_PRICE_CENT_DIGITS_0){
		s+= priceCentSplitter;
		if(desetinna == 0 && priceShowMinusInsteadZeros) s+= '-';
		else{
			if(priceCentDigits != IX_PRICE_CENT_DIGITS_1) s+= Math.round(desetinna*10);
			else s+= Math.round(desetinna*100);
		}
	}
	if(priceMena != '') s+= ' '+priceMena;
	return s;
}

function urlencode(str){
	str = (str + '').toString();
	return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
}


