/*
 * Phillip Butah fancy stuff
 *
*/
// preload images

	jQuery(function () {
			jQuery('#bg img').hide();//hide all the images on the page
		});
		
		var i = 0;//initialize
		var int=0;//Internet Explorer Fix
		jQuery(window).bind("load", function() {//The load event will only fire if the entire page or document is fully loaded
			var int = setInterval("doThis(i)", 500);//500 is the fade in speed in milliseconds
		});

		function doThis() {
			var imgs = jQuery('#bg img').length;//count the number of images on the page
			if (i >= imgs) {// Loop the images
				clearInterval(int);//When it reaches the last image the loop ends
			}
			jQuery('img:hidden').eq(0).fadeIn('slow');//fades in the hidden images one by one
			i++;//add 1 to the count
		}
	
// full screen
	// You need to specify the size of your background image here (could be done automatically by some PHP code)
	var FullscreenrOptions = {  width: 1595, height: 920, bgID: '#bg img' };
	// This will activate the full screen background!
	jQuery.fn.fullscreenr(FullscreenrOptions);

// fade in
	jQuery(function() {
		jQuery("#content img").fadeIn("slow");
	});
	
// gallery no link

	jQuery(document).ready(function(){
		// Remove link from gallery images
		jQuery(".gallery-icon a").each(function () {
			jQuery(this).replaceWith(jQuery(this.childNodes));
		});
	});	

// gallery more	info
	
	jQuery(function() {
			jQuery(".cross").hide();
			jQuery(".more-info").hide();
			jQuery(".less-info").hide();
			
		if (jQuery("#gallery-post-content .entry-content p").length > 0){
		
			jQuery(".cross").show();
			jQuery(".gallery-post-title h3, .cross").css("cursor","pointer");
			
				jQuery(".gallery-post-title h3, .cross").mouseover(function () {
					jQuery(".more-info").fadeIn("slow");
				}).mouseout(function () {
					jQuery(".more-info").fadeOut("slow");
				}); 
		}
	});	
	
	jQuery(function() {
		jQuery("#gallery-post-content .entry-content p").hide();
			jQuery(".gallery-post-title h3, .cross").click(function () {
				jQuery("#gallery-post-content .entry-content p").slideToggle("slow");
				
				var text = jQuery('.more-info').text();
				jQuery('.more-info').text(
					text == "Less Information" ? "More Information" : "Less Information");
					
			});    
	});
	
// bookmark

	jQuery(document).ready(function(){
		jQuery(".bookmark a").click(function(e){
			e.preventDefault(); // this will prevent the anchor tag from going the user off to the link
			var bookmarkUrl = 'http://new.phillipbutah.com/';
			var bookmarkTitle = 'Phillip Butha';
		 
			if (window.sidebar) { // For Mozilla Firefox Bookmark
				window.sidebar.addPanel(bookmarkTitle, bookmarkUrl,"");
			} else if( window.external || document.all) { // For IE Favorite
				window.external.AddFavorite( bookmarkUrl, bookmarkTitle);
			} else if(window.opera) { // For Opera Browsers
				$(".bookmark a").attr("href",bookmarkUrl);
				$(".bookmark a").attr("title",bookmarkTitle);
				$(".bookmark a").attr("rel","sidebar");
			} else { // for other browsers which does not support
				 alert('Your browser does not support this bookmark action');
				 return false;
			}
		});
	});
	
	jQuery(function () {
		if (jQuery.browser.webkit) {
			jQuery("li.bookmark").css("display", "none");
		}
	});
	
