$(document).ready(function() {
	 $('a[rel=external]').click(function(){
		window.open( $(this).attr('href') );
		return false;
	}); 


	$('a').tooltip({
		track: true,
		delay: 750,
		showURL: false,
		showBody: " - ",
		fade: 250
	});

	$('#IPsearch').focus(function() {
		if( $(this).val()=='Search Here' )
			$(this).val('');	
	});
	

	$('#IPsearch').blur(function() {
		if( $(this).val()=='' )
			$(this).val('Search Here');	
	});


	$('.IPsearch').focus(function() {
		if( $(this).val()=='Search Here' )
			$(this).val('');	
	});
	

	$('.IPsearch').blur(function() {
		if( $(this).val()=='' )
			$(this).val('Search Here');	
	});



	$(".popup").each( function() {

		var linkto = $(this).attr("src");
		var title = $(this).attr("alt");
		var path = linkto.split("/");
		var filename = path[path.length-1];
		
		var fullsize = "full/" + filename;
		
		path.pop();
		path.push(fullsize);
		
		var newpath = path.join("/");

		
		$(this).wrap("<a href='" + newpath + "' title='" + title + "' class='fancy' rel='group'></a>");
	
	});

	

	$("a.fancy").fancybox({
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'overlayColor' : '#000',
		'overlayOpacity' : '0.6'
	});



	$('.replybtn').click(function(){
	
		var comment = $(this).parent();
		
		$.get("/ajax/form-comments.php", { blogid: $('#blogid').val(), commentid: $(this).attr('id') },
			function(data){
			comment.append(data);
		});
		
		$(this).remove();


		$(".commentForm").parent().remove();
		
	});




	if($('#portfolio').length>0)
	{

		if($('#portfolio').hasClass('studentWork'))
		{
		
			$('#portfolio').cycle({ 
				prev:   '#prev', 
				next:   '#next', 
				timeout: 0,
				before: studentText 
			});
		
			
		} else {

			$('#portfolio').cycle({ 
				prev:   '#prev', 
				next:   '#next', 
				timeout: 0 
			});
		
		}
			
	}
	

});


function studentText(currSlideElement, nextSlideElement, options, forwardFlag)
{
	var pid = $(this).attr('id').replace('student_','');
		
	$('#feature').fadeOut('slow', function() {
		$('#feature').html($('#photoDesc_' + pid).html()).fadeIn('slow');
	
	});
}


// suckerfish for sucker-browser!

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


