facebook = new Image();
facebook.src = "/_img/FacebookOver.png";

youtube = new Image();
youtube.src = "/_img/YouTubeOver.png";

twitter = new Image();
twitter.src = "/_img/TwitterOver.png";

linkedin = new Image();
linkedin.src = "/_img/LinkedInOver.png";

share = new Image();
share.src = "/_img/ShareOver.png";

$(document).ready(function () {
							
    $('#sidebar dl.lvl2:last dt').addClass('lastItem');
    
	// add a "rel" attrib if Opera 7+
	if(window.opera) {
		if ($("a.jqbookmark").attr("rel") != ""){ // don't overwrite the rel attrib if already set
			$("a.jqbookmark").attr("rel","sidebar");
		}
	}

	$("a.jqbookmark").click(function(event){
									 alert("bookmark");
		event.preventDefault(); // prevent the anchor tag from sending the user off to the link
		var url = this.href;
		var title = this.title;

		if (window.sidebar) { // Mozilla Firefox Bookmark
			window.sidebar.addPanel(title, url,"");
		} else if( window.external ) { // IE Favorite
			window.external.AddFavorite( url, title);
		} else if(window.opera) { // Opera 7+
			return false; // do nothing - the rel="sidebar" should do the trick
		} else { // for Safari, Konq etc - browsers who do not support bookmarking scripts (that i could find anyway)
			 alert('Unfortunately, this browser does not support the requested action,'
			 + ' please bookmark this page manually.');
		}

	});
				

/*\------------------------------------------------------------------------
	open links in new window
------------------------------------------------------------------------\*/
	
    $('a[rel="external"]').click( function() {
        window.open( $(this).attr('href') );
        return false;
    });		


	$(".l1").bind("click", function(e){
		$("#menu").find("h3").removeClass("active");
		
		$(".lvl1, .lvl2").addClass("hidden");
		$(this).find("dl").removeClass("hidden");
		$(this).find("h3").addClass("active");
	});

	$(".l2").bind("click", function(e){
		$(".lvl2").addClass("hidden");
		$(".lvl2 dd").addClass("hidden");
		$(".lvl2 dt a").addClass("hover");
		
		$(".l2").removeClass("active");
		
		$(this).addClass("active");
		$(this).find("a").removeClass("hover");
		$(this).nextAll("dd").removeClass("hidden");
	});
	
	$('a[rel*=spemail]').spemail('|,:','linkbase');	
	
	
	
	contactForm	=	function(){
		
		$(".cfitem").bind("focus", function(e){
			var title = ($(this).attr('title'));
			if($(this).attr("value") == $(this).attr('title')){
				$(this).attr("value", "");
			}
		});
		$(".cfitem").bind("blur", function(e){
			if($(this).attr("value") == ""){
				$(this).attr("value",  $(this).attr('title'));
			}
		});
	};
	contactForm();	
	
	
});
	
$.fn.spemail = function(opt,type){
	// Added this to be able to change what the options by default the | will be used as the first parameter an initiate the '@' and the : will initiate the '.'
	var opt_in = opt.split(",");
	var type;
	
	if (type == "linkbase")
	{
		this.each(function() {
			el = $(this);
			el.each(function(){
			// Finds the href with rel: 'whatever you want' and inserts mailto: and replaces the characters for real ones.
			// Done this way to keep consistancy throughout the emails on the site.
			el.attr('href','mailto:' + el.attr('href').replace(opt_in[0],'@').replace(opt_in[1],'.'));
			// Will add a title attribute to the link like: Email: whoever@whereever.com
			el.attr('title',el.attr('href').replace(opt_in[0],'@').replace(opt_in[1],'.').replace('mailto.','Email: '));
			// Will change the html of the link itself to the email address of the person.
			//el.html(el.attr('href').replace(opt_in[0],'@').replace(opt_in[1],'.').replace('mailto.','').replace('mailto:',''));
			});
		});
	}
	else if(type == "mailbase") {
		this.each(function() {
			el = $(this);
			el.each(function(){
		    // Will create the whole href link with title and everything for the text provided. (probably the best option - to me at least
			el.html('<a href="mailto:'+el.html().replace(opt_in[0],'@').replace(opt_in[1],'.')+'" title="Email: '+el.html().replace(opt_in[0],'@').replace(opt_in[1],'.')+'">'+el.html().replace(opt_in[0],'@').replace(opt_in[1],'.')+'</a>');
			});
		});
	}
	else if(type == "plainbase") {
		// WILL JUST CHANGE TEXT TO THE EMAIL ON DOM REGULAT TEXT TO REGULAR TEXT	
		this.each(function() {
			el = $(this);
			el.each(function(){
			el.html(el.html().replace(opt_in[0],'@').replace(opt_in[1],'.'));
			});
		});
	}
};


