/***********************
// SMOOTH SLIDE TO ANCHOR ON PAGE
// http://css-tricks.com/snippets/jquery/smooth-scrolling/
//Anonymous function that is applied to all internal-links
***********************/

function smoothSlide() {
	//overide the "normal" behaviour which would be a "hard" jump
    $('a[href*=#]').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
        && location.hostname == this.hostname) {
	       //Get the target
            var $target = $(this.hash);
            $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
            if ($target.length) {
                var targetOffset = $target.offset().top;
			 //perform animated scrolling  html,body,#container
                $('#container').animate({scrollTop: targetOffset}, 2000); //scrolldelay: 2 seconds
                return false;
            }
        }
    });
}; 



/***********************
// LOGIN / REGISTER  panel at top 
// basic slide panel - checkout: http://web-kreation.com/all/nice-clean-sliding-login-panel-built-with-jquery/
***********************/

function panelExpand() {

	// Expand Panel
	$("#open").click(function(){
		$("div#panel").slideDown("slow");
		return false;
	});	 
	
	// Collapse Panel
	$("#close").click(function(){
		$("div#panel").slideUp("slow");
		return false;		
	});	
	
	// Switch buttons from "Log In | Register" to "Close Panel" on click
	$("#toggle a").click(function () {
		$("#toggle a").toggle();
	});		
		
};

/* ###################
Colorbox - image viewer like lightbox
http://colorpowered.com/colorbox/
#################### */

function colorBox() {
	//Examples of how to assign the ColorBox event to elements
	$("a[rel='colorbox']").colorbox();
	$("a[rel='colorboxframe']").colorbox({width:"710px", height:"700px", iframe:true}); 
	// $("a[rel='colorbox']").colorbox({transition:"fade"});
	// $("a[rel='colorbox']").colorbox({slideshow:true});
	};
	

/***********************
// SHOW HIDE TABBED CONTENT - PAGE BLOCK SHOW HIDE
// http://www.sohtanaka.com/web-design/simple-tabs-w-css-jquery/
***********************/

/*
$(document).ready(function() {

	//When page loads...
	$(".tab_content").hide(); //Hide all content
	$("#slidedisplaycontrol a:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content

	//On Click Event
	$("#slidedisplaycontrol a").click(function() {

		$("#slidedisplaycontrol a").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tabs + its content
		$(activeTab).fadeIn(); //fadeIn the active ID content
		return false;
	});

});

*/

/* ##############
Text (or element) Fade function
http://cssbeauty.com/skillshare/discussion/1593/jquery-fade-in-on-mouse-over/
fade options: slow, normal or fast are available - "normal" speed used below
################ */

/* Fade UP on hover */
/*
$(function(){
$(".testing, .test2").fadeTo("normal", 0.6); // This sets the opacity of the thumbs to fade down to 60% when the page loads
$(".testing, .test2").hover(function(){
$(this).fadeTo("normal", 0.9999); // This should set the opacity to 99.99% on hover - counteract MAC FF and Camino blink
},function(){
$(this).fadeTo("normal", 0.6); // This should set the opacity back to 60% on mouseout
});
});
*/

/* Fade DOWN on hover */ 
/*
$(function(){
$("#top-menu li a").fadeTo("normal", 0.9999); // This sets the opacity of the thumbs to 99.99% when the page loads to counteract MAC FF and Camino blink
$("#top-menu li a").hover(function(){
$(this).fadeTo("normal", 0.5); // This should set the opacity to 60% on hover
},function(){
$(this).fadeTo("normal", 0.9999); // This should set the opacity back to 99.99% on mouseout - counteract MAC FF and Camino blink
});
});
*/

/* ##############
Superfish jquery ease drop down sublevels script - 
it can automatically add the  &raquo; to elements that have a sub menu
you can hide the class that displays these if required in script options
http://users.tpg.com.au/j_birch/plugins/superfish/#examples
################ */

/*
$(function(){
		$("ul#top-menu").superfish({
			autoArrows:false,  // disable generation of arrow mark-up 
			});
     $("ul#left-menu").superfish({
		  pathClass:'current', // the class you have applied to list items that lead to the current page
			pathLevels:3, // the number of levels of submenus that remain open or are restored using pathClass 
			speed:'normal', // faster animation speed
			delay:1000, // the delay in milliseconds that the mouse can remain outside a submenu without it closing 
			autoArrows:false,  // disable generation of arrow mark-up 
		}); 
	   $("ul.admin-nav").superfish({
			delay:1000,   // one second delay on mouseout 
			speed:'fast', // faster animation speed 
			autoArrows:false,  // disable generation of arrow mark-up 
	   }); 
  });
*/

/***********************
* ONLOAD functions script
***********************/
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(smoothSlide);
addLoadEvent(panelExpand);
addLoadEvent(colorBox);
//addLoadEvent(createGridder);
addLoadEvent(function() {
  /* more code to run on page load */
});

