
window.onload = init;

function init() {
	shp_select_mod();
}


/* funkce více o... otevírá okno doprostřed stránky; parametry adr-url adresa; wdth-šířka */
function moreAbout(adr, wdth) {
	newWin = window.open(adr,"moreAbout",'height='+(screen.height-59)+',menubar=0,personalbar=0,resizable=0,scrollbars=1,status=0,toolbar=0,width='+wdth);
	newWin.moveTo((screen.width/2)-(wdth/2),0);
	}

/* funkce vyhodí pop-up okno s obrazkem i v prislusnych velikostech w, h a prislusnym popisem */
function imgs(desc,w,h,i) {
	msgWindow=window.open("","displayWindow",'height='+h+',menubar=0,personalbar=0,resizable=0,scrollbars=0,status=0,toolbar=0,width='+w);
	msgWindow.moveTo((screen.width/2)-(w/2),10);
	msgWindow.document.write("<html><head><title>"+desc+"</title></head>");
	msgWindow.document.write('<body style="margin: 0px; padding: 0px"><div align=center><a href="javascript: window.close()"><img src="./img/'+i+'" height="'+h+'" width="'+w+'" alt="'+desc+'" border="0"></a></div></body></HTML>');
	}

function highlight(oid) {
	var root = document.getElementById("aktuality");
	
	var lis = root.getElementsByTagName("h2"); 
	for (i=0; i < lis.length; i++) {
		lis[i].style.color = "#000";
		}
	
	var title = document.getElementById(oid).getElementsByTagName("h2");
	title[0].style.color = "#9B6803";
	}

function banner() {	
	bannerSpans = Array();
	spans = document.getElementsByTagName("SPAN");
	for(i = 0; i < spans.length; i++) {
		if(spans[i].className.indexOf("headerTicker") >= 0) {
			bannerSpans[bannerSpans.length] = spans[i];
		}
	}
	actLine = 0;
	setTimeout("ticker()",4000);
}

function ticker() {
	bannerSpans[actLine].style.display = "none";
	if(actLine < 2) actLine++; else actLine = 0;
	bannerSpans[actLine].style.display = "block";
	setTimeout("ticker()",4000);
}


var msgWin = window.msgWin;

function popup(alink, type) { 
	var retValue = false;
	
	if(type == 1) prefix = "/image_popup.php?path="; // img_from_link
	path = prefix + alink.href + "&title=" + alink.getAttribute("TITLE");
	
	if (msgWin != null && !msgWin.closed) { 
		msgWin.location.href = path;
		msgWin.focus();
	} else {
		msgWin = window.open(path, "_gallery","height=150,menubar=0,personalbar=0,resizable=1,scrollbars=0,toolbar=0,width=150,top=100,left=100,status=0");
		if (msgWin == null || typeof(msgWin) == "undefined") {
			retValue = true; 
			}
		else { 
			alink.target = "_gallery";
			msgWin.focus(); 
		} 
	} 
	
	return retValue; 
}

var showWin = window.showWin;

function show_window(alink, width, height, left, top, type) {
	path = alink.href;
	
	switch(type) {
		case "indirect":
			ar = new Array();
			if(width) ar[ar.length] = (width ? 'width=' + width : '');
			if(height) ar[ar.length] = (height ? 'height=' + height : '');
			if(left) ar[ar.length] = (left ? 'left=' + left : '');
			if(top) ar[ar.length] = (top ? 'top=' + top : '');
			path += ((ar.length > 0) ? "?" + ar.join("&") : "");
			showWin = window.open(path + "?", "show_window", "height=100,menubar=0,personalbar=0,resizable=1,scrollbars=1,toolbar=0,width=100,top=100,left=100,status=0");
			break;
		default:
			showWin = window.open(path, "show_window", "height="+height+",menubar=0,personalbar=0,resizable=1,scrollbars=1,toolbar=0,width="+width+",top="+top+",left="+left+",status=0");
	}

	if (showWin == null || typeof(showWin) == "undefined") {
		return true; 
	} else {
		showWin.focus();
		return false;
	}
}


