var onLoad = '';

function appendOnLoad(js) {
	onLoad = onLoad + js;
}

window.onload = function() {
	eval(onLoad);
}

function styleForms() {
	var esi = document.getElementsByTagName('input');
	var est = document.getElementsByTagName('textarea');
	for (var i = 0; i < esi.length + est.length; i++) {
		var e = (i < esi.length ? esi[i] : est[i - esi.length]);
		var type = (i < esi.length ? (ie ? e.type : e.getAttribute('type')) : '').toLowerCase();
		if (i >= esi.length || type == 'text' || type == 'password') {
			e.onfocus = function() { this.className = 'focus'; }
			e.onblur = function() { this.className = ''; }
		}
	}
}

function polaroid() {
	var p1 = new Image();
	p1.src = STATICURL + 'img/polaroid1.jpg';
	var p2 = new Image();
	p2.src = STATICURL + 'img/polaroid2.jpg';
	var p3 = new Image();
	p3.src = STATICURL + 'img/polaroid3.jpg';
	var p4 = new Image();
	p4.src = STATICURL + 'img/polaroid4.jpg';
	document.getElementById('polaroid').innerHTML = '<img src="' + p1.src + '" alt="" /><img src="' + p2.src + '" alt="" /><img src="' + p3.src + '" alt="" /><img src="' + p4.src + '" alt="" />';
	$('#polaroid').cycle({ fx: 'fade', speed: 800, timeout: 3000 });
	$('#a-row1-left').hover( function() { $('#bg-row1-left').fadeIn('fast'); }, function() { $('#bg-row1-left').fadeOut('slow'); } );
	$('#a-row1-right').hover( function() { $('#bg-row1-right').fadeIn('fast'); }, function() { $('#bg-row1-right').fadeOut('slow'); } );
	$('#a-row2-left').hover( function() { $('#bg-row2-left').fadeIn('fast'); }, function() { $('#bg-row2-left').fadeOut('slow'); } );
	$('#a-row2-right').hover( function() { $('#bg-row2-right').fadeIn('fast'); }, function() { $('#bg-row2-right').fadeOut('slow'); } );
}

function cycle(idfrom, idto) {
	var from = document.getElementById(idfrom);
	var to = document.getElementById(idto);
	from.style.zIndex = 1;
	to.style.zIndex = 2;
	for (var i = 1; i <= 800; i++) {
		setTimeout('setopacity(\'' + idfrom + '\', ' + (i / 800) + ')', i);
	}
}

function setopacity(id, o) {
	document.getElementById(id).style.opacity = o;
}