// JavaScript Document
var xmlHttp
var language
var type

function showAll(str)
{
type="all";
//if (str.length==0)
  //{ 
  document.getElementById("rightmenu").innerHTML = "<br />";
  document.getElementById("homepage").innerHTML="";
  //document.getElementById("newsSlider").innerHTML="";
  document.getElementById("headline").innerHTML="";
  //return;
  //}
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="load_cat.php";
url=url+"?lang="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
} 

function showMain(str,lang) {
type="search";
language = lang;
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
//alert(str);
var url="search.php";
url=url+"?keyword="+str+"&lang="+lang;
width = 0;
var theDiv = document.getElementById("txtHint");
var width = theDiv.offsetWidth;
var height = theDiv.offsetHeight;

/*var theDiv1 = document.getElementById("container");
var width1 = theDiv1.offsetWidth;
var height1 = theDiv1.offsetHeight;*/

var theDiv2 = document.getElementById("leftMenu");
var width2 = theDiv2.offsetWidth;
var height2 = theDiv2.offsetHeight;
/*
if ((height < 1000) && (height2 < 1000)) {
document.getElementById('container').style.height=1000+"px";
} else {
if (height>height2) {
	document.getElementById('container').style.height=50+height+"px";
} else {
	document.getElementById('container').style.height=50+height2+"px";
} //end if  
}//((height < 1000) && (height2<1000)
*/
document.getElementById('homepage').innerHTML = "";
//document.getElementById("newsSlider").innerHTML = "";
if (document.getElementById('txtHint').style.opacity < 100) {
  opacity('txtHint',0,100,1000);
}

if (document.getElementById('headline').style.opacity < 100) {
  opacity('headline',0,100,1000);
}
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
} 

function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
}
if (type=="search") {
document.getElementById("rightmenu").innerHTML = '<br />';
if (language == "rs") {
document.getElementById("headline").innerHTML = 'REZULTATI PRETRAGE';
} else {
document.getElementById("headline").innerHTML = 'SEARCH RESULTS';	
}
} else {

document.getElementById("headline").innerHTML="ARHIVA AGROSAVETNIK-a";
document.getElementById("txtHint").innerHTML=xmlHttp.responseText;	
}

height = 0;
height1 = 0;
height2 = 0;

var theDiv = document.getElementById("mainarea");
var height = theDiv.offsetHeight+230;
var theDiv1 = document.getElementById("siteContainer");
var height1 = theDiv1.offsetHeight;
var theDiv2 = document.getElementById("leftMenu");
var height2 = theDiv2.offsetHeight+230;		  

	if ((height>=height2) && (height>=height1)) {
		document.getElementById('siteContainer').style.height=height+"px";
		document.getElementById('copyright').style.top =height+"px";
		document.getElementById('copyright').style.left ="40px";
	}
	if ((height1>=height2) && (height1>=height)) {
		document.getElementById('siteContainer').style.height=height1+"px";
		document.getElementById('copyright').style.position = "apsolute";
		document.getElementById('copyright').style.top =height1+"px";
		document.getElementById('copyright').style.left ="40px";
	}
	if ((height2>=height) && (height2>=height1)) {
		document.getElementById('siteContainer').style.height=height2+"px";
		document.getElementById('copyright').style.position = "apsolute";
		document.getElementById('copyright').style.top =height2+"px";
		document.getElementById('copyright').style.left ="40px";
	} //end if  
}

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;
}
