// necessary for HTML validation since apparently GET Attributes don't validate (?)
function val(s) {

	if (s == "html") window.open("http://validator.w3.org/check?uri=http%3A%2F%2Fwww.theoriginalrealdeal.com%2F&charset=%28detect+automatically%29&doctype=Inline&group=0");
	else if (s == "css") window.open("http://jigsaw.w3.org/css-validator/validator?uri=http%3A%2F%2Fwww.theoriginalrealdeal.com%2F&profile=css3&usermedium=all&warning=1&vextwarning=&lang=en");

	}

function swap(i,s) {

	document.getElementById(i).src = s;

	}

function appendCorners() {

	imgURL = "img/design/corner.png";
	imgALT = "corner";
	imgHeight = 20;
	imgWidth = 20;

	el = document.getElementsByTagName("DIV");
	matchingElements = [];
	matchingClasses = ["container"];
	for (i=0;i<el.length;i++) {

		for (j=0;j<matchingClasses.length;j++) {

			if (el[i].className == matchingClasses[j]) {

				matchingElements.push(el[i]);

				}

			}

		}

	if (matchingElements.length > 0) {

		for (i=0;i<matchingElements.length;i++) {

			w = (matchingElements[i].offsetWidth+(parseInt(window.getComputedStyle(matchingElements[i],null).getPropertyValue("width"))/2))+"px";
			h = (window.getComputedStyle(matchingElements[i],null).getPropertyValue("bottom"))+"px";

			id = Math.random();
			fx.makeElement({

				elementType		:	'img',
				elementParent	:	matchingElements[i],
				styles			:	{

					position	:	'absolute',
					left		:	w,
					top			:	h

					},

				attr			:	{

					src			:	imgURL,
					alt			:	imgALT,
					id			:	id

					}

				});

			}

		}

	}

function snagEmail() {

	u = "andy@";
	u+= "theoriginalrealdeal";
	u+= ".com";

	location.href="mailto:"+u;

	}

function alignBars() {

	barLeft = document.getElementById("bar_left");
	barLeft.style.left = ((document.body.offsetWidth)/2)-300+"px";
	barLeft.style.top = "10px";

	barRight = document.getElementById("bar_right");
	barRight.style.left = ((document.body.offsetWidth)/2)+300+"px";
	barRight.style.top = "10px";


	}

refridgerator = {

	start : function() {

		if (document.getElementById("boom_goes_the_crown")) {

			document.getElementById("boom_goes_the_crown").parentNode.removeChild(document.getElementById("boom_goes_the_crown"));

			}

		x = document.createElement("img");
		x.setAttribute("id","boom_goes_the_crown");
		x.alt = "Boom goes the crown!";
		x.src = "/img/design/crown.png";
		x.style.position = "absolute";

		l = (((document.body.clientWidth)/2)-475)+"px";
		x.style.left = l;
		x.style.top = "0px";
		document.body.appendChild(x);
		scrollTo(0,0);
		system.addEvent(window,"resize",function() {

			refridgerator.start();

			});

		}

	}

television = {

	start : function() {

		killTV = function() {

			try {

				document.body.removeChild(document.getElementById('teevee'));

				}

			catch(e) {

				//alert(e);

				}

			}

		if (document.getElementById("teevee")) killTV();

		dir = "img/tv/";
		imgs = ['place_holder.gif'];
		img = dir+imgs[0];
		id = "teevee";
		fx.makeElement({

			elementType		:	'img',
			elementParent	:	document.getElementById('tv_hide_div'),
			html			:	'',
			attr			:	{

				src			:	img,
				alt			:	'teevee',
				id			:	id

				},

			styles			:	{

				position	:	'fixed',
				right		:	'66px',
				bottom		:	'17px',
				width		:	'116px',
				height		:	'108px',
				zIndex		:	'0'

				},

			events			:	{

				mouseout	:	killTV

				}

			});

		}

	}

function autoComplete() {

	el = document.getElementsByTagName("INPUT");
	for (i=0;i<el.length;i++) {

		t = el[i].getAttribute("type").toLowerCase();
		if (t == "text" || t == "password") {

			el[i].setAttribute("autocomplete","off");

			}

		}

	}

function preloadImages() {

	if (document.images) {

		imgSet =	['img/icons/permanent.png',
					'img/icons/facebook.png',
					'img/logos/news_on.png',
					'img/logos/archives_on.png',
					'img/logos/art_on.png',
					'img/logos/poetry_on.png',
					'img/logos/webdev_on.png',
					'img/logos/links_on.png',
					'img/design/fridge_on.png',
					'img/design/tv_on.png'];

		fakeImg = new Image();
		for (i=0;i<=imgSet.length;i++) {

			fakeImg.src = imgSet[i];
			system.console.log("preloading image "+imgSet[i]);

			}

		}

	}

system.addEvent(window,"load",function() {

	setTimeout("preloadImages();",500);
	system.console.log("window.onload set to preloadImages()");

	});