function show_video(nick, lang, flvNick) {
	
	switch(lang) {
	case "en":
		txtClose = "Close window";
		txtVideo = 'You need Adobe Flash plug-in 8 installed and JavaScript allowed in order to view the video.';
		break;
	case "de":
		txtClose = "Close window";
		txtVideo = 'You need Adobe Flash plug-in 8 installed and JavaScript allowed in order to view the video.';
		break;
	default:
		txtClose = "Zavřít prezentaci";
		txtVideo = 'Pro přehrátí videa je zapotřebí mít nainstalován Adobe Flash plug-in 8 a povolený JavaScript.';
		break;
		
	}
	
	if(old = document.getElementById("lb")) {
		old.style.display = "block";
		return false;
	}
	
	d = document.createElement('div');
	d.setAttribute("id", "lb");
	
	dpv = document.createElement('div');
	dpv.setAttribute("id", "lbVideo");
	
	dph = document.createElement('div');
	dph.setAttribute("id", "lbHolder");
	
	a = document.createElement('a');
	txt = document.createTextNode(txtClose);
	a.appendChild(txt);
	a.href = window.location.href;
	a.id = "closeLink";
	a.onclick = function() { hide_video(); return false;}
	
	dpm = document.createElement('div');
	dpm.setAttribute("id", nick + "Movie");
	
	p = document.createElement('p');
	txt = document.createTextNode(txtVideo);
	p.appendChild(txt);
	dpm.appendChild(p);
	dph.appendChild(dpm);
	dph.appendChild(a);
	//dpv.appendChild(dph);
	
	d.appendChild(dph);
	d.appendChild(dpv);
	
	var objBody = document.getElementsByTagName("body").item(0);
	objBody.appendChild(d);
	
	pg = getPageSize();
	overlay = document.getElementById("lbVideo");
	overlay.style.height = pg[1] + 'px';
	overlay.style.display = "block";
	
	movie = document.getElementById("lbHolder");
	movie.style.top = (getPageScroll() + 200) + "px";
	movie.style.left = (pg[0] / 2 - 200)+ "px";
	fov = new FlashObject("/img/video_" + nick + ".swf", "vd_" + nick, "320", "280", "8", "#ffffff");
	fov.addVariable("lng", lang);
	fov.addVariable("predstaveni", flvNick);
	fov.write(nick + "Movie");
	
	return false;
}

function show_custom_flash(nick, lang, path, swfWidth, swfHeight, swfOffsetTop, customText) {
	switch(lang) {
		case "en":
			txtClose = "Close window";
			txtVideo = 'You need Adobe Flash plug-in 8 installed and JavaScript allowed in order to view the animation.';
			break;
		case "de":
			txtClose = "Close window";
			txtVideo = 'You need Adobe Flash plug-in 8 installed and JavaScript allowed in order to view the animation.';
			break;
		default:
			txtClose = "Zavřít prezentaci";
			txtVideo = 'Pro přehrátí animace je zapotřebí mít nainstalován Adobe Flash plug-in 8 a povolený JavaScript.';
			break;
	}
	
	if(old = document.getElementById("lb")) {
		old.style.display = "block";
		return false;
	}
	
	d = document.createElement('div');
	d.setAttribute("id", "lb");
	
	dpv = document.createElement('div');
	dpv.setAttribute("id", "lbVideo");
	
	dph = document.createElement('div');
	dph.setAttribute("id", "lbHolder");
	dph.setAttribute("class", nick + "SWFclass");
	dph.style.width = swfWidth + 40;
	
	a = document.createElement('a');
	txt = document.createTextNode(txtClose);
	a.appendChild(txt);
	a.href = window.location.href;
	a.id = "closeLink";
	a.onclick = function() { hide_video(); return false;}
	
	cust = false;
	if(customText) {
		cust = document.createElement('span');
		txt = document.createTextNode(customText);
		cust.appendChild(txt);
	}
	
	dpm = document.createElement('div');
	dpm.setAttribute("id", nick + "Movie");
	
	p = document.createElement('p');
	txt = document.createTextNode(txtVideo);
	p.appendChild(txt);
	dpm.appendChild(p);
	dph.appendChild(dpm);
	if(cust) {dph.appendChild(cust);}
	dph.appendChild(a);
	//dpv.appendChild(dph);
	
	d.appendChild(dph);
	d.appendChild(dpv);
	
	var objBody = document.getElementsByTagName("body").item(0);
	objBody.appendChild(d);
	
	pg = getPageSize();
	overlay = document.getElementById("lbVideo");
	overlay.style.height = pg[1] + 'px';
	overlay.style.display = "block";
	
	movie = document.getElementById("lbHolder");
	movie.style.top = (getPageScroll() + swfOffsetTop) + "px";
	movie.style.left = (pg[0] / 2 - (swfWidth / 2))+ "px";
	fov = new FlashObject(path, "swf_" + nick, swfWidth, swfHeight, "8", "#ffffff");
	fov.addParam("quality", "high");
	fov.write(nick + "Movie");
	
	return false;
}

//
// getPageSize()
// Returns array with page width, height and window width, height
// Code from - quirksmode.org & Lightbox JS by Lokesh Dhakar
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

//
// getPageScroll()
// Returns y page scroll values.
// Code from - quirksmode.org & Lightbox JS by Lokesh Dhakar
//
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	return yScroll;
}

function hide_video() {
	obj = document.getElementById("lb");
	obj.parentNode.removeChild(obj);
}

function shp_select_mod() {
	f = document.getElementById("frmCheck");
	if(f) {
		trpo = document.getElementById("post");
		trpl = document.getElementById("platba");
	 	if(f.stat.value != 35) {
			trpo.style.display = "none";
			trpl.style.display = "none";
		}
		f.stat.onchange = function () {
			if(this.value == 35) {
				trpo.style.display = "block";
				trpl.style.display = "block";
			} else {
				trpo.style.display = "none";
				trpl.style.display = "none";
			}
		} 
	}
}
