﻿//--------------------promene---------------------------
//nazev klienta
var user;
//cesty k sys souborum
var prvekPath = new Array();
prvekPath['menu'] = 'sys/org.php';
prvekPath['prop'] = 'sys/properties.php';
prvekPath['text'] = 'sys/editor.php';
prvekPath['galerie'] = 'sys/galerie.php';
prvekPath['images'] = 'sys/images.php';
prvekPath['anketa'] = 'sys/survey.php';
prvekPath['discussion'] = 'sys/comments.php';
prvekPath['cont'] = 'sys/contact.php';
prvekPath['backup'] = 'sys/backup.php';
prvekPath['lang'] = 'sys/lang.php';
prvekPath['invoice'] = 'sys/invoiceData.php';
prvekPath['katalog'] = '#';
prvekPath['objednavka'] = 'sys/objednavka.php';
//pomocna promena pro modaly cross domain
var lastId = "";
//cesta k systemu
var sysPath = 'http://stranky-jednoduse.cz/cms/';
//var sysPath = 'http://strankyjednoduse.cz/cms/';
// cesty k obrazkum v modalu
var loadingImage = sysPath + 'sysImages/common/loading.gif';		
var closeButton = sysPath + 'sysImages/common/close.gif';		

//promene z XML
var xmlSite = 0;
var xmlMaxCont = new Array();
var xmlMaxOrder = new Array();
var xmlNewCont = 0;
var xmlCont;
var xmlType;
var xmlSide;
var newContText;
var tarif;
var vyzkouset;
var locallink = document.location.href.substring(0,document.location.href.lastIndexOf('/') + 1);
var localfile = document.location.href.substring(document.location.href.lastIndexOf('/') + 1);
localfile = localfile.split('.')[0];
if (!localfile || localfile.split('#')[0] == '') {
	localfile = 'index'; 
}

//modaly nacitane do stranky
var modals = new Array();
modals['login'] = '<div class="modalLogin">' + 	
          			'<div class="close"><span onclick="hideOverlay();document.loginf.login_pw.value=\'\'">x</span></div>' + 
					'<form name="loginf" method="post" onsubmit="preloader();if(document.loginf.login_pw.value!=\'\'){json(\'' +sysPath+ 'sys/json.php?loadCont=1&login_name=\' +user+\'&login_pw=\' +MD5(document.loginf.login_pw.value)+\'&file=\' + localfile + \'&link_cus=\' + locallink);}else{alert(\'Zadejte prosím heslo.\');}hideOverlay();return false;">' + 
					'<div class="insertLogin">Zadejte prosím heslo:</div>' + 
					'<input class="inputLogin" name="login_pw" type="password" size="10" value="" />' + 
					'<input id="logS" type="submit" value="Přihlásit se" />' + 
					'</form>' + 
					'<div class="copywrite"><a href="http://www.stranky-jednoduse.cz"><span>&copy; www.stranky-jednoduse.cz</span></a></div>' + 
					'</div>';
modals['loginError'] = '<div class="modalLogin">' + 	
          			'<div class="close"><span onclick="hideOverlay();">x</span></div>' + 
					'<form name="loginf" method="post" >' + 
					'<div class="insertLogin">Pravděpodobně jste zadali špatné heslo.<br /><br /><a href="#" onclick="hideOverlay();modalIn(\'login\');" >Zkusit to znovu</a></div>' + 
					'</form>' + 
					'<div class="copywrite"><a href="http://www.stranky-jednoduse.cz"><span>&copy; www.stranky-jednoduse.cz</span></a></div>' + 
					'</div>';

modals['delCont'] = '<form name="formNew" class="delFormModal">' +
					'<div class="modalEdit">' +
					'<div class="modalInfo mi5">' +
					'Smazat prvek ...' +
					'</div>' +
					'<div class="modalData">' +
					'<p>Opravdu si přejete smazat tento prvek?</p>' +
					'</div>&nbsp;' +
					'</div>' +
					'<div class="modalButtons">' +
					'<input type="button" onclick="preloader();json(\'' +sysPath+ 'sys/json.php?delCont=1&file=\' +localfile+\'&cont=\' +xmlCont+\'&side=\' +xmlSide);hideOverlay();" value="&nbsp; Smazat &nbsp;" />' +
					'<input type="button" onclick="hideOverlay();" value="&nbsp; Zrušit &nbsp;" />' +
					'</div>' +
					'</form>';
modals['restore'] = '<form action="index.php" name="formNew">' +
					'<div class="modalBookmarks noBookmarks">' +
					'<div class="mbRight">' +
//					'<a href=""><strong>?</strong> nápověda</a>' +
					'</div>' +
					'<div class="fc"></div>' +
					'</div>' +
					'<div class="modalEdit">' +
					'<div class="modalInfo mi5">' +
					'Obnovení stránek ze zálohy ...' +
					'</div>' +
					'<div class="modalData">' +
					'<p>Vaše stránky byly obnoveny ze zálohy.</p>' +
					'</div>&nbsp;' +
					'</div>' +
					'<div class="modalButtons">' +
					'<input type="submit" value="&nbsp; OK &nbsp;" />' +
					'</div>' +
					'</form>';
					
//--------------------fce--------------------------------

//*************************************************
// * dom-drag.js
// * 09.25.2001
// * www.youngpup.net
// * Script featured on Dynamic Drive (http://www.dynamicdrive.com) 12.08.2005
// **************************************************
// * 10.28.2001 - fixed minor bug where events
// * sometimes fired off the handle, not the root.
// *************************************************

