 
// Žádná část tohoto souboru nesmí býti použita bez výslovného svolení autora.
// 
// Licenční smlouva: Koupí softwarového produktu (dále jen "sw produkt"), jehož neoddělitelnou částí 
// je i tento soubor získává zákazník právo využívat tento sw produkt k jeho zamýšleným 
// účelům. Jakékoliv změny sw produktu nebo jeho zdrojového kódu jsou porušením této smlouvy.
//
// Odpovědnost: Autor nenese žádnou právní odpovědnost za žádné škody vzniklé používáním sw produktu
// a to do jakékoliv rozsahu.
//
// Záruka: Autor poskytuje záruku na funkčnost sw produktu dle platných zákonných norem a lhůt, 
// zejména dle Zákona na ochranu spotřebitele. Pro zákazníky s IČ platí záruční doba 90 dnů.
// 
// Copyright notice: No parts of this file can be used without explicit permission of the author.
// Licence agreement: By buying this software the customer is allowed to use this software
// for its intended purposes. The author is not liable to any possible extends for
// any risks or damages resulting from using this software. 
// Warranty notice: The author does provide limited warranty under valid law period on 
// hidden flaws and flaws directing against inteded purpose of this software.
//
// Webová prezentace www.citybikes.cz, verze 3
// Copyright © 2005-2011 Jakub Široký
// Please, do not hesitate to contact me on jakub@stoneware.cz
//var elh = elHtml();

var ie6=false;
var ie67=false;
var ie78=false;
var ie678=false;
var iex=false;
var ie9=false;

var ie6tweaks=0;

var reqObj = new Array();

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); }

Object.prototype.size = function () {
	  var len = this.length ? --this.length : -1;
	  for (var k in this)
		 len++;
	  return len;
	}

function genericElementMethods() {
	this.ac=ac;	// appendChild
	this.st=st; // styling
	this.cl=cl; // clone
	this.listenTo = listenTo;
	this.repl = repl; // replaceChild
	this.rc = rc;  // removeChild
	this.getProp = getProp;
	this.close = close; // removeMyself
	this.ib = ib; // insertBefore
	this.ia = ia; // insertAfter
	this.rns = rns; // removeNextSibling
}

function close() {
	if (this.parentNode)
		this.parentNode.removeChild(this);
}

function gId(id) {
	var o = document.getElementById(id);
	if (o) {
		genericElementMethods.apply(o);
		return o; 
	}
}

function getId(id) {
	var o = document.getElementById(id);
	if (o) {
		return o; 
	}
}

function gTn(tn) {
	return document.getElementsByTagName(tn);
	}

function el(name) { //element
	elem=document.createElement(name);
	//alert(name);
	if (arguments[1]!=null)
		for (j in arguments[1])
			if (j=='clas')
				elem.setAttribute('class',arguments[1][j]);
			else
				elem.setAttribute(j,arguments[1][j]);
	genericElementMethods.apply(elem);
	if (arguments.length==3) 
		if (typeof(arguments[2])=='object')
			elem.ac(arguments[2]);
		else
			if (typeof(arguments[2])=='number' || typeof(arguments[2])=='string')
				elem.ac(tn(arguments[2]));
	return elem;
}

function printPreview() {
	if (document.body.insertAdjacentHTML) {
		var OLECMDID = 7;
		/* OLECMDID values:
		* 6 - print
		* 7 - print preview
		* 1 - open window
		* 4 - Save As
		*/
		var PROMPT = 1; // 2 DONTPROMPTUSER
		var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
		document.body.innerHTML+=WebBrowser; 
		WebBrowser1.ExecWB(OLECMDID, PROMPT);
		WebBrowser1.outerHTML = "";
	} else
		window.print();
}


