Array.prototype.in_array = function ( obj ) {
	var len = this.length;
	for ( var x = 0 ; x <= len ; x++ ) {
		if ( this[x] == obj ) return true;
	}
	return false;
}

function getObj(name)
{
  if (document.getElementById)
    {this.obj = document.getElementById(name);
    this.style = document.getElementById(name).style;}
  else if (document.all)
    {this.obj = document.all[name];
    this.style = document.all[name].style;}
  else if (document.layers)
    {this.obj = document.layers[name];
    this.style = document.layers[name];}
}

function hidestyle(whichid)
{
  mainobject = new getObj(whichid);
  if (mainobject.style.display=='none')
    {mainobject.style.display='';}
  else
    {mainobject.style.display='none';}
}
function hidestyleON(whichid)
{
  mainobject = new getObj(whichid);
  mainobject.style.display='none';
}

function hidestyleOFF(whichid)
{
  mainobject = new getObj(whichid);
  mainobject.style.display='';
}
function DomWriteIn(whichid,str) {
  mainobject = new getObj(whichid);
  mainobject.obj.innerHTML = str;
}
function DomDisable(whichid,bool) {
  mainobject = new getObj(whichid);
  mainobject.obj.disabled = bool;
}
function DomCheck(whichid,bool) {
  mainobject = new getObj(whichid);
  mainobject.obj.checked = bool;
}
function DomSetVal(whichid,str) {
  mainobject = new getObj(whichid);
  mainobject.obj.value = str;
}

function DomGetVal(whichid) {
  mainobject = new getObj(whichid);
  return mainobject.obj.value;
}

function WindowOpen(uri,w,h) {
  window.open(uri,'','width='+w+',height='+h+',status=yes,resizable=yes,scrollbars=yes');
}
function FotoOpen(uri,w,h) {
  window.open('/foto.php?f='+uri,'','width='+w+',height='+h+',left='+(screen.width/2-w/2)+',top='+(screen.height/2-h/2)+',status=yes,resizable=no,scrollbars=no');
}
function FotoGalleryOpen(id,ext,w,h,sekce) {
  window.open('/foto.php?id='+id+'&sekce='+sekce+'&ext='+ext,'','width='+w+',height='+h+',left='+(screen.width/2-w/2)+',top='+(screen.height/2-h/2)+',status=yes,resizable=no,scrollbars=no');
}
function GetFileName(p) {
  var pole = p.split('\\');
  var file = pole[pole.length-1];
  var pole = file.split('.');
  if(pole.length>=2) return pole[pole.length-2];
  if(pole.length>=1) return pole[pole.length-1];
}

function print_r(theObj){
  if(theObj.constructor == Array ||
     theObj.constructor == Object){
    for(var p in theObj){
      if(theObj[p].constructor == Array||
         theObj[p].constructor == Object){
alert("["+p+"] => "+typeof(theObj));
        print_r(theObj[p]);
      } else {
alert("["+p+"] => "+theObj[p]);
      }
    }
  }
  return;
}





function loadXMLdata(url) {
  if(window.XMLHttpRequest) {
    xmlhttp=new XMLHttpRequest();
    xmlhttp.onreadystatechange=state_Change;
    xmlhttp.open("GET",url,true);
    xmlhttp.send(null);
  }
  else if(window.ActiveXObject) {
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    if(xmlhttp) {
      xmlhttp.onreadystatechange=state_Change;
      xmlhttp.open("GET",url,true);
      xmlhttp.send();
    }
  }
  return true;
}

function state_Change() {
  var src,sources,i;
  if(xmlhttp.readyState==4) {
    //if(xmlhttp.status==200) {
      var src = xmlhttp.responseText;
      if(src && src!='') {
        sources = src.split('#nextajax#');
        for(i=0;i<sources.length;i++) {
          var id = sources[i].substring(0,10);
          source = sources[i].substring(10,sources[i].length);
          tmp = source.split('#javascript#');
          if(tmp.length>0) source = tmp[0]; else source = '';
          if(tmp.length>1) javascript = tmp[1]; else javascript = '';
          //pokud nejde jen o js tak vlepit kod dovnitr
          if(id!='noajaxfunc') {
            mainobject = new getObj(id);
            mainobject.obj.innerHTML = source;
          }
          if(javascript) {
            eval(javascript);
          }
        }
      }
      today = new Date();
      //window.status = 'Last AJAX update '+(today.getHours())+':'+(today.getMinutes())+':'+(today.getSeconds());
      //StyleTabletrs();
    //}
  }
}

function EmailValid(email) {
  var emailPattern = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/;  
  return emailPattern.test(email);
}