var Drag = {

	obj : null,

	init : function(o, oRoot, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper)
	{
		o.onmousedown	= Drag.start;

		o.hmode			= bSwapHorzRef ? false : true ;
		o.vmode			= bSwapVertRef ? false : true ;

		o.root = oRoot && oRoot != null ? oRoot : o ;

		if (o.hmode  && isNaN(parseInt(o.root.style.left  ))) o.root.style.left   = "0px";
		if (o.vmode  && isNaN(parseInt(o.root.style.top   ))) o.root.style.top    = "0px";
		if (!o.hmode && isNaN(parseInt(o.root.style.right ))) o.root.style.right  = "0px";
		if (!o.vmode && isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom = "0px";

		o.minX	= typeof minX != 'undefined' ? minX : null;
		o.minY	= typeof minY != 'undefined' ? minY : null;
		o.maxX	= typeof maxX != 'undefined' ? maxX : null;
		o.maxY	= typeof maxY != 'undefined' ? maxY : null;

		o.xMapper = fXMapper ? fXMapper : null;
		o.yMapper = fYMapper ? fYMapper : null;

		o.root.onDragStart	= new Function();
		o.root.onDragEnd	= new Function();
		o.root.onDrag		= new Function();
	},

	start : function(e)
	{
		var o = Drag.obj = this;
		e = Drag.fixE(e);
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		o.root.onDragStart(x, y);

		o.lastMouseX	= e.clientX;
		o.lastMouseY	= e.clientY;

		if (o.hmode) {
			if (o.minX != null)	o.minMouseX	= e.clientX - x + o.minX;
			if (o.maxX != null)	o.maxMouseX	= o.minMouseX + o.maxX - o.minX;
		} else {
			if (o.minX != null) o.maxMouseX = -o.minX + e.clientX + x;
			if (o.maxX != null) o.minMouseX = -o.maxX + e.clientX + x;
		}

		if (o.vmode) {
			if (o.minY != null)	o.minMouseY	= e.clientY - y + o.minY;
			if (o.maxY != null)	o.maxMouseY	= o.minMouseY + o.maxY - o.minY;
		} else {
			if (o.minY != null) o.maxMouseY = -o.minY + e.clientY + y;
			if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y;
		}

		document.onmousemove	= Drag.drag;
		document.onmouseup		= Drag.end;

		return false;
	},

	drag : function(e)
	{
		e = Drag.fixE(e);
		var o = Drag.obj;

		var ey	= e.clientY;
		var ex	= e.clientX;
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		var nx, ny;

		if (o.minX != null) ex = o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX);
		if (o.maxX != null) ex = o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX);
		if (o.minY != null) ey = o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY);
		if (o.maxY != null) ey = o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY);

		nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));
		ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));

		if (o.xMapper)		nx = o.xMapper(y)
		else if (o.yMapper)	ny = o.yMapper(x)

		Drag.obj.root.style[o.hmode ? "left" : "right"] = nx + "px";
		Drag.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px";
		Drag.obj.lastMouseX	= ex;
		Drag.obj.lastMouseY	= ey;

		Drag.obj.root.onDrag(nx, ny);
		setCookie ('positionMainIco',nx + '|' + ny,365);
		return false;
	},

	end : function()
	{
		document.onmousemove = null;
		document.onmouseup   = null;
		Drag.obj.root.onDragEnd(	parseInt(Drag.obj.root.style[Drag.obj.hmode ? "left" : "right"]), 
									parseInt(Drag.obj.root.style[Drag.obj.vmode ? "top" : "bottom"]));
		Drag.obj = null;
	},

	fixE : function(e)
	{
		if (typeof e == 'undefined') e = window.event;
		if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
		if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
		return e;
	}
};

function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString()) + "; path=/";
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return 0;
}

function maxArr( array ){
    return Math.max.apply( Math, array );
};

function minArr( array ){
    return Math.min.apply( Math, array );
};

function setWindow() {
    imgx = document.img.width;
    imgy = document.img.height;
    if(document.img.width > 984)  { imgx = 1024; } else { imgx += 40; }
    if(document.img.height > 723) { imgy = 768; }  else { imgy += 55; }
    window.resizeTo(imgx, imgy+22 )
}


function openPopup( url, wdh, hgh)
{
  window.open( url, '_blank', 'width=' +(wdh ? wdh : '800')+'px,height=' +(hgh ? hgh : '600')+'px,scrollbars=1,resizable=yes');
  return false;
}


//pristup k prvkum kvuli browserum
function objGet(x) {
	if (typeof x != 'string') return x;
	else if (Boolean(document.getElementById)) return document.getElementById(x);
	else if (Boolean(document.all)) return eval('document.all.' +x);
	else return null;
}

/*
////v1.03 Copyright (c) 2006 Stuart Colville
////http://muffinresearch.co.uk/archives/2006/04/29/getelementsbyclassname-deluxe-edition/
////
////Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
////documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
////the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 
////and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
////
////The above copyright notice and this permission notice shall be included in all copies or substantial 
////portions of the Software.
////
////THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
////TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
////THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
////CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 
////IN THE SOFTWARE.
*/
  
function getElementsByClassName(strClass, strTag, objContElm) {
  strTag = strTag || "*";
  objContElm = objContElm || document;    
  var objColl = objContElm.getElementsByTagName(strTag);
  if (!objColl.length &&  strTag == "*" &&  objContElm.all) objColl = objContElm.all;
  var arr = new Array();                              
  var delim = strClass.indexOf('|') != -1  ? '|' : ' ';   
  var arrClass = strClass.split(delim);    
  for (var i = 0, j = objColl.length; i < j; i++) {                         
    var arrObjClass = objColl[i].className.split(' ');   
    if (delim == ' ' && arrClass.length > arrObjClass.length) continue;
    var c = 0;
    comparisonLoop:
    for (var k = 0, l = arrObjClass.length; k < l; k++) {
      for (var m = 0, n = arrClass.length; m < n; m++) {
        if (arrClass[m] == arrObjClass[k]) c++;
        if ((delim == '|' && c == 1) || (delim == ' ' && c == arrClass.length)) {
          arr.push(objColl[i]); 
          break comparisonLoop;
        }
      }
    }
  }
  return arr; 
}

// To cover IE 5 Mac lack of the push method
Array.prototype.push = function(value) {this[this.length] = value; };


function winH() {
   if (window.innerHeight)
      /* NN4 a kompatibilní prohlížece */
      return window.innerHeight;
   else if
   (document.documentElement &&
   document.documentElement.clientHeight)
//       MSIE6 v std. režimu - Opera a Mozilla
//      již uspely s window.innerHeight 
      return document.documentElement.clientHeight;
   else if
   (document.body && document.body.clientHeight)
      /* starší MSIE + MSIE6 v quirk režimu */
      return document.body.clientHeight;
   else
      return null;
}

function frameH() {
var p = objGet('ApFrame');

if (window.innerHeight)
return p.style.height = ((winH()) - 103) + "px"; 

else if (document.documentElement && document.documentElement.clientHeight)
return p.style.height = ((winH()) - 102) + "px"; 

}


function frameHorg() {
var p = objGet('ApFrame');

if (window.innerHeight)
return p.style.height = ((winH()) - 172) + "px"; 

else if (document.documentElement && document.documentElement.clientHeight)
return p.style.height = ((winH()) - 173) + "px"; 
}


	
//MODAL
IE= null;
NS= null;


ua = navigator.appName.toLowerCase();

if(ua.indexOf('explorer')>-1 && document.getElementById && document.childNodes) {IE=true;}
if(ua.indexOf('netscape')>-1 && document.getElementById && document.childNodes) {NS=true;}


function test_prohlizec()
{

	if(!IE && !NS) 
	{
		self.location = "javascript: alert('Chyba v dokumentu "+self.location+" .Prohlizec nepodporuje metody standardu W3C DOM a neni mozno dokument spravne zobrazit.')";
	}
 
}


	
function posunX()
{
	if(IE) return document.body.scrollLeft;
	if(NS) return window.pageXOffset;
}

function posunY() {
   if (window.scrollTop)
      /* NN4 a kompatibilní prohlížece */
      return window.scrollTop;
   else if
   (document.documentElement &&
   document.documentElement.scrollTop)
//       MSIE6 v std. režimu - Opera a Mozilla
//      již uspely s window.innerHeight 
      return document.documentElement.scrollTop;
   else if
   (document.body && document.body.scrollTop)
      /* starší MSIE + MSIE6 v quirk režimu */
      return document.body.scrollTop;
   else
      return 0;
}

function winW() {
   if (window.innerWidth)
      /* NN4 a kompatibilní prohlížece */
      return window.innerWidth;
   else if
   (document.documentElement &&
   document.documentElement.clientWidth)
//       MSIE6 v std. režimu - Opera a Mozilla
//      již uspely s window.innerHeight 
      return document.documentElement.clientWidth;
   else if
   (document.body && document.body.clientWidth)
      /* starší MSIE + MSIE6 v quirk režimu */
      return document.body.clientWidth;
   else
      return 0;
}

