window.onload = function () {
	if( arguments.callee.actions){
		for(var ii=0;ii < arguments.callee.actions.length;ii++){
			if(typeof arguments.callee.actions[ii] === "function"){
				arguments.callee.actions[ii]();
			}		
		}
	}
};

function addLoadEvent(func){
	if(window.onload.actions === undefined)window.onload.actions = Array();
	window.onload.actions.push(func);
}

if (typeof addLoadEvent == 'function'){
	addLoadEvent(function(){
		//
	});
}

function openWindow(theURL,winName,features) {
  var base = $$('base').first();
  theURL = base.href+theURL;
  popup = window.open(theURL,winName,features);
  popup.focus();
}

if (Object.isUndefined(NVB)) { var NVB = { } }

NVB.load = Class.create({
	initialize: function(options) {
		this.scripts = options.scripts || new Array();
		this.onload_events = options.onload || new Array();
		this.additional_css = options.css || new Array();
		
		this.path = options.path || 'www/js/';
		this.css_path = options.css_path || 'www/css/';
		this.google = options.google_analytics || false;
		this.events = {
			onload: this.onload.bind(this)
		}
		
		this.include();
		if(this.onload_events || this.google)document.observe('dom:loaded', this.events.onload);
	},
	addLoadEvent:function(func){
		this.onload_events.push(func);
	},
	onload: function(){
		if(Object.isArray(this.onload_events)){
			this.onload_events.each(
				function(s){
					if(Object.isFunction(s))s();
					else eval(s);
				}
			);
		}else if(Object.isFunction(this.onload_events)){
			this.onload_events();
		}
		if(this.google){
			var pageTracker = _gat._getTracker(this.google);
			pageTracker._initData();
			pageTracker._trackPageview();
		}
	},
	include: function(){
		this.scripts.each( function(s){
			if(s.indexOf('www') == -1) document.write('<script type="text/javascript" src="'+this.path+s+'"><\/script>');			
			else document.write('<script type="text/javascript" src="'+s+'"><\/script>');			
		}.bind(this));
		this.additional_css.each( function(s){
			if(s.indexOf('www') == -1) document.write('<link rel="stylesheet" href="'+this.css_path+s+'" type="text/css" media="screen" />');
			else document.write('<link rel="stylesheet" href="'+s+'" type="text/css" media="screen" />');			
		}.bind(this));

		if(this.google){
			document.write('<script type="text/javascript" src="http://www.google-analytics.com/ga.js"><\/script>');
		}
	}
});

function init(){
	if($$('ul.portfolio_list').first()){
		porto = new NVB.portfolio();
	}
}
new NVB.load({
	onload:new Array(
		init
	),
	scripts: new Array(
		'portfolio.js',
		'supersleight.js',
		'lightbox/js/builder.js',
		'lightbox/js/effects.js',
		'lightbox/js/lightbox.js'
		//,'sifr.js'
	),
	css_path: 'www/',
	css: new Array(
		'js/lightbox/css/lightbox.css'
	)
	//,google_analytics: "UA-4059529-1"
});

