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

window.defaultStatus="www.eon.cz";

var onBeforePrint_EventHandler = null;
var onAfterPrint_EventHandler = null;
function onBeforePrint(win)
{
	if ( onBeforePrint_EventHandler != null ) return onBeforePrint_EventHandler(win);
	return true;
}
function onAfterPrint()
{
	if ( onAfterPrint_EventHandler != null ) return onAfterPrint_EventHandler();
	return true;
}

function printPage(url)
{
	//if ( onBeforePrint() == false ) return false;
  openHardWin('_print',url,700,460,'yes');
	//onAfterPrint();
	return false;
}

// window status function
/*function ws(txt) {
	window.status = txt;
	return true;
}*/
function stripHTML(str) {
	return str.replace(/<[^>]*>/g," ");
}
function ws(txt) {
	txt = stripHTML(txt);
	window.status = txt;
	return true;
}

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

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


// open new win func
function openWin( path, width, height ) {
		var zcewin = window.open(path,'_eon','scrollbars=yes,resizable=yes,resize=no,width='+width+',height='+height+',screenX='+getCenterW(width)+',screenY='+getCenterH(height)+',top='+getCenterH(height)+',left='+getCenterW(width) );
		zcewin.focus();
}
function openHardWin( name, path, width, height, scroll ) {
		if (!scroll || scroll != 'yes') { scroll = 'no' };
		var eonwin = window.open(path,name,'scrollbars=' + scroll + ',resizable=no,resize=no,width='+width+',height='+height+',screenX='+getCenterW(width)+',screenY='+getCenterH(height)+',top='+getCenterH(height)+',left='+getCenterW(width)+',locationbar=no,directories=no,dependent=yes' );
		eonwin.focus();
		return eonwin;
}
function openSiteMap(path) {
	openHardWin('_sitemap',path,780,580);
}

function printFrame(id) {
	var oW = window.parent.top.frames[id].window;
	oW.focus();
	oW.print();
}

function wClose() {
	parent.window.close();
}

// rollover object
function rollOver ( path, name, first, last )	{
	// properties
	this.path = path;
	this.name = name;
	this.extension = "gif";
	this.first = first;
	this.last = last;
	this.active = first-1;
	// methods
	this.preloadImages = preloadImages;
	this.preload = preload;
	this.roll = roll;
	this.set = set;
	this.dis = dis;
}
// rollover public method
function preloadImages( ext ) {
	var nameOver = (null!=ext)?'_'+ext:'';
	for (num=this.first; num<=this.last; num++) {
		this.preload( this.name + '_' + num + nameOver );
	}
}

function preload(imgSrc) {
	if (document.images) {
		eval(imgSrc+' = new Image()');
		eval(imgSrc+'.src = "' +this.path + '/' + imgSrc + '.' + this.extension + '"');
	}
}
// rollover public method - set active item
function set(num,over,pic) {
	this.prev = this.active;
	this.active = num+1;
	this.roll(num,over,pic);
	this.active = num;
	if (this.prev != 0) 
		this.roll(this.prev);
}
// rollover public method - disable item
function dis(num,over,pic) {
	this.active = num;
}
// rollover public method - roll item
function roll(num,over,pic) {
	pic = (null != pic)?pic:num;
	over = (null != over)?over:'';
	if (num == this.active)	{
		return false;
	}
	if (document.images) {
		var imgObj;
		if (over != '') {
			imgObj = this.name + '_' + num + '_' + over;
		}
		else {
			imgObj = this.name + '_' + num;
		}
		var imgName = this.name + '_' + pic;
		if (document.images[imgName])	{
			document.images[imgName].src = eval(imgObj+".src");
		}
	}
}

function hiLiteMenuItem(index, tryNo) {
	if ( typeof(tryNo) == "undefined" ) tryNo = 1; if ( tryNo > 100 ) return;
	if ( top.frames[0].mn.set ) { top.frames[0].mn.set(index,'ovr'); 	return; }
	else { window.setTimeout("hiLiteMenuItem(" + index + ", " + tryNo + 1 + ")", 1000); return; }
}

function showSiteMap()
{
	openHardWin( "eonsitemap", "/cz/sitemap/sitemap.shtml", 780, 460 );
}

