// JavaScript Document
var myimages=new Array()
function preloadimages(){
	for (i=0;i<preloadimages.arguments.length;i++){
	myimages[i]=new Image()
	myimages[i].src=preloadimages.arguments[i]
	}
}
preloadimages( './system/admin/images/btnLogHover.gif', './system/admin/images/btnLogHoverRev.gif', './images/ePoodKotiSisuHover.gif');

function findObj(theObj, theDoc)
{
  var p, i, foundObj;
  
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  
  return foundObj;
}

function changeView(hide,doThis)
{
obj = findObj(hide);
 if (obj)
  {
  	if(doThis)
	{
		obj.className=doThis;	
	}
	else if(obj.className=='hide')
		{
		obj.className='show';
		
		}
	else{
		obj.className='hide';
	}
  
  }
}

function changeDisplay(object)
{
	var obj = findObj(object);
	if (obj)
	  {
		if(obj.style.display=='none')
			{
			obj.style.display='';
			}
		else{
				try
				{
					Effect.Fade(object); 
					return false;	
				}
				catch(err)
				{	
					obj.style.display='none';
				}
			}	  
	  }
}

function imageReLoad(id, source)
{
	var obj = findObj(id);
	if(obj)
	{
		obj.src=source;	
	}
}
var globalID;
function imagePopup(id, str)
{ 
	xmlHttp=GetXmlHttpObject()
	globalID=id;
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url='./module/tood/popUp.php?pilt='+ str + '&tID=' + id;
	url=url
	url=url+"&ssid="+Math.random()
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	xmlHttp.onreadystatechange=imagePopupChanged;
}

function imagePopupChanged()
{
	var obj = findObj('popUp');
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
		
	var myWidth = 0, myHeight = 0;
	  if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	  }  
		if (document.documentElement && document.documentElement.scrollTop)
			{theTop = document.documentElement.scrollTop;}
		else if (document.body)
			{theTop = document.body.scrollTop}
		
		obj.innerHTML=xmlHttp.responseText;
		obj.style.top=(myHeight/2)-325+'px';
		obj.style.left=(myWidth/2)-250+'px';		
		Effect.Appear('popUp');
		var obj2 = findObj('laen'+globalID);
		obj2.style.display='none';
		//obj.style.display='';
 }
 else
 {
	
	obj.innerHTML="Laen pilti";	 
 }
}
/*function hideVisibleLayer()
{
	obj2 = findObj(globalVisibleLayerID);
	if(obj2)
	{
		try
		{
			Effect.Fade(obj2); 
			return false;	
		}
		catch(err)
		{	
			obj2.style.display='none';
		}
	}
	
}

var globalVisibleLayerID = null;*/

