
jQuery(document).ready(function ($) {
	
	if ( window.location.href.indexOf('#newsletterok') > 0 ) {
		alert('Thank you for signing up to receive the Loveland newsletter!');
	}	

	$('#portalheader').hover(function () {
		$('#flipdown').fadeOut('fast');
		
		$(this).animate({top:'0px'},'medium',null, function () {
			$(this).mouseleave(function () {
				
				$("ul#portalnav li ul.subnav").hide();
				$("ul#portalnav li").removeClass('hover');
				
				
				$(this).animate({top:'-100px'}, 'medium', null, function () {
					$(this).unbind('mouseleave');
					$('#flipdown').fadeIn('fast');
				});
			});
		});
	});
	
	$('input.labelinside,textarea.labelinside').labelToggle();
	
	$('#header').hover(function () {
		$('#flipdown').fadeOut('fast');
		
		$(this).animate({top:'0px'},'medium',null, function () {
			$(this).mouseleave(function () {
				$(this).animate({top:'-100px'}, 'medium', null, function () {
					$(this).unbind('mouseleave');
					$('#flipdown').fadeIn('fast');
				});
			});
		});
	});
	
	$('.clickable').each(function () {
		
		$(this).css('cursor','pointer');
		$(this).click(function () {
			
			dest = $('a', $(this)).attr('href');

			if (dest.indexOf('#') ) {
				handle_anchor(dest);
			} else {
				window.location=dest;
			}

		});
		
	});

});


jQuery.fn.labelToggle = function() {

	return this.each(function () {
		
		jQuery(this).focus(function () {
			if ( !jQuery(this).attr('data-label') ) {
				jQuery(this).attr('data-label', jQuery(this).val() );
			}

			if ( jQuery(this).val() == jQuery(this).attr('data-label') ) {
				jQuery(this).val('')
			}
			

		});
		
		jQuery(this).blur(function () {
			if ( jQuery(this).val() == '' && jQuery(this).attr('data-label') ) {
				 jQuery(this).val( jQuery(this).attr('data-label') ) 
			}
		});
		
	});
	
};


function handle_anchor(url) {
	
	window.location=dest;
	
	if ( url.indexOf('#photoset:') ) {
				
	}
	
	if ( url.indexOf('#video:') ) {
		
	}
}


function photoset_openphoto(blogid, postid, photoid) {
	jQuery.fn.colorbox({
		width: '865px',
		height: '660px',
		href:'/wp-content/mu-plugins/loveland/photoviewer/?blogid='+blogid+'&postid='+postid + '&photoid=' + photoid,
		onComplete: function () {
			swfobject.switchOffAutoHideShow();
			swfobject.registerObject("photoviewer_flash", "10.0", "/wp-content/mu-plugins/loveland/swfobject/expressInstall.swf");
		}
	});
}

function photoset_open(blogid, postid) {
	
	jQuery.fn.colorbox({
		width: '865px',
		height: '660px',
		href:'/wp-content/mu-plugins/loveland/photoviewer/?blogid='+blogid+'&postid='+postid,
		onComplete: function () {
			swfobject.switchOffAutoHideShow();
			swfobject.registerObject("photoviewer_flash", "10.0", "/wp-content/mu-plugins/loveland/swfobject/expressInstall.swf");
		}
	});
	
}

function video_open(blogid, postid) {
	jQuery.fn.colorbox({
		width:829,
		height: 585,
		href:'/wp-content/mu-plugins/loveland/videoviewer/?blogid='+blogid+'&postid='+postid,
		onComplete: function () {
			swfobject.switchOffAutoHideShow();
			swfobject.registerObject("videoviewer_flash", "10.0", "/wp-content/mu-plugins/loveland/swfobject/expressInstall.swf");
		}
	});
}




function dj_lightbox(id) {
	
	jQuery.fn.colorbox({
		width: 430,
		height: 550,
		inline:true,
		href:'#details_' + id,
		onComplete: function () {
			if ( jQuery('#details_'+id+ '_video') ) {
				swfobject.switchOffAutoHideShow();
				swfobject.registerObject('details_'+id+ '_video', "10.0", "/wp-content/mu-plugins/loveland/swfobject/expressInstall.swf");
			}

		}
	});
	
}



