// JavaScript Document

var quotes = new Array("quote1.png", "quote2.png", "quote3.png", "quote4.png", "quote5.png");
var quote_pointer = 0;
var layer_pointer = 2;
var quote_interval = 5000;
var quote_zindex = 100;
$(document).ready(function(){
	$(document).pngFix();
	$.preloadImages = function() {
		for(var i = 0; i<arguments.length; i++) {
			$("<img>").attr("src", arguments[i]);
		}
	}	
	$("a.coming-soon").click(function(){
			alert("Coming Soon!");
			return false;
	});
	$(".rollover").each(function() {
		if ($(this).attr("src")) {
		if($(this).attr("src").indexOf(".gif") != -1) {
					var newSrc = $(this).attr("src").replace(".gif","-over.gif");
					
				} else if($(this).attr("src").indexOf(".jpg") != -1) {
					var newSrc = $(this).attr("src").replace(".jpg","-over.jpg");
					
				} else if($(this).attr("src").indexOf(".png") != -1) {
					var newSrc = $(this).attr("src").replace(".png","-over.png");
					
				}	
				$.preloadImages(newSrc);
		}
									  
	});
	
	$.makeQuote = function() {
		var image = $("<img />", {"src": "images/quotes/" + quotes[quote_pointer], "height": 100, "width": 430}).addClass("quote").attr("id", "quote-" + layer_pointer);
		layer_pointer++;
		quote_pointer++;
		if (quote_pointer >= quotes.length) {
			quote_pointer = 0;
		}
		return image;
	}
	$.quoteRotate = function(){
		var image = $.makeQuote().hide();
		$('#hx_quotes').append(image);
		var id = $(image).attr("id");
		$(image).bind("load", function() {
			$(".quote").each(function(){
				if ($(this).attr("id") != id) {
					$(this).fadeOut(3000, function(){$(this).remove()});
				}
			});
			$(this).fadeIn(3000, function(){
			setTimeout('$.quoteRotate()', quote_interval);
			});
		});
	}
	$('#hx_quotes').each(function(){
		var image = $.makeQuote();
	//	$(this).append($(image));
		setTimeout('$.quoteRotate()', quote_interval);
	});
	
	$(".rollover").hover(
		function(){
			if($(this).attr("src").indexOf("-active") == -1 && $(this).attr("src").indexOf("#sticky") == -1) {
				if($(this).attr("src").indexOf(".gif") != -1) {
					var newSrc = $(this).attr("src").replace(".gif","-over.gif");
					$(this).attr("src",newSrc);
				} else if($(this).attr("src").indexOf(".jpg") != -1) {
					var newSrc = $(this).attr("src").replace(".jpg","-over.jpg");
					$(this).attr("src",newSrc);
				} else if($(this).attr("src").indexOf(".png") != -1) {
					var newSrc = $(this).attr("src").replace(".png","-over.png");
					$(this).attr("src",newSrc);
				}
			}
		},
		function(){
			if($(this).attr("src").indexOf("-over.gif") != -1) {
				var oldSrc = $(this).attr("src").replace("-over.gif",".gif");
				$(this).attr("src",oldSrc);
			} else if($(this).attr("src").indexOf("-over.png") != -1) {
				var oldSrc = $(this).attr("src").replace("-over.png",".png");
				$(this).attr("src",oldSrc);
			} else if($(this).attr("src").indexOf("-over.jpg") != -1) {
				var oldSrc = $(this).attr("src").replace("-over.jpg",".jpg");
				$(this).attr("src",oldSrc);
			}
		}
	);
});

function pop_window(u, w, h, n) {
	var dimensions = "width=" + w + ",height=" + h + ",scrollbars=0";
	window.open(u ,"pop" + n,dimensions);
	
}
function pop_window_scroll(u, w, h, n) {
	var dimensions = "width=" + w + ",height=" + h + ",scrollbars=1";
	window.open(u ,"pop" + n,dimensions);
	
}
