// setup rel='external' to handle '_blank' style links
function externalLinks() {   
 if (!document.getElementsByTagName) return;   
 var anchors = document.getElementsByTagName("a");   
 for (var i=0; i<anchors.length; i++) {   
   var anchor = anchors[i];   
   if (anchor.getAttribute("href") &&   
	   anchor.getAttribute("rel") == "external")   
	 anchor.target = "_blank";   
 }   
}   
window.onload = externalLinks;	

// function for popup windows
function popUp(pURL,pWidth,pHeight) {
	window.open(pURL,"","width=" + pWidth + ",height=" + pHeight + ",resizable=yes,scrollbars=yes");	
}

jQuery.preloadImages = function()
{
	for(var i = 0; i<arguments.length; i++)
	{
		jQuery("<img>").attr("src", arguments[i]);
	}
}

$(document).ready(function(){

	// setup the support bar	
	$('#supportbar-button img').mouseover (function(){
		if ($('#supportbar-options').is(':hidden')) {
			$('#supportbar-options').slideDown('slow');
			$('#supportbar-button img').attr('src','/images/2010/support-bar-button-open.png');
		}
	});
	
	$(document).mousemove(function(e) { 
		if ($('#supportbar-options').is(':visible')) {								   
			if (e.pageY > 100) {
				$('#supportbar-options').slideUp('slow');
				$('#supportbar-button img').attr('src','/images/2010/support-bar-button-closed.png');
			}
		}
	});
	
	// setup services menu rollovers
	$('#menu-services ul li img').hover(
		function() { this.src = this.src.replace('-off','-on') },
		function() { this.src = this.src.replace('-on','-off') }
	);
	
	/*
	// setup popup menus
	$('#menu-services > ul > li').mouseenter(function(){
		$("ul",this).fadeIn('fast');
	}).mouseleave(function(){
		$("ul",this).fadeOut('slow');
	});
	// popup rollovers
	$('.popup > li').mouseenter(function(){
		$(this).css("background-image",$(this).css("background-image").replace("-off","-over"));
	}).mouseleave(function(){
		$(this).css("background-image",$(this).css("background-image").replace("-over","-off"));
	});
	*/
	
	// icon rollovers
	$('#mt1').hover (
		function() {$('#mt1 a img').attr('src','/images/2010/icon-home-over.gif')},
		function() {$('#mt1 a img').attr('src','/images/2010/icon-home.gif')}
	);
	$('#mt2').hover (
		function() {$('#mt2 a img').attr('src','/images/2010/icon-about-over.gif')},
		function() {$('#mt2 a img').attr('src','/images/2010/icon-about.gif')}
	);
	$('#mt3').hover (
		function() {$('#mt3 a img').attr('src','/images/2010/icon-support-over.gif')},
		function() {$('#mt3 a img').attr('src','/images/2010/icon-support.gif')}
	);
	$('#mt4').hover (
		function() {$('#mt4 a img').attr('src','/images/2010/icon-jobs-over.gif')},
		function() {$('#mt4 a img').attr('src','/images/2010/icon-jobs.gif')}
	);
	$('#mt5').hover (
		function() {$('#mt5 a img').attr('src','/images/2010/icon-links-over.gif')},
		function() {$('#mt5 a img').attr('src','/images/2010/icon-links.gif')}
	);
	$('#mt6').hover (
		function() {$('#mt6 a img').attr('src','/images/2010/icon-contact-over.gif')},
		function() {$('#mt6 a img').attr('src','/images/2010/icon-contact.gif')}
	);
	$('#mt7').hover (
		function() {$('#mt7 a img').attr('src','/images/2010/icon-admin-over.gif')},
		function() {$('#mt7 a img').attr('src','/images/2010/icon-admin.gif')}
	);
	
	// tour rollovers
	$('.tourbutton').hover (
		function() {this.src = this.src.replace("-off","-over");},
		function() {this.src = this.src.replace("-over","-off");}
	);
	
	// hosting signup buttons 
	$('.btn-signup').hover (
		function() {this.src = this.src.replace("-off","-over");},
		function() {this.src = this.src.replace("-over","-off");}
	);
	
});
