// JavaScript Document
jQuery(document).ready(function() {
	
	
	var photos = jQuery("#keiser-homes").find("img");
	if(photos) {
		
		jQuery("#keiser-homes .image").hover( function() {
		//alert(jQuery(photos[0]).queue("fx").length);
		if(jQuery(photos[0]).queue("fx").length<1){
		jQuery(photos[0]).animate({
					paddingTop : "20px"
			 },500, 'easeOutQuad');		
			//alert(jQuery("#keiser-homes img").queue("fx").length);
		}
     	}, 
      function () {
		  		if(jQuery(photos[0]).queue("fx").length<2){

        jQuery(photos[0]).animate({
					paddingTop : "40px"
			 },100, 'easeOutQuad');
      }}
	);
	}
	var photos2 = jQuery("#keiser-construction").find("img");
	if(photos2) {
		
		jQuery("#keiser-construction .image").hover( function() {
			if(jQuery(photos2[0]).queue("fx").length<1){						   
			jQuery(photos2[0]).animate({
					paddingTop : "20px"
			 },500, 'easeOutQuad');
			}}, 
      function () {
		  if(jQuery(photos2[0]).queue("fx").length<2){
        jQuery(photos2[0]).animate({
					paddingTop : "40px"
			 },100, 'easeOutQuad');	
		  }
      }
	);
	}		
function cycleSlideShow() {
	if(count==photos.length-1) {
		jQuery(photos[count]).fadeOut(500);
			count=0;
		jQuery(photos[count]).fadeIn(1000);
	}
	else {	
		jQuery(photos[count]).fadeOut(500);
			count++;	
		jQuery(photos[count]).fadeIn(1000);
	}	
}
	if( jQuery('#post-266').hasClass('.post') ) {
		var photos2 = jQuery('#post-266').find(".size-full");
		$('.size-full').css({'position' : 'absolute', 'background' : 'none', 'padding' : '0', 'padding-left' : '5px'});
		//$('#post-266 .entry').css({'padding-top' : '355px'});
	
		if(photos2) {
			$(photos2).remove();
			$(photos2).hide();
			$('#post-266 .entry').prepend('<div id="show"></div>');
				if(jQuery.browser.msie) {
				$('#show').css({'margin-top' : '-20px'});
			} else {}
			$('#show').append(photos2);
			
			$(photos2[0]).show();
			var count2 = 0;
			var timer2 = setInterval(cycleSlideShow2,5000);
		}
	}		
function cycleSlideShow2() {
	if(count2==photos2.length-1) {
		$(photos2[count2]).fadeOut(500);
			count2=0;
		$(photos2[count2]).fadeIn(1000);
	}
	else {	
		$(photos2[count2]).fadeOut(500);
			count2++;	
		$(photos2[count2]).fadeIn(1000);
	}	
}

	if( jQuery('#f-content').children().hasClass('.photo-gallery') ) {
		var thumbs = jQuery(".photo-gallery").find(".size-thumbnail").remove();
		var classes = new Array();
		var images = new Array();
		var links = jQuery(".photo-gallery").find("a");
		
		var i = 0;
		$(thumbs).each (
   			function( i ){
				var getClass = $(this).attr('class').split(' ');
				for (j in getClass) { 
				
				if(getClass[j].substring(0,8)=='wp-image') {
					var useClass = getClass[j];
				//alert(useClass);
				}}
				classes[i] = useClass;
				images[i] = '<img class="size-full '+classes[i]+'" src="'+$(links[i]).attr('href')+'" />';
				$('.photo-gallery').append(images[i]);
				i++;
			}
		);
		

		//alert(links[2]);
		if(thumbs) {
			$("#photo-thumbs ul li").append(thumbs);
			$('.photo-gallery img').hide();
			$('.photo-gallery .'+classes[0]).show();
			$('.'+classes[0]).addClass('selected');
			$('#photo-info').append('<h1>'+$(thumbs[0]).attr('title')+'</h1>');
			$('#photo-info').append('<p>'+$(thumbs[0]).attr('alt')+'</p>');

			//$("#photo-thumbs ul li").append(thumbs);
		}
	}		

	jQuery("#photo-thumbs ul li img").click(
		function(){
			if(!$(this).hasClass('selected')){
			var tempClass = $(this).attr("class").split(" ");
			
			for (i in tempClass) { 	
				if(tempClass[i].substring(0,8)=='wp-image') {
				var useClass = tempClass[i];
			}}
			$('.photo-gallery .selected').fadeOut(300).removeClass('selected');
			$('#photo-info').children().remove();
			
			$("#photo-thumbs ul li img").removeClass('selected');
			$('.photo-gallery .'+useClass).fadeIn(500);
			$('#photo-info').append('<h1>'+$("#photo-thumbs ul li ."+useClass).attr('title')+'</h1>');
			$('#photo-info').append('<p>'+$("#photo-thumbs ul li ."+useClass).attr('alt')+'</p>');
			$('.'+useClass).addClass('selected');
			}
});
	
	if( jQuery('#sidebar ul').children().hasClass('.side-content') ) {
		var content = jQuery(".side-content").remove();
		//var randnum = Math.floor(Math.random()*(content.length));
		//$('#sidebar ul').prepend(content[randnum]);
		
		$('#sidebar ul').prepend(content);
		$(content[0]).show();
		var count = 0;
		var timer = setInterval(cycleSidebar,9000);
	}

function cycleSidebar() {
	if(count==content.length-1) {
		sideOut(content[count]);
			count=0;
		sideIn(content[count]);
	}
	else {	
		sideOut(content[count]);
			count++;	
		sideIn(content[count]);
	}	
}
function sideOut(arg) {
	if(jQuery.browser.msie) {
		$(arg).hide();
	} else {
	$(arg).fadeOut(200);
	}
}
function sideIn(arg) {
	if(jQuery.browser.msie) {
		$(arg).show();
	} else {	
	$(arg).fadeIn(500);
	}
}


});


