function blinkColor(id) {
//  alert(id);
  document.getElementById(id).className="violet";
  setTimeout("setBlinkColor('"+id+"')",1500);
  //alert(idsa);
}

function setBlinkColor(id) {
  //alert(id);
  document.getElementById(id).className="blue";
  setTimeout("setSecondBlinkColor('"+id+"')",1500);
}

function setSecondBlinkColor(id) {
  document.getElementById(id).className="lightgreen";
  setTimeout("setThirdBlinkColor('"+id+"')",1500);
}

function setThirdBlinkColor(id) {
  document.getElementById(id).className="orange";
  setTimeout("blinkColor('"+id+"')",1500);
}

function moveContent(odkud, kam){
  if (document.getElementById(odkud).innerHTML!='' && odkud!=kam){
      // kvuli antsipamove otazce
      //var antispam = document.getElementById('cap').value;
      document.getElementById(kam).innerHTML = document.getElementById(odkud).innerHTML ;
      document.getElementById(odkud).innerHTML ='';
      document.getElementById('priReaHref').href = "javascript:zobrazSkryj(['"+kam+"'],['b']);";
      //document.getElementById('cap').value = antispam;
  }
}

function setReplyForm(aktualniID) {
  var minuleID = document.getElementById('lastID').value;
  if (minuleID == '') {
    moveContent('reply-form','reply-'+aktualniID);
    //zobrazSkryj(['reply-'+aktualniID],['b']);
  } else if (aktualniID != minuleID) {
    moveContent('reply-' + minuleID,'reply-' + aktualniID);
    //zobraz('odpovidate-' + aktualniID);
    //skryj('odpovidate-' + minuleID);
  } else if (aktualniID == minuleID) {
    zobrazSkryj(['reply-' + aktualniID],['b']);
  }
  //if (odpovedi == 'a') show_hide();  // pokud jsou odpovedi jen pro chranena, zobraz policko pro heslo
  document.getElementById('lastID').value = aktualniID;
}

function priKon(a,b,c) {
  a = document.getElementById(a);
  b = document.getElementById(b);
  c = document.getElementById(c);
  if (a.value=="" || b.value=="") {
    alert("Zadali jste příliš krátké Jméno nebo Vzkaz...");
    return false;
  }
}

function nactiProfil(obj,jaz) {
  $.ajax({
    url: "../profily_ajax.inc.php?id="+obj+"&jazyk_id="+jaz+"",
    dataType: "script",
    success: function(data){
      document.getElementById('proloa'+obj).className = "nactenyProfil";
      $('#pro'+obj).hide();
      $('#pro'+obj).html(data);
      $('#pro'+obj).fadeIn("slow");
    	var lightbox = new LightBox({
    		loadingimg:'/lb_plus/loading.gif',
    		expandimg:'/lb_plus/expand.gif',
    		shrinkimg:'/lb_plus/shrink.gif',
    		previmg:'/lb_plus/prev.gif',
    		nextimg:'/lb_plus/next.gif',
    		effectimg:'/lb_plus/zzoop.gif',
    		effectpos:{x:-40,y:-20},
    		effectclass:'effectable',
    		closeimg:'/lb_plus/close.gif',
    		resizable:true
    	});
    },
    beforeSend: function(){
      document.getElementById('proloa'+obj).className = "nacitamProfil";
    }
  });
  document.getElementById('href'+obj).href="javascript:animate(['pro"+obj+"'],['sl'],['slow'])";
}

function initialize() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(50.106674, 15.714829), 15);
        map.setMapType(G_HYBRID_MAP);
        map.setUIToDefault();
        map.openInfoWindow(map.getCenter(),
                   document.createTextNode("route333, 7. - 11. 2010"));
      }
    }

