// 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)
{
	var w = 650;
	if ( wide ) w = 1000;
	openWin(url,"koradoMontage",w,700,"yes")
	return false;
}

function openChooser(url, type)
{
	var w = 925;
	/*if ( type == "radik" ) w = 890;*/
	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=utf-8">\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=utf-8">\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();
}

/* skryvani odkryvani onMouseOver info textu - krok 2 */
function viewInfo(id) {
	if (document.getElementById('i'+id)) {
		document.getElementById('i'+id).style.display = 'block';
	}
	return false;
}
function hideInfo(id) {
	if (document.getElementById('i'+id)) {
		document.getElementById('i'+id).style.display = 'none';
	}
	return false;
}

// put away leading zeros
function replaceZeros(str){
    return str.replace(/^[0]+/g,"");
}

// wait in milis
function pause(numberMillis)
{
    var now = new Date();
    var exitTime = now.getTime() + numberMillis;
    while (true)
    {
        now = new Date();
        if (now.getTime() > exitTime)
            return;
    }
} 

String.prototype.capitalize = function() {
	return this.replace(/\w+/g, function(a) {
		return a.charAt(0).toUpperCase() + a.substr(1).toLowerCase();
	});
};

