/////////////////////////////////////
//		Global Variables
/////////////////////////////////////
var domain_name = ['http://', location.host].join('');
var wp_root = '/betasite/';
var site_root = 'wp-content/themes/soupergirl/';
var page_path = location.href.replace(domain_name,'');
var loader_image = [domain_name, wp_root, site_root, 'images/loader.gif'].join('');
var loader = ['<div class="loaderbox"><image src="', loader_image, '" height="55" width="54" /></div>'].join('');
var today = new Date();
var navTimers = [];

// Break out of any frames that may try to wrap this page.
if (top.location != location) {
	top.location.href = document.location.href;
}

/////////////////////////////////////
//		Initialize page functions
/////////////////////////////////////
$(document).ready(function() {
	// preload loader
	$(['<img src="', loader_image, '" />'].join(''));
	// Preload all rollovers
	$.each($("a.imgrollover"), function() { $(['<img src="', $(this).children('img').attr('src').replace(/(\.[^.]+)$/, '_over$1'), '" />'].join('')); });
	// Set rollovers
	$("a.imgrollover").live('mouseover', function() { // the over state
		$(this).children('img').attr('src', $(this).children('img').attr('src').replace(/(\.[^.]+)$/, '_over$1'));
	});
	$("a.imgrollover").live('mouseout', function() { // the out state
		$(this).children('img').attr('src', $(this).children('img').attr('src').replace(/_over(\.[^.]+)$/, '$1'));
	});
	// Set form fields with erasecontent class to empty on focus and fill from alt if empty on losing focus
	$(".erasecontent").bind("focus", function () { $(this).val('') });

	$('#menu > ul > li > a').parent('li').hover(
		function () {
			$(this).addClass('menuover');
			$(this).children('ul').fadeIn(300);
		},
		function () {
			$(this).removeClass('menuover');
			$(this).children('ul').fadeOut(200);
		}
	);

	$('#tabs').tabs();

});

/////////////////////////////////////
//		Functions
/////////////////////////////////////
jQuery.fn.wait = function(time, type) {
	time = time || 1000;
	type = type || "fx";
	return this.queue(type, function() {
		var self = this;
		setTimeout(function() {
			$(self).dequeue();
		}, time);
	});
};