// Extension Core JavaScript Document

$(document).ready(function () {
    
	//For Horizontal Tabs
	var tabContainers = $('div.tabs > div').addClass('tab-content');
    $("ul.folderTabs li:first").addClass("selected").show();
    tabContainers.hide().filter(':first').show();
    
    $("ul.folderTabs li").click(function() {

		$("ul.folderTabs li").removeClass("selected");
		$(this).addClass("selected");		
		tabContainers.hide();

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).show();
		return false;
	});
	
	// For mega drop-down
	function addMega(){
        $(this).addClass("hovering");
        }

      function removeMega(){
        $(this).removeClass("hovering");
        }

    var megaConfig = {
         interval: 250,
         sensitivity: 4,
         over: addMega,
         timeout: 500,
         out: removeMega
    };

    $("li.mega").hoverIntent(megaConfig)
    
    // For link highlighting - only temporary
    //$("a[href='']").addClass('noLink');
	
 });
 
// For popups
/*
* jQuery popup v1.1 - A jQuery popup plugin.
* By Jordan Thomas - http://labs.wondergroup.com
* Licensed under the do whatever you want to license.
* If you like, keep this message intact so 
* someone else can find the origin.
*/
jQuery.fn.popup=function(options){var defaults={width:screen.width/2,height:screen.height/2,titlebar:true,status:true,resizable:true,toolbar:true,scrollbars:true,menubar:true};var options=jQuery.extend(defaults,options);Boolean.prototype.setProperty=function(){if(this==true){return"yes";}else{return"no";}};return this.each(function(){jQuery(this).click(function(){var target=this.target;var href=this.href;var posY=(parseInt(screen.height/2))-(parseInt(options.height/2));var posX=(parseInt(screen.width/2))-(parseInt(options.width/2));var win=window.open(href,target,'titlebar='+options.titlebar.setProperty()+', screenX='+posX+', screenY='+posY+', left='+posX+', top='+posY+', status='+options.status.setProperty()+', resizable='+options.resizable.setProperty()+', toolbar='+options.toolbar.setProperty()+', scrollbars='+options.scrollbars.setProperty()+', menubar='+options.menubar.setProperty()+', width='+options.width+', height='+options.height);win.focus();return false;});});};

$(document).ready(function () {
$(".popup").popup({
		width: 640,
		height: 480,
		titlebar: false,
		status: false,
		resizable: true,
		toolbar: false,
		scrollbars: true,
		menubar: false
	});
$(".popupLarge").popup({
		width: 980,
		height: 640,
		titlebar: false,
		status: false,
		resizable: true,
		toolbar: false,
		scrollbars: true,
		menubar: false
	});
});


$(document).ready(function() {

/* For random image rotator on About and Feedback */
 var img_urls= ['/assets/img/e-community-main.jpg', '/assets/img/e-ag-main-large.jpg', '/assets/img/e-en-main.jpg', '/assets/img/e-fam-main.jpg', '/assets/img/e-garden-main.jpg', '/assets/img/e-youth-main.jpg' ];
 var i= Math.floor(Math.random()*img_urls.length);
 $('#aboutMainImage').attr('src', img_urls[i]);
 
 /* Pop up rel="external" in new window */
    $('a[rel="external"]').click( function() {
        window.open( $(this).attr('href') );
        return false;
    });
});