
function initChallenge() {
    //Default Action
	$(".tab_content").hide(); //Hide all content
	$("ul#tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content
		
	$(".tab_content2").hide(); //Hide all content
	$("ul#sub-initiatives li:first").show(); //Activate first tab
	$(".tab_content2:first").show(); //Show first tab content
	
	$(".tab_content3").hide(); //Hide all content
	$("ul#sub-participate li:first").show(); //Activate first tab
	$(".tab_content3:first").show(); //Show first tab content
	
	//On Click Event
	$("ul#tabs li").click(function() {
		$("ul#tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content
		var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active content
		return false;
	});
	
	$("ul#sub-initiatives li").click(function() {
		$("ul#sub-initiatives li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content2").hide(); //Hide all tab content
		var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active content
		return false;
	});
	
	$("ul#sub-participate li").click(function() {
		$("ul#sub-participate li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content3").hide(); //Hide all tab content
		var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active content
		return false;
	});
}

function initSubscribe() {
	if ($("a:contains('My membership')").length) {
		$('div.subscribe-manage').show();
		$("a:contains('My membership')").hide();
	}

	if ($("a:contains('Join')").length) {
		$("a:contains('Join')").before("<p>Receive updates about ASU's progress on the Challenges Before Us.</p>");
	}
}

function initSIFR() {
	sIFR.replace(aksidenz, {
	  selector: 'h1.gray',
	  css: ['.sIFR-root {color: #CCC; font-size:24px; font-weight:normal; margin-bottom:0; leading:-4; kerning:true; cursor:arrow; }'],
	  wmode: 'transparent'
	});
	
	sIFR.replace(aksidenz, {
	  selector: 'h1.project',
	  css: ['.sIFR-root { color: #777; font-size:22px; font-weight:normal; margin-bottom:0; letter-spacing: -1;leading:-5; kerning:true; cursor:arrow; }'],
	  wmode: 'transparent'
	});
	
	sIFR.replace(aksidenz, {
	  selector: 'h2.projectdesc',
	  css: ['.sIFR-root {color: #a1a1a1;font-size:20px; font-weight:normal; margin-bottom:0; letter-spacing: -1; leading:-4;kerning:true; cursor:arrow; }'],
	  wmode: 'transparent'
	});
	
	sIFR.replace(aksidenz, {
	  selector: 'h1.darkgray',
	  css: ['.sIFR-root {color: #777;font-size:40px;letter-spacing:-2; font-weight:normal; margin-bottom:0; leading:-4; kerning:true; cursor:arrow; }'],
	  wmode: 'transparent'
	});

/*

	sIFR.replace(aksidenz, {
	  selector: 'h4.exemplar',
	  css: ['.sIFR-root {color: #444;font-size:16px;letter-spacing:0; font-weight:normal; margin-bottom:0; leading:-4; kerning:true; cursor:arrow; }'],
	  wmode: 'transparent'
	});
	
	sIFR.replace(aksidenz, {
	  selector: 'h4.initiatives',
	  css: ['.sIFR-root {color: #000; font-size:14px; letter-spacing:0; font-weight:normal; margin-bottom:0; padding:0; leading:-4; kerning:true; cursor:arrow; line-height:14px;}'],
	  wmode: 'transparent'
	});

*/

}

function firstTab() {
	//alert("firstTab");
	//$tabsChallenge.tabs('select', 0); // switch to first tab
}

// Project page scripts

var _aProjectLayers = [ "#updates-all", "#updates-news", "#updates-events", "#updates-reports" ];
function initProject() {
	$('a#initiative-updates-all').click(function() { showDivs("#updates-all", _aProjectLayers); return false; });
	$('a#initiative-updates-news').click(function() { showDivs("#updates-news", _aProjectLayers); return false; });
	$('a#initiative-updates-events').click(function() { showDivs("#updates-events", _aProjectLayers); return false; });
	$('a#initiative-updates-reports').click(function() { showDivs("#updates-reports", _aProjectLayers); return false; });
	
	$('#updates-all').show();
}

function initProjectFlash(xmlFile, embedFile) {
	var flashvars = {
		paramXMLPath: "http://www.asuchallenges.com/sites/all/themes/challenge/param.xml",
		xmlfile: xmlFile,
		xmlfiletype: "Default",
		captionPosition: "Bottom",
		initialURL: escape(document.location)
	}
	var params = { 
		base: ".",
		bgcolor: "#000000",
		allowfullscreen: "true"
	}                
	var attributes = {}
	swfobject.embedSWF(embedFile, "flashcontent", "637", "446", "9.0.0", false, flashvars, params, attributes);  
}

function flashPutHref(href) { location.href = href; }


// Initialize Project Tabs
function initBreadCrumbs() {
	$("a[href='/og']").attr('href', '/');
}


function initHome() {
	//Set default open/close settings
	//Disabled for now - SH
	$('.acc_container').hide(); //Hide/close all containers
	$('.view-display-id-block_1 .acc_container').show();//show intro
	//setTimeout(update, 10000);//Set Timeout

	//On Click
	$('.acc_trigger:not(:first)').click(function() {
		$('.view-display-id-block_1 .acc_container').slideUp();//hide intro
		clearTimeout(update);
		if( $(this).next().is(':hidden') ) { //If immediate next container is closed...
			$('.acc_trigger').removeClass('active').next().slideUp(); //Remove all "active" state and slide up the immediate next container
			$(this).toggleClass('active').next().slideDown(); //Add "active" state to clicked trigger and slide down the immediate next container			
		} else if($(this).next().is(':visible') ) {
			$(this).removeClass('active');
			$('.acc_container').slideUp();
		}
		return false;
	});

	$('.acc_trigger:first').click(function(){
		//$('.view-display-id-block_1 .acc_container').slideToggle();//show intro
		clearTimeout(update);
		if( $(this).next().is(':hidden') ) { //If immediate next container is closed...
			$('.acc_trigger').removeClass('active').next().slideUp(); //Remove all "active" state and slide up the immediate next container
			$(this).toggleClass('active').next().slideDown(); //Add "active" state to clicked trigger and slide down the immediate next container
		} 
		return false; //Prevent the browser jump to the link anchor
	});

	var hoverbtnConfig = {
		interval: 200,
		sensitivity: 4,
		over: challengeBtn,
		timeout: 500
	};
	
	$('.acc_trigger:first').hoverIntent(hoverbtnConfig);
	
	//});
}

function update() {
	$('.view-display-id-block_1 .acc_container').slideUp();
}

function challengeBtn() {
	$('.view-display-id-block_1 .acc_container').slideToggle('slow');
}

