// Main JS

window.defaultStatus = "KBA-Grafitec";
eval("try {document.execCommand('BackgroundImageCache', false, true);} catch(e) {}");

// Window Status Text
function ws(txt) {
	if (!txt) window.status = "KBA-Grafitec";
	else window.status = txt;
	return true;
}

function change(obj)	{
	if (act == 1)	{
		if (obj)	{
			mnu.Mouse(act,obj);
			eSales(true);
		} else {
			mnu.Mouse(act);
			eSales(false);
			act = 0;
		}
	} else {
		if (act == 2) {
			if (obj)	{
				mnu.Mouse(act,obj);
				eServices(true);
			} else {
				mnu.Mouse(act);
				eServices(false);
				act = 0;
			}
		}
	}
}
function popupWin(path,w,h,txt,alt)	{
	var hi = h+36;
	var wi = w+36;
	if (!alt) alt = '';
	if (!txt) txt = 'Grafitec, spol. s .r. o.';
	winpopup = window.open('','popup','height='+hi+', width='+wi+',menubar=no,scrollbars=no,status=no,toolbar=no,screenX='+getCenterW(wi)+',screenY='+getCenterH(hi)+',top='+getCenterH(hi)+',left='+getCenterW(wi));	
	winpopup.document.open();
	winpopup.document.write('<html>\n<head>\n');
	winpopup.document.write('<title>'+eval('txt')+'</title>');
	winpopup.document.write('</head>\n');
	winpopup.document.write('<body bgcolor="#FFFFFF" link="#09A1A3" alink="#09A1A3" style="margin-bottom: 18px; margin-left: 18px; margin-right: 18px; margin-top: 18px;">\n');       
	winpopup.document.write('<img src="'+path+'" width="'+w+'" height="'+h+'" border="0" alt="'+alt+'"');
	winpopup.document.write('</body>\n</html>\n');
	winpopup.document.close(); 
}
function getCenterW(width) {
	return parseInt( eval( (screen.width-parseInt(width))/2 ) );
}
function getCenterH(height) {
	return parseInt( eval( (screen.height-parseInt(height))/2 ) );
}

// funkce prida do selectu DOM polozku
function addSelectItem(DOM, value, text, selected) {
	var option = document.createElement("OPTION");
	DOM.options.add(option);
	option.text = text;
	option.value = value;
	if ( selected ) option.selected = true;
}

// funkce odebere ze selectu DOM polozku s indexem idnex
function removeSelectItem(DOM, index) {
	if ( !DOM.options.remove ) return;
	DOM.options.remove(index);
}

// funkce odebere ze selectu DOM vsechny polozky pocinaje indexem fromIndex
function removeAllSelectItems(DOM, fromIndex) {
	if ( DOM.options.length == 0 ) return;
	if ( !fromIndex ) fromIndex = 0;
	else fromIndex--;
	for ( var i=DOM.options.length-1;i>=fromIndex;i-- ) {
		removeSelectItem(DOM, i);
	}
}

// funkce vypise button BACK v dane lang verzi
function btnBack (lang)	{
	var lng	= lang ? lang : 'cs';
	if (lng == 'cs')	document.write('<div id="btn-back"><a href="javascript:history.back()" onMouseOver="return ws(\'zpět\')">zpět</a></div>');
	else if (lng == 'es')	document.write('<div id="btn-back"><a href="javascript:history.back()" onMouseOver="return ws(\'volver\')">volver</a></div>');
		else if (lng == 'pl')	document.write('<div id="btn-back"><a href="javascript:history.back()" onMouseOver="return ws(\'z powrotem\')">z powrotem</a></div>');
			else if (lng == 'de') document.write('<div id="btn-back"><a href="javascript:history.back()" onMouseOver="return ws(\'z powrotem\')">zurück</a></div>');
				else	document.write('<div id="btn-back"><a href="javascript:history.back()" onMouseOver="return ws(\'back\')">back</a></div>');
}
 
// funkce vrati true / false podle toho zda je v o nejaka hodnota
// true i kdyz space = true a o = ""
function isNot(o, space) {
	if ( o == null || typeof(o) == "undefined" || !o ) return true;
	if ( space && String(o).replace(/ /g, "") == "" ) return true;
	return false;
}

function getCenterW(width) {
	return parseInt( eval( (screen.availWidth-parseInt(width))/2 ) );
}

function getCenterH(height) {
	return parseInt( eval( (screen.availHeight-parseInt(height))/2 ) );
}

// open new win func
function openWin( path, name, width, height ) {
	var win = window.open(path, name,'scrollbars=yes,resizable=yes,width='+width+',height='+height+',screenX='+getCenterW(width)+',screenY='+getCenterH(height)+',top='+getCenterH(height)+',left='+getCenterW(width) );
	win.focus();
	return win;
}

// zvyrazni polozku zpravy na HP pri prejeti mysi, zobrazi obrazek, pokud neni img prazdny retezec
function highlightItem(eTR, state, img) {
	if ( state == true ) eTR.className += "Over";
	else eTR.className = eTR.className.replace("Over", "");
	if (img != '/img/u/motive_hp/') {
		self.document['hpMotive'].src = img;
	}
}
function hide(id) {
	document.getElementById(id).style.display="none";
}