var TeenBrain =
{
	start: function()
	{
	



		//do accordions
		Site.start();

		//fix ie7 eolas
		TeenBrain.fix_eolas_tags();
		

		//preload images
		var aPreLoad	= new Array();
		var aPreLoadi	= 0;

		//do rollover
		$$('img','input').each(function(el){

			if(el.hasClass('roll'))
			{
				//let's preload
				aPreLoad[aPreLoadi] = new Image();
				aPreLoad[aPreLoadi].src = el.src.replace(el.src.replace(/(\.[^.]*)$/, "_h$1"));
				aPreLoadi++;

				el.addEvent('mouseover',function(){
					this.setAttribute('src',this.src.replace(/(\.[^.]*)$/, "_h$1"));
				});

				el.addEvent('mouseout',function(){
				this.setAttribute('src',this.src.replace(/_h(\.[^.]*)$/, "$1"));

				});
			}
		});

		//external links
    	$$('a').each(function(el)
		{
			if(el.hasClass('external'))
			{
				el.setAttribute('target','teenbrain-external');
			}
			if(el.hasClass('t-print'))
			{

				el.addEvent('click',function(){
				if(window.webkit && !window.webkit420)
				{
					alert("For optimal printing in Safari, please reload page and open all toggles before printing.");
				}
				
				window.print();
				return false;
				});
			}
		});
		
		
		//memory clean up
		delete aPreLoad;

	},

	fix_eolas_tags: function()
	{
		$$('object','embed').each(function(el){

				//set parent object for brevity
				parentObj = el.parentNode;

				//grab the html inside of the element before removing it from the DOM
				newHTML = parentObj.innerHTML;

				//remove element from the DOM
				parentObj.removeChild(el);

				//stick the element right back in, but as a new object
				parentObj.innerHTML = newHTML;
		});
	}

};

// ---

window.addEvent('domready', TeenBrain.start);