// FG Forrest, a.s. (c) 1996-2006

function go2Product(url)
{
	var w = window;
	if ( window.opener ) w = window.opener;

	w.location.href = url;
	w.focus();
	
	if ( window.opener ) window.close();
	
	return false;
}

function openMontage(url, wide, resize)
{
	var w = 650;
	if ( wide ) w = 1035;
	openWin(url,"koradoMontage",w,700,"yes");
	if (!wide)
		window.resizeTo(650,700);
	if (resize)
		window.resizeTo(1035,700);
	return false;
}

function openChooser(url, type)
{
	var w = 925;
	if ( type == "radik" ) w = 940;
	openWin(url,"koradoChooser",w,650,"yes")
	return false;
}
var fulltextQuery = '';
function fillFulltextQuery() {
	if (fulltextQuery!='') {
		document.forms[0].query.value=fulltextQuery;
	}
}

var sExpr = "";
function exprFocused(dom) {
	if ( dom.value.indexOf("-- ") > -1) {
		sExpr = dom.value;
		dom.value = "";
	}
}
function exprBlured(dom) {
	if ( dom.value == "" ) dom.value = sExpr;
}


// Open new window
function openWin(src,winName,w,h,scrll,xshift) {
	if (!xshift) { xshift = 0; }
	if (!scrll) { scrll = "no"; }
	var winLeft = (screen.width - w) / 2;
	var winTop = (screen.height - h) / 2;
	var winProp = 'menubar=no,resizable=no,scrollbars='+scrll+',status=no,toolbar=no,locationbar=no,directories=no';
	winProp += ',width='+w+',height='+h+',left='+eval(winLeft+xshift)+',top='+winTop;
	Win = window.open(src,winName,winProp);
	Win.focus();
}
// Open new window for image
/*function imgWin(imgsrc,imgname,w,h) {
	var isOpera = (navigator.userAgent.indexOf("Opera") != -1);
	openWin('','foto',w+15,h+15);
	if(isOpera) {
		if (w != Win.innerWidth || h != Win.innerHeight) { 
			Win.resizeTo(w+27,h+47); 
		}*/
	/*} else {
		if (w != Win.document.body.clientWidth || h != Win.document.body.clientHeight) { 
			Win.resizeTo(w+10,h+30); 
		}
	}*/
/*	Win.document.open();
	Win.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">\n');
	Win.document.write('<html>\n');
	Win.document.write('<head>\n');
	Win.document.write('	<title>'+imgname+'</title>\n');
	Win.document.write('	<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">\n');	
	Win.document.write('	<script type="text/javascript" src="/js/u/main.js"><\/script>\n');	
	Win.document.write('</head>\n');
	Win.document.write('<body>\n');
	Win.document.write('<a href="javascript:window.close()"><img src="'+imgsrc+'" width="'+w+'" height="'+h+'" border="0" alt="'+imgname+'"></a>\n');
	Win.document.write('</body>\n');
	Win.document.write('</html>\n');
	Win.document.close();
	Win.focus();
}*/

var rImgNo, rImgCnt, rClient, rDir;
function showPicture(imgNo, imgCnt, client, _dir, lng) {
	rImgNo = imgNo;
	rImgCnt = imgCnt;
	rClient = client;
	rDir = _dir;
	var w = openWin("/" + lng + "/popup.shtml", "gallery", 515, 544, false, false);
	return false;
}
function _showLoc(loc) { document.getElementById("loc_" + loc).style.display = "block"; }
function _hideLoc(loc) { document.getElementById("loc_" + loc).style.display = "none"; }


var map = "eu";
var isDetail = false;
var eEUOver = null;
var teuOver;
var ready2HideMap = false;
var ready2HideMapEU = false;

function highLightEu(state)
{
	// modra mapa
	if ( eEUOver == null ) eEUOver = document.getElementById("euOver");

	if ( isDetail && map == "eu" ) return false;

	if ( state == true )
	{
		ready2HideMapEU = false;
		_showEU();
	}
	else
	{
		ready2HideMapEU = true;
		teuOver = window.setTimeout(_hideEU, 0);
	}
}

function _showEU() { if ( isDetail && map == "eu" ) return false; window.clearTimeout(teuOver); _highLightH2EU(true); eEUOver.style.display = "block"; }
function _hideEU() { if ( isDetail && map == "eu" ) return false; if ( ready2HideMapEU == false ) return; _highLightH2EU(false); eEUOver.style.display = "none"; }
function _highLightH2EU(state) { if ( isDetail == true && map == "eu" ) return false; document.getElementById("h2").className = ( state == true ? "over" : "" ); }