function elm(name) { //element
	elem=document.createElement(name);
	//alert(name);
	if (arguments[1]!=null && arguments[1]!='')
		for (j in arguments[1])
			if (j=='clas') {
//				if (ie())
				//alert(arguments[1][j]);
					elem.className=arguments[1][j];
// 				else
				 //elem.setAttribute('class',arguments[1][j]);
			//else if (j=='style') {
				//var xx; //elem.style.cssText=arguments[1][j];
				//elem.style.cssText=arguments[1][j];
				//}
			}
			else
				elem.setAttribute(j,arguments[1][j]);
	genericElementMethods.apply(elem);
	if (arguments.length>2)
		for (i=2;i<arguments.length;i++)
			if (typeof(arguments[i])=='object')
				elem.ac(arguments[i]);
			else
				if (typeof(arguments[i])=='number' || typeof(arguments[i])=='string')
					elem.ac(tn(arguments[i]));
	return elem;
}

function waitCursor() {
	if (!ie)
		gTn('body').item(0).style.cursor="wait";
}

function autoCursor() {
	if (!ie)
		gTn('body').item(0).style.cursor="auto";
}

function getTransFragment(xml,xsl) {
	var data=jXquery("fetchroot="+xml);
	//alert(data);
	var stylesheet=jXquery("fetchroot="+xsl);
	if (document.implementation.createDocument) {
		var xslp= new XSLTProcessor();
		if (arguments.length>2)
			for (i=2;i<arguments.length;i++) {
				if (arguments[i]!=null) {
					parts=arguments[i].split("=");
					//alert(parts[0]+" "+parts[1]);
					xslp.setParameter('',parts[0],parts[1]);
				}
			}
		//alert("stylesheet: "+stylesheet);
		xslp.importStylesheet(stylesheet);
		fragment = xslp.transformToFragment(data, document);
	} else if (window.ActiveXObject) {
		try {
			var doc = new ActiveXObject("MSXML2.FreeThreadedDOMDocument");
			var sheet = new ActiveXObject("MSXML2.FreeThreadedDOMDocument");
			var temp = new ActiveXObject("MSXML2.XSLTemplate");
			doc.async=false;
			sheet.async=false;

			doc.loadXML(data.xml);
			if (doc.parseError.errorCode != 0) {
				var myerr = doc.parseError;
				alert("Doc chyba: "+myerr.reason);
			}
			sheet.loadXML(stylesheet.xml);
			if (sheet.parseError.errorCode != 0) {
				var myerr = doc.parseError;
				alert("Sheet chyba: "+myerr.reason);
			}
			temp.stylesheet=sheet;
			var proc = temp.createProcessor();
			proc.input = doc;
			if (arguments.length>2)
				for (i=2;i<arguments.length;i++)
					if (arguments[i]!=null) {
						parts=arguments[i].split("=");
						proc.addParameter(parts[0],parts[1]);
					}
			proc.transform();
			var c = elm("div");
			c.innerHTML=proc.output;
			fragment= c.firstChild;
		} catch (e) {
			alert(e.description);
			return null;
		}
	}
	return fragment;
}

function ie() {
	if (window.ActiveXObject)
		return true;
	else
		return false;
}

function ie6() {
	if (ie()) {
		var words = navigator.appVersion.split(";");
		var i;
		for (i = 0;i<words.length;i++) {
			//alert(words[i]);
			if (words[i].indexOf("MSIE")!=-1) {
			//if (words[i].substr(0,4)=="MSIE") {
				var parts = words[i].trim().split(" ");
				if (parts[1]=="6.0")
					return true;
			}
		}
	}
	return false;
}

function iev() {
	if (!window.ActiveXObject)
		return "";
	var words = navigator.appVersion.split(";");
	var i;
	for (i = 0;i<words.length;i++) {
		//alert(words[i]);
		if (words[i].indexOf("MSIE")!=-1) {
			iex=true;
		//if (words[i].substr(0,4)=="MSIE") {
			var parts = words[i].trim().split(" ");
			if (parts[1].charAt(0)=="6" || parts[1].charAt(0)=="7" || parts[1].charAt(0)=="8" )
				ie678=true;
			if (parts[1].charAt(0)=="7" || parts[1].charAt(0)=="6" )
				ie67=true;
			if (parts[1].charAt(0)=="7" || parts[1].charAt(0)=="8" )
				ie78=true;
			if (parts[1].charAt(0)=="6")
				ie6=true;
			if (parts[1].charAt(0)=="9")
				ie9=true;
			var subparts = parts[1].split(".");
				return "ie"+subparts[0];
		}
	}

	
}


