/*-- Copy Start ---*/
//----


function showObj(id){
	var styleObject = document.getElementById(id);

  if (styleObject != null){
		styleObject = styleObject.style;
		styleObject["display"] = "block";
  }
}

//General hide div-function
function hideObj(id){
	var styleObject = document.getElementById(id);

  if (styleObject != null){
		styleObject = styleObject.style;
		styleObject["display"] = "none";
  }
}

function uniqid()
{
    var newDate = new Date;
    return newDate.getTime(); 
} 

/* quick getElement reference */
function $() {
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}

function createXMLHttpRequest() {
	//alert("createXMLHttpRequest called");
   try { return new XMLHttpRequest(); } catch(e) {}
   try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
   //alert("XMLHttpRequest not supported");
   return null;
}

var delayedcallback = null;

var ajaxrequest=null;
var nodeid=null;
function updateNodeWithUrlResponse(elementId,urlpath) {
	//alert("updateNodeWithUrlResponse called "+urlpath);
	nodeid = elementId;
	ajaxrequest = createXMLHttpRequest();
	ajaxrequest.open("GET", urlpath, true);
	ajaxrequest.onreadystatechange = onGetResponse;
	ajaxrequest.send(null);
} 

function onGetResponse() {
   if (ajaxrequest.readyState != 4)  { return null; }
   //alert("nodeid="+nodeid);
   //alert("$nodeid="+$(nodeid));
   $(nodeid).innerHTML = ajaxrequest.responseText;
   //var oScript = document.createElement("script");
   //oScript.src = "../../libraries/js/ajax.js";
   //$(nodeid).appendChild(oScript);
   if (delayedcallback) {
   	window.status="dc";
        setTimeout(delayedcallback, 4000);
	//alert("test");
	//--
   } else {
   	window.status="ndc";
   }
    
    return "";
}

//----
var contextroot="/search";
//var contextroot="";


function onoffSearchOuterFirstPage(tqnr,text,hitspp,additionalaterms) {
	//alert("onoffSearchOuterFirstPage called ,text:"+text+" additionalaterms="+additionalaterms);
	aessSearchGotoPage(tqnr,text,1,hitspp,"/file/onoff/se/searchframe.adsp","aesshitlist",additionalaterms);
} 

function onoffSearchInnerGotoPage(tqnr,text,page,hitspp,additionalaterms) {
	if (page==0) {hitspp=500;page=1;} 
	aessSearchGotoPage(tqnr,text,page,hitspp,"/file/onoff/se/aessHitlistPage.adsp","aesshitlistPage",additionalaterms);
} 

function aessSearchGotoPage(tqnr,text,page,hitspp,adsppage,targetnode,additionalaterms) {
	//alert("aessSearchGotoPage called ,text:"+text+" page:"+page+" hitspp:"+hitspp+" adsppage:"+adsppage+" targetnode:"+targetnode+" additionalaterms="+additionalaterms);
	var urlpath = contextroot+adsppage+"?ATERM0="+text+"&TQNR="+tqnr+"&ARANGE="+page+":"+hitspp+"&uid="+uniqid();
	if (additionalaterms!=null) {
	    urlpath += ("&" + additionalaterms);
	}
	//open(urlpath);
    updateNodeWithUrlResponse(targetnode,urlpath);
} 
/*-- Copy End ---*/