/*!
 * Copyright (c) 2010 Liberty Concepts
 * http://www.libertyconcepts.com
 * All right reserved *
 * @version 1.5
 * @description Put all jQuery code into engine.structure.allBrowsers
 * engine.structure.ie is reserved only for IE lte 8.0 browsers
 */

var engine = {
    structure: {
        init : function(){
            if (!jQuery.support.opacity) {
                this.ie();
                this.allBrowsers();
            }
            else {
                this.allBrowsers();
            }
        },
        ie : function(){
        //HERE GOES jQUERY FOR IE BROWSERS ONLY!
        },
        allBrowsers : function(){
			// slide show
			$j(".slides").cycle({
				fx: 'fade' ,
				timeout: 8000,
				cleartypeNoBg: true,
		 		pager:  '.controls' ,
				pagerAnchorBuilder: function(index, el) {
         		return '<a href="#">'+(index+1)+'</a>'; // whatever markup you want#     
				}
			});

			//css
			$j('.mainContent img').addClass('shadedImage');
			$j('.mainContent img[align=left]').css({'margin':'0 20px 10px 0'});
			$j('.mainContent img[align=right]').css({'margin':'0 0 10px 20px'});
			$j('.events li:last-child, .tab .item:last-child, .mainContent .item:last-child, .sidebar-events li:last-child').css({'border-bottom':'none'});
			$j('.events li:last-child, .tab .item:last-child').css({'background':'none'});
			if ($j('.tab .item img, .mainContent .item img').length) { 
				$j(this).parent('.item').children('.entry').css( {'float':'right', 'width':'75%'});
			}			
			
			//home page tab widget
			$j('newsTab, #blogTab').hide();
			$j('#homeTabs li').click(
			  function () {
				var $myId = $j(this).find('a').attr('href');
				var $myTab = $j('#homeTabs').find('div#'+$myId);
				$j(this).addClass('sel');
				$j(this).siblings('li').removeClass('sel');
				$j($myTab).siblings('div.tab').hide();
				$j($myTab).fadeIn();
				Cufon.refresh();
				return false;
			  });
			
			//fonts
			Cufon.replace('.sf-menu>li>a', { fontFamily: 'Museo Sans 500', hover: true, separate: 'none' });
			Cufon.replace('.ms5, a.readMore', { fontFamily: 'Museo Sans 500', hover: true });
			Cufon.replace('.mainContent h2', { fontFamily: 'Museo Sans 500',  color: '-linear-gradient(#3172b3, #1f3a70)' });
			Cufon.replace('.mainContent .video h2', { fontFamily: 'Museo Sans 500',  color: '#5C4C44' });
			Cufon.replace('.ms7, .item h3, .video h3', { fontFamily: 'Museo Sans 700', hover: true });			
			Cufon.replace('.actions .ms7, .contribute .ms7', { textShadow: '0px -1px rgba(51, 51, 51, 0.6)' });
			
			//twitter
 	        if ($j('#twitterFeed').length) {
	            $j('#twitterFeed').twitterSearch({
		            term: 'from%3Ajimlangevin',	
		            bird: false,		
		            avatar: false,
		            colorExterior: false,
		            colorInterior: false,
		            pause:   true,
		            timeout: 5000
	            });
            }			
			
			
jQuery.fn.fadingSiblings = function() {
    return this.each(function(i) {
        jQuery(this).children().hover(function () {
            jQuery(this).siblings(":visible").stop().fadeTo(800, 0.4);
        },
        function () {
            jQuery(this).siblings(":visible").stop().fadeTo(700, 1);
        });
    })
};
jQuery(function(){
   jQuery('.actions').fadingSiblings();
})
			
			
			//menus
            if ($j("ul.sf-menu").length) {
                $j("ul.sf-menu").supersubs({
                    minWidth:15,
                    maxWidth:30,
                    extraWidth:1
                }).superfish({delay:0}).find('ul').bgIframe({
                    opacity:false
                });
            }
        }
    }
}

$j(function(){
    $j.fn.formLabels() //optional: {excludeElts: 'elts to exclude'}
    engine.structure.init();
    plugins.pageTools.init(".pagewidth");
    plugins.externalLinks();
    /*
    plugins.flickrFeed({
            cont: "#flickr",
            type: "set",                    //anything other than 'set' will be treated as userID.
            set: "72157607183698849",       //put set number if type: "set", otherwise property will be ignored.
            userId : "",                    //leave blank when working with type: "set", otherwise put userID http://idgettr.com/
            num: 9,                         //how many photos to show on a page.
            limit: 15                       //how many photos to retrive from Flickr.
    });
    */
});
