$(document).ready(function(){
	
///////////////////////////////////////////////////
///// Search box
							
	$("#searchbox").focus(function(){  
		if($(this).attr("value") == 'Search...') $(this).attr("value", "");  
	});  

	$("#searchbox").blur(function(){  
		if($(this).attr("value") == "") $(this).attr("value", 'Search...');  
	});  
					
///////////////////////////////////////////////////
///// Fade Out Success and Error Messages //
	$('a.delete').click(function(){
		$(this).parent().fadeOut('fast');		
		return false;
	});
	
///////////////////////////////////////////////////
///// Highlight Current Page in Navigation ///
	$(function(){
		$page = $('body').attr('class');
		
		$('nav ul li a#' + $page).each(function(){
			$(this).addClass('current');
		});
	});
	
////////////////////////////////////////////////////////////////////////////////////
///// Colorbox ///
	$(".pop-item").colorbox({onComplete:function() {
													  
	}});
	
	$(".pop-video").colorbox({iframe:true, innerWidth:450, innerHeight:350, onComplete:function(){
		$('#cboxContent').css({"background":"#f4f4f4"});
		$('#cboxLoadedContent').css({"margin-top":"30px"});		
	}});

////////////////////////////////////////////////////////////////////////////////////
///// Tell a friend ///
	$(".tell-a-friend").colorbox({onComplete:function() {

		$("#tell-a-form").submit(function() {
			
			$('#tell-submit-button').hide();
			
			$.post('/notifications/tell_a_friend', $("#tell-a-form").serialize(), function(data) {
				$('#status').html(data);
				$('#taf-friends_name').val("");
				$('#taf-friends_email').val("");			
				$('#taf-verify').val("");
				$('#tell-submit-button').show();
			});
						
			return false;
		});

	}});

////////////////////////////////////////////////////////////////////////////////////
///// Adjust for smaller screens ///
	if(screen.width < 1024) {
		$('#myslidemenu').css('font-size','15px');
		$('#float-it-shirts').hide();
		$('#float-it-apps').hide();		
		$('#float-it-juice').hide();	
	}
	
////////////////////////////////////////////////////////////////////////////////////
///// Replace div with ajax content ///
	$('a.replacer').click(function(){
		
		$('a.replacer').html("Loading...");
		$('#' + $(this).attr('rel')).load($(this).attr('href'));
		return false;
	});

////////////////////////////////////////////////////////////////////////////////////
///// Shows loader for upload image ///
	$('#images-upload').click(function(){
						 
		$('img.loader').show();
		$(this).hide();
	});

////////////////////////////////////////////////////////////////////////////////////
///// Add Class of 'Last' to last <td> in each row on Submit Event page ///
	//$('.submit-event tr td:last-child').addClass('last');

});//End file

////////////////////////////////////////////////////////////////////////////////////
///// Isset function ///
function isset(  ) {
	// http://kevin.vanzonneveld.net
	// +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +   improved by: FremyCompany
	// *     example 1: isset( undefined, true);
	// *     returns 1: false
	// *     example 2: isset( 'Kevin van Zonneveld' );
	// *     returns 2: true
 
	var a=arguments; var l=a.length; var i=0;
	
	while ( i!=l ) {
		if (typeof(a[i])=='undefined') { 
			return false; 
		} else { 
			i++; 
		}
	}
	
	return true;
}