function winH() {
   if (window.innerHeight)
      /* NN4 a kompatibilní prohlížece */
      return window.innerHeight;
   else if
   (document.documentElement &&
   document.documentElement.clientHeight)
//       MSIE6 v std. režimu - Opera a Mozilla
//      již uspely s window.innerHeight 
      return document.documentElement.clientHeight;
   else if
   (document.body && document.body.clientHeight)
      /* starší MSIE + MSIE6 v quirk režimu */
      return document.body.clientHeight;
   else
      return null;
}

// funkce pro odstraneni nepovolenych znaku
function removeBreaks(noBreaksText){

noBreaksText = noBreaksText.replace(/(\n\r|\n|\r)/gm,"<1br />");

re1 = /<1br \/><1br \/>/gi;
re1a = /<1br \/><1br \/><1br \/>/gi;

noBreaksText = noBreaksText.replace(re1," ");

re2 = /\<1br \/>/gi;
noBreaksText = noBreaksText.replace(re2, " ");

re3 = /\s+/g;
noBreaksText = noBreaksText.replace(re3," ");

re4 = /<2br \/>/gi;
noBreaksText = noBreaksText.replace(re4,"\n\n");
return noBreaksText;
}

//fce obdrzeni zpravy z modalu na cross domain
function checkForMessages(){
	var runJson = 1;
	var hidModal = 1;
	if(document.location.hash != lastId){
		lastId = document.location.hash;
			if (lastId.split('&')[0]=='#newWys'){
				var request = sysPath+'sys/json.php?newCont=1&cont=' +lastId.split('&')[2]+'&side=' +lastId.split('&')[3]+'&type=' +lastId.split('&')[1]+'&file=' +localfile;
			}else if (lastId.split('&')[0]=='#closeWys'){
				var request = sysPath+'sys/json.php?changeCont=1&cont=' +lastId.split('&')[2]+'&side=' +lastId.split('&')[3]+'&type=' +lastId.split('&')[1]+'&file=' +localfile;
			}else if (lastId.split('&')[0]=='#menu'){
				objOverlayDiv = document.getElementById('overlay');
				objOverlayDiv.style.visibility = 'hidden';
				preloader();
				var request = sysPath+'sys/json.php?menu=1&cont=' +lastId.split('&')[2]+'&side=' +lastId.split('&')[3]+'&type=' +lastId.split('&')[1]+ '&file=' +localfile;
			}else if (lastId.split('&')[0]=='#gal'){
				var request = sysPath+'sys/json.php?gal=1&cont=' +lastId.split('&')[2]+'&side=' +lastId.split('&')[3]+'&type=' +lastId.split('&')[1]+ '&file=' +localfile+ '&newGal=' + lastId.split('&')[4];
			}else if (lastId.split('&')[0]=='#com'){
				var request = sysPath+'sys/json.php?com=1&cont=' +lastId.split('&')[2]+'&side=' +lastId.split('&')[3]+'&type=' +lastId.split('&')[1]+ '&file=' +localfile+ '&newCom=' + lastId.split('&')[4];
			}else if (lastId.split('&')[0]=='#sur'){
				var request = sysPath+'sys/json.php?sur=1&cont=' +lastId.split('&')[2]+'&side=' +lastId.split('&')[3]+'&type=' +lastId.split('&')[1]+ '&file=' +localfile+ '&newSur=' + lastId.split('&')[4];
			}else if (lastId.split('&')[0]=='#cont'){
				var request = sysPath+'sys/json.php?contSub=1&cont=' +lastId.split('&')[2]+'&side=' +lastId.split('&')[3]+'&type=' +lastId.split('&')[1]+ '&file=' +localfile+ '&newContact=' + lastId.split('&')[4];
			}else if (lastId.split('&')[0]=='#lang'){
				window.location.href='index.php';
				runJson = 0;
				hidePreloader();
			}else if (lastId.split('&')[0]=='#restore'){
				hideOverlay();
				modalIn('restore');
				hidModal = 0;
				runJson = 0;
				hidePreloader();
			}else if (lastId.split('&')[0]=='#prop'){
				runJson = 0;
				createNewText('headercont',lastId.split('&')[1]);
				createNewText('copyright',lastId.split('&')[2]);
				hidePreloader();
			}else if (lastId.split('&')[0]=='#propMail'){
				runJson = 0;
				hidePreloader();
			}else if (lastId.split('&')[0]=='#comDel'){
				runJson = 0;
				var delStr;
				var delComAr = lastId.split('&')[4].split('|');
				for (i = 0; i != delComAr.length; i++) {
					delStr = 'com-' + lastId.split('&')[2] + '-' + delComAr[i];
					hid(delStr);
				}
				hidePreloader();
			}else if (lastId.split('&')[0]=='#unvisible'){
				objOverlayDiv = document.getElementById('overlay');
				objOverlayDiv.style.visibility = 'hidden';
				//objOverlayDiv.style.display = 'none';
				preloader();
				runJson=0;
				hidModal=0;
				checkForMessages();
			}else if (lastId.split('&')[0]=='#'){
				runJson=0;
			}else if (lastId.split('&')[0]=='#hidePreloader'){
				runJson=0;
				hidModal=0;
				hidePreloader();
				objOverlayDiv = document.getElementById('overlay');
				objOverlayDiv.style.visibility = 'visible';
				//objOverlayDiv.style.display = 'block';
				checkForMessages();
			}
			if (runJson==1){
				json (request);
			}
			if (hidModal==1){
				hideOverlay();
			}
		}else{
		setTimeout(checkForMessages, 200);
		}
	}

function hu(name) {	
	test_prohlizec();
	var p = objGet(name);
	if  (p.style.display == 'none') { 
	p.style.display = 'block';
	}
	else {p.style.display = 'none';}
}

function hid(name) {
	test_prohlizec();
	var p = objGet(name);
	if (p){
		p.style.display = 'none';
	}
}

function unhid(name) {	
	test_prohlizec();
	var p = objGet(name);
	p.style.display = 'block';
}
function unhidLine(name) {	
	test_prohlizec();
	var p = objGet(name);
	if (p){
		p.style.display = 'inline';
	}
}

function invis(name) {	
	test_prohlizec();
	var p = objGet(name);	
	p.style.visibility = 'hidden';
}

function vis(name) {	
	test_prohlizec();
	var p = objGet(name);
	p.style.visibility = 'visible';
}

//galerie oznacovani images
function galGal(pic,tag){
	var gale = new Array();
	gale = getElementsByClassName('galSec galSecHover',tag,document);
	if (gale[0]){
		gale[0].className = 'galSec';
	}
	var p = objGet(pic);
	p.className = 'galSec galSecHover';
}

//galerie oznacovani images
function galMulti(pic,deactiv,activ){
	var p = objGet(pic);
	if (p.className == deactiv){
		p.className = activ;
	}else{
		p.className = deactiv;
	}
}

