// JavaScript Document
// 2011 Sidewalk Dog

// Script by Jon Christensen
// First Scribe



// FONT REPLACEMENTS
// Puts in font and resizes accordingly (Resize is for those who do not have JS enabled so the default appears correctly)
			Cufon('#main_content #side_menu ul li a', {hover: true, fontFamily: 'ChaletComprime', fontSize: '24px'});
			Cufon.replace('#events p.date', { fontFamily: 'ChaletComprime60', fontSize: '22px' });
			Cufon.replace('div.bucket h3', {fontFamily: 'ChaletComprime60', fontSize: '24px' });
			Cufon.replace('div#bucket_wrap a.bucket_btn', {fontFamily: 'ChaletComprime', fontSize: '18px'});
			Cufon.replace('div#slider div.info a.slider_btn', {fontFamily: 'ChaletComprime', fontSize: '16px'});
			Cufon.replace('div#slider div.info h1', {fontFamily: 'ChaletComprime', fontSize: '34px'});
			Cufon.replace('div#slider div.info h2', {fontFamily: 'ChaletComprime60', fontSize: '22px'});
			Cufon.replace('div#slider div.info p', {fontFamily: 'ChaletComprime60', fontSize: '18px' });
			Cufon.replace('div#slider div.info p.bigger', {fontFamily: 'ChaletComprime60', fontSize: '24px' });
			Cufon.replace('#side_menu ul li a', {fontFamily: 'ChaletComprime', fontSize: '24px'});


$(document).ready(function() {			
// Picture gallery for profiles that support it 
$(function () {
	$('#photo_list a.lightbox').lightBox();
});
			
// HOME PAGE SLIDER		
// Plug-in Anything Slider at https://github.com/ProLoser/AnythingSlider/
$(function () {
	$('#homepage_slider').anythingSlider({
				startStopped   	: false,
				toggleControls 	: false,
				theme          	: 'metallic',
				infiniteSlides 	: true,
				buildNavigation	: true,
				enableNavigation: true,
				buildArrows 	: false,
				delay 			: 8000,
				animationTime 	: 500,
				pauseOnHover 	: true
	});
});


// Bryan Bowers <bryan@ideapark.com> 2011-08-10: Added to change bucket header bg color when parent is hovered.
$("div#bucket_wrap #reviews").hover(function(){$(this).children("h3:first").css("background","#a0c5db");},function(){$(this).children("h3:first").css("background","#ccc");});
$("div#bucket_wrap #events").hover(function(){$(this).children("h3:first").css("background","#c5c19d");},function(){$(this).children("h3:first").css("background","#ccc");});
$("div#bucket_wrap #blog").hover(function(){$(this).children("h3:first").css("background","#bbb2a6");},function(){$(this).children("h3:first").css("background","#ccc");});
$("div#bucket_wrap #tweets").hover(function(){$(this).children("h3:first").css("background","#870038");},function(){$(this).children("h3:first").css("background","#ccc");});


	
// Tabs changing script
	$("ul.menu #rescues").click(function(){ $(this).addClass("active"); $("ul.menu a").not(this).removeClass("active"); $(".tabs").find(".rescues").show(); $(".tabs").children("div").not("div.rescues").hide();});
	$("ul.menu #other").click(function(){ $(this).addClass("active"); $("ul.menu a").not(this).removeClass("active");$(".tabs").find(".other").show(); $(".tabs").children("div").not("div.other").hide();});
	$("ul.menu #reviews").click(function(){ $(this).addClass("active"); $("ul.menu a").not(this).removeClass("active");$(".tabs").find(".reviews").show(); $(".tabs").children("div").not("div.reviews").hide();});
	$("ul.menu #photos").click(function(){ $(this).addClass("active"); $("ul.menu a").not(this).removeClass("active");$(".tabs").find(".photos").show(); $(".tabs").children("div").not("div.photos").hide();});
	$("ul.menu #videos").click(function(){ $(this).addClass("active"); $("ul.menu a").not(this).removeClass("active");$(".tabs").find(".videos").show(); $(".tabs").children("div").not("div.videos").hide();});
	$("ul.menu #addrev").click(function(){ $(this).addClass("active"); $("ul.menu a").not(this).removeClass("active");$(".tabs").find(".addrev").show(); $(".tabs").children("div").not("div.addrev").hide();});
	
// Changes backgrounds for top searches if there is text
	$('#search_form input').bind($.browser.msie ? 'focus blur' : 'change load', function () {
		var str = $(this).val();
		if ( str != "" ) {$(this).addClass('active');}
		else {$(this).removeClass('active');}
	});

	// Fix for IE 7
	if ($.browser.msie && $.browser.version < 8) {
  	$("#search_form input").focus( function() {$(this).addClass('active');});
	}

// IE Fix for Calendar table
	$('table.calendar tr:nth-child(3) td.calendar').css({borderTop: '1px solid #CCC'});

// Fix for headers with long titles
	var title = $('#content_header #title_wrap').width();
	$('#content_header #image').width( 527 - title + 'px');
	
	// Rescue Page Navigation
	$('.rescues #prev').click (function() {$(this).parents('.rescues').addClass('hide');$(this).parents('.rescues').prev().removeClass('hide');	return false;});
	$('.rescues #next').click (function() {$(this).parents('.rescues').addClass('hide');$(this).parents('.rescues').next().removeClass('hide'); return false;});
	
	
	// Bryan Bowers <bryan@ideapark.com> 2011-08-12: Added to force url schema.
	$("form#listing_form dl.zend_form dd#link-element input#link").focus(function(){if($(this).val().length==0){$(this).val("http://");};});
	$("form#listing_form dl.zend_form dd#link-element input#link").blur(function(){
		var txt = $(this).val();
		if (txt.length == 0) { return true; }
		if (/^(https?):\/\/$/i.test(txt)) {
			$(this).val("");
			return true;
		}
		if (!/^(https?):\/\//i.test(txt)) {
			$(this).val("http://"+txt);
			return true;
		}
	});
	
	$('#login-form dd#password-element input').after('<a href="/user/password-reset.php">Please reset my password</a>');
	
	
});
