/**
 * @copyright  Copyright (c) 2007 August Ash Inc. (http://www.augustash.com)
 * @version    $Id: aailib.js 22 2008-06-03 20:59:10Z bcoyour $
 */

/**
 * Prepare Links - using jQuery
 * 
 * Checks the document, when ready, for all link nodes with a class
 * name "external" and opens them in a new window when clicked.
 */
$(document).ready(function(){
	$("a").filter(".external").click(function (){
		var NewWindow = new OpenWindow($(this).attr("href"));
		return NewWindow.open();
	})
    .end();
});

$(document).ready(function(){
	$("a").filter(".serviceButton").click(function (){
		if ($("#service-times").is(":hidden")) {
			$("#service-times").slideDown("slow");
			$(".serviceButton").css({ "background-image":"url(/img/tpl/service-times/btn_service-times-on.png)" });
		  } else {
			$("#service-times").slideUp();
			$(".serviceButton").css({ "background":"none" });
		  }
		  return false;
	})
    .end();
});

/**
 * Rotate
 * http://www.htmldog.com/
 */
function timedSplash(){
	var one = setTimeout("rotate(2);",8000);
	var two = setTimeout("rotate(3);",16000);
	var three = setTimeout("rotate(4);",24000);
	var four = setTimeout("rotate(5);",32000);
	var five = setTimeout("rotate(1);",40000);
	var five = setTimeout("timedSplash();",48000);
}

function rotate(number){
		$(".splash").fadeOut("slow", function () {
        	$(".splash").css({ "background-image":"url(/img/tpl/bg_main-splash0" + number + ".jpg)" });
			$(".splash").fadeIn("slow");
      	});
		$(".splash").css({ "cursor":"pointer" });
		$(".splash").click(function (){
			var newUrl = $(".number0" + number +" a").attr("href");
			window.location = (newUrl);							 
		});
		if (number == 1) {
			$(".number02 a, .number03 a, .number04 a, .number05 a").css({ "background":"none" })
			$(".number0" + number + " a").css({ "background":"url(/img/tpl/fave5/btn_" + number + "-on.jpg) no-repeat top left" })
		} else {
			$(".number0" + number + " a").css({ "background":"url(/img/tpl/fave5/btn_" + number + "-on.jpg) no-repeat top left" })
		}
}

/**
 * OpenWindow Class
 * 
 * Creates an OpenWindow object that allows you to define the URL, 
 * window name, and features for firing a pop-up window.
 * 
 * @param {String} href
 */
function OpenWindow(href)
{
	// Set default values
	var _href     = href;
	var _name     = "external";
	var _features = "";
	
	function __construct() {
		// Define methods		
		this.getHref     = function() { return _href; }
		this.setHref     = function(href) { _href = href; }
		this.getName     = function() { return _name; }
		this.setName     = function(name) { _href = name; }
		this.getFeatures = function() { return _features; }
		this.setFeatures = function(features) { _features = features; }
		
		this.open = function() {
			window.open(_href, _name, _features);
			return false;
		}
	};
	
	return new __construct();
}

/**
 * Son of Suckerfish Drop Down Menu
 * http://www.htmldog.com/
 */
$(document).ready(function(){
	var sfEls = $("ul#nav li");
	for (var i = 0; i < sfEls.length; i++) {
		$(sfEls[i]).mouseover(function(){
			$(this).addClass("sfhover");
		});
		$(sfEls[i]).mouseout(function(){
			$(this).removeClass("sfhover");
		});
	}
});