var cWindow = null;
function showDetail(cType, anch, lng, hTop) {
	this.hCode = "";
	this.writeHCode = writeHCode;

	var strTop, srcMain, srcFooter, heightTop;

	if ( typeof(lng) == "undefined" ) lng = "cz";
	heightTop =  ( !hTop ) ? heightTop = 50 : hTop;
	
	srcTop = "/" + lng + "/contact/summary_" + cType + "_top.shtml";
	srcMain = "/cms/" + lng + "/contact/summary_" + cType + "_main.shtml#" + anch;
	srcFooter = "/" + lng + "/footer_close_print.shtml";
	
	this.hCode += '<!--#include virtual="/cms/inc/u/_doctype_frame.shtml"-->\n';
	this.hCode += '<head>\n';
	this.	hCode += '	<title>E.ON</title>\n';
	this.	hCode += '</head>\n';
	this.	hCode += '<frameset rows="' + heightTop + ',*,25" border="0" frameborder="0" framespacing="0">\n';
	this.	hCode += '<frame name="cont_top" src="' + srcTop + '" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" noresize>\n';
	this.	hCode += '<frame name="cont_main" src="' + srcMain + '" marginwidth="0" marginheight="0" scrolling="auto" frameborder="0" noresize>\n';
	this.	hCode += '<frame name="cont_footer" src="' + srcFooter + '" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" noresize>\n';
	this.	hCode += '<noframes>\n';
	this.	hCode += '	Váš prohlížeč nepodporuje rámce.\n';
	this.	hCode += '</noframes>\n';
	this.	hCode += '</frameset>\n';
	this.	hCode += '</html>\n';
	
	if ( xIE && cWindow ) cWindow.close();
	cWindow = openHardWin("_contact", "/u/blank.html", 460, 460 );

	this.writeHCode();
	return;
	
	function writeHCode() {
		if ( cWindow.loaded ) {
			cWindow.document.write(hCode);
			cWindow.focus();
		}
		else {
			window.setTimeout(this.writeHCode, 200);
			return;
		}
	}
}

function SwitchMenu(obj) {
	var mi;
	if ( document.getElementById ) {
	var el = document.getElementById(obj);
	var ar;
	for ( mi=0;mi<3;mi++ ) {
		ar = document.getElementById("masterdiv" + mi).getElementsByTagName("span"); 
			if(el.style.display != "block"){ 
				for (var i=0; i<ar.length; i++){
					if (ar[i].className=="subm") 
					ar[i].style.display = "none";
				}
				el.style.display = "block";
			}else{
				el.style.display = "none";
			}
		}
	}
}	
// funkce vypise button BACK v dane lang verzi
function btnBack (lang)	{
	var lng	= lang ? lang : 'cs';
	if (lng == 'cs')	document.write('<a href="javascript:history.back()" onMouseOver="return ws(\'zpět\')"><img src="/img/u/back.gif" width="10" height="19" alt="Zpět" border="0">Zpět</a>'); 
	else	document.write('<a href="javascript:history.back()" onMouseOver="return ws(\'Back\')"><img src="/img/u/back.gif" width="10" height="19" alt="Back" border="0">Back</a>'); 	
}