/* EU */
function highLightLocalityEu(state, loc)
{
	if ( state == true )
	{
		_showEU();
		_showLoc(loc);
	}
	else
	{
		_hideLoc(loc);
	}
}


/* obr - FHL */
function imgWin(imgsrc,imgname,w,h) {
	newObr('','fotos',w, h);
	Win.document.open();
	Win.document.write('<html>\n');
	Win.document.write('<head>\n');
	Win.document.write('	<title>'+imgname+'</title>\n');
	Win.document.write('	<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">\n');
	Win.document.write('	<style type="text/css">body {margin: 0; padding: 0;}</style>\n');
	Win.document.write('</head>\n');
	Win.document.write('<body bgcolor="#000000">\n');
	Win.document.write('<img src="'+imgsrc+'" width="'+w+'" height="'+h+'" border="0" title="' + imgname + '" alt="' + imgname + '" onclick="window.close();">\n');
	Win.document.write('</body>\n');
	Win.document.write('</html>\n');
	Win.document.close();
	Win.focus();
}

function newObr(src,winName,w,h,prop,lp,tp) {
	winLeft = (!lp)? (screen.width - w) / 2 : lp;
	winTop = (!tp)? ((screen.height - h) / 2) : tp;
	winProp = (!prop)? 'menubar=no,resizable=no,scrollbars=0,status=no,toolbar=no,locationbar=no,directories=no' : prop;
	winProp += ',width='+w+',height='+h+',left='+winLeft+',top='+winTop;
	Win = window.open(src,winName,winProp);
	Win.focus();
}

function openWindowX( url, name, width, height )	{
	var win = window.open( url, name, 'scrollbars=yes,resizable=yes,resize=yes,locationbar=yes,status=yes,directories=no,width='+width+',height='+height+',screenX='+getCenterW(width)+',screenY='+getCenterH(height)+',top='+getCenterH(height)+',left='+getCenterW(width) );
    win.focus();
	return false;
}
function getCenterW(width) {
	return parseInt( eval( (screen.width-parseInt(width))/2 ) );
}

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

// Bookmark

function bookmark(url, title){
	if (window.sidebar) // firefox
	    window.sidebar.addPanel(title, url, "");
	else if(window.opera && window.print){ // opera
	    var elem = document.createElement('a');
	    elem.setAttribute('href',url);
	    elem.setAttribute('title',title);
	    elem.setAttribute('rel','sidebar');
	    elem.click();
	}
	else if(document.all)// ie
	    window.external.AddFavorite(url, title);
}

// Motivy na HP
var currentSlide = 2;
var fadespeed = 400;
var counter = 1;

// Preload motivů
var img1 = new Image();
img1.src = "/img/pl/motiv/radik-1.jpg";
var img2 = new Image();
img2.src = "/img/pl/motiv/radik-2.jpg";
var img3 = new Image();
img3.src = "/img/pl/motiv/radik-3.jpg";
var img4 = new Image();
img4.src = "/img/pl/motiv/koralux-1.jpg";
var img5 = new Image();
img5.src = "/img/pl/motiv/koralux-2.jpg";
var img6 = new Image();
img6.src = "/img/pl/motiv/koralux-3.jpg";
var img7 = new Image();
img7.src = "/img/pl/motiv/koratherm-1.jpg";
var img8 = new Image();
img8.src = "/img/pl/motiv/koratherm-2.jpg";
var img9 = new Image();
img9.src = "/img/pl/motiv/koratherm-3.jpg";


function changeMotive() {
	if(counter == 1) {
		$("#motive-radik img").fadeOut(fadespeed, function() {
			$("#motive-radik img").attr("src", "/img/pl/motiv/radik-"+currentSlide+".jpg").fadeIn(fadespeed); 
		});
	}
	if(counter == 2) {
		$("#motive-koralux img").fadeOut(fadespeed, function() {
			$("#motive-koralux img").attr("src", "/img/pl/motiv/koralux-"+currentSlide+".jpg").fadeIn(fadespeed); 
		});
	}
	if(counter == 3) {
		$("#motive-koratherm img").fadeOut(fadespeed, function() {
			$("#motive-koratherm img").attr("src", "/img/pl/motiv/koratherm-"+currentSlide+".jpg").fadeIn(fadespeed); 
		});	
	}
	counter++;
	if(counter == 4) {
		counter = 1;
		currentSlide++;
		if(currentSlide == 4) {currentSlide = 1;}
	}
}