$(window).load(function(){
						   
	// -- NIVO SLIDER --

	$('#fader').nivoSlider({
		effect:'fold', 		//sliceDownRight, sliceDownLeft, sliceUpRight, sliceUpLeft, sliceUpDown, sliceUpDownLeft, fold, fade
		slices:15,								//Number of slices
		animSpeed:250,							//Speed of animation
		pauseTime:5000,							//Time for which slides remain visible
		directionNav:false, 					//Next & Prev
		directionNavHide:true,					//Only show on hover		
		startSlide:0, 							//Set starting Slide (0 index)
		controlNav:true, 						//Nav Bullets
		keyboardNav:true, 						//Use left & right arrows
		pauseOnHover:true, 						//Stop animation while hovering
		captionOpacity:0 						//We're using custom captions. So hide default ones using '0' opacity.
	})
	
	// -- MINI SLIDERS WITH JQUERY CYCLE --	
	
    $('#sl780').cycle({	
		fx: 'scrollLeft',
		speed:  1300, 
		timeout: 4000,
		easing:'backinout',		
		sync:1,
		pause:1,		
		pager:'#slnav780', 	
		// callback fn that creates a thumbnail to use as pager anchor 
		pagerAnchorBuilder: function(idx, slide) { 
			return '<li><a href="#"></a></li>'; 
		}
	})	
	
    $('#sl580').cycle({	
		fx: 'scrollRight',
		speed:  1300, 
		timeout: 4000,
		easing:'backinout',		
		sync:1,
		pause:1,		
		pager:'#slnav580', 	
		// callback fn that creates a thumbnail to use as pager anchor 
		pagerAnchorBuilder: function(idx, slide) { 
			return '<li><a href="#"></a></li>'; 
		}
	})
	
    $('#sl380').cycle({	
		fx: 'scrollLeft',
		speed:  1300, 
		timeout: 4000,
		easing:'backinout',	
		sync:1,
		pause:1,		
		pager:'#slnav380', 	
		// callback fn that creates a thumbnail to use as pager anchor 
		pagerAnchorBuilder: function(idx, slide) { 
			return '<li><a href="#"></a></li>'; 
		}
	})
	
    $('#sl280').cycle({	
		fx: 'scrollRight',
		speed:  1000, 
		timeout: 4000,
		easing:'backinout',
		sync:1,
		pause:1,
		pager:'#slnav280', 	
		// callback fn that creates a thumbnail to use as pager anchor 
		pagerAnchorBuilder: function(idx, slide) { 
			return '<li><a href="#"></a></li>'; 
		}
	})
	
    $('#sl246').cycle({	
		fx: 'scrollRight',
		speed:  1000, 
		timeout: 4000,
		easing:'backinout',
		sync:1,
		pause:1,
		pager:'#slnav246', 	
		// callback fn that creates a thumbnail to use as pager anchor 
		pagerAnchorBuilder: function(idx, slide) { 
			return '<li><a href="#"></a></li>'; 
		}
	})	
	
    $('#sl180').cycle({	
		fx: 'fade',
		speed:  600, 
		timeout: 4000,
		sync:1,
		pause:1,		
		pager:'#slnav180', 	
		// callback fn that creates a thumbnail to use as pager anchor 
		pagerAnchorBuilder: function(idx, slide) { 
			return '<li><a href="#"></a></li>'; 
		}
	})		
	
}) // -- End window.load call


