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 BgImage(whichid,imagesrc)
{
  mainobject = new getObj(whichid);
  mainobject.style.backgroundImage='url('+imagesrc+')';
}
function ChangeClass(whichid,clsnm)
{
  var mainobject = new getObj(whichid);
  mainobject.obj.className = clsnm;
}
function DomWriteIn(whichid,str) {
  mainobject = new getObj(whichid);
  mainobject.obj.innerHTML = str;
}
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 DayDiff(datefrom,dateto) {
 tmp = datefrom.split('-');
 day1 = tmp[2];
 month1 = tmp[1];
 year1 = tmp[0];
 tmp = dateto.split('-');
 day2 = tmp[2];
 month2 = tmp[1];
 year2 = tmp[0];

 prvni = new Date();
 prvni.setFullYear(year1*1);
 prvni.setMonth(month1*1-1,day1*1);
 prvni.setDate(day1*1);

 druhy = new Date();
 druhy.setFullYear(year2*1);
 druhy.setMonth(month2*1-1,day2*1);
 druhy.setDate(day2*1);

 t1 = prvni.getTime();
 t2 = druhy.getTime();

 t = Math.round((t2 - t1) / 86400000);

 if (t<0)
 {
     return -1;
 }

 if (t==0)
 {
     return 1;
 }

 if (t>0)
 {
     return t+1;
 }
}

function StrToSysDate(str) {
 pos = str.indexOf('.');
 if(pos>0) {
   tmp = str.split('.');
   if(tmp[1]*1<10) tmp[1] = '0' + tmp[1]*1;
   if(tmp[0]*1<10) tmp[0] = '0' + tmp[0]*1;
   str = tmp[2]+'-'+tmp[1]+'-'+tmp[0];
 }
 return str;
}
