/*!
 * Copyright (c) 2010 Liberty Concepts
 * http://www.libertyconceots.com
 * All right reserved *
 * @version 1.1
 * @changelog
 *      v1.1
 *          + Added formLabels support
 *          + Flickr tool call was commented out
 *
 * @description Put all jQuery code into engine.structure.allBrowsers
 * engine.structure.ie is reserved only for IE lte 8.0 browsers
 */
Cufon.replace("#mainNav .sf-menu>li>a, #slides li h2", {
    textShadow: '0 -1px rgba(0,0,0,0.5)'
})
var engine = {
    structure: {
        init : function(){
            if (!jQuery.support.opacity) {
                this.ie();
                this.allBrowsers();
            }
            else {
                this.allBrowsers();
            }
        },
        ie : function(){
            $j("#mainNav ul li:last-child, ul.news-list li:last-child ").css({
                "border-right":"0"
            });
            $j("div.actionItem:last-child").css({
                "margin-bottom":"0"
            });
            $j("#social-sidebar li:last-child").css({
                "margin":"0"
            });
            $j(".sf-menu li li:first-child").css({"border-top":"1px solid #D02128"})
            $j(".sf-menu li li:last-child").css({"border-bottom":"1px solid #D02128", "border-right":"1px solid #D02128"})
        },
        allBrowsers : function(){
            if ($j("ul.sf-menu").length) {
                $j("ul.sf-menu").supersubs({
                    minWidth:10,
                    maxWidth:30,
                    extraWidth:1
                }).superfish({delay:0}).find('ul').bgIframe({
                    opacity:false
                });
            }
            $j(".issues-radio input:radio").change(function(){
                var highlightNumber = $j(this).index();
                $j("ul.issue-options li").removeClass("active").filter(":eq("+ highlightNumber +")").addClass("active")
            })
            $j("#slides").cycle({
                fx : 'fade',
                timeout: 8000,
                pager: "#slCount",
                pause: 1,
                cleartypeNoBg: true,
                pagerAnchorBuilder:function(idx,slide){
                    return '<li><a href="#">'+ parseFloat(idx+1) +'</a></li>';
                }
            });
            if ($j('#twitterFeed').length) {
	            $j('#twitterFeed').twitterSearch({
		            term: 'from%3ADWStweets',		
		            bird: false,		
		            avatar: false,
		            colorExterior: '#ddd',
		            colorInterior: 'white',
		            pause:   true,
		            timeout: 4000
	            });
            }
        }
    }
}

$j(function(){
    $j.fn.formLabels()
    engine.structure.init();
    plugins.pageTools.init("#contentHere");
    plugins.externalLinks();
    $j("#actionCenter, #social-sidebar, #headerSocial").fadingSiblings()
    
if ($j("#flickr").length) {  
	plugins.flickrFeed({
	        cont: "#flickr",
	        type: "user",
	        userId: "51142067@N02",
	        num: 5
	    });
    }
});
