// JavaScript Document

function AjaxGet(theurl,theid,tempText,secPage)
	{
	if (tempText != ''){document.getElementById(theid).innerHTML = tempText;}
	
	loading(true)
	
	if (Right(theurl,4) == ".asp")
		{theurl=theurl + "?sid=" + Math.random()}
	else
		{theurl=theurl + "&sid=" + Math.random()}
	var url=theurl
	
	xmlHttp = GetXmlHttpObject(Function('if(xmlHttp.readyState==4 || xmlHttp.readyState==\'complete\'){document.getElementById(\'' + theid + '\').innerHTML = xmlHttp.responseText;loading(false);}'))
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}

function GetXmlHttpObject(handler)
{ 
	var objXmlHttp=null
	if (navigator.userAgent.indexOf("Opera")>=0)
	{
		alert("Funktionalitetur ikki virkin.\n\nVirkar bert í Internet Explorer og Firefox") 
		return; 
	}
	if (navigator.userAgent.indexOf("MSIE")>=0)
	{ 
		var strName="Msxml2.XMLHTTP"
		if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
		{
			strName="Microsoft.XMLHTTP"
		} 
		try
		{ 
			objXmlHttp=new ActiveXObject(strName)
			objXmlHttp.onreadystatechange=handler 
			return objXmlHttp
		} 
		catch(e)
		{ 
			alert("Error. Scripting for ActiveX might be disabled") 
			return 
		} 
	} 
	if (navigator.userAgent.indexOf("Mozilla")>=0)
	{
		objXmlHttp=new XMLHttpRequest()
		objXmlHttp.onload=handler
		objXmlHttp.onerror=handler 
		return objXmlHttp
	}
}
function loading(theAction){
	var temp = document.getElementById('load_root');
	var sBlockMe = document.getElementById('disableScreen');
	if(theAction==true){
		temp.style.top = parseInt(document.body.clientHeight/2)-100;
		temp.style.left = parseInt(document.body.offsetWidth/2)-75;
		temp.style.visibility = 'visible';
		
		sBlockMe.style.visibility = 'visible';	
	}
	else
	{
		temp.style.visibility = 'hidden';
		sBlockMe.style.visibility = 'hidden';
	}
}

function setHeight(){
	var availableHeight = 0;
	if(document.all)
		{
		availableHeight = document.body.clientHeight;
		}
	else
		{
		availableHeight = innerHeight;
		}
		
	//var sMainFrame = document.getElementById('MainContent');
	var sBlockMe = document.getElementById('disableScreen');
	//sMainFrame.style.height = availableHeight-75;
	sBlockMe.style.height = availableHeight;
}







function xmlhttpPost(strURL,theid) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(self.xmlHttpReq.responseText,theid);
        }
    }
    self.xmlHttpReq.send(getquerystring());
}

function getquerystring() {
    var form     = document.forms['f1'];
    var word = form.word.value;
    qstr = 'w=' + escape(word);  // NOTE: no '?' before querystring
    return qstr;
}

function updatepage(str,theid){
    document.getElementById("content").innerHTML = str;
}