$(document).ready(function () {

    // -- NAVIGATION MENU --

    $('.navigation ul').css({ display: "none" });
    $('.navigation li:has(ul)').addClass('has_child');
    $('.navigation li').hover(function () {
        $(this).find('ul:first').css({ visibility: "visible", display: "none" }).slideDown(250);
    }, function () {
        $(this).find('ul:first').css({ visibility: "hidden" });
    })

    // -- JQUERY TABS --

    //$("#tabs").tabs({fx:{ height: 'toggle', opacity: 'toggle', duration: 300 }})
    $("#tabs, #tabs2, #tabs3, #tabs4").tabs({ fx: { opacity: 'toggle', duration: 150} })


    // -- ACCORDION --
    $('ul.accordion').accordion()


    // -- INPUT TEXTBOX DEFAULT --

    $('#subscribe').example(function () {
        return $(this).attr('title');
    })

    // -- PRETTYPHOTO INIT --

    $("a[rel^='prettyPhoto[group1]'], a[rel^='prettyPhoto[group2]']").prettyPhoto({ theme: 'dark_square', showTitle: false, opacity: 0.6 })

    // -- PORTFOLIO THUMBNAIL HOVER MINI PLUGIN --

    jQuery.fn.thumbHover = function (options) {
        var settings = jQuery.extend({ xOffset: 0, yOffset: 0 }, options);
        $(this).each(function () {
            $action = 'play';
            if ($(this).attr('href').match(/\.(jpg|jpeg|jpe|png|gif|tif|tiff)/))
                $action = 'zoom';
            var $item = $(this).contents("img");
            if ($item.length > 0) {
                var $mediaIcon = $("<span class='" + $action + "'></span>").appendTo($(this));
                $(this).hover(function () {
                    $x = $item.width();
                    $y = $item.height();
                    $xy = $item.position();
                    $mediaIcon.css({ width: $x, height: $y, top: $xy.top + settings.xOffset, left: $xy.left + settings.yOffset });
                    $(this).contents("img").stop().animate({ "opacity": "0.5" }, 350);
                }, function () {
                    $(this).contents("img").stop().animate({ "opacity": "1" }, 350);
                }
				);
            }
        });
        return this;
    };
    $("a[rel^='prettyPhoto[group1]']").thumbHover({ xOffset: 8, yOffset: 8 });
    $("a[rel^='prettyPhoto[group2]']").thumbHover({ xOffset: 2, yOffset: 2 });
    $('a.myclass').thumbHover({ xOffset: 2, yOffset: 2 });
    $('a.myclass2').thumbHover({ xOffset: 2, yOffset: 2 });

    jQuery.fn.thumbHover2 = function (options) {
        var settings = jQuery.extend({ xOffset: 0, yOffset: 0 }, options);
        $(this).each(function () {
            $action = 'folder';
            if ($(this).attr('href').match(/\.(jpg|jpeg|jpe|png|gif|tif|tiff)/))
                $action = 'folder';
            var $item = $(this).contents("img");
            if ($item.length > 0) {
                var $mediaIcon = $("<span class='" + $action + "'></span>").appendTo($(this));
                $(this).hover(function () {
                    $x = $item.width();
                    $y = $item.height();
                    $xy = $item.position();
                    $mediaIcon.css({ width: $x, height: $y, top: $xy.top + settings.xOffset, left: $xy.left + settings.yOffset });
                    $(this).contents("img").stop().animate({ "opacity": "0.5" }, 350);
                }, function () {
                    $(this).contents("img").stop().animate({ "opacity": "1" }, 350);
                }
				);
            }
        });
        return this;
    };

    jQuery.fn.thumbHover3 = function (options) {
        var settings = jQuery.extend({ xOffset: 0, yOffset: 0 }, options);
        $(this).each(function () {
            $action = 'tvicon';
            if ($(this).attr('href').match(/\.(jpg|jpeg|jpe|png|gif|tif|tiff)/))
                $action = 'tvicon';
            var $item = $(this).contents("img");
            if ($item.length > 0) {
                var $mediaIcon = $("<span class='" + $action + "'></span>").appendTo($(this));
                $(this).hover(function () {
                    $x = $item.width();
                    $y = $item.height();
                    $xy = $item.position();
                    $mediaIcon.css({ width: $x, height: $y, top: $xy.top + settings.xOffset, left: $xy.left + settings.yOffset });
                    $(this).contents("img").stop().animate({ "opacity": "0.7" }, 350);
                }, function () {
                    $(this).contents("img").stop().animate({ "opacity": "1" }, 350);
                }
				);
            }
        });
        return this;
    };

    $('a.catmyclass').thumbHover2({ xOffset: 2, yOffset: 2 });
    $('a.tvmyclass').thumbHover3({ xOffset: 2, yOffset: 2 });

    // -- FLICKR IMAGE GALLERY HOVER --	
    $('.community_images>li>a').each(function () {
        var $items = $(this).contents("img");
        if ($items.length > 0) {
            var $fl = $("<span class=\"flickr_ico\"></span>").appendTo($(this));
            $fl.css({ display: "none" });
            $(this).hover(function () {
                $ab = $items.position();
                $fl.css({ width: 24, height: 24, top: $ab.top, left: $ab.left });
                $(this).contents("img").stop().animate({ "opacity": "0.4" }, 350);
                $fl.css({ visibility: "visible", display: "none" }).fadeIn();
            }, function () {
                $(this).contents("img").stop().animate({ "opacity": "1" }, 350);
                $fl.css({ visibility: "visible" }).fadeOut();
            }
			);
        }
    })
}) // end document.ready call