function animate(obj,param,speed) {
  for (var i in obj) {
    if (param[i] == 'sl') {
      if (isVisible(obj[i])) {
        jQuery('#'+obj[i]).slideUp(speed[i]);
      } else {
        jQuery('#'+obj[i]).slideDown(speed[i]);
      }
    } else if (param[i] == 'fa') {
      if (isVisible(obj[i])) {
        jQuery('#'+obj[i]).fadeOut(speed[i]);
      } else {
        jQuery('#'+obj[i]).fadeIn(speed[i]);
      }
    }
  }
}
function vepisHTML(idecka,html) {
  for (var i in idecka) {
    document.getElementById(idecka[i]).innerHTML = html[i];
  }
}
function toggleVepisHTML(idecka,html1,html2) {
  for (var i in idecka) {
    var ls = document.getElementById(idecka[i]);
    if (ls.innerHTML == html1[i]) {
      ls.innerHTML = html2[i];
    } else {
      ls.innerHTML = html1[i];
    }
  }
}
function isVisible(objname) {
    var el = document.getElementById(objname);
    if (el && document.defaultView && window.getComputedStyle) { // FF, Safari, Opera and others
      var style = document.defaultView.getComputedStyle(el, null);
      clr = style.getPropertyValue("display");
      if (clr == 'none') { return false; } else { return true; }
    } else if (el && el.currentStyle) { // IE and others
      if (el.currentStyle.display == 'none' || el.currentStyle.display == null || el.currentStyle.display == "") { return false; } else { return true; }
    }
}
function zobrazSkryj(idecka,typy){
  for (var i in idecka) {
    var typ = (typy[i] == 'b') ? 'block' : 'inline';
    var el = document.getElementById(idecka[i]);
    if (el && document.defaultView && window.getComputedStyle) { // FF, Safari, Opera and others
      var style = document.defaultView.getComputedStyle(el, null);
      clr = style.getPropertyValue("display");
      el.style.display = (clr != 'none') ? 'none' : typ;
    } else if (el && el.currentStyle) { // IE and others
      if (el.currentStyle.display == 'none' || el.currentStyle.display == null || el.currentStyle.display == "") {
        el.style.display = typ;
      } else {
        el.style.display = "none";
      }
    }
	}
}
function skryj(idecko) {
  el=document.getElementById(idecko).style.display='none';
}
function nastavHodnoty(policka,hodnoty) {
  for ( var i in policka ) {
    var el = document.getElementById(policka[i]);
    if (el != null) document.getElementById(policka[i]).value=hodnoty[i];
  }
}
function uniForm(akce,idecko) {
  document.getElementById('uniformaction').value=akce;
  document.getElementById('uniformid').value=idecko;
  document.forms['uniform'].submit();
}
function potvrdFormular(formular) {
  document.forms[formular].submit();
}
function zeptejPotvrdFormular(text,formular) {
  if (confirm(text)) document.forms[formular].submit();
}
function enableRadio(numa,name,numastartend,numaendend) {
	for (var i = 1; i<numa+1; i++){
	  document.getElementById(name + i).disabled = false;
	}
	for (var i = numastartend; i<numaendend+1; i++){
	  document.getElementById(name + i).disabled = true;
	}
}
// spica javascript libraries - spica.js -- version 0.05
// == written by Takuya Otani <takuya.otani@gmail.com> ===
// == Copyright (C) 2006 SimpleBoxes/SerendipityNZ Ltd. ==