function show(anch)	{
	return popImage(anch.href,"E.ON - detail obrázku");
}
function popImage( imageURL,imageTitle ){
	var AutoClose = true;
	var PositionX = 100;
	var PositionY = 100;
	var defaultWidth  = 200;
	var defaultHeight = 200;
	var imgWin = window.open('','photoDetail','scrollbars=no,resizable=1,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY);
	if( !imgWin ) { return true; } //popup blockers should not cause errors
	imgWin.document.write('<html><head><title>'+imageTitle+'<\/title><script type="text\/javascript">\n'+
		'function resizeWinTo() {\n'+
		'if( !document.images.length ) { document.images[0] = document.layers[0].images[0]; }'+
		'var oH = document.images[0].height, oW = document.images[0].width;\n'+
		'if( !oH || window.doneAlready ) { return; }\n'+ //in case images are disabled
		'window.doneAlready = true;\n'+ //for Safari and Opera
		'var x = window; x.resizeTo( oW + 100, oH + 100 );\n'+
		'var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;\n'+
		'if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }\n'+
		'else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }\n'+
		'else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }\n'+
		'if( window.opera && !document.childNodes ) { myW += 16; }\n'+
		'x.resizeTo( oW = oW + ( ( oW + 100 ) - myW ), oH = oH + ( (oH + 100 ) - myH ) );\n'+
		'var scW = screen.availWidth ? screen.availWidth : screen.width;\n'+
		'var scH = screen.availHeight ? screen.availHeight : screen.height;\n'+
		'if( !window.opera && screen.width>800 ) { x.moveTo(Math.round((scW-oW)/2),Math.round((scH-oH)/2)); }\n'+
		'}\n'+
		'<\/script>'+
		'<\/head><body onload="resizeWinTo();"'+(AutoClose?' onblur="self.close();"':'')+'>'+
		(document.layers?('<layer left="0" top="0">'):('<div style="position:absolute;left:0px;top:0px;">'))+
		'<img src="'+imageURL+'" alt="Otevírám obrázek ..." title="" onload="resizeWinTo();" onclick="window.close();">'+
		(document.layers?'<\/layer>':'<\/div>')+'<\/body><\/html>');
	imgWin.document.close();
	if( imgWin.focus ) { imgWin.focus(); }
	return false;
}

/* kalkulator ceny plynu */
function resetGasCalcForm() {
	var oForm = document.forms['gasCalcForm'];
	
	var o = oForm.elements['obec'];
	if (o) { o.options[o.selectedIndex].selected = false; o.options[0].selected = true; }
	
	var o = oForm.elements['umisteni_plynomeru'];
	if (o) { o.options[o.selectedIndex].selected = false; o.options[0].selected = true; }
	
	var o = oForm.elements['status_zakaznika'];
	if (o) { o.options[o.selectedIndex].selected = false; o.options[0].selected = true; }
	
	var o = oForm.elements['obdobi_od'];
	if (o) { o.options[o.selectedIndex].selected = false; o.options[0].selected = true; }

	var o = oForm.elements['obdobi_do'];
	if (o) { o.options[o.selectedIndex].selected = false; o.options[0].selected = true; }

	var o = oForm.elements['spotreba'];
	if (o) o.value = '';
}
/* kalkulator ceny plynu */
/**/

function showDP(anch,title,subtitle)	{
	return popImageDP(anch.href,title,subtitle);
}

function popImageDP(imageURL,imageTitle,imageSubtitle){
	var AutoClose = true;
	var PositionX = 10;
	var PositionY = 10;
	var defaultWidth  = 640;
	var defaultHeight = 480;
	var imgWin = window.open('','photoDetail','scrollbars=no,resizable=1,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY);
	if( !imgWin ) { return true; } //popup blockers should not cause errors
	imgWin.document.write('<!DOCTYPE HTML PUBLIC "-\/\/W3C\/\/DTD HTML 4.01 Transitional\/\/EN" "http:\/\/www.w3.org\/TR\/html4\/loose.dtd">\n' +
		'<html>\n'+
		'<head><title>'+imageTitle+' - '+imageSubtitle+'<\/title>\n'+
		'<meta http-equiv="Content-Type" content="text\/html; charset=windows-1250">\n'+
		'<script type="text\/javascript">\n'+
		'function resizeWinTo() {\n'+
		'if( !document.images.length ) { document.images[0] = document.layers[0].images[0]; }'+
		'var oH = document.images[0].height, oW = document.images[0].width;\n'+
		'oW = oW + 690; oH = oH + 551\n' +
		'if( !oH || window.doneAlready ) { return; }\n'+ //in case images are disabled
		'window.doneAlready = true;\n'+ //for Safari and Opera
		'var x = window; x.resizeTo( oW + 300, oH + 300 );\n'+
		'var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;\n'+
		'if( x.innerWidth ) { myW = x.innerWidth+30; myH = x.innerHeight; }\n'+
		'else if( d && d.clientWidth ) { myW = d.clientWidth+30; myH = d.clientHeight; }\n'+
		'else if( b && b.clientWidth ) { myW = b.clientWidth+30; myH = b.clientHeight; }\n'+
		'if( window.opera && !document.childNodes ) { myW += 16; }\n'+
		'x.resizeTo( oW = oW + ( ( oW + 300 ) - myW ), oH = oH + ( (oH + 300 ) - myH ) );\n'+
		'var scW = screen.availWidth ? screen.availWidth : screen.width;\n'+
		'var scH = screen.availHeight ? screen.availHeight : screen.height;\n'+
		'if( !window.opera && screen.width>800 ) { x.moveTo(Math.round((scW-oW)/2),Math.round((scH-oH)/2)); }\n'+
		'}\n'+
		'<\/script>'+
		'<link rel="stylesheet" type="text\/css" href="\/css\/u\/popup.css">'+
		'<\/head><body id="photoDetail" onload="resizeWinTo();"'+(AutoClose?' onblur="self.close();"':'')+'>'+
		'<div id="content">'+'<div id="fr-top"><div class="top-popup"><div class="fLeft">'+'<img src="\/img\/u\/logo_pop_big.gif" alt="E.ON" width="121" height="37" border="0">'+'<\/div><div class="fRight">'+'<img src="\/img\/cs\/career\/technician\/title_mapa_pracovnich_mist.gif" alt="Mapa stránek" class="nomenu">'+'<\/div>'+'<br class="break">'+'<\/div>'+'<\/div>'+
		'<img src="'+imageURL+'" alt="Otevírám obrázek ..." title="" ><br>'+
		'<div class="bottom-popup">'+'<div class="fRight">'+'<a href="javascript:window.top.close()" title="Zavřít" class="close">Zavřít<\/a>'+'<\/div>'+'<\/div>\n' +
		(document.layers?'<\/layer>':'<\/div>')+'<\/body><\/html>');
	imgWin.document.close();
	if( imgWin.focus ) { imgWin.focus(); }
	return false;
}

//změna způsobu plateb

function changeInvoicePayment(invoiceObj,group)	{
	var valSel = invoiceObj.value;
	var straight = xGetElementById("straight");
	if (group=="citizen"){
		var sipo = xGetElementById("sipo");
	}
	var bank = xGetElementById("bank");
	var bankPerm = xGetElementById("bankPerm");
	var bill = xGetElementById("bill");
	var unselectedHide = xGetElementById("unselectedHide");
	var noticeSelect = xGetElementById("noticeSelect");
	if (valSel == 1 ) {
		unselectedHide.style.display = "block";
		straight.style.display = "list-item";
		bank.style.display = "none";
		bankPerm.style.display = "none";
		bill.style.display = "none";
		noticeSelect.style.display = "block";
		if (group=="citizen"){
			sipo.style.display = "list-item";
		}
	} else if (valSel == 3) {
		unselectedHide.style.display = "block";
		straight.style.display = "none";
		bank.style.display = "list-item";
		bankPerm.style.display = "list-item";
		bill.style.display = "none";
		noticeSelect.style.display = "block";
		if (group=="citizen"){
			sipo.style.display = "list-item";
		}
	} else if (valSel == 4) {
		bank.style.display = "none";
		bankPerm.style.display = "none";
		bill.style.display = "list-item";
		noticeSelect.style.display = "none";
		unselectedHide.style.display = "block";
		straight.style.display = "none";
		if (group=="citizen"){
			sipo.style.display = "list-item";
		}
	} else {
		unselectedHide.style.display = "none";
		straight.style.display = "none";
		bank.style.display = "none";
		bankPerm.style.display = "none";
		bill.style.display = "none";
		noticeSelect.style.display = "none";
		if (group=="citizen"){
			sipo.style.display = "none";
		}
	}
}

function initialize(){
	var invoiceObj = xGetElementById('invoicePayment');
	changeInvoicePayment(invoiceObj);
}

/* samoodecet napoveda*/

function initHelp() {
	document.getElementById('place-number').style.display = "none";
	document.getElementById('electrometer-number').style.display = "none";
	document.getElementById('electrometer-state').style.display = "none";
	document.getElementById('electrometer-type').style.display = "none";
}

function showHelp(objx) {
	objx = document.getElementById(objx);
	if (objx.style.display == "none"){
	objx.style.display = "block";
	}else{
		objx.style.display = "none";
	}
}
function hideHelp(objx) {
	objx = document.getElementById(objx);
	objx.style.display = "none";
}