/**************************************/
/*              core.js               */
/*     Written by: Chester Potter     */
/*         Chetpot@gmail.com          */
/*      http://chesterpotter.com      */
/*                                    */
/**************************************/
Init=[];
function addInit(func,args){
	if(arguments.length>1){
		var arg='';
		for(i=1;i<=(arguments.length-1);i++){
			arg+='"'+arguments[i]+((i!=arguments.length-1)?'",':'"')
		}
			eval('Init['+Init.length+']=function(){'+func+'('+arg+')}');
	}
	else Init[Init.length]=eval(func);
}
function getBrowser(){
	var ua=navigator.userAgent.toLowerCase();
	ie=(ua.indexOf('msie')>-1&&ua.indexOf('opera')==-1)?ua.slice(ua.indexOf('msie')+5,ua.indexOf('msie')+8):false;
	ff=(ua.indexOf('firefox')>-1)?ua.slice(ua.indexOf('firefox')+8,ua.indexOf('firefox')+11):false;
	sf=(ua.indexOf('safari')>-1&&ua.indexOf('version')!=-1)?ua.slice(ua.indexOf('version')+8,ua.indexOf('version')+11):false;
	op=(ua.indexOf('opera')>-1)?ua.slice(ua.indexOf('opera')+6,ua.indexOf('opera')+9):false;
	out=((ie)?'Internet Explorer '+ie:'')+((ff)?'Firefox '+ff:'')+((sf)?'Safari '+sf:'')+((op)?'Opera '+op:'');
	return out;
}
browser=getBrowser();
if(ie){
	navigator.language=navigator.userLanguage;
	document.namespaces.add("v", "urn:schemas-microsoft-com:vml");
	function assignIE(method){
		for(i=0;i<document.all.length;i++){
			eval('document.all['+i+'].'+method+'='+eval(method));
		}
	}
	function getElementsByClassName(x){
		var j=0;
		var out=new Array();
		var temp=this.getElementsByTagName('*');
		for(i=0;i<temp.length;i++){
			if(temp[i].getAttribute('className') && temp[i].getAttribute('className')==x){
				out[j]=temp[i];
				j++;
			}
		}
		return out;
	}
	document.getElementsByClassName=getElementsByClassName;
	addInit('assignIE','getElementsByClassName');
}
String.prototype.x=function(x){
	if(arguments.length==0)return this;
	if(x<=0)return this;
	var out='';
	for(i=0;i<x;i++){
		out+=this;
	}
	return out;
}
function loadFrame(id,uri,name,style) { 
	var f=document.getElementById(id);
	var b=document.getElementsByTagName("body")[0];
	if(f){ 
		b.removeChild(f); 
	}
	f=document.createElement("iframe"); 
	var r=Math.round(Math.pow(10,8)*(Math.random()*Math.PI)); 
	f.setAttribute("src",uri + "#" +r);
	f.setAttribute("id",id);
	f.setAttribute("name",name);
	f.setAttribute("style",style);
	b.appendChild(f); 
}
function loadScript(id,uri) { 
	var s=document.getElementById(id);
	var h=document.getElementsByTagName("head")[0];
	if(s){ 
		h.removeChild(s); 
	}
	s=document.createElement("script"); 
	var r=Math.round(Math.pow(10,8)*(Math.random()*Math.PI)); 
	s.setAttribute("src",uri + "#" +r); 
	s.setAttribute("id",id); 
	h.appendChild(s); 
}
function TABS(num){
	t=new Array();
	t[0]='';
	for(i=1;i<num+1;i++){
		var tbs='\t'.x(i);
		t[i]=tbs;
	}
}
TABS(40);
function center(who,id){
	if(typeof(who)=='string'){
		return '<div class="c1"><div class="c2"><div class="c3">'+who+'</div></div></div>';
	}
	else{
		var CLASS=(!ie)?'class':'className';
		for(i=1;i<4;i++){
			eval('var c'+i+'=document.createElement("div")');
			eval('c'+i+'.setAttribute("'+CLASS+'","c'+i+'")');
			if(i>1)eval('c'+(i-1)+'.appendChild(c'+i+')')
			if(i==3)c3.appendChild(who)
		}
		if(id)c1.setAttribute('id',id);
		return c1;
	}
}
loading={
	loaded:false,
	current:[],
	interval:75,
	position:0,
	size:100,
	image:'img/loading.png',
	load:function(){
		this.max=this.size*-15
		this.img=new Image();
		this.img.src=this.image;
		this.img.onload=function(){
			loading.loaded=true;
		}
	},
	start:function(where,center){
		var id='loading'+this.current.length.toString();
		var e=(!where)?document.getElementsByTagName('body')[0]:document.getElementById(where);
		var i='<img id="loader" border="none" src="img/x.gif" alt="loading..." style="position:relative;top:0px;left:0px'+(ie?';filter:progid:DXImageTransform.Microsoft.AlphaImageLoader':'')+'">';
		var l=document.createElement('div');
		l.style.overflow='hidden';
		l.style.position='relative';
		l.style.height=this.size+'px';
		l.style.width=this.size+'px';
		l.innerHTML=i;
		if(!center){
			l.setAttribute('id','loading');
			e.appendChild(l);
		}
		else{
			var CLASS=(!ie)?'class':'className';
			for(i=1;i<4;i++){
				eval('var c'+i+'=document.createElement("div")');
				eval('c'+i+'.setAttribute("'+CLASS+'","c'+i+'")');
				if(i>1)eval('c'+(i-1)+'.appendChild(c'+i+')')
				if(i==3)c3.appendChild(l)
			}
			c1.setAttribute('id','loading');
			e.appendChild(c1);
		}
		if(this.loaded)document.getElementById('loader').src=this.img.src;
		setTimeout('loading.animate()',this.interval);
	},
	animate:function(){
		document.getElementById('loader').style.left=(this.position-this.size).toString()+'px';
		if(this.position-this.size==this.max)this.position=0
		else this.position=this.position-this.size;
		this.timeout=setTimeout('loading.animate()',this.interval)
	},
	stop:function(where,when){
		var e=(!where)?document.getElementsByTagName('body')[0]:document.getElementById(where);
		clearTimeout(loading.timeout);
		e.removeChild(document.getElementById('loading'));
	}
}
loading.load();

addInit('zofiaart.load');
window.onload=function(){
	if(Init.length>0){
		var j=0;
		for(i=0;i<Init.length;i++){
			Init[i]();
			i=j;
			j++;
		}
	}
	Init=null;
}