// === array ===
if (!Array.prototype.pop)
{
	Array.prototype.pop = function()
	{
		if (!this.length) return null;
		var last = this[this.length - 1];
		--this.length;
		return last;
	}
}
if (!Array.prototype.push)
{
	Array.prototype.push = function()
	{
		for (var i=0,n=arguments.length;i<n;i++)
			this[this.length] = arguments[i];
		return this.length;
	}
}
if (!Array.prototype.indexOf)
{
	Array.prototype.indexOf = function(value,idx)
	{
		if (typeof(idx) != 'number') idx = 0;
		else if (idx < 0) idx = this.length + idx;
		for (var i=idx,n=this.length;i<n;i++)
			if (this[i] === value) return i;
		return -1;
	}
}
// === browser ===
function Browser()
{
	this.name = navigator.userAgent;
	this.isWinIE = this.isMacIE = false;
	this.isGecko  = this.name.match(/Gecko\//);
	this.isSafari = this.name.match(/AppleWebKit/);
	this.isKHTML  = this.isSafari || navigator.appVersion.match(/Konqueror|KHTML/);
	this.isOpera  = window.opera;
	if (document.all && !this.isGecko && !this.isSafari && !this.isOpera)
	{
		this.isWinIE = this.name.match(/Win/);
		this.isMacIE = this.name.match(/Mac/);
	}
}
var Browser = new Browser();
// === event ===
if (!window.Event) var Event = new Object;
Event = {
	cache : false,
	getEvent : function(evnt)
	{
		return (evnt) ? evnt : ((window.event) ? window.event : null);
	},
	getKey : function(evnt)
	{
		evnt = this.getEvent(evnt);
		return (evnt.which) ? evnt.which : evnt.keyCode;
	},
	stop : function(evnt)
	{
		try{ evnt.stopPropagation() } catch(err){};
		evnt.cancelBubble = true;
		try{ evnt.preventDefault() } catch(err){};
		return (evnt.returnValue = false);
	},
	register : function(object, type, handler)
	{
		if (type == 'keypress' && (Browser.isKHTML || object.attachEvent)) type = 'keydown';
		if (type == 'mousewheel' && Browser.isGecko) type = 'DOMMouseScroll';
		if (!this.cache) this.cache = [];
		if (object.addEventListener)
		{
			this.cache.push([object,type,handler]);
			object.addEventListener(type, handler, false);
		}
		else if (object.attachEvent)
		{
			this.cache.push([object,type,handler]);
			object.attachEvent(['on',type].join(''),handler);
		}
		else
		{
			object[['on',type].join('')] = handler;
		}
	},
	deregister : function(object, type, handler)
	{
		if (type == 'keypress' && (Browser.isKHTML || object.attachEvent)) type = 'keydown';
		if (type == 'mousewheel' && Browser.isGecko) type = 'DOMMouseScroll';
		if (object.removeEventListener)
			object.removeEventListener(type, handler, false);
		else if (object.detachEvent)
			object.detachEvent(['on',type].join(''), handler);
		else
			object[['on',type].join('')] = null;
	},
	deregisterAll : function()
	{
		if (!Event.cache) return
		for (var i=0,n=Event.cache.length;i<n;i++)
		{
			Event.deregister(Event.cache[i]);
			Event.cache[i][0] = null;
		}
		Event.cache = false;
	}
};
Event.register(window, 'unload', Event.deregisterAll);
// === dom ===
document.getElemetsByClassName = function(name,target)
{
	var result = [];
	var object  = null;
	var search = new RegExp(['(^|\\s)',name,'(\\s|$)'].join(''));
	if (target && target.getElementsByTagName)
		object = target.getElementsByTagName('*');
	if (!object)
		object = document.getElementsByTagName ? document.getElementsByTagName('*') : document.all;
	for (var i=0,n=object.length;i<n;i++)
	{
		var check = object[i].getAttribute('class') || object[i].className;
		if (check.match(search)) result.push(object[i]);
	}
	return result;
}
// === library ===
function Library()
{
	this._path = '';
	this._cache = [];
	this.lang = '';
	this.base = '';
	return this._init();
}
Library.prototype = {
	_init : function()
	{
		var rs_path = document.getElementsByName('X-Resource-Dir')[0];
		var js_path = document.getElementsByName('X-Script-Dir')[0];
		if (rs_path)
		{
			this.base = this._check_path(rs_path.getAttribute('content'));
			if (!js_path) this._path = [this.base,'js/'].join('');
		}
		if (js_path)
			this._path = this._check_path(js_path.getAttribute('content'));
		return this;
	},
	_initLang : function()
	{
		var html = document.getElementsByTagName('html')[0];
		if (!html) return;
		this.lang = html.getAttribute('xml:lang') || html.getAttribute('lang');
	},
	_check_path : function(path)
	{
		if (!path) return '';
		if (!path.match(/\/$/)) path = [path,'/'].join('');
		return path;
	},
	require : function(libs)
	{
		var pre  = '\n<script type="text/javascript" src="';
		var post = '.js"></script>';
		for (var i=0,n=libs.length;i<n;i++)
		{
			if (this._cache.indexOf(libs[i]) > -1) continue;
			document.write([pre,this._path,libs[i],post].join(''));
			this._cache.push(libs[i]);
		}
	},
	path : function(path)
	{
		this._path = this._check_path(path);
	}
}
var Library = new Library();
Event.register(window,'load',function() { Library._initLang() });