function changeClass(name,val) {
	var trid = objGet(name);
	trid.className = val;
}
function trida1(name) {
	var trid = objGet(name);
	trid.className = 'act';
}
function trida2(name) {
	var trid = objGet(name);
	trid.className = '';
}
function trida3(name) {
	var trid = objGet(name);
	trid.className = 'endB';
}

 
function bgObrazek(obrazek, cssPath) {
	var bgObr = obrazek;
	rte1.document.body.style.backgroundImage = 'url(' +bgObr+')';
	rte1.document.body.style.backgroundRepeat = 'no-repeat';
	document.RTEDemo.bgrPath.value = cssPath;
}


// zkopirovano z richtext.js
function popUpWin (url, win, width, height, options) {
	var leftPos = (screen.availWidth - width) / 2;
	var topPos = (screen.availHeight - height) / 2;
	options += 'width=' + width + ',height=' + height + ',left=' + leftPos + ',top=' + topPos;
	return window.open(url, win, options);
}

function checkBox(name,val) {
	test_prohlizec();
	var p = objGet(name);
	if (val == 0){
		p.checked = false;
	}else{
		p.checked = true;
	}
	
}
function disableBox(name,val){
	test_prohlizec();
	var p = objGet(name);
	if (val == 0){
		p.disabled=false;
	}else{
		p.disabled=true;
	}
}
function newAtribut(id,name,text) {
	test_prohlizec();
	var p = objGet(id);
	p.setAttribute(name,text);
}
function createText(name,text) {
	test_prohlizec();
	var p = objGet(name);
	p.innerHTML += text;
}
function createNewText(name,text) {
	test_prohlizec();
	var p = objGet(name);
	removeText(name);
	p.innerHTML = text;
}
function changeAtr(name,atr,text) {
	test_prohlizec();
	var p = objGet(name);
	p.atr = text;
}
function changeDispl(name,text) {
	test_prohlizec();
	var p = objGet(name);
	p.style.display = text;
}
function changeWidth(name,text) {
	test_prohlizec();
	var p = objGet(name);
	p.style.width = text;
}
function removeAllNodes (element) {
	while (element.firstChild) {
	  element.removeChild(element.firstChild);
	}
}
function removeText(name) {
	test_prohlizec();
	var p = objGet(name);
	if (p){
		removeAllNodes(p);
	}
}
function removeEl(fname,chname){
	var childnode=objGet(chname);
	var removednode=objGet(fname);
	removednode.removeChild(childnode);
}	
function hrefLocation(url)
	{
	  window.location.href = url;
	}

//function dominnerText(node, text)
// {
// while (node.hasChildNodes())
//  {
//   node.removeChild(node.firstChild);
//  }
// node.appendChild(document.createTextNode(text));
// }
//
//function setValue (name, text){
// var m = objGet(name);
// dominnerText(m, text);
//}

// JSONscriptRequest -- a simple class for making HTTP requests
// using dynamically generated script tags and JSON
//
// Author: Jason Levitt
// Date: December 7th, 2005
//
// A SECURITY WARNING FROM DOUGLAS CROCKFORD:
// "The dynamic <script> tag hack suffers from a problem. It allows a page 
// to access data from any server in the web, which is really useful. 
// Unfortunately, the data is returned in the form of a script. That script 
// can deliver the data, but it runs with the same authority as scripts on 
// the base page, so it is able to steal cookies or misuse the authorization 
// of the user with the server. A rogue script can do destructive things to 
// the relationship between the user and the base server."
//
// So, be extremely cautious in your use of this script.
//

//Pavel funkce pro vytvoreni obj. JSON
function json (request){
	aObj = new JSONscriptRequest(request);
	aObj.buildScriptTag();
	aObj.addScriptTag();
}
// Constructor -- pass a REST request URL to the constructor
//
function JSONscriptRequest(fullUrl) {
    // REST request path
    this.fullUrl = fullUrl; 
    // Keep IE from caching requests
    this.noCacheIE = '&noCacheIE=' + (new Date()).getTime();
    // Get the DOM location to put the script tag
	//this.headLoc = parent.document.getElementsByTagName("head").item(0);
	this.headLoc = document.getElementsByTagName("head").item(0);
    // Generate a unique script tag id
    this.scriptId = 'JscriptId' + JSONscriptRequest.scriptCounter++;
}

// Static script ID counter
JSONscriptRequest.scriptCounter = 1;

// buildScriptTag method
//
JSONscriptRequest.prototype.buildScriptTag = function () {

    // Create the script tag
    this.scriptObj = document.createElement("script");
    
    // Add script object attributes
    this.scriptObj.setAttribute("type", "text/javascript");
    this.scriptObj.setAttribute("charset", "utf-8");
    this.scriptObj.setAttribute("src", this.fullUrl + this.noCacheIE);
    this.scriptObj.setAttribute("id", this.scriptId);
}
 
// removeScriptTag method
// 
JSONscriptRequest.prototype.removeScriptTag = function () {
    // Destroy the script tag
    this.headLoc.removeChild(this.scriptObj);  
}

// addScriptTag method
//
JSONscriptRequest.prototype.addScriptTag = function () {
    // Create the script tag
    this.headLoc.appendChild(this.scriptObj);
}

//call back function from JSON
function callbackfunc(jsonData) {
      aObj.removeScriptTag();
}
//prohozeni divu
function putOrder(fname,oldname,newname,inspar){
//	alert(fname+'--' +newname+'--' +oldname+'--' +inspar+'--' +firstId+'--' +lastId);
	test_prohlizec();
	var f = objGet(fname);
	var n = objGet(newname);
	var o = objGet(oldname);
	if (inspar==0){
		f.insertBefore(n,o);
	}else if (inspar==1) {
		f.insertBefore(n,o.nextSibling);
	}
}

function DragDropMainIco () {
	if (!getCookie('positionMainIco')){
		setCookie ('positionMainIco','100|100',365);
	}
	Drag.init(document.getElementById("edit-0-ico")); 
	(document.getElementById("edit-0-ico")).style.left = (getCookie('positionMainIco').split('|')[0]) + "px";
	(document.getElementById("edit-0-ico")).style.top = (getCookie('positionMainIco').split('|')[1]) + "px";
}

