/*!
 * 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
 */

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(){
			
			Cufon.replace('#nav li a, .content h2, #footer .pgWrap li, .join button, .gMd', { fontFamily: 'Gotham Medium', hover:true });
			Cufon.replace('.share, .gBk', { fontFamily: 'Gotham Book' });
			Cufon.replace('.searchForm label, h1.pgTitle', { fontFamily: 'Archer Medium' });
			Cufon.replace('.hRight p', { fontFamily: 'Archer Book' });
			
			// fix navigation li width so rollovers don't break layout
			$j('#nav li:nth-child(1)').css({'width':'114px','margin-left':'20px'});
			$j('#nav li:nth-child(2)').css({'width':'145px'});
			$j('#nav li:nth-child(3)').css({'width':'114px'});
			$j('#nav li:nth-child(4)').css({'width':'106px'});
			
			// image swap rollovers 
			var myimages=new Array()
			function preloadimages(){
				for (i=0;i<preloadimages.arguments.length;i++){
					myimages[i]=new Image()
					myimages[i].src=preloadimages.arguments[i]
				}
			}
			preloadimages('/system/storage/49/4c/5/423/sign_o.png',
					'/system/storage/49/3c/e/409/learn-more_o.png',
					'/system/storage/49/80/e/421/sign-the-petition_o.png',
					'/system/storage/49/80/d/429/wc-radio_o.png')			
			
			
			$j('.petition img').hover(function(){
			 	$j(this).attr('src','/system/storage/49/80/e/421/sign-the-petition_o.png');
			 	}, function(){
			  		$j(this).attr('src','/system/storage/49/57/4/420/sign-the-petition_n.png');
			 		}
			);			
			$j('.radio img').hover(function(){
			 	$j(this).attr('src','/system/storage/49/80/d/429/wc-radio_o.png');
			 	}, function(){
			  		$j(this).attr('src','/system/storage/49/46/3/428/wc-radio_n.png');
			 		}
			);			
			$j('img.sign').hover(function(){
			 	$j(this).attr('src','/system/storage/49/4c/5/423/sign_o.png');
			 	}, function(){
			  		$j(this).attr('src','/system/storage/49/54/b/422/sign_n.png');
			 		}
			);			
			$j('img.pos').hover(function(){
			 	$j(this).attr('src','/system/storage/49/3c/e/409/learn-more_o.png');
			 	}, function(){
			  		$j(this).attr('src','/system/storage/49/31/3/408/learn-more_n.png');
			 		}
			);			


			if ($j("ul.sf-menu").length) {
                $j("ul.sf-menu").supersubs({
                    minWidth:15,
                    maxWidth:30,
                    extraWidth:1
                }).superfish().find('ul').bgIframe({
                    opacity:false
                });
            }
        }
    }
}

$j(function(){
    $j.fn.formLabels({
        labelParent:'form'
    }) //optional: {excludeElts: 'elts to exclude'}
    engine.structure.init();
    plugins.pageTools.init(".content");
    plugins.externalLinks();
    //plugins.flickrFeed();
});
