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 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(obj,pre,child)
 {
   if(pre === undefined)   pre   = false;
   if(child === undefined) child = 0;

   var n  = "\n";
   var t  = "&nbsp;&nbsp;&nbsp;&nbsp;";
   var ts = "";

   if(pre) for(var i = 0; i <= child; i++) ts += t;

   if(obj.constructor == Array || obj.constructor == Object)
   {
     if(pre && child == 0)
     {
       document.write('<pre>'+n);
       document.write('Array'+n);
       document.write('('+n);
     }
     else if(pre && child > 0)
     {
       document.write(ts+'('+n);
     }
     else
     {
       document.write('Array (');
     }

     for(var value in obj)
     {
       if(obj[value].constructor == Array|| obj[value].constructor == Object)
       {
         var newChild = child + 1;

         if(pre && child == 0)
         {
           document.write(ts+'['+value+'] => Array'+n);
         }
         else if(pre && child > 0)
         {
           document.write(ts+t+'['+value+'] => Array'+n);
           newChild++;
         }
         else
         {
           document.write(" ["+value+"] => ");
         }

         print_r(obj[value],pre,newChild);
       }
       else
       {
         if(pre && child == 0)
         {
           document.write(t+'['+value+'] => '+obj[value]+n);
         }
         else if(pre && child > 0)
        {
           document.write(ts+t+'['+value+'] => '+obj[value]+n);
         }
         else
         {
           document.write(' ['+value+'] => '+obj[value]+' ');
         }
       }
     }

     if(pre && child == 0)
     {
        document.write(') ');
        document.write('</pre>');
     }
     else if(pre && child > 0)
     {
       document.write(ts+') '+n);
     }
     else
     {
       document.write(') ');
     }
   }
 }