/* #############################################################################
# LEGAL:
# All technical material (specificaly the PHP, CSS, JS, code documentation, 
# configs and htaccess) in this website was indepentantly created by 
# Owen Beresford, with his own resources.
# The page structure and template system is an original work of Owen Beresford, 
# designed indepentantly with his own resources.
# All this was built without reference to any companies intellectual property.
#  
# All this is released for general use in websites under the terms of the 
# perl artistic licence.
# The complete terms of this licence may be found at
# http://dev.perl.org/perl6/rfc/346.html
# or typing
# `man perlartistic'
# in a any usefull shell.
############################################################################*/


function list2array()
{{{
	if((arguments.length%2)!=0)			{ return false;	}
	var tt=new Array();
	var LENGTH=arguments.length;
	for( var x=0; x< LENGTH; x+=2)		{ tt[arguments[x]]=arguments[x+1]; }
	return tt;
}}}

function trim(STRraw)
{{{
	var Start=0,Stop=STRraw.length;
	for(var i=0;i<Stop;i++)
	{
		var CHRtemp=STRraw.charAt(i);
		if(CHRtemp<=' ')				Start++;
		else							break;
	} 

	var Max=Stop-1;//array boundary thingie
	for(var i=Max;i>Start;i--)
	{
		var CHRtemp=STRraw.charAt(i);
		if(CHRtemp<=' ')				Stop--;
		else							break;
	}
	return STRraw.substring(Start,Stop);
}}} 

function obj2alert(obj)
{{{
	var buf="";
	var count=0, batch=0;
	for (var i in obj)			
	{
		buf+="["+i+"]='"+obj[i]+"'\n";
		count++;
		if(count>10) {
			alert("{{batch "+batch+"}}\n"+buf);
			count=0;
			batch++;
			buf="";
		}
	}
	alert("{{batch "+batch+"}}\n"+buf);
	return true;
}}}

function $loadqueue(f,pos)
{{{
	if(pos) 
		window._loadqueue[pos]=f;
	else
	{
		window._loadqueue[window._loadqueue[0]]=f;
		window._loadqueue[0]++;
	}
}}}

function $iterqueue()
{{{
	var $LEN=window._loadqueue.length;
	for($i=1;$i<$LEN;$i++)
	{
		if(window._loadqueue[$i]!="")
		{
			try				{ eval(window._loadqueue[$i]); }
			catch(e)		{ window.log("load queue loading error: "+e); }
		}
	} 
}}}

function $log1(msg)
{{{
	if(window.log_buffer)				{ window._msg+=msg+"\n"; }
	else
	{
		alert(window._msg+msg); 
		window._msg="";
	}
	return false;
}}}

function $log2(msg, id)
{{{
// ignore the buffer
	if(!id)								{ id='formerrors'; }
	var $t=window.get(id);
	$t.style.display='block';
	if(msg)								{ $t.innerHTML+="<li>"+msg+"</li>"; }
}}}

//as taken from 
////http://www.siteexperts.com/tips/contents/ts16/page3.asp?main=on
function $ie_getElementsByTagName(tag) 
{{{
	if (tag=="*")						{ return document.all; } 
	else								{ return document.all.tags(tag); }
}}}

function $getAttribute_o($name) 
{{{
	var $re=new RegExp('^.+?'+$name+'="([^\'"]+)".+$');
	var $html=this.outerHTML.toString();
	var $result=$html.match($re);
	if($result)
		return $result[0];
	else 
		return null;
 }}}

function $getAttribute_msie($name)
{{{
	return this[$name];
}}}

function $getElementById($id)
{{{
//WARN: add auto-clever for lamer browsers
	var $tmp=document._getElementById($id);
// intentionally pass-through exceptions
	if(window.opera)				{ $tmp.getAttribute=$getAttribute_o; }
	if(document.expando)			{ $tmp.getAttribute=$getAttribute_msie;	}
// XXX IOIO more to be added
	return $tmp;
}}}


if(!window.core)
{
	window.core=1;

// configure later
// put a switch, 
// PHP side config for site
	window.log=$log2;
	window.log_buffer=0;
	window._msg="";

	window.loadqueue=$loadqueue;
	window._loadqueue=new Array();
	window._loadqueue[0]=1;

	document._getElementById=document.getElementById;
	document.getElementById=null;
	window.get=$getElementById;
/*
	if(!Node.ELEMENT_NODE) 
	{
		Node.prototype.ELEMENT_NODE=1;
		Node.prototype.ATTRIBUTE_NODE=2;
		Node.prototype.TEXT_NODE=3;
		Node.prototype.CDATA_SECTION_NODE=4;
		Node.prototype.ENTITY_REFERENCE_NODE=5;
		Node.prototype.ENTITY_NODE=6;
		Node.prototype.PROCESSING_INSTRUCTION_NODE=7;
		Node.prototype.COMMENT_NODE=8;
		Node.prototype.DOCUMENT_NODE=9;
		Node.prototype.DOCUMENT_TYPE_NODE=10;
		Node.prototype.NOTATION_NODE=11;
	}
*/

	if (document.expando)
	{
		document.getElementsByTagName=$ie_getElementsByTagName;
	}
	window.onload=$iterqueue;

	//ha; confused you!
	if(!undefined)						undefined;
	if(!null)							null;
	
} 
// vi: ts=4
// vim: syn=javascript sw=4 st=4 tw=4 fdm=marker
