// JavaScript Document
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 changeDisplay(object, action)
{
	var obj = findObj(object);
	if (obj)
	  {
		if(obj.style.display=='none' && !action)
			{
			obj.style.display='';	
			}
		else{
			obj.style.display='none';
		}	  
	  }
}

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';
	}
  
  }
}

var iMousePosX = 0;
var iMousePosY = 0;

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function pageHeight() {return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;} 

function moveThumb(obj)
{
	object = findObj(obj);
	
	if(iMousePosX){
	//	if (document.all) {
      	 //	e = window.event;			
			pageH = pageHeight();
			if (navigator.appName == "Microsoft Internet Explorer"){var position = (document.body.scrollTop)?document.body.scrollTop:document.documentElement.scrollTop;}
			else {var position = window.pageYOffset;}
			//document.getElementById('container').innerHTML = pageH+ ' ja ' +position + ' ja'+object.clientHeight;
			if((pageH-object.clientHeight+position)<=iMousePosY+10)
			{
				iMousePosY=pageH-object.clientHeight-10+position;
			}	
		//}
		object.style.left=iMousePosX+15+"px";
		object.style.top=iMousePosY+"px";
	}	
}

function hideThumb(obj)
{
	object7 = findObj(obj);
	object7.className='hide';
	clearTimeout(timeOn);
	timeOn=null;
}

function showThumb(obj, pic)
{

timeOn = setTimeout("showThumb2('"+obj+"','"+pic+"')", 400);
}

function showThumb2(obj, pic)
{
	clearTimeout(timeOn);
	timeOn=null;
	object9 = findObj(obj);
	if(iMousePosX){
			pageH = pageHeight();
			if (navigator.appName == "Microsoft Internet Explorer"){var position = (document.body.scrollTop)?document.body.scrollTop:document.documentElement.scrollTop;}
			else {var position = window.pageYOffset;}
			obHeight=(object9.clientHeight)?object9.clientHeight:'350';
			if((pageH-obHeight+position)<=iMousePosY+10)
			{
				iMousePosY=pageH-obHeight-10+position;
			}	
		object9.style.left=iMousePosX+15+"px";
		object9.style.top=iMousePosY+"px";
	}
	object9.className='show';
	object9.innerHTML='<div class="loading"><img src="./user_files/image/kinnisvara/medThumb/'+ pic +'" onMouseOut="javascript:hideThumb(\''+obj+'\');" /></div>';	
}
var globalID;
function imagePopup(id, str, thisID)
{ 
	xmlHttp=GetXmlHttpObject()
	globalID=thisID;
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url='./system/tooted/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=(theTop<=70)?theTop+70+'px':theTop+10+'px';		
		Effect.Appear('popUp');
		var obj2 = findObj('laen'+globalID);
		obj2.style.display='none';
 }
 else
 {
	
	obj.innerHTML="Laen pilti";	 
 }
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}
