function getObj(name)
{
	if (document.getElementById)
	{
		this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
		return true;
	}
	else if(document.all)
	{
		this.obj = document.all[name];
		this.style = document.all[name].style;
		return true;
	}
	else return false;
}

function addClass(trida,ajdi){
	var element = document.getElementById(ajdi);
	if(element){
		element.className = element.className + ' ' + trida;
		return true;
	}else{
    return false;
  }
}

function replaceClass(trida,ajdi){
	var element = document.getElementById(ajdi);
	if(element){
		element.className = trida;
		return true;
	}else{
    return false;
  }
}

function reply2(what, par) {
	if (! par){
        par = 0;
    }
    document.addpost.parent.value = par
	var text_now = document.addpost.text.value;	// ziskani soucasneho obsahu
	if (text_now == "") {
		document.addpost.text.value=what;
	} else {
		document.addpost.text.value+"\n\n"+what;
	}
}
function switchInfobox(id){
  var box = document.getElementById(id);

  if(!box) return;
  var classes = box.className.split(' ');
  var date = new Date();
  date.setTime(date.getTime()+(30*24*60*60*1000));//ulozi se to na 30 dni
  
  if(classes.length == 2){
      box.className = box.className+' zavr';
      setCookie(id+'View','off',date,'/');
  }else{
      setCookie(id+'View','on',date,'/');
      box.className = classes[0]+' '+classes[1];
  }
}

function initInfobox(id){
  var date = new Date();
  date.setTime(date.getTime()+(30*24*60*60*1000));//ulozi se to na 30 dni
  if(getCookie(id+'View')=='off'){
    switchInfobox(id);
  }else{
    setCookie(id+'View','on',date,'/');//prodlouzime to
  }
}


function w(url,type){
	switch(type){
        case 1:
			var directories='no';
			var location='no';
			var menubar='no';
			var status='no';
			var toolbar='no';
			var posWidth = 1044;
			var posHeight = 1044;
			wname = 'galerie-full';
		break
        case 2:
            var directories='yes';
			var toolbar='yes';
			var status='yes';
			var menubar='yes';
			var location='yes';
			var posWidth = 900;
			var posHeight = 640;
			wname = 'cizi-okno';
		break
        default:
            var directories='yes';
			var toolbar='yes';
			var status='yes';
			var menubar='yes';
			var location='yes';
			var posWidth = 690;
			var posHeight = 720;
			wname = 'galerie';
	}
	if(window.screen.availHeight < posHeight){posHeight = window.screen.availHeight;} 
	if(window.screen.availWidth < posWidth){posWidth = window.screen.availWidth;}
	var posLeft = (window.screen.availWidth - posWidth)/2;
	var posTop = (window.screen.availHeight - posHeight)/2;
	var args='scrollbars=yes,resizable=yes,location='+location+',directories='+directories+',status='+status+',menubar='+menubar+',toolbar='+toolbar+',width=' + posWidth + ',height=' + posHeight + ',left=' + posLeft + ',top=' + posTop;
	var win = window.open(url,wname,args);
	if(win){
		win.focus;
		return false;
	} else return true;
}






function range(/*[start,] stop[, step]*/) {
    if (!arguments.length) {
     return [];
    }

    var min, max, step;
    if (arguments.length == 1) {
        min = 0;
        max = arguments[0]-1;
        step = 1;
    }
    else {
        /* default step to 1 if it’s zero or undefined */
        min = arguments[0];
        max = arguments[1]-1;
        step = arguments[2] || 1;
    }

    /* convert negative steps to positive and reverse min/max */
    if (step < 0 && min >= max) {
        step *= -1;

        var tmp = min;
        min = max;
        max = tmp;

        min += ((max-min) % step);
    }

    var a = [];
    for (var i = min; i <= max; i += step) {
        a[i] = i;
    }
    return a;
}


   function in_array(v,a){
      for(key in a){
         if(a[key]==v) return true
      }
      return false
   }

   


function init(){
  //inicializace menu - ale jen, pokud ma smysl
  if(document.getElementById('menu'))
    if (window.initMenu){
        initMenu();
    }
}

window.onload = init;

