$(document).ready(function(){	

	  Cufon.replace('h1,h2,h3,h4', { fontFamily: 'Diavlo Bold' });
	  Cufon.replace('.sf-menu', { fontFamily: 'Diavlo Bold',hover: true }); 

	   //Our share it script   *******************************************************//
	$('ul.sf-menu').superfish({ 
						hoverClass:    'sfHover',
						animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
						autoArrows:  false,                           // disable generation of arrow mark-up 
						dropShadows: false                            // disable drop shadows 
	}); 

//staff menu
	$("#staffMenu li").click(function(){
	//make a variable and assign the hovered id to it
	var elid = $(this).attr('id');
	//hide the image currently there
	$("#staffImages div").hide();
	//fade in the image with the same id as the selected buttom
	$("#staffImages #" + elid + "").fadeIn("slow");

	});
	
	
	
	
	
	

	//grab all the anchor tag with rel set to shareit
	$('a[rel=shareit], #shareit-box').mouseenter(function() {		
		
		//get the height, top and calculate the left value for the sharebox
		var height = $(this).height();
		var top = $(this).offset().top;
		
		//get the left and find the center value
		var left = $(this).offset().left + ($(this).width() /2) - ($('#shareit-box').width() / 2);		
		
		//grab the href value and explode the bar symbol to grab the url and title
		//the content should be in this format url|title
		var value = $(this).attr('href').split('|');
		
		//assign the value to variables and encode it to url friendly
		var field = value[0];
		var url = encodeURIComponent(value[0]);
		//var title = encodeURIComponent(value[1]);
		var title = 'Classurfieds';
		//assign the height for the header, so that the link is cover
		$('#shareit-header').height(height);
		
		//display the box
		//$('#shareit-box').show();
		$('#shareit-box').fadeIn(); 
		
		//set the position, the box should appear under the link and centered
		$('#shareit-box').css({'top':top, 'left':left});
		
		//assign the url to the textfield
		$('#shareit-field').val(field);
		
		//make the bookmark media open in new tab/window
		$('a.shareit-sm').attr('target','_blank');
		//Setup the bookmark media url and title
		$('a[rel=shareit-mail]').attr('href', 'mailto:info@'+url+'?subject=Share This Page' + title);
		$('a[rel=shareit-delicious]').attr('href', 'http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=www.' + url + '&title=' + title);
		$('a[rel=shareit-designfloat]').attr('href', 'http://www.designfloat.com/submit.php?url=www.'  + url + '&amp;title=' + title);
		$('a[rel=shareit-digg]').attr('href', 'http://digg.com/submit?phase=2&amp;url=www.' + url + '&amp;title=' + title);
		$('a[rel=shareit-stumbleupon]').attr('href', 'http://www.stumbleupon.com/submit?url=www.' + url + '&title=' + title);
		$('a[rel=shareit-twitter]').attr('href', 'http://twitter.com/home?status=www.' + title + '%20-%20' + title);
		
	});

	//onmouse out hide the shareit box
	$('#shareit-box').mouseleave(function () {
		$('#shareit-field').val('');
		$(this).fadeOut();
	});
	
	//hightlight the textfield on click event
	$('#shareit-field').click(function () {
		$(this).select();
	});	  
	  
	
	$(function() {
		$('#slideshow').cycle({
			fx:     'fade',
			speed:  'slow',
			timeout: 6000,
			delay:  -2000
		});
		});
	
	Cufon.now();
			$(".fade").fadeTo("50", 0.0); // This sets the opacity of the thumbs to fade down to 30% when the page loads
				$(".fade").hover(function(){
				$(this).fadeTo("50", 1.0); // This should set the opacity to 100% on hover
				},function(){
				$(this).fadeTo("10", 0.0); // This should set the opacity back to 30% on mouseout
			 });
				
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;


    
 

});


