//javascript trim funkcia
function jsTrim(str) {
	return str.replace(/^\s*|\s*$/g,'');
}

// Prepinanie class tlacitka
function textboxClass(obj, oldClass) {
	if ( !oldClass ) {
		oldClass = "textbox";
	}	
	if ( obj.className == oldClass ) {
		obj.className+= " active";
	} else {
		obj.className = oldClass;
	}
//obj.blur();
}

// Prepinanie class tlacitka
function buttonClass(obj, oldClass) {
	if ( !oldClass ) {
		oldClass = "button";
	}	
	if ( obj.className == oldClass ) {
		obj.className+= " active";
	} else {
		obj.className = oldClass;
	}
//obj.blur();
}

// Prepinanie tabov
function switchTab(id) {
	//ulozim do pomocnej premennej typ zakaznika
	document.getElementById('hbTypZakazTab').value = id;
	//---------------------------------------+
	// prejdem zalozky, aktivujem/deaktivujem
	//-------------------------------------+
	div = document.getElementById('tabPlusTabulaTab');
	pole = div.getElementsByTagName('li');
	for (i=0; i < pole.length; i++) {
		pole[i].className = 'tab';
	}
	//--------------------------------------+
	// prejtem plochy, aktivujem/deaktivujem
	//-------------------------------------+
	div = document.getElementById('tabPlusTabulaTabula');
	pole = div.getElementsByTagName('div');
	for (i=0; i < pole.length; i++) {
		if ( pole[i].className == 'plocha' ) {
			pole[i].style.display = 'none';
		}
	}
	document.getElementById('t_'+id).className = 'tab_h';
	document.getElementById('t_'+id).blur();
	document.getElementById('p_'+id).style.display = 'block';
	if ( document.getElementById('hlaska') ) {
		document.getElementById('hlaska').style.display = 'none';
	}
	return false;
}

function otvor_obr_okno(img)
{ 	
	picfile = new Image();
	picfile.src =(img);
	kontrolaSuboru(img);
}
function kontrolaSuboru(img)
{ 	
	if( (picfile.width!=0) && (picfile.height!=0) )
	{
		urobOkno(img);
	}
	else
	{
		funzione="kontrolaSuboru('"+img+"')";
		intervallo=setTimeout(funzione,50);
	}
}
function urobOkno(img)
{ 	
	ht = picfile.height + 20;
	wd = picfile.width + 20;

	var args= "height=" + ht + ",innerHeight=" + ht;
	args += ",width=" + wd + ",innerWidth=" + wd;
	if (window.screen)
	{
		var avht = screen.availHeight;
		var avwd = screen.availWidth;
		var xcen = (avwd - wd) / 2;
		var ycen = (avht - ht) / 2;
		args += ",left=" + xcen + ",screenX=" + xcen;
		args += ",top=" + ycen + ",screenY=" + ycen + ",resizable=yes";
	}
	return window.open(img, '', args);
} 

function wopen(url, name, height, width, str1) {
	var str = "height=" + height + ",innerHeight=" + height;
	str += ",width=" + width + ",innerWidth=" + width;
	   
	str += ", "+str1;
	   
	   
	if (window.screen) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;

		var xc = (aw - width) / 2;
		var yc = (ah - height) / 2;

		str += ",left=" + xc + ",screenX=" + xc;
		str += ",top=" + yc + ",screenY=" + yc;
	}
	var win=window.open(url, name, str);
	win.focus();
	return win;
}

$(document).ready(function(){
	$('div.produkt').hover(function(){
		//alert($(this).parent().parent().parent().find('a span.bar').html());
		$(this).find('a span.bar').addClass('active');
		$(this).find('h3.nadpis a').addClass('active');
	}, function(){
		$(this).find('a span.bar').removeClass('active');
		$(this).find('h3.nadpis a').removeClass('active');
	});
	$('div.produkt').click(function(){
		location.href=$(this).find('a').attr('href');
	});
});