function gecko() {
	if (navigator.userAgent.indexOf("Gecko")!=-1)
		return true;
	else
		return false;
}

function ieTransform(xml,xsl) {
	if (document.implementation.createDocument) return null;
}

function eSrc(e) {
	if (window.event)
		return window.event.srcElement;
	else if (e.originalTarget) 
		return e.originalTarget;
}

function transXML(xml,xsl) {
	//alert(data);
	//alert(xsl.xml);
	//alert(xml);
	//alert(xsl);
	if (window.ActiveXObject) {
		try {
			var doc=null;
			var sheet=null;
			var temp=null;
			doc = new ActiveXObject("MSXML2.FreeThreadedDOMDocument");
			sheet = new ActiveXObject("MSXML2.FreeThreadedDOMDocument");
			temp = new ActiveXObject("MSXML2.XSLTemplate");
			doc.async=false;
			sheet.async=false;
			if (typeof(xml)=="string")
				doc.loadXML(xml);
			else
				doc.loadXML(xml.xml);
			if (doc.parseError.errorCode != 0) {
				var myerr = doc.parseError;
				alert("Doc chyba: "+myerr.reason);
			}
			if (typeof(xsl)=="string")
				sheet.loadXML(xsl);
			else
				sheet.loadXML(xsl.xml);
			if (sheet.parseError.errorCode != 0) {
				var myerr = doc.parseError;
				alert("Sheet chyba: "+myerr.reason);
			}
			temp.stylesheet=sheet;
			var proc = temp.createProcessor();
			proc.input = doc;
			if (arguments.length>2)
				for (i=2;i<arguments.length;i++)
					if (arguments[i]!=null) {
						parts=arguments[i].split("=");
						proc.addParameter(parts[0],parts[1]);
					}
			//alert(xml.name);
			proc.transform(); // WHAT ABOUT CREATING DOCUMENT FRAGMENT
			var c = elm("div");
			//alert(proc.output);
			c.innerHTML=proc.output;
			fragment= c.firstChild; // SPATNE ZREJME
			//fragment=proc.output;
		} catch (e) {
			alert(e.description);
			return null;
		}
	} else if (document.implementation && document.implementation.createDocument) {
		var xslp= new XSLTProcessor();
		if (arguments.length>2)
			for (i=2;i<arguments.length;i++) {
				parts=arguments[i].split("=");
				//alert(parts[0]+" "+parts[1]);
				xslp.setParameter('',parts[0],parts[1]);
				//alert(arguments[i]);
			}
		if (typeof(xsl)=="string") {
			var parser = new DOMParser();
			xsl = parser.parseFromString(xsl,"text/xml");
		}
		if (typeof(xml)=="string") {
			if (!isSet(parser))
				var parser = new DOMParser();
			xml = parser.parseFromString(xml,"text/xml");
		}
		xslp.importStylesheet(xsl);
		fragment = xslp.transformToFragment(xml, document);
	} 
	return fragment;
}

function append(where,what) {
	where.appendChild(what);
}
function replace(where,what,bywhat) {
	if (what!=null) {
		//alert(typeof(where));
 		//alert(what.id);
		what.parentNode.replaceChild(bywhat,what);
		//where.replaceChild(bywhat,what);
		}
	else
		where.appendChild(bywhat);
}

function repl(bywhat,what) {
	try {
		this.replaceChild(bywhat,what);
	} catch(e) {
		alert(e.number+" "+e.description);
	}
}

function rc(what) {
	try {
		this.removeChild(what);
	} catch(e) {
		alert(e.number+" "+e.description);
	}
}

function rns() { //removeNextSibling
	if (this.nextSibling)
		try {
			this.parentNode.removeChild(this.nextSibling);
		} catch(e) {
			alert(e.number+" "+e.description);
		}
}

