
window.isIE=window.navigator.appVersion.indexOf('MSIE')!=-1;
window.isSafari=window.navigator.appVersion.indexOf('Safari')!=-1;

if (typeof(String.trim)=='undefined') String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,'')}
String.prototype.pathEnd=function(){var e=this.split('?')[0].split('#')[0].split('/');return e[e.length-1]}
String.prototype.pathFront=function(p){var e=this.pathEnd().length;return this.split('?')[0].split('#')[0].substr(0,this.length-e-1)}
String.prototype.trimSlash=function(){return this.replace(/^\/+|\/+$/g,'')}
String.prototype.trimEndSlash=function(){return this.replace(/\/+$/,'')}

function aaPath() {
	try {
		var o = '';
		var a = aaPath.arguments;
		if (a.length) o = a[0].trimEndSlash();
		for (var i=1;i<a.length;i++) if (a[i]) o += (o?'/':'') + a[i].trimSlash();
		return o;
	} catch (ex) {
		var ot = '';
		for (var i=0;i<a.length;i++) ot += a[i]+',';
		alert(ot);
		throw ex;
	}
}

if(typeof Array.prototype.zap=="undefined"){Array.prototype.zap=function(idx){var l=this.length;if(idx<l&&idx>=0){var i=0;var j=0;while(j<l){if(j==idx)i--;else this[i]=this[j];i++;j++;}this.length=l-1;}}}
if(typeof Array.prototype.has=="undefined"){Array.prototype.has=function(v){for(var i=0;i<this.length;i++)if(this[i]==v)return true;return false}}
if(typeof Array.prototype.add=="undefined"){Array.prototype.add=function(h){var l=this.length;this[l]=h;return l}}

function aaEvent(e) {if(typeof(e)=='undefined'&&typeof(window.event)!='undefined')return window.event;return e}
function aaFn(o,f) {return function(a,b,c){return o[f](a,b,c)}} // Function args come from the calling framework
function aaCall(o,f,a,b,c) {return function(){return o[f](a,b,c)}} // Function args come from the function creator
function aaFnpt(o,f) {return function(a,b,c){return o[f](this,a,b,c)}}
function aaEv(o,f,a,b,c) {return function(e){return o[f](this,aaEvent(e),a,b,c)}}
function aaNada(){}
function aaWidth(o){return o.offsetWidth||o.clientWidth}
function aaHeight(o){return o.offsetHeight||o.clientHeight}


function aaU() {
	var d = new Date();
	window.myUni = 0;
	window.myU1 = Date.UTC(d.getUTCFullYear(),d.getUTCMonth()+1,d.getUTCDate(),d.getUTCHours(),d.getUTCMinutes(),d.getUTCSeconds(),d.getUTCMilliseconds());
}
aaU();
function aaUni() {return myU1+'.'+(++myUni)}

window.myObjects=new Object();
function aaRegister(f,n,a,b,c) {if(!window[n]){log.trace('registered',n);myObjects[n]=new f(a,b,c);window[n]=myObjects[n]}}

function aaDoScript(u,tg) {
	dbg.trace('aaDoScript',u);
	var scp = document.createElement('script');
	scp.setAttribute('language',"JavaScript");
	document.getElementsByTagName(tg||'body')[0].appendChild(scp);
	scp.setAttribute('src',u);
}

function aaSetCookie(nn,vv,dd,path) {
	var ck = nn + '=' + escape(vv);
	if (dd && dd > 0) {
		var date = new Date();
		date.setTime(date.getTime() + (dd * 86400000));
		ck += '; expires=' + date.toGMTString();
	}
	ck += '; path=' + (path || '/');
	document.cookie = ck;
}
function aaClearCookie(nn,path) {
	var date = new Date();
	date.setTime(date.getTime()-(3000*24*60*60*1000));
	ck = nn + '=; expires=' + date.toGMTString();
	ck += '; path=' + (path || '/');
	document.cookie = ck;
}
function aaGetCookie(name) {
	return unescape(aaReadRawCookie(name,document.cookie));
}
function aaReadRawCookie(nm,ck) {
	var ar,ln,nl,i;
	nm += '=';
	if (ck) ar = ck.split(';');
	else ar = new Array();
	ln = ar.length;
	nl = nm.length;
	document.coCnt = ln;
	for (i=0;i<ln;i++) {	// clip any leading space
		while (ar[i].charAt(0) == ' ') ar[i] = ar[i].substr(1);
	}
	for (i=0;i<ln;i++) {
		if (ar[i].substr(0,nl) == nm) return ar[i].substr(nl);
	}
	return '';
}
function aaEndEvent(e) {
	e = aaEvent(e);
	e.returnValue = false;
	e.cancelBubble = true;
	e.cancel = true;
	if (e.preventDefault) e.preventDefault();
	if (e.stopPropagation) e.stopPropagation();
	return false;
}

function aaFileName() {
	var p = document.location.pathname.split('/');
	return p[p.length-1];
}

function aaLoadCss(url) {
	var css = document.createElement('link');
	css.setAttribute('rel',"stylesheet");
	css.setAttribute('type',"text/css");
	css.setAttribute('href', url);
	document.getElementsByTagName('head')[0].appendChild(css);
}

function aaIDoc(f) {
	var w = f.contentWindow || f.contentDocument;
	if (w.document) return w.document;
	return null;
}

function aaIDocHTML(f) {
	var d = aaIDoc(f);
	if (d && d.body) return d.body.innerHTML;
	return null;
}

function aaExtend(sC,bC) {
	function iH(){};
	iH.prototype = bC.prototype;
	sC.prototype = new iH();
	sC.prototype.constructor = sC;
	sC.bCC = bC;
	sC.bC = bC.prototype;
	sC.prototype.baseCall = function(n,a,b,c,d,e) {this.bC[n].call(this,a,b,c,d,e)};
	sC.prototype.baseConstruct = function(t,a,b,c,d,e) {sC.bCC.call(this,a,b,c,d,e)};
}

// Default debug handler
function aaDbg() {window.myDbgTrc=''}
aaDbg.prototype.ex=function(n,v){dbg.trace('EX:'+n,v)}
aaDbg.prototype.warn=function(n,v){dbg.trace('WARN:'+n,v)}
aaDbg.prototype.dump=function(o){dbg.trace('DUMP:'+o)}
aaDbg.prototype.trace=function(n,v){myDbgTrc=escape(n)+(v!==undefined?'='+escape(v):'')+'\r\n'+myDbgTrc}
aaDbg.prototype.error=function(n,v){alert(n+"="+v)}
aaDbg.prototype.autovar=function(vtx){dbg.trace('VAR:'+vtx)}
aaDbg.prototype.clear=function(){myDbgTrc=''}
window.log=new aaDbg();
window.dbg=log;


