﻿Cufon.replace('h1, h2, h3, h4, h5, h6, #menu ul li a, #breadcrumb');

    var islides = 0;
	
$(document).ready(function(){

    $("#slider img").each(function(){
        islides = islides + 1;
    });
    
    islides = islides * 21;

    if($.browser.version!="6.0"){
        $.each($('#menu li'), function() {
            $(this).html('<span class="hover" style="opacity:0;">&nbsp;</span>' + $(this).html());
        });
        
        
        $("#menu li span").css("filter","alpha(opacity=00)");
        
        $("#menu li a").hover(function() {
            $(this).siblings("span").stop().animate({opacity: "1"}, 'easeOutSine');
        },
        function() {
            $(this).siblings("span").stop().animate({opacity: "0"}, 'easeOutQuad');
        });
    }
        
    my_lightbox("a[rel^='prettyPhoto'], a[rel^='lightbox']",true);
        
	$('.content img').hide();//hide all the images on the page
});



var i = 0;//initialize
var int=0;//Internet Explorer Fix
$(window).bind("load", function() {//The load event will only fire if the entire page or document is fully loaded
	var int = setInterval("doThis(i)",300);//500 is the fade in speed in milliseconds
});

function doThis() {
	var images = $('.content img').length;//count the number of images on the page
	if (i >= images) {// Loop the images
		clearInterval(int);//When it reaches the last image the loop ends
	}
	$('.content img:hidden').eq(0).fadeIn(500);//fades in the hidden images one by one
	
	i++;//add 1 to the count
}
	
	
function my_lightbox($elements, autolink){	
	
	if(autolink)
	{
		jQuery('a[href$=jpg], a[href$=png], a[href$=gif], a[href$=jpeg], a[href$=.mov] , a[href$=.swf] , a[href*=vimeo.com] , a[href*=youtube.com]').contents("img").parent().each(function()
		{
			if(!jQuery(this).attr('rel') != undefined && !jQuery(this).attr('rel') != '' && !jQuery(this).hasClass('noLightbox'))
			{
				jQuery(this).attr('rel','prettyPhoto[auto_group]')
			}
		});
	}
		
	jQuery($elements).each(function()
	{	
		var $image = jQuery(this).contents("img");
		$newclass = 'lightbox_video';
		
		if(jQuery(this).attr('href').match(/(jpg|gif|jpeg|png|tif)/)) $newclass = 'lightbox_image';
			
		if ($image.length > 0)
		{	
			
			var $bg = jQuery("<span class='"+$newclass+" '></span>").appendTo(jQuery(this));
			
			jQuery(this).bind('mouseenter', function()
			{
				$height = $image.height();
				$width = $image.width();
				if(jQuery.browser.msie &&  jQuery.browser.version == 7){
				    $height = $height + 4;
				    $width = $width + 4;
				}
				$pos =  $image.position();		
				$bg.css({height:$height, width:$width, top:$pos.top, left:$pos.left});
			});
		}
	});	
	
	jQuery($elements).contents("img").hover(function()
	{
		jQuery(this).stop().animate({opacity:0.5},400);
	},
	function()
	{
		jQuery(this).stop().animate({opacity:1},400);
	});
}


$(function(){
$('form#msgfrm .labelslide label').each(function(){
	$('.labelslide label').click(function(){ $(this).next().focus(); });
	
	var labelColor = '#999';
	var restingPosition = '25px';

	// style the label with JS for progressive enhancement
	$(this).css({
		'color' : labelColor,
		 	'position' : 'absolute',
	 		'top' : restingPosition,
			'left' : '5px',
			'display' : 'inline',
    		        'z-index' : '99'
	});

	var inputval = $(this).next().val();

	// grab the label height, then add 5 pixels to it
	var labelheight = $(this).height();
	var labelmove = labelheight + 5 +'px';

	// onload, check if a field is filled out, if so, move the label out of the way
	if(inputval !== ''){
		$(this).stop().animate({ 'top':'-0' }, 1);
	}    	

	// if the input is empty on focus move the label to the left
	// if it's empty on blur, move it back
	$('input, textarea, label').focus(function(){
		var label = $(this).prev('label');
		var height = $(label).height();
		var adjust = '0px';
		var value = $(this).val();

		if(value == ''){
			label.stop().animate({ 'top':'-'+adjust }, 'fast');
		} else {
			label.css({ 'top':'-'+adjust });
		}
	}).blur(function(){
		var label = $(this).prev('label');
		var value = $(this).val();

		if(value == ''){
			label.stop().animate({ 'top':restingPosition }, 'fast');
		}	

	});
}); // End "each" statement
}); // End loaded jQuery
