/**
 *
 * @access public
 * @return void
 **/
function dynaLoad(s) {
  var sElem = document.createElement('script');
  sElem.type = 'text/javascript';
  sElem.src = s;
  document.getElementsByTagName('head')[0].appendChild(sElem);
}
function axwpAddEngine() {
	if ((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function")) {
		window.sidebar.addSearchEngine(
			"http://pediax.de/pediaX.src",
			"http://pediax.de/pediaX.png", "pediaX", "Reference" );
	} else
		alert("You will need a browser which supports Sherlock to install this plugin.");
}
function ajaxsearch() {
	ow.AjaxRequest(document.getElementById('axsearch'),'search',document.getElementById('searchInput').value);
}
/**
 *
 * @access public
 * @return void
 **/
function axwpLoadPreview(articleid,elem) {
//	elem=document.getElementById('lid'+articleid+'_'+counter);
	text=ow.AjaxRequest(null,'getAbstract',articleid);
	if(text)
		elem.insertAdjacentHTML('afterEnd','<span id="preview'+articleid+'" onmouseout="axwpRemovePreview(\''+articleid+'\')" style="text-align:left; font-style:normal; font-weight:normal; background-color:#efe; border:solid black 1px; position:absolute; padding-left:5px; margin-top:1.5em; margin-left:-100px;width:300px; z-index:100;">'+text+'</span>');
}
/**
 *
 * @access public
 * @return void
 **/
function axwpRemovePreview(articleid){
	d=document.getElementById('preview'+articleid);
	if(d)
		d.parentNode.removeChild(d);
}
function axwpLoadImage(img,url,pos,width) {
	img.insertAdjacentHTML(pos,'<span onmouseout="this.parentNode.removeChild(this);" style="background-color:white; width:'+width+'px; z-index:100; border:solid black 1px; position:absolute; margin-left:-'+(pos=='afterEnd'?width:'0')+'px;"><img src="'+url+'" /></span>');
}

function axwpLoadImage(img,url,pos) {
	img.insertAdjacentHTML(pos,'<span onmouseout="this.parentNode.removeChild(this);" style="background-color:white; z-index:100; position:absolute; margin-left: 0px;"><a name="ajaximage"><img name="ajaxImage" border="1" src="'+url+'" /></span>');
	var difference = document.ajaxImage.height - img.getAttribute("height");
	window.scrollBy(0, difference);
document
}

function axwpDeleteImage(img) {
	img.parentNode.removeChild(img.nextSibling);
}
function ow() {
}
ow.XMLHttpRequst=function(url,node) {
	var req = window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP");
	req.open('GET',url,node?true:false);
	if(node)
		req.onreadystatechange=function() {
			if(req.readyState==4)
				if(req.status==200)
					node.innerHTML=req.responseText;
				else
					dump("Error loading page\n");
			};
	req.send(null);
	if(!node)
		return req.responseText;
}
ow.AjaxRequest=function(node,func) {
	var url=location.protocol+'//'+location.host+'/skins/axwp/ajax.php?f='+func;
	for(var i=2;i<arguments.length;i++)
		url+='&p['+(i-1)+']='+encodeURIComponent(arguments[i]);
	return ow.XMLHttpRequst(url,node);
}
ow.AjaxRequest1=function(node,func) {
	var url=location.protocol+'//'+location.host+'/skins/axwp/ajax1.php?f='+func;
	for(var i=2;i<arguments.length;i++)
		url+='&p['+(i-1)+']='+encodeURIComponent(arguments[i]);
	return ow.XMLHttpRequst(url,node);
}
ow.toggleVisibility=function(id) {
	if(typeof id=='string')
		id=document.getElementById(id);
	if(!id)
		return;
	if(id.style.display!='')
		id.style.display='';
	else id.style.display='none';
	return id.style.display;
}
// implement some ie specific methods (insertAdjacentElement, insertAdjacentHTML,
// insertAdjacentText) for mozilla
if(typeof HTMLElement!="undefined" && ! HTMLElement.prototype.insertAdjacentElement) {
	HTMLElement.prototype.insertAdjacentElement = function (where,parsedNode) {
		switch (where) {
			case 'beforeBegin':
				this.parentNode.insertBefore(parsedNode,this)
				break;
			case 'afterBegin':
				this.insertBefore(parsedNode,this.firstChild);
				break;
			case 'beforeEnd':
				this.appendChild(parsedNode);
				break;
			case 'afterEnd':
				if (this.nextSibling) this.parentNode.insertBefore(parsedNode,this.nextSibling);
				else this.parentNode.appendChild(parsedNode);
				break;
		}
	}
	HTMLElement.prototype.insertAdjacentHTML = function (where,htmlStr) {
		var r = this.ownerDocument.createRange();
		r.setStartBefore(this);
		var parsedHTML = r.createContextualFragment(htmlStr);
		this.insertAdjacentElement(where,parsedHTML)
	}
	HTMLElement.prototype.insertAdjacentText = function (where,txtStr) {
		var parsedText = document.createTextNode(txtStr)
		this.insertAdjacentElement(where,parsedText)
	}
/*	HTMLElement.prototype.outerHTML setter  = function(html) {
		var range = this.ownerDocument.createRange();
		range.setStartBefore(this);
		var fragment = range.createContextualFragment(html);
		this.parentNode.replaceChild(fragment, this);
		return html;
	}
	HTMLElement.prototype.outerHTML getter  = function() {
		return HTMLElement_GetOuterHTML(this);
	}*/
	function HTMLElement_GetOuterHTML(node) {
		var output = "";
		var empties = ["IMG", "HR", "BR", "INPUT"];
		switch(node.nodeType) {
			case Node.ELEMENT_NODE:
				output += "<" + node.nodeName;
				//  get the element's attributes...
				for(var i = 0; i < node.attributes.length; i++) {
					if(node.attributes.item(i).nodeValue != null) {
					output += " ";
					output += node.attributes.item(i).nodeName + "=\"";
					output += node.attributes.item(i).nodeValue + "\"";
					}
				}

				if(node.childNodes.length == 0 && empties.getIndexOf(node.nodeName) > 0)
					output += ">";
				else {
					output += ">";
					output += node.innerHTML;
					output += "</" + node.nodeName + ">"
				}
				break;
			case Node.TEXT_NODE:
				output += node.nodeValue;
				break;
			case Node.CDATA_SECTION_NODE:
				output += "<![CDATA[" + node.nodeValue + "]]>";
				break;
			case Node.ENTITY_REFERENCE_NODE:
				output += "&" + node.nodeName + ";"
				break;
			case Node.COMMENT_NODE:
				output += "<!"+ "--" + node.nodeValue + "-->"
				break;
		}

		return output;
	}
	Array.prototype.getIndexOf  = function() {
		var index = -1;
		if(arguments.length > 0)
		for(var i = 0; i < this.length; i++)
			if(this[i] == arguments[0]) {
				index = i;
				break;
			}
		return index;
    }
}
function powl() {
}
// Body onload utility (supports multiple onload functions)
powl.gSafeOnload = new Array();
powl.SafeAddOnload=function(f) {
	isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;
	NS4 = (document.layers) ? true : false;
	IEmac = ((document.all)&&(isMac)) ? true : false;
	IE4plus = (document.all) ? true : false;
	IE4 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 4.")!=-1)) ? true : false;
	IE5 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 5.")!=-1)) ? true : false;
	ver4 = (NS4 || IE4plus) ? true : false;
	NS6 = (!document.layers) && (navigator.userAgent.indexOf('Netscape')!=-1)?true:false;

	if (IEmac && IE4) { // IE 4.5 blows out on testing window.onload
		window.onload = powl.SafeOnload;
		powl.gSafeOnload[gSafeOnload.length] = f;
	} else if  (window.onload) {
		if (window.onload != powl.SafeOnload) {
			powl.gSafeOnload[0] = window.onload;
			window.onload = powl.SafeOnload;
		}
		powl.gSafeOnload[powl.gSafeOnload.length] = f;
	} else
		window.onload = f;
}
powl.SafeOnload=function() {
	for (var i=0;i<powl.gSafeOnload.length;i++)
		powl.gSafeOnload[i]();
}
powl.setCookie=function(name, value, expire) {
	var duration = 700;
	var today = new Date()
	var defaultExpire = new Date()
	defaultExpire.setTime(today.getTime() + 1000*60*60*24*duration)
	var currentCookie = name + "=" +
		escape(value) +
		((expire == null) ?
			("; expires=" + defaultExpire.toGMTString()) :
			("; expires=" + expire.toGMTString()));
	document.cookie = currentCookie;
}
powl.getCookie=function(name) {
	var prefix = name + "="
	var cookieStartIndex = document.cookie.indexOf(prefix)
	if (cookieStartIndex == -1)
		return null
	var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
	if (cookieEndIndex == -1)
		cookieEndIndex = document.cookie.length
	return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}