function newMainIco(){
	var tarifText1;
	var tarifText2;
	if (vyzkouset!=''){// tarif STANDARD //// tarif START //
		tarifText1 = '<iframe id="boxFrame2" class="boxFrame" scrolling="no" src="http://stranky-jednoduse.cz/cms/sys/box2.html"></iframe>';
		tarifText2 = '<div onclick="modal(\'invoice\');checkForMessages();" class="body15">Faktury</div>';
	}else{// tarif VYZKOUSET //
		tarifText1 = '<iframe id="boxFrame1" class="boxFrame" scrolling="no" src="http://stranky-jednoduse.cz/cms/sys/box1.html"></iframe>' + 
					'<div onclick="modal(\'objednavka\');checkForMessages();" class="objednat"><span>Objednat a zprovoznit stránky</span></div>';
		tarifText2 = '';
	}
	// varianta pro uzivatele //
	var text = '<div style="top: 100px; left: 100px; position: absolute;" class="edit-ico" id="edit-0-ico">' + 
				'<div id="header0"></div>' + 
				'<div id="body0">' + 
				'<div class="body10">' + 
				tarifText1 + 
				'</div>' + 
				'<div class="bodyBox">' + 
				tarifText2 + 
				'<div onclick="preloader();json(\'' + sysPath + 'sys/json.php?logout=1&url=' + document.location.href + '\');" class="body12" title="Po ukončení úprav stránek se nezapomeňte odhlásit">Odhlásit se</div>' + 
				'</div>' +
				'</div>';
	
	// varianta pro webdesignery //
	var text1 = '<div style="top: 100px; left: 100px; position: absolute;" class="edit-ico" id="edit-0-ico">' + 
				'<div id="header0"></div>' + 
				'<div id="body0">' + 
				'<div class="body10">' +
				
				'<div onclick="modal(\'menu\');checkForMessages();" class="body13">Organizace stránek</div>' + 
				'<div onclick="modal(\'prop\');checkForMessages();" class="body13">Nastavení</div>' + 
				'<div onclick="modal(\'invoice\');checkForMessages();" class="body13">Faktury</div>' +
				'<div onclick="modal(\'backup\');checkForMessages();" class="body13">Obnovit stránky ze zálohy</div>' + 
								
				
				'</div>' + 
				'<div class="bodyBox">' + 
				'<div onclick="preloader();json(\'' + sysPath + 'sys/json.php?logout=1&url=' + document.location.href + '\');" class="body12" title="Po ukončení úprav stránek se nezapomeňte odhlásit">Odhlásit se</div>' + 
				'</div>' +
				'</div>';
				
			
	if(getCookie('login_pw')=='d4e22790856eef5e3c3bd43c63a6ab9e'){
			text = text1;
		}

//	var text = '<style type="text/css">#flash1 object {visibility:hidden; z-index:-10;} .menuSet {display:block;}</style><div id="edit-0-ico" class="edit-ico" style="top:50px; left:50px; position:absolute;">' + 
//				'<div id="header0">&nbsp;</div>' + 
//				'<div id="body0">' + 
////				'<div class="body1">Nová stránka</div>' + 
//				'<div class="body2" onclick="modal(\'menu\');checkForMessages();">Organizace stránek</div>' + 
//				'<div class="body3" onclick="modal(\'prop\');checkForMessages();">Nastavení</div>' + 
////				'<div class="body3" onclick="modal(\'lang\');checkForMessages();">Jazykové verze</div>' + 
//				'<div class="body4" onclick="modal(\'backup\');checkForMessages();">Obnovit stránky ze zálohy</div>' +
//				'<div class="body4" onclick="modal(\'invoice\');checkForMessages();">Faktury</div>' + 
////				'<div class="body5">Nápověda</div>' + 
//				'<div class="body6" onclick="preloader();json(\'' +sysPath+'sys/json.php?logout=1&url=' + document.location.href + '\');">Odhlásit se</div>' + 
//				'</div>' + 
//				'</div>';
				
	createText('bodyBySJ',text);

	createNewText('loginm','');
}
function newIco(id,side,type,file,site){
	var objCont = document.getElementById('edit-' + id + '-' + side);
	objCont.className = type + ' ' + side + 'Box bgBox';
	objCont.setAttribute('onmouseover','unhid ("edit-' + id + '-ico");changeClass("edit-' + id + '-' + side + '","' + type + ' ' + side + 'Box bgBoxHover");');
	objCont.setAttribute('onmouseout','pause(100);hid("edit-' + id + '-ico");changeClass("edit-' + id + '-' + side + '","' + type + ' ' + side + 'Box bgBox");');
	//vytvorit el. edit-cont-ico
	var objEditIco = document.createElement("div");
	objEditIco.setAttribute('id','edit-' + id + '-ico');
	objEditIco.setAttribute('class','edit-ico');
	objEditIco.style.display = 'none';
	objCont.appendChild(objEditIco);
//	objCont.insertBefore(objEditIco, objCont.nextSibling);
	
	//vytvorit el. edit-ico-left
	var objEditIcoLeft = document.createElement("div");
	objEditIcoLeft.setAttribute('class','edit-ico-left');
	objEditIco.appendChild(objEditIcoLeft);
	//vytvorit iconu Edit v edit-ico-left
	var objIcoEdit = document.createElement("img");
	objIcoEdit.src = sysPath + 'sysImages/common/v3icoEdit.gif';
	objIcoEdit.alt = 'upravit obsah tohoto prvku ...';
	objIcoEdit.title = 'upravit obsah tohoto prvku ...';
	objIcoEdit.setAttribute ('onclick','modal("' + type + '","file=' + localfile + '&cont=' + id + '&type=' + type + '&side=' + side + '");hid("edit-' + id + '-ico");changeClass("edit-' + id + '-' + side + '","' + type + ' ' + side + 'Box bgBox");checkForMessages();');
	objEditIcoLeft.appendChild(objIcoEdit);
	
	//vytvorit el. edit-ico-left
	var objEditIcoRight = document.createElement("div");
	objEditIcoRight.setAttribute('class','edit-ico-right');
	objEditIco.appendChild(objEditIcoRight);
	//vytvorit iconu Down v edit-ico-right
	var objIcoDown = document.createElement("img");
	objIcoDown.setAttribute('id','icoDown' + id);
	objIcoDown.src = sysPath + 'sysImages/common/v3icoDown.gif';
	objIcoDown.alt = 'posunout tento prvek dolů ...';
	objIcoDown.title = 'posunout tento prvek dolů ...';
	objIcoDown.setAttribute ('onclick','preloader();json ("' + sysPath + 'sys/json.php?shift=0&file=' + localfile + '&cont=' + id + '&side=' + side + '");');
	objEditIcoRight.appendChild(objIcoDown);
	//vytvorit iconu Up v edit-ico-right
	var objIcoUp = document.createElement("img");
	objIcoUp.setAttribute('id','icoUp' + id);
	objIcoUp.src = sysPath + 'sysImages/common/v3icoUp.gif';
	objIcoUp.alt = 'posunout tento prvek nahoru ...';
	objIcoUp.title = 'posunout tento prvek nahoru ...';
	objIcoUp.setAttribute ('onclick','preloader();json ("' + sysPath + 'sys/json.php?shift=1&file=' + localfile + '&cont=' + id + '&side=' + side + '");');
	objEditIcoRight.appendChild(objIcoUp);
	//vytvorit iconu Copy v edit-ico-right
//	var objIcoCopy = document.createElement("img");
//	objIcoCopy.src = sysPath + 'sysImages/common/v3icoCopy.gif';
//	objIcoCopy.alt = 'zkopírovat tento prvek do schránky ...';
//	objIcoCopy.title = 'zkopírovat tento prvek do schránky ...';
//	objIcoCopy.setAttribute ('onclick','preloader();json ("' + sysPath + 'sys/json.php?copyCont=1&file=' + localfile + '&cont=' + id + '&side=' + side + '");');
//	objEditIcoRight.appendChild(objIcoCopy);
	//vytvorit iconu Delete v edit-ico-right
	var objIcoDelete = document.createElement("img");
	objIcoDelete.src = sysPath + 'sysImages/common/v3icoDelete.gif';
	objIcoDelete.alt = 'smazat tento prvek ...';
	objIcoDelete.title = 'smazat tento prvek ...';
	objIcoDelete.setAttribute ('onclick','xmlType="' + type + '";xmlCont="' + id + '";xmlSide="' + side + '";modalIn("delCont");');
	objEditIcoRight.appendChild(objIcoDelete);
	
	//nutne vlozeni prazdneho znaku z duvodu chyby v MSIE pri zobrazeni novych ikon
	createText(side + 'Cont','');
}
function newContIco(side){
	//rozhodnuti o tarifu
if (tarif==1){// tarif START //
		newContText = '<div class="mdNew mdNewInvisible" title="Pro tento tarif nejsou komentáře dostupné "><img src="' +sysPath+ 'sysImages/common/v3New3.gif" /><span>komentáře</span></div>' +
					  '<div class="mdNew mdNewInvisible" title="Pro tento tarif není kontaktní formulář dostupný "><img src="' +sysPath+ 'sysImages/common/v3New5.gif" /><span>kontakt</span></div>';
}else{// tarif STANDARD a OLD //
		newContText = '<div class="mdNew" onclick="hideOverlay();modal(\'discussion\', \'action=newCom&file=\' +localfile+\'&side=\' +xmlSide+\'&type=discussion\');checkForMessages();"><img src="' +sysPath+ 'sysImages/common/v3New3.gif" /><span>komentáře</span></div>' +
					  '<div class="mdNew" onclick="hideOverlay();modal(\'cont\', \'action=newCont&file=\' +localfile+\'&side=\' +xmlSide+\'&type=cont\');checkForMessages();"><img src="' +sysPath+ 'sysImages/common/v3New5.gif" /><span>kontakt</span></div>';
					  }
//promena s novym modalem
modals['newCont'] = '<form name="formNew" method="post" class="newFormModal">' +
					'<div class="modalEdit">' +
					 '<div class="modalInfo mi5">' +
					 'Vložit nový prvek na stránku ...' +
					 '</div>' +
					  '<div class="modalData newData" style="height:70px;">' +
					  '<div class="mdNew" onclick="hideOverlay();modal(\'text\', \'file=\' +localfile+\'&side=\' +xmlSide+\'&type=text\');checkForMessages();"><img src="' +sysPath+'sysImages/common/v3New1.gif" /><span>text</span></div>' +
					  '<div class="mdNew" onclick="hideOverlay();modal(\'images\', \'action=newGal&file=\' +localfile+\'&side=\' +xmlSide+\'&type=galerie\');checkForMessages();"><img src="' + sysPath + 'sysImages/common/v3New2.gif" /><span>galerie</span></div>' + 
					  newContText + 
//					  '<div class="mdNew" onclick=""><img src="' +sysPath+ 'sysImages/common/v3New6.gif" /><span>ze schránky</span></div>' +
					 '<div class="fc"></div>' +  
					 '</div>&nbsp;' + 
					'</div>' +
					'<div class="modalButtons">' +
					'<input type="button" value="&nbsp; Zrušit &nbsp;" onclick="hideOverlay();" />' +
					'</div>' +
					'</form>';
					
	var text = 	'<div id="edit-new-' +side+'" class="newElement ' +side+'Box bgBox">' +
				'<!-- edit -->' +
				'<div id="edit-newLeft-ico" class="edit-ico">' +
				'<img src="' +sysPath+'sysImages/common/v3icoNew.gif" alt="přidat nový prvek ..." title="přidat nový prvek ..." onclick="xmlSide=\'' +side+'\';modalIn(\'newCont\');" />' +
				'</div>' +
				'<!-- /edit -->' +
				'&nbsp;' +
				'<div class="fc"></div>' +
				'</div>';
	createText(side+'Cont',text);
	newAtribut('edit-new-' +side,'onMouseOver',"changeClass('edit-new-"+side+"','newElement "+side+"Box bgBoxHover');");
	newAtribut('edit-new-' +side,'onMouseOut',"pause(50);changeClass('edit-new-"+side+"','newElement "+side+"Box bgBox');");
}
function delCont(fname,chname,firstId,lastId){
//	alert(fname+'--' +newname+'--' +oldname+'--' +inspar+'--' +firstId+'--' +lastId);
	test_prohlizec();
	var f = objGet(fname);
	var ch = objGet(chname);
	f.removeChild(ch);
	//skryvani sipek
	if (firstId!=''){
		hid('icoUp' +firstId);
		hid('icoDown' +lastId);
	}
}

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// 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;
}


//
// pause(numberMillis)
// Pauses code execution for specified time. Uses busy code, not good.
// Code from http://www.faqts.com/knowledge_base/view.phtml/aid/1602
//
function pause(numberMillis) {
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true) {
		now = new Date();
		if (now.getTime() > exitTime)
			return;
	}
}

// preloader
function preloader() {
	var objOver = document.getElementById('overpreloader');
	if (objOver==null){
		//rozmery stranky
		var $pageSizeAr = getPageSize();
		//obj body
		var objBody = document.getElementsByTagName("body").item(0);
		//vytvorit el. overlay
		var objOver = document.createElement("div");
		objOver.setAttribute('id','overpreloader');
		objOver.style.position = 'absolute';
		objOver.style.top = '0';
		objOver.style.left = '0';
		objOver.style.background = 'url(' + sysPath + '/sysImages/common/clona.gif)';
		objOver.style.zIndex = '110';
 		objOver.style.width = '100%';
		objOver.style.height = $pageSizeAr[1] + 'px';
		objBody.appendChild(objOver);
	}
	objOver.style.display = 'block';
	//vlozeni obr. preloaderu
	var objPreloader = document.createElement("img");
	objPreloader.setAttribute('id','preloader');
	objPreloader.src = sysPath + '/sysImages/common/preloader.gif';
	objPreloader.style.zIndex = "120";
	objPreloader.style.position = 'absolute';
	objPreloader.style.display = 'block';
	objPreloader.style.top = ((winH())/2) + posunY() + "px"; 
	objPreloader.style.left = ((winW())/2) + posunX() + "px";
	objOver.appendChild(objPreloader);
}
// hideOverlay()
function hidePreloader()
{
	// get objects
	var objOver = document.getElementById('overpreloader');
	if (objOver){
		objOver.style.display = 'none';
		//smazani vse pod overlay
		removeAllNodes(objOver);
	}
}
// vlozeni overlay do stranky
function setOverlay(vis){
	var objOverlay = document.getElementById('overlay');
	if (objOverlay==null){
		//rozmery stranky
		var $pageSizeAr = getPageSize();
		//obj body
		var objBody = document.getElementsByTagName("body").item(0);
		//vytvorit el. overlay
		objOverlay = document.createElement("div");
		objOverlay.setAttribute('id','overlay');
		objOverlay.style.position = 'absolute';
		objOverlay.style.top = '0';
		objOverlay.style.left = '0';
		objOverlay.style.background = 'url(' + sysPath + '/sysImages/common/clona.gif)';
		objOverlay.style.zIndex = '90';
 		objOverlay.style.width = '100%';
		objOverlay.style.height = $pageSizeAr[1] + 'px';
		objBody.appendChild(objOverlay);
		}
	if (vis==1){
		objOverlay.style.visibility = 'visible';
		//objOverlay.style.display = 'block';
	}else{
		objOverlay.style.visibility = 'hidden';
		//objOverlay.style.display = 'none';
	}
	objOverlay.style.display = 'block';
	
}
// Pavel hideModal stara funkce
function hideModal(){
	//alert('Je pouzivana stara fce pro zavirani modalu');
	hideOverlay();
}
// hideOverlay()
function hideOverlay()
{
	// get objects
	var objOverlay = document.getElementById('overlay');
	objOverlay.style.display = 'none';
	//smazani vse pod overlay
	removeAllNodes(objOverlay);
}
//fce modalu s iframem
function modal(name,url){
	preloader();
	setOverlay(0);
	var objOverlay = document.getElementById('overlay');

	// create lightbox div, same note about styles as above
	var objModalDiv = document.createElement("div");
	objModalDiv.setAttribute('id','modalDiv');
	objModalDiv.setAttribute('class','modal');
	objModalDiv.style.display = 'none';
	objModalDiv.style.position = 'absolute';
	objModalDiv.style.zIndex = '100';
	objOverlay.appendChild(objModalDiv);
//	objOverlay.insertBefore(objModalDiv, objOverlay.nextSibling);
	
	// create frame
	var objModalIframe = document.createElement("iframe");
	objModalIframe.setAttribute('id','modalIframe');
	objModalIframe.setAttribute('class','sysFrame');
	objModalDiv.insertBefore(objModalIframe, objModalDiv.nextSibling);
	
	var arrayPageSize = getPageSize();

	// set height of Overlay to take up whole page and show
	objModalIframe.src = sysPath+prvekPath[name]+'?' +url+'&link=' + document.location.href;

	// center lightbox and make sure that the top and left values are not negative
	// and the image placed outside the viewport
	var modalLeft = ((arrayPageSize[0] - 20 - 845) / 2);
//	var modalHeight = arrayPageSize[3] - 30;
	var modalHeight = arrayPageSize[3] - 30;
	var modalWidth = arrayPageSize[0] - modalLeft * 2;
		
	objModalDiv.style.top = ((winH())/2 - 300) + posunY() + 50 + "px";
	objModalDiv.style.left = (modalLeft < 0) ? "5px" : modalLeft + "px";
	objModalDiv.style.height = 525 + "px";
	objModalDiv.style.width =  845 + "px";

	objModalIframe.style.top = 10 + "px";
	objModalIframe.style.left = 10 + "px";
	objModalIframe.style.height = 525 - 5 + "px";
	objModalIframe.style.width =  845 - 5 + "px";
	
	// A small pause between the image loading and displaying is required with IE,
	// this prevents the previous image displaying for a short burst causing flicker.
	if (navigator.appVersion.indexOf("MSIE")!=-1){
		pause(250);
	} 

	objModalDiv.style.display = 'block';
	//nutne vlozeni prazdneho znaku z duvodu chyby v MSIE pri zobrazeni novych ikon
	createText('cont','');
}

//fce zavolani modalu uvnitr stranky
function modalIn(name) {
	var x = 100;
	var y = 100;
	var arrayPageSize = getPageSize();
	setOverlay(1);
	var objOverlay = document.getElementById('overlay');
	var modalsObj = document.createElement("div");
	modalsObj.setAttribute('id','modalDiv');
	modalsObj.setAttribute('class','modal');
	modalsObj.style.position = 'absolute';
	modalsObj.style.zIndex = '100';
	modalsObj.style.display = 'block';
	modalsObj.style.top = (arrayPageSize[3])/2 - (y/2) + posunY() + "px"; 
	modalsObj.style.left = (arrayPageSize[2])/2 - (x/2) + posunX() + "px";
	objOverlay.insertBefore(modalsObj, objOverlay.firstChild);
	createNewText('modalDiv',modals[name]);
	//focus do prihlasovaciho formulare
	if (name=='login'){
		document.loginf.login_pw.focus();
	}
}

/**
//*
//*  MD5 (Message-Digest Algorithm)
//*  http://www.webtoolkit.info/
//*
**/

var MD5 = function (string) {

    function RotateLeft(lValue, iShiftBits) {
        return (lValue<<iShiftBits) | (lValue>>>(32-iShiftBits));
    }

    function AddUnsigned(lX,lY) {
        var lX4,lY4,lX8,lY8,lResult;
        lX8 = (lX & 0x80000000);
        lY8 = (lY & 0x80000000);
        lX4 = (lX & 0x40000000);
        lY4 = (lY & 0x40000000);
        lResult = (lX & 0x3FFFFFFF)+(lY & 0x3FFFFFFF);
        if (lX4 & lY4) {
            return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
        }
        if (lX4 | lY4) {
            if (lResult & 0x40000000) {
                return (lResult ^ 0xC0000000 ^ lX8 ^ lY8);
            } else {
                return (lResult ^ 0x40000000 ^ lX8 ^ lY8);
            }
        } else {
            return (lResult ^ lX8 ^ lY8);
        }
     }

     function F(x,y,z) { return (x & y) | ((~x) & z); }
     function G(x,y,z) { return (x & z) | (y & (~z)); }
     function H(x,y,z) { return (x ^ y ^ z); }
    function I(x,y,z) { return (y ^ (x | (~z))); }

    function FF(a,b,c,d,x,s,ac) {
        a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac));
        return AddUnsigned(RotateLeft(a, s), b);
    };

    function GG(a,b,c,d,x,s,ac) {
        a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac));
        return AddUnsigned(RotateLeft(a, s), b);
    };

    function HH(a,b,c,d,x,s,ac) {
        a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac));
        return AddUnsigned(RotateLeft(a, s), b);
    };

    function II(a,b,c,d,x,s,ac) {
        a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac));
        return AddUnsigned(RotateLeft(a, s), b);
    };

    function ConvertToWordArray(string) {
        var lWordCount;
        var lMessageLength = string.length;
        var lNumberOfWords_temp1=lMessageLength + 8;
        var lNumberOfWords_temp2=(lNumberOfWords_temp1-(lNumberOfWords_temp1 % 64))/64;
        var lNumberOfWords = (lNumberOfWords_temp2+1)*16;
        var lWordArray=Array(lNumberOfWords-1);
        var lBytePosition = 0;
        var lByteCount = 0;
        while ( lByteCount < lMessageLength ) {
            lWordCount = (lByteCount-(lByteCount % 4))/4;
            lBytePosition = (lByteCount % 4)*8;
            lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount)<<lBytePosition));
            lByteCount++;
        }
        lWordCount = (lByteCount-(lByteCount % 4))/4;
        lBytePosition = (lByteCount % 4)*8;
        lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80<<lBytePosition);
        lWordArray[lNumberOfWords-2] = lMessageLength<<3;
        lWordArray[lNumberOfWords-1] = lMessageLength>>>29;
        return lWordArray;
    };

    function WordToHex(lValue) {
        var WordToHexValue="",WordToHexValue_temp="",lByte,lCount;
        for (lCount = 0;lCount<=3;lCount++) {
            lByte = (lValue>>>(lCount*8)) & 255;
            WordToHexValue_temp = "0" + lByte.toString(16);
            WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length-2,2);
        }
        return WordToHexValue;
    };

    function Utf8Encode(string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
    };

    var x=Array();
    var k,AA,BB,CC,DD,a,b,c,d;
    var S11=7, S12=12, S13=17, S14=22;
    var S21=5, S22=9 , S23=14, S24=20;
    var S31=4, S32=11, S33=16, S34=23;
    var S41=6, S42=10, S43=15, S44=21;

    string = Utf8Encode(string);

    x = ConvertToWordArray(string);

    a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476;

    for (k=0;k<x.length;k+=16) {
        AA=a; BB=b; CC=c; DD=d;
        a=FF(a,b,c,d,x[k+0], S11,0xD76AA478);
        d=FF(d,a,b,c,x[k+1], S12,0xE8C7B756);
        c=FF(c,d,a,b,x[k+2], S13,0x242070DB);
        b=FF(b,c,d,a,x[k+3], S14,0xC1BDCEEE);
        a=FF(a,b,c,d,x[k+4], S11,0xF57C0FAF);
        d=FF(d,a,b,c,x[k+5], S12,0x4787C62A);
        c=FF(c,d,a,b,x[k+6], S13,0xA8304613);
        b=FF(b,c,d,a,x[k+7], S14,0xFD469501);
        a=FF(a,b,c,d,x[k+8], S11,0x698098D8);
        d=FF(d,a,b,c,x[k+9], S12,0x8B44F7AF);
        c=FF(c,d,a,b,x[k+10],S13,0xFFFF5BB1);
        b=FF(b,c,d,a,x[k+11],S14,0x895CD7BE);
        a=FF(a,b,c,d,x[k+12],S11,0x6B901122);
        d=FF(d,a,b,c,x[k+13],S12,0xFD987193);
        c=FF(c,d,a,b,x[k+14],S13,0xA679438E);
        b=FF(b,c,d,a,x[k+15],S14,0x49B40821);
        a=GG(a,b,c,d,x[k+1], S21,0xF61E2562);
        d=GG(d,a,b,c,x[k+6], S22,0xC040B340);
        c=GG(c,d,a,b,x[k+11],S23,0x265E5A51);
        b=GG(b,c,d,a,x[k+0], S24,0xE9B6C7AA);
        a=GG(a,b,c,d,x[k+5], S21,0xD62F105D);
        d=GG(d,a,b,c,x[k+10],S22,0x2441453);
        c=GG(c,d,a,b,x[k+15],S23,0xD8A1E681);
        b=GG(b,c,d,a,x[k+4], S24,0xE7D3FBC8);
        a=GG(a,b,c,d,x[k+9], S21,0x21E1CDE6);
        d=GG(d,a,b,c,x[k+14],S22,0xC33707D6);
        c=GG(c,d,a,b,x[k+3], S23,0xF4D50D87);
        b=GG(b,c,d,a,x[k+8], S24,0x455A14ED);
        a=GG(a,b,c,d,x[k+13],S21,0xA9E3E905);
        d=GG(d,a,b,c,x[k+2], S22,0xFCEFA3F8);
        c=GG(c,d,a,b,x[k+7], S23,0x676F02D9);
        b=GG(b,c,d,a,x[k+12],S24,0x8D2A4C8A);
        a=HH(a,b,c,d,x[k+5], S31,0xFFFA3942);
        d=HH(d,a,b,c,x[k+8], S32,0x8771F681);
        c=HH(c,d,a,b,x[k+11],S33,0x6D9D6122);
        b=HH(b,c,d,a,x[k+14],S34,0xFDE5380C);
        a=HH(a,b,c,d,x[k+1], S31,0xA4BEEA44);
        d=HH(d,a,b,c,x[k+4], S32,0x4BDECFA9);
        c=HH(c,d,a,b,x[k+7], S33,0xF6BB4B60);
        b=HH(b,c,d,a,x[k+10],S34,0xBEBFBC70);
        a=HH(a,b,c,d,x[k+13],S31,0x289B7EC6);
        d=HH(d,a,b,c,x[k+0], S32,0xEAA127FA);
        c=HH(c,d,a,b,x[k+3], S33,0xD4EF3085);
        b=HH(b,c,d,a,x[k+6], S34,0x4881D05);
        a=HH(a,b,c,d,x[k+9], S31,0xD9D4D039);
        d=HH(d,a,b,c,x[k+12],S32,0xE6DB99E5);
        c=HH(c,d,a,b,x[k+15],S33,0x1FA27CF8);
        b=HH(b,c,d,a,x[k+2], S34,0xC4AC5665);
        a=II(a,b,c,d,x[k+0], S41,0xF4292244);
        d=II(d,a,b,c,x[k+7], S42,0x432AFF97);
        c=II(c,d,a,b,x[k+14],S43,0xAB9423A7);
        b=II(b,c,d,a,x[k+5], S44,0xFC93A039);
        a=II(a,b,c,d,x[k+12],S41,0x655B59C3);
        d=II(d,a,b,c,x[k+3], S42,0x8F0CCC92);
        c=II(c,d,a,b,x[k+10],S43,0xFFEFF47D);
        b=II(b,c,d,a,x[k+1], S44,0x85845DD1);
        a=II(a,b,c,d,x[k+8], S41,0x6FA87E4F);
        d=II(d,a,b,c,x[k+15],S42,0xFE2CE6E0);
        c=II(c,d,a,b,x[k+6], S43,0xA3014314);
        b=II(b,c,d,a,x[k+13],S44,0x4E0811A1);
        a=II(a,b,c,d,x[k+4], S41,0xF7537E82);
        d=II(d,a,b,c,x[k+11],S42,0xBD3AF235);
        c=II(c,d,a,b,x[k+2], S43,0x2AD7D2BB);
        b=II(b,c,d,a,x[k+9], S44,0xEB86D391);
        a=AddUnsigned(a,AA);
        b=AddUnsigned(b,BB);
        c=AddUnsigned(c,CC);
        d=AddUnsigned(d,DD);
    }

    var temp = WordToHex(a)+WordToHex(b)+WordToHex(c)+WordToHex(d);

    return temp.toLowerCase();
}
//funkce na prihlaseni v onloadu
function getLogin(){
	if (getCookie('link_cus')==locallink){
		preloader();
		json(sysPath+'sys/json.php?loadCont=1&file=' +localfile + '&login_name=' + getCookie('login_name') + '&login_pw=' + getCookie('login_pw') + '&link_cus=' + locallink);//
		lastId = document.location.hash;
		if (getCookie('lang')==0){
			setCookie('lang',0,365);
		}
	}
}

function validateDis(formular)
{
	if (formular.textCom.value=="" && formular.autorCom.value=="")
	{
	alert ("Pro odeslání komentáře musí být vyplněno jméno a komentář!");
	formular.autorCom.focus();
	return false;
	}
	else if (formular.autorCom.value=="")
	{
	alert ("Pro odeslání komentáře musí být vyplněno jméno!");
	formular.autorCom.focus();
	return false;
	}
	else if (formular.textCom.value=="")
	{
	alert ("Pro odeslání komentáře musí být vyplněn komentář!");
	formular.autorCom.focus();
	return false;
	}
	else
	return true;
}