function fireMouseEventAt(tgt) {
	var o;
	if (typeof(tgt)=='string')
		o=gId(tgt);
	else
		o=tgt;
	if (ie()) {
		var eventObj = document.createEventObject();
		eventObj.button=1;
		o.fireEvent("onclick",eventObj);
	} else if (document.implementation.hasFeature("Events","2.0")) {
		var evt = document.createEvent("MouseEvents");
		evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); 
		o.dispatchEvent(evt);
  }
}

function enterShortCut(e,src,tgt) {
	var o;
	if (typeof(tgt)=='string')
		o=gId(tgt);
	else
		o=tgt;
	if (wasSameEnter(e,src))
		fireSingleMouseEventAt(tgt);
}

function fireSingleMouseEventAt(tgt) {
	var o;
	if (typeof(tgt)=='string')
		o=gId(tgt);
	else
		o=tgt;
	if (ie()) {
		var eventObj = document.createEventObject();
		eventObj.button=1;
		eventObj.bubbles=false;
		o.fireEvent("onclick",eventObj);
	} else if (document.implementation.hasFeature("Events","2.0")) {
		var evt = document.createEvent("MouseEvents");
		evt.initMouseEvent("click", false, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); 
		o.dispatchEvent(evt);
  }
}



function debug(obj) {
	var text;
	for (i in obj) {
		text+=i+'\t';
	}
	alert(text);
}

function debugVal(obj) {
	var text;
	for (i in obj) {
		text+=i+"\t"+obj[i]+"\n";
	}
	alert(text);
}

function debugValFname(obj) {
	var text;
	for (i in obj) {
		if (typeof(obj[i])!="function")
			text+=i+"\t"+obj[i]+"\n";
		else
			text+="funkce "+i+"\n";
	}
	alert(text);
}

function debugValNoF(obj) {
	var text;
	for (i in obj) {
		if (typeof(obj[i])!="function")
			text+=i+"\t"+obj[i]+"\n";
	}
	alert(text);
}

function printDebug(obj) {
	var text;
	for (i in obj) {
		text+=i+': '+obj[i]+'\t';
	}
	return(text);
}

function getProperties(obj) {
	var text='';
	for (i in obj) {
		text+=i+'\t';
	}
	return(text);
}

function getProp() {
	var text='';
	for (i in this) {
		text+=i+'\t';
	}
	return(text);
}


function nest(elem,content) {
	if (typeof(content)=="string"||typeof(content)=="number") {
		elem.appendChild(document.createTextNode(content));
	}
	return elem;
}

function ac() { // appendChild
	if (arguments[0])
		this.appendChild(arguments[0]);
}

function ib() { // insertBefore this node
	if (arguments[0])
		this.parentNode.insertBefore(arguments[0],this);
}

function ia() { // insertAfter this node
	if (arguments[0]) {
		if (this.nextSibling)
			this.parentNode.insertBefore(arguments[0],this.nextSibling);
		else
			this.parentNode.ac(arguments[0]);
	}
}

function listenTo(evt,func,bubb) {
 	if (typeof(nonexistentfc)=="string") {
 		alert('Please, supply function.')
 		return;
 	} else
 	func= eval(func);
	if (ie())
		this.attachEvent('on'+evt,func);
	else if (document.implementation.hasFeature("Events","2.0")) {
		this.addEventListener(evt,func,bubb);
	} else {
		this.setAttribute("on"+evt,func);
	}
}

function tn(content) { //textNode
	return document.createTextNode(content);
	}

function st() { //style
//	alert(arguments[0]);
	for(i=0;i<arguments.length;i++){
		for (j in arguments[i]) {
			if (typeof(arguments[i][j])!="function")
				eval("this.style."+j+"=\""+arguments[i][j]+"\"");
		}
	}
}

function cl() { //clone
	newobj=this.cloneNode(arguments[0]);
	genericElementMethods.apply(newobj);
	return newobj;
}

function exitHandler(e) {
	if (e.originalTarget.name=="exitNewLogin" || e.originalTarget.name=="exitDispatchBasketPreview") {
		//alert(e.originalTarget.name);
		//e.preventDefault();
		//e.stopPropagation();
		//alert(e.target);
		//alert(document.implementation.hasFeature("LS-Async","3.0"));
		if (this.nextSibling.nextSibling) this.parentNode.removeChild(this.nextSibling.nextSibling);
		if (this.nextSibling) this.parentNode.removeChild(this.nextSibling);
		this.parentNode.removeChild(this);
		//if (e.originalTarget.name=="exitDispatchBasketPreview") document.body.style.overflow='auto'
	}
}



function treatKeyboard(e) {
	if (e.which == 27) {
		this.parentNode.removeChild(this.nextSibling.nextSibling);
		this.parentNode.removeChild(this.nextSibling);
		this.parentNode.removeChild(this);
	}
}

function simpleExitHandler(e) {
	if (e.originalTarget.name=="exit") {
		//alert(e.originalTarget.name);
		//e.preventDefault();
		//e.stopPropagation();
		//alert(e.target);
		//alert(document.implementation.hasFeature("LS-Async","3.0"));
		//this.parentNode.removeChild(this.nextSibling.nextSibling);
		//this.parentNode.removeChild(this.nextSibling);
		this.parentNode.removeChild(this);
	}
}

function fireExit(e) {
	//ex=document.createEvent("MutationEvents");
	//ex.initMutationEvent("DOMNodeRemoved",false,false,div,null,null,null,3);
	//alert(e.bubbles);
	//debug(e);
}

function member(item,list) {
	//alert(item);
	for (j=0;j<list.length;j++)
		if (list[j]==item) return true;
	return false;
}

function getByName(_name,list) {
	//alert(item);
	for (j=0;j<list.length;j++)
		if (list[j].name==_name) return list[j];
	return null;
}

function docURI() {
	return document.documentURI.substring(0,document.documentURI.indexOf("?"))
}

function docRoot() {
	return "/";
	if (document.documentURI)
		return (document.documentURI.search(/\/citybikes/)!=-1) ? "/citybikes/" : "/";
	else
		return (document.URL.search(/\/citybikes/)!=-1) ? "/citybikes/" : "/";
	
}

function symRoot() {
	return docRoot();
}

function nap(m) { // in seconds
	var then = new Date(new Date().getTime() + m*1000); 
	while (new Date() < then) 
		{}
}

function box(evt) {
	div = elm("div",{style: "border:1px solid black;background-color:white;position:absolute;width:50px;height:50px;top:"+trueY(evt)+"px;left:"+trueX(evt)+"px"});
	document.body.appendChild(div);
}

function getXMLHttpObj(){
	if(typeof(XMLHttpRequest)!='undefined')
		return new XMLHttpRequest();

	var axO=['Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.4.0',
		'Msxml2.XMLHTTP.3.0', 'Msxml2.XMLHTTP', 'Microsoft.XMLHTTP'], i;
	for(i=0;i<axO.length;i++)
		try{
			return new ActiveXObject(axO[i]);
		}catch(e){}
	return null;
}

function env(e,variable,txt) {
	//alert(query);
	var oXML = getXMLHttpObj();
	oXML.open('GET', docRoot()+"include/jq.php?enva="+variable+"&envb="+txt, false);
	alert("calling: "+docRoot()+"include/jq.php?env="+txt);
	oXML.send('');
	if (oXML.status>199 && oXML.status<299) {
		alert(oXML.responseText);
		return oXML.responseText;
	}	else alert(oXML.status+": "+oXML.statusText);
}

function jquery(query) {
	waitOn();
	var oXML = getXMLHttpObj();
	oXML.open('GET', docRoot()+"include/jq.php?"+query, false);
	oXML.setRequestHeader("Pragma", "no-cache");
	oXML.setRequestHeader("Cache-control", "no-store,no-cache,must-revalidate,post-check=0,pre-check=0");
	oXML.send('');
	if (oXML.status>199 && oXML.status<299) {
//		alert(oXML.responseText);
		waitOff();
		//alert(oXML.responseText);
		return oXML.responseText;
	}	else {
		alert(oXML.status+": "+oXML.statusText);
		waitOff();
		return null;
	}
}

function j2query(evt,query) {
	addOn(evt);
	waitOn();
	var oXML = getXMLHttpObj();
	oXML.open('GET', docRoot()+"include/jq.php?"+query, false);
	oXML.setRequestHeader("Pragma", "no-cache");
	oXML.setRequestHeader("Cache-control", "no-store,no-cache,must-revalidate,post-check=0,pre-check=0");
	oXML.send('');
	if (oXML.status>199 && oXML.status<299) {
//		alert(oXML.responseText);
		waitOff();
		return oXML.responseText;
	}	else {
		alert(oXML.status+": "+oXML.statusText);
		waitOff();
		return null;
	}
}

function jAquery(query) {
	waitOn();
	var oXML = getXMLHttpObj();
	oXML.open('GET', docRoot()+"include/jq.php?action="+query, false);
	oXML.setRequestHeader("Pragma", "no-cache");
	oXML.setRequestHeader("Cache-control", "no-store,no-cache,must-revalidate,post-check=0,pre-check=0");
	oXML.send('');
	if (oXML.status>199 && oXML.status<300) {
//		alert(oXML.responseText);
		waitOff();
		return oXML.responseText;
	}	else {
		alert(oXML.status+": "+oXML.statusText);
		waitOff();
		return null;
	}
}

function asyncResult(http_request) {
	if (http_request.readyState == 4) {
		if (http_request.status >199 && http_request.status<300) {
				return; //alert(http_request.responseText);
		} else {
 			alert('Nastaly potíže během komunikace se serverem. Status:'+http_request.status);
		}
	}
}

function asyncFunc(http_request,replyFunc) {
	var xmlmode = arguments[2] ? arguments[2] : false;
	if (http_request.readyState == 4) {
		if (http_request.status >199 && http_request.status<300) {
			if(xmlmode)
				replyFunc(http_request.responseXML);
			else
				replyFunc(http_request.responseText);
		} else {
 			alert('Nastaly potíže během komunikace se serverem. Status:'+http_request.status);
		}
	}
}

function asyncFunc2(http_request,replyFunc,s) {
	if (http_request.readyState == 4) {
		if (http_request.status >199 && http_request.status<300) {
				replyFunc(s,http_request.responseText);
		}
	}
}

function jAsyncQuery(query) {
	var oXML = getXMLHttpObj();
	oXML.onreadystatechange = function() {asyncResult(oXML);};
	oXML.open('GET', docRoot()+"include/jq.php?"+query, true);
	oXML.setRequestHeader("Pragma", "no-cache");
	oXML.setRequestHeader("Cache-control", "no-store,no-cache,must-revalidate,post-check=0,pre-check=0");
	oXML.send(null);
}

function jAsyncReplyQuery(query,replyFunc) {
	var xmlmode = arguments[2] ? arguments[2] : false;
	var oXML = getXMLHttpObj();
	oXML.onreadystatechange = function() {asyncFunc(oXML,replyFunc, xmlmode);};
	oXML.open('GET', docRoot()+"include/jq.php?"+query, true);
	oXML.setRequestHeader("Pragma", "no-cache");
	oXML.setRequestHeader("Cache-control", "no-store,no-cache,must-revalidate,post-check=0,pre-check=0");
	oXML.send(null);
}

function jAsyncReplyQuery2(query,replyFunc,s) {
	var oXML = getXMLHttpObj();
	oXML.onreadystatechange = function() {asyncFunc2(oXML,replyFunc,s);};
	oXML.open('GET', docRoot()+"include/jq.php?"+query, true);
	oXML.setRequestHeader("Pragma", "no-cache");
	oXML.setRequestHeader("Cache-control", "no-store,no-cache,must-revalidate,post-check=0,pre-check=0");
	oXML.send(null);
	return (oXML);
}

function jGenAsyncReplyQuery(url,replyFunc) {
	var oXML = getXMLHttpObj();
	oXML.onreadystatechange = function() {asyncFunc(oXML,replyFunc);};
	oXML.open('GET', url, true);
	oXML.setRequestHeader("Pragma", "no-cache");
	oXML.setRequestHeader("Cache-control", "no-store,no-cache,must-revalidate,post-check=0,pre-check=0");
	oXML.send(null);
}



function postQuery(data) {
	waitOn();
	var oXML = getXMLHttpObj();
	for (i in arguments) {
		oXML.setParameter(arguments[i]);
	}
	oXML.open('POST', docRoot()+"include/jq.php", false);
	oXML.setRequestHeader('Content-Type',"application/x-www-form-urlencoded");
	oXML.setRequestHeader("Pragma", "no-cache");
	oXML.setRequestHeader("Cache-control", "no-store,no-cache,must-revalidate,post-check=0,pre-check=0");
	oXML.send(data);
	if (oXML.status>199 && oXML.status<299) {
//		alert(oXML.responseText);
		waitOff();
		return oXML.responseText;
	}	else {
		alert(oXML.status+": "+oXML.statusText);
		waitOff();
		return null;
	}
}


function jXquery(query) {
	waitOn();
	//alert(docRoot()+"include/jq.php?"+query);
	var oXML = getXMLHttpObj();
	oXML.open('GET', docRoot()+"include/jq.php?"+query, false);
	oXML.setRequestHeader("Pragma", "no-cache");
	oXML.setRequestHeader("Cache-control", "no-store,no-cache,must-revalidate,post-check=0,pre-check=0");
	oXML.send('');
	if (oXML.status>199 && oXML.status<299) {
//		alert(oXML.responseText);
		waitOff();
		return oXML.responseXML;
	}	else {
		alert(oXML.status+": "+oXML.statusText);
		waitOff();
		return null;
	}
}

function deleteAllChild(parent) {
	while (parent.hasChildNodes()) 
		parent.removeChild(parent.lastChild);
}

function getByAttribute(atname,name,list) {
	for (i=0;i<list.length;i++)
		if (list[i].getAttribute(atname)==name)
			return list[i];
	return null;
}


function removeEl(name) {
	if (typeof(name)=='string') {
		if (el=getId(name))
			el.parentNode.removeChild(el);
	}	else
		try {
			if(name)
				name.parentNode.removeChild(name);
		} catch (e) {
			alert(e.description);
		}
}

function wasEnter(e) {
	if (window.event && window.event.keyCode==13) {
		window.event.cancelBubble=true;
		return true;
	} else if (e.which==13) {
		e.stopPropagation();
		return true;
	}	else 
		return false;
}

function wasSameEnter(e,o) {
	//alert(window.event.keyCode);
	if (window.event && window.event.keyCode==13 && window.event.srcElement.getAttribute("id")==o.getAttribute("id"))
		return true;
	else if (e.which==13 && e.originalTarget.getAttribute("id")==o.getAttribute("id")) {
		//alert(e.originalTarget.getAttribute("id"));
		return true;
	}	else
		return false;
} 

function trueHeight() {
	if(ie())
		return elHtml().clientHeight-20;
	else
		return elHtml().scrollHeight;
}

function trueWidth() {
	return elHtml().scrollWidth;
}

function elHtml() {
	return document.getElementsByTagName("html")[0];
}

function windowWidth() {
	if (window.innerWidth)
		return window.innerWidth; 
	else if (document.documentElement.clientWidth)
		return document.documentElement.clientWidth;
	else
		return document.body.clientWidth;
}
function windowHeight() {
	if (window.innerHeight)
		return window.innerHeight; 
	else if (document.documentElement.clientHeight)
		return document.documentElement.clientHeight;
	else
		return document.body.clientHeight;
}

function yOffset() {
	if (window.pageYOffset)
		return window.pageYOffset; 
	else if (document.documentElement.scrollTop)
		return document.documentElement.scrollTop;
	else
		return document.body.scrollTop;
}

function removeClasses(_name) {
	divs = document.getElementsByTagName('*');
// 	alert(divs.length);
	//divs = document.getElementsByTagName('div');
	for(i=0;i<divs.length;i++) {
		if (divs[i].className==_name || divs[i].getAttribute('class')==_name)
// 			alert(divs[i].style.top);
			removeEl(divs[i])
	}
}

