//--Copyright (C) 2002 Neotek Limited (http://www.neotek.co.nz). All rights reserved. -->
var aFrame = new Array();
var iFrameNo = 8;
var bfirsttime = true;
var iControlRefresh = 600000;
var sSkinPath = '';
var wSplash;
var TOId=0;
var w = window.screen.width;
var h = window.screen.height;

// Display the Splash Loading box
function showSplash(){
	try{
	/*
		if (h=768) w=1024;
		var l = (w-200)/2;
		var t = (h-170)/2;
		wSplash = top.open('/main/splash.htm', "_about", 'fullscreen=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0' );
		wSplash.blur();
		window.focus();	
		wSplash.resizeTo(200,170);
		wSplash.moveTo(l, t);
		wSplash.focus();
	*/
		tbElement('License_processing','');
		tbElement('License_siteByNeotek','none');		
	}catch(e){
	}
	TOId=setTimeout("hideSplash()",30000)
}

function tbElement(name,visible){
	top.toolbar.document.getElementById(name).style.display=visible;
}

function hideSplash(){
	clearTimeout(TOId)
	if(wSplash!=null) wSplash.window.close();
	wSplash=null;
	try{
		tbElement('License_processing','none');
		tbElement('License_siteByNeotek','');		
	}catch(e){
	} 
}

function edit(id){
    top.frames['content'].frames['results'].document.location.href='/editor3/editcontent.aspx?id=' + id;
}

function setText(obj,text){
	if (document.getElementById) {
		obj.innerHTML = text;
	}else if (document.getElementById){
		rng = document.createRange();
		rng.setStartBefore(div);
		htmlFrag = rng.createContextualFragment(text)
		while(obj.hasChildNodes()) obj.removeChild(Node.lastChild);
		obj.appendChild(htmlFrag);
	}
}

showSplash();

window.moveTo(0,0); 
if (window.outerHeight) {
	window.outerHeight = screen.availHeight; window.outerWidth = w; //screen.availWidth;
}else{ 
	window.resizeTo(w,screen.availHeight); 
} 

function frameLoaded(frame){
	found=false;
	for (i = 0; i < aFrame.length; i++) {
		if (aFrame[i] == frame) {
			i = aFrame.length;
			found=true;
		}
		if (aFrame[i] == '-'+frame) {
			aFrame[i]=frame
			i = aFrame.length;
			found=true;
		}
	}
	if (found==false){
		aFrame[i++]=frame;
	}
	return true
}

// Note: do not use onload() as a function name because this has a special meaning in firefox.
function neotekOnload(){
	hideSplash();
	if (iControlRefresh!=0) setTimeout("ControlRefresh()",iControlRefresh);
}

function ControlRefresh(){
	top.control.location.replace("../main/Control.aspx");
	if (iControlRefresh!=0) setTimeout("ControlRefresh()",iControlRefresh);
}

function isFrameLoaded(frame){
	for (i = 0; i < aFrame.length; i++) {
		if (aFrame[i] == frame) {
			return true;
		}
	}
	return false;
}

function GetXmlHttpObject(){ 
    var objXMLHttp = null;

    if (typeof XMLHttpRequest != "undefined"){
        objXMLHttp = new XMLHttpRequest();

        if (objXMLHttp.overrideMimeType){
        objXMLHttp.overrideMimeType('text/xml');
        }
    } else if (window.ActiveXObject){
        objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }

    return objXMLHttp;
} 

function neotekscript(url, params, callback){
    try{
	   var xmlHttp = GetXmlHttpObject();
   
       if (typeof callback == 'undefined' || callback==null){
            xmlHttp.onreadystatechange = function() {processScript(xmlHttp)};
	   }else{
	        xmlHttp.onreadystatechange = function() {callback(xmlHttp)};
	   }
        if(typeof params == 'undefined' || params==null){
	        xmlHttp.open('GET',url,true);
	        xmlHttp.send(null);
	 	}else{
	        xmlHttp.open('POST',url,true);
            xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            xmlHttp.setRequestHeader("Content-length", params.length);
            xmlHttp.setRequestHeader("Connection", "close");
	        xmlHttp.send(params);
	    }
	}catch(e){
	    alert(url + ' error:' + e);
	}
}


function processScript(xmlHttp){
    if(xmlHttp.readyState == 4) {
	    if(xmlHttp.status==200){
		    var scripts = xmlHttp.responseXML.getElementsByTagName("scripts")[0];
		    if (scripts!=null){
                var script='';
		        for(var i=0; i<scripts.childNodes.length; i++){
			        try{
			            if (scripts.childNodes[i].textContent!=null){
		                    script=scripts.childNodes[i].textContent
		                }else{
		                    script=scripts.childNodes[i].text
		                }
			            eval(script);
			        }catch(e){
			            alert(script + e)
			        }
			    }
	        }else{
	            alert('Failed to get a response!');
	        }
	    }
    }
}

// Ajax call that gets the text returned and passes to your supplied callback function
function neotekText(url, callback, elementId){ 
    try{
	   var xmlHttp = GetXmlHttpObject();
   
	    xmlHttp.open('GET',url,true);
	    xmlHttp.onreadystatechange = function() {
		    if (xmlHttp.readyState == 4) {
		        if(xmlHttp.status==200 && callback != null)
		            if (typeof elementId == 'undefined' || elementId==null){
		                callback(xmlHttp.responseText);
	                }else{
	                    callback(getInnerHTML(xmlHttp.responseText,elementId));
	                }
		    }
	    }
	    xmlHttp.send(null);
	}catch(e){
	    alert(e);
	}
}

function getInnerHTML(html, elementId){
    try //Internet Explorer
      {
      xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
      xmlDoc.async="false";
      xmlDoc.loadXML(html);
      }
    catch(e)
      {
      try //Firefox, Mozilla, Opera, etc.
        {
        parser=new DOMParser();
        xmlDoc=parser.parseFromString(html,"text/xml");
        }
      catch(e) {alert(e.message)}
      }
   return xmlDoc.getElementById(elementId).innerHTML
 }