/* *********************** */
/*        GLOBAL		   */      
/* *********************** */ 

var global = function() {
	
	return {
	
		init : function (){
			global.initNavigation();
			global.initButtons();
		},
		
		initButtons : function () {
			
			var spanLeft = "<span class='btn-left' />";
			var spanRight = "<span class='btn-right' />";
			
			$('.btn').each(function(){
				
				$(this).prepend(spanLeft);
				$(this).append(spanRight);
				
				var input = $(this).find(":submit");
				if (input.length > 0) {
					var btnText = input.val(); 
					linkBtn = $('<a>').insertAfter(input).text(btnText).click(function(){
						$(this).parents("form")[0].submit();
					})
				}
			});
		},
				
		initNavigation : function () {	
			if ($("#home").length > 0)
				$("#nav_home").attr("src", "/images/en-US/helpingkids/home_on.png");
			if ($("#about").length > 0)
				$("#nav_about").attr("src", "/images/en-US/helpingkids/about_on.png");
			if ($("#help").length > 0)
				$("#nav_help").attr("src", "/images/en-US/helpingkids/help_on.png");
			if ($("#storyIndex").length > 0 || $("#storyDetail").length > 0)
				$("#nav_stories").attr("src", "/images/en-US/helpingkids/stories_on.png");
			
			$("div.toc-top-header ul img").hover(
				function () {	
					if ($(this).attr("src").indexOf("_on") == -1)
						$(this).attr("src", "/images/en-US/helpingkids/" + $(this).attr("id").substring(4) + "_over.png");
				}, 
				function () {
					if ($(this).attr("src").indexOf("_on") == -1)
						$(this).attr("src", "/images/en-US/helpingkids/" + $(this).attr("id").substring(4) + "_off.png");
				}
		    );
		}	
	};
}();


/* *********************** */
/*        HOMEPAGE		   */      
/* *********************** */ 

var home = function() {
	
	return {
	
		init : function (){
		
			var flashvars = {};
			
			flashvars.configPath = "/media/flash/helpingkids/home/xml/config.xml";
			flashvars.XMLPath = "/en-US/xml/tocHomeLanding/toc-home.jspx";
			flashvars.StoryUrl = "/en-US/helping-kids/story/quilt-";
			
			var params = {};
			params.allowScriptAccess="always";
			params.wmode="transparent";
	
			var attributes = {};
			swfobject.embedSWF("/media/flash/helpingkids/home/downyTOC.swf", "flashContent", "700", "425", "9.0.28.0", "/media/flash/expressInstall.swf",  flashvars, params, attributes);
						
		},
		
		expandModule : function (){
			$("div#centerCol").css("width","631px");
		},
		
		contractModule : function (){
			$("div#centerCol").css("width","345px");
		}
	};
}();


/* *********************** */
/*        ABOUT  		   */      
/* *********************** */


var about = function() {
	
	return {
	
		init : function (){
			
			
		}
	};
}();


/* *********************** */
/*        HELP  		   */      
/* *********************** */

var help = function() {
	
	return {
	
		init : function (){
			
			
		}
	};
}();


/* *********************** */
/*        STORY INDEX  	   */      
/* *********************** */

var storyIndex = function() {
	
	return {
	
		init : function (){
		
			
		}
	};
}();

/* *********************** */
/*      STORY DETAIL  	   */      
/* *********************** */

var storyDetail = function() {
	
	return {
	
		init : function (){
		
			
		}
	};
}();



$(document).ready( function() {
	
	global.init();
	
	if ($("#home").length > 0) home.init();
	if ($("#about").length > 0) about.init();
	if ($("#help").length > 0) help.init();
	if ($("#storyIndex").length > 0) storyIndex.init();
	if ($("#storyDetail").length > 0) storyDetail.init();
	
});













