// remap jQuery to $
$(document).ready(function() {
	(function($){
		
$('#slideshow img:first').fadeIn(1000, function() {
$('#slideshow') 
.before('<div id="nav">') 
.cycle({ 
    fx:     'fade', 
    speed:  2000, 
    timeout: 8000,
	sync:   1,
	pause: 1,
	slideExpr: 'li',
    pager:  '#nav' 
});
});

			
			$('$[rel^=gallery]').prettyPhoto({
			animation_speed: 'normal', /* fast/slow/normal */
			slideshow: 5000, /* false OR interval time in ms */
			autoplay_slideshow: false, /* true/false */
			opacity: 0.80, /* Value between 0 and 1 */
			show_title: true, /* true/false */
			allow_resize: true, /* Resize the photos bigger than viewport. true/false */
			default_width: 300,
			default_height: 200,
			counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
			theme: 'facebook', /* light_rounded / dark_rounded / light_square / dark_square / facebook */
			horizontal_padding: 20, /* The padding on each side of the picture */
			hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
			wmode: 'opaque', /* Set the flash wmode attribute */
			autoplay: true, /* Automatically start videos: True/False */
			modal: false, /* If set to true, only the close button will close the window */
			deeplinking: false, /* Allow prettyPhoto to update the url to enable deeplinking. */
			overlay_gallery: true, /* If set to true, a gallery will overlay the fullscreen image on mouse over */
			keyboard_shortcuts: true, /* Set to false if you open forms inside prettyPhoto */
			changepicturecallback: function(){}, /* Called everytime an item is shown/changed */
			callback: function(){}, /* Called when prettyPhoto is closed */
			social_tools:false
			}); // lightbox code

			//-------- advanced example
            $(".dropdown1 dt a").click(function() {
                $(".dropdown1 dd ul").toggle();
            });

            $(".dropdown1 dd ul li a").click(function() {
                var text = $(this).html();
                $(".dropdown1 dt a span").html(text);
                $(".dropdown1 dd ul").hide();
                $("#result").html("Selected value is: " + getSelectedValue("sample"));
            });

            $(document).bind('click', function(e) {
                var $clicked = $(e.target);
                if (! $clicked.parents().hasClass("dropdown1"))
                    $(".dropdown1 dd ul").hide();
            });
			
			//-------- advanced example
            $(".dropdown2 dt a").click(function() {
                $(".dropdown2 dd ul").toggle();
            });

            $(".dropdown2 dd ul li a").click(function() {
                var text = $(this).html();
                $(".dropdown2 dt a span").html(text);
                $(".dropdown2 dd ul").hide();
                $("#result").html("Selected value is: " + getSelectedValue("sample"));
            });

            $(document).bind('click', function(e) {
                var $clicked = $(e.target);
                if (! $clicked.parents().hasClass("dropdown2"))
                    $(".dropdown2 dd ul").hide();
            });
			
			//-------- advanced example
            $(".dropdown3 dt a").click(function() {
                $(".dropdown3 dd ul").toggle();
            });

            $(".dropdown3 dd ul li a").click(function() {
                var text = $(this).html();
                $(".dropdown3 dt a span").html(text);
                $(".dropdown3 dd ul").hide();
                $("#result").html("Selected value is: " + getSelectedValue("sample"));
            });

            $(document).bind('click', function(e) {
                var $clicked = $(e.target);
                if (! $clicked.parents().hasClass("dropdown3"))
                    $(".dropdown3 dd ul").hide();
            });
			
			/* get selected value */
			
			function getSelectedValue(id) {
                return $("#" + id).find("dt a span.value").html();
            }
			
			/**/
			$('a.side-nav, .navigation a, a.navigation').live('click', function(){
				var link = $(this).attr('href');
				
					$('#maincontent').fadeOut(500, function() {
					// Animation complete.
					$('#maincontent').html('<div class="loading"><h2>Loading...</h2></div>');
					$('#maincontent').load(link + ' #maincontent', function(){
					$('#maincontent').fadeIn(500);
					
					$('$[rel^=gallery]').prettyPhoto({
						animation_speed: 'normal', /* fast/slow/normal */
						slideshow: 5000, /* false OR interval time in ms */
						autoplay_slideshow: false, /* true/false */
						opacity: 0.80, /* Value between 0 and 1 */
						show_title: true, /* true/false */
						allow_resize: true, /* Resize the photos bigger than viewport. true/false */
						default_width: 300,
						default_height: 200,
						counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
						theme: 'facebook', /* light_rounded / dark_rounded / light_square / dark_square / facebook */
						horizontal_padding: 20, /* The padding on each side of the picture */
						hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
						wmode: 'opaque', /* Set the flash wmode attribute */
						autoplay: true, /* Automatically start videos: True/False */
						modal: false, /* If set to true, only the close button will close the window */
						deeplinking: false, /* Allow prettyPhoto to update the url to enable deeplinking. */
						overlay_gallery: true, /* If set to true, a gallery will overlay the fullscreen image on mouse over */
						keyboard_shortcuts: true, /* Set to false if you open forms inside prettyPhoto */
						changepicturecallback: function(){}, /* Called everytime an item is shown/changed */
						callback: function(){}, /* Called when prettyPhoto is closed */
						social_tools:false
					}); // lightbox code
					
					
			//-------- dropdown-code
            $(".dropdown1 dt a").click(function() {
                $(".dropdown1 dd ul").toggle();
            });

            $(".dropdown1 dd ul li a").click(function() {
                var text = $(this).html();
                $(".dropdown1 dt a span").html(text);
                $(".dropdown1 dd ul").hide();
                $("#result").html("Selected value is: " + getSelectedValue("sample"));
            });

            $(document).bind('click', function(e) {
                var $clicked = $(e.target);
                if (! $clicked.parents().hasClass("dropdown1"))
                    $(".dropdown1 dd ul").hide();
            });
			
			//-------- advanced example
            $(".dropdown2 dt a").click(function() {
                $(".dropdown2 dd ul").toggle();
            });

            $(".dropdown2 dd ul li a").click(function() {
                var text = $(this).html();
                $(".dropdown2 dt a span").html(text);
                $(".dropdown2 dd ul").hide();
                $("#result").html("Selected value is: " + getSelectedValue("sample"));
            });

            $(document).bind('click', function(e) {
                var $clicked = $(e.target);
                if (! $clicked.parents().hasClass("dropdown2"))
                    $(".dropdown2 dd ul").hide();
            });
			
			//-------- advanced example
            $(".dropdown3 dt a").click(function() {
                $(".dropdown3 dd ul").toggle();
            });

            $(".dropdown3 dd ul li a").click(function() {
                var text = $(this).html();
                $(".dropdown3 dt a span").html(text);
                $(".dropdown3 dd ul").hide();
                $("#result").html("Selected value is: " + getSelectedValue("sample"));
            });

            $(document).bind('click', function(e) {
                var $clicked = $(e.target);
                if (! $clicked.parents().hasClass("dropdown3"))
                    $(".dropdown3 dd ul").hide();
            });
					
					
					});			
				});

			return false;
			});
			/**/	

})(window.jQuery);
});