function getClasses(_class) {
	_all = document.getElementsByTagName("*");
	var pole = new Array();
	for (i=0;i<_all.length;i++)
		if (_all[i].className==_class || _all[i].getAttribute('class')==_class)
			pole.push(_all[i]);
	return pole;
}

function removeId(_id) {
	try {
		document.getElementById(_id).parentNode.removeChild(document.getElementById(_id));
		return true;
	} catch (e) {
		//report(e);
	}
}

function report(e) {
	alert(e.name+": "+e.description);
}

function xOffset() {
	if (window.pageXOffset)
		return window.pageXOffset; 
	else if (document.documentElement.scrollLeft)
		return document.documentElement.scrollLeft;
	else
		return document.body.scrollLeft;
}

function allRequired(list) {
	parts=list.split(",");
	for (i in parts)
		if (!gId(parts[i]))
			return false;
	return true;
}

function liveSubmit(o) {
	if (ls = gId('livesubmit'))
		if (ls.checked)
			o.form.submit();
}

function isLiveSubmit() {
	if (ls = gId('livesubmit'))
		if (ls.checked)
			return true;
}
	
function reportDim(w,h) {
	jquery("post=screen&width="+w+"&height="+h);
	//alert(elHtml().scrollHeight);
//	alert("post=screen&width="+w+"&height="+h);
}

function error(str) {
	alert(str);
	//alert(this.toSource());
	//alert("error code: "+this.result+" error callee:"+arguments.callee);
}

function preloadBanner(name,steps) {
	var width = windowWidth();
//	if (ie())
	//	width-=18;
	var prefix = "/image/fx/"+(width-(185+2*30))+"/";
	var i,im = new Array(steps);
	for (i=0;i<steps;i++) {
		im[i] = new Image();
		im[i].src = prefix+name+"_"+(i+1)+".jpg";
		//alert(im[i].src);
	}
}

function loadBg(name,bg) {
	var obj = gId(name);
	obj.style.backgroundImage="url(/image/"+bg+")";
//	alert(obj.style.backgroundImage);
}

function checkIcqs() {
	//if (window.location.indexOf("mirror1.citybikes.cz")!=-1)
		//return false;
	var uins = {"icqc": 382855851}; //,"icqn": 354027515}; // object literal
	//var uins = new Object(icqc: 382855851,icqn: 354027515); // object literal ??? NEFUNGUJE
	//var uins = [["icqc",382855851],["icqn", 354027515]]; //array literal
	//var uins = new Array(new Array("icqc",382855851),new Array("icqn",354027515)); // another array
	for (var i in uins) {
		reqObj[reqObj.length] = jAsyncReplyQuery2("fetch=IcqStatus&uin="+uins[i],al,i);
	}
}

function al(str,n) {
	var im = gId(str);
	if (im!=undefined)
		im.src="/image/icq"+n+".gif";
	var im2 = gId(str+"2");
	if (im2!=undefined)
		im2.src="/image/icq"+n+".gif";
}

function abortAllRequests() {
	return;
	for (var i in reqObj)
		reqObj[i].abort();
}

function isSet(o) {
	if (window.o === undefined)
		return false;
	else
		return true;
}

function doc2obj(doc) { // jen table rows
	var obj = new Object();
	var i = 0;
	var xRes = doc.evaluate(".",doc,null,XPathResult.UNORDERED_NODE_ITERATOR_TYPE,null);
	var row = xRes.iterateNext();
	while (row) {
		var yRes = doc.evaluate(".",row,null,XPathResult.UNORDERED_NODE_ITERATOR_TYPE,null);
		var col = yRes.iterateNext();
		while (col) {
			obj[i].col.nodeName = col.nodeValue;
			col = yRes.iterateNext();
		}
		i++;
	}
	return obj;
}

function gxp(doc,query) {
	//var xpathResult = document.evaluate( xpathExpression, contextNode, namespaceResolver, resultType, result );
	var images = null;
	try {
		images = doc.evaluate(query,doc,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);
	} catch (e) {
		alert(e);
		return null;
	}
	return images;
}

function getFirstElemChild(node) {
	for (var i in node.childNodes)
		if (node.childNodes[i].nodeType==3)
			return node.childNodes[i];
	return null;
}
