function addClassName(el, sClassName) {
	var s = el.className;
	var p = s.split(" ");
	var l = p.length;
	for (var i = 0; i < l; i++) {
		if (p[i] == sClassName) {
			return;
		}
	}
	p[p.length] = sClassName;
	el.className = p.join(" ");
}

function removeClassName(el, sClassName) {
	var s = el.className;
	var p = s.split(" ");
	var np = [];
	var l = p.length;
	var j = 0;
	for (var i = 0; i < l; i++) {
		if (p[i] != sClassName) {
			np[j++] = p[i];
		}
	}
	el.className = np.join(" ");   
}

function format_currency(num) {
	num += '';
	x = num.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? ',' + x[1] : '';
	
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + '&nbsp;' + '$2');
	}
	return x1 + x2.substr(0,3) + '&nbsp;Kč';
}

function format_currency2(num,curr,before) {
	
	num += '';
//	x = num.split('.');  
//	num = x[0] + ',' + x[1];
	x = num.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? ',' + x[1] : '' ; 
	// x2 = x.length > 1 ? ',' + Math.round(x[1].substr(0,2)) : '';
	
	/*var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + '&nbsp;' + '$2');
	}  */
	if (before == 1) {
		return curr + x1 + x2.substr(0,3);
	} else {
		return x1 + x2.substr(0,3) + '&nbsp;' + curr;
	}
}

function mailReplace(){
	var name, server, i; 
	var protocol = 'send';

	for (i = 0; i < document.links.length; i++) {
		link = document.links[i];

		if (link.protocol == protocol + ':') {
			href = link.href;
			name = link.href.substring((protocol.length+1), link.href.indexOf(')'));
			server = link.href.substring((link.href.indexOf(')') + 1), link.href.indexOf('('));

			finalHref = name + '@' + server;
			link.firstChild.nodeValue = finalHref;
			link.href = 'mailto:' + finalHref;
		}
	}
}



function activate_tab_pl(tab, count, prefix)
{
	if(b2c == 1 && tab == 1 ) {
    if( document.getElementById("list_top_products") != null ) {		
      if(document.getElementById("product-tools2") != null) document.getElementById("product-tools2").style.display = 'block';
      if(document.getElementById("product-tools1") != null) document.getElementById("product-tools1").style.display = 'none';
      }  
	} else {
		if( document.getElementById("list_top_products") != null ) {		
    if(document.getElementById("product-tools2") != null) document.getElementById("product-tools2").style.display = 'none';
		if(document.getElementById("product-tools1") != null) document.getElementById("product-tools1").style.display = 'block';
		}
               
	}
  if (!prefix)
	{
		prefix = '';
	}

	var e_tab;
	var e_box;

	for (i = 0; i < count; i++){
		e_tab = document.getElementById(prefix + 'tab_' + i);
		e_box = document.getElementById(prefix + 'box_' + i);
//alert(e_tab + ' | ' + e_box);
		if (i == tab){ // aktivni
			e_tab.className     = 'active';
			//e_tab.className     = 'normal';
			e_box.style.display = 'block';
		}
		else { // neaktivni
			if(e_tab != null){
				e_tab.className = 'normal';
				if(e_box != null){
					e_box.style.display = 'none';
				}
			}
		}
  }
}

function div_show_hide(className,i) {
			var rh = document.getElementById('related-hide')
			var text_show = document.getElementById('text_show_all_products')
			var text_hide = document.getElementById('text_hide_all_products')
			var rhi = document.getElementById('related-hide-img')

			var img_src = new String(rhi.src)

			if(rh){
				if (rh.style.display != 'none') {
					rh.style.display = 'none'
					text_show.style.display = 'block'
					text_hide.style.display = 'none'
					rhi.src = img_src.replace(/-[0-9](\..+)$/, '-1$1')
				} else {
					rh.style.display = ''
					text_show.style.display = 'none'
					text_hide.style.display = 'block'
					rhi.src = img_src.replace(/-[0-9](\..+)$/, '-2$1')
				}
			}
		}
		
function addClassName2(el, sClassName) {
	var s = el.className;
	var p = s.split(" ");
	var l = p.length;
	for (var i = 0; i < l; i++) {
		if (p[i] == sClassName) {
			return;
		}
	}
	p[p.length] = sClassName;
	el.className = p.join(" ");
}

function removeClassName2(el, sClassName) {
	var s = el.className;
	var p = s.split(" ");
	var np = [];
	var l = p.length;
	var j = 0;
	for (var i = 0; i < l; i++) {
		if (p[i] != sClassName) {
			np[j++] = p[i];
		}
	}
	el.className = np.join(" ");   
}		


function getPageSizeWithScroll2(){
    	if (window.innerHeight && window.scrollMaxY) {// Firefox
    		yWithScroll = window.innerHeight + window.scrollMaxY;
    		xWithScroll = window.innerWidth + window.scrollMaxX;
    	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
    		yWithScroll = document.body.scrollHeight;
    		xWithScroll = document.body.scrollWidth;
    	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
    		yWithScroll = document.body.offsetHeight;
    		xWithScroll = document.body.offsetWidth;
      	}
    	arrayPageSizeWithScroll = new Array(xWithScroll, yWithScroll);
    	//alert(arrayPageSizeWithScroll[1]);
      return arrayPageSizeWithScroll  
    	//alert( 'The height is ' + yWithScroll + ' and the width is ' + xWithScroll );
    	//return yWithScroll;
    }


function heightwindow() {

th = getPageSizeWithScroll2(); 

document.getElementById('popup-close').style.height = th[1]+"px"; 
document.getElementById('popup-close').style.width = th[0]+"px";
                                                                  
}