/*
	@filetype:.js
	@filename:kc_home.js
	@purpose:
		Control the display of the homepage.
		If a customer logs in, he can be identified using javascript-variables (roles)
		published into the frontend, e.g. "LoggedIn", "MobileOnly", etc.

		In the HTML part of the homepage div-containers corresponding to the role can be found.
		E.g. "div.home_stage_con#loggedOut" or "div.home_stage_con#loggedInQuickstart".
*/

jQuery(
	function($) {
		if((typeof(LoggedIn) != 'undefined') && (LoggedIn == true)) {	//	customer logged in
			//	hide loggedOut stage
			$('div.home_stage_con#loggedOut').hide();
				
			//	toggle footnotes (always check, if this is necessary!)
			$('#kc_main_left_wrap #kc_center_wrap #kc_center_footer_con ul#kc_footnotes').hide();
			
			if((typeof(Residential)!='undefined') && (Residential == true)) {
				//	show loggedIn stage for 'Quickstart'-customers
				if((typeof(Quickstart)!='undefined') && (Quickstart == true)) {
					$('div.home_stage_con#loggedInQuickstart').show();
					$('div.home_stage_con[id!="loggedInQuickstart"]').hide();
					$('div#home_stage_bot').hide();
				}
				
				//	show loggedIn stage for 'Quickstart'-customers with multiple contracts
				else if((typeof(QuickstartMultipleContracts)!='undefined') && (QuickstartMultipleContracts == true)) {
					$('div.home_stage_con#loggedInQuickstart').show();
					$('div.home_stage_con[id!="loggedInQuickstart"]').hide();
					$('div#home_stage_bot').hide();
				}

				//	show loggedIn stage for 'MobileOnly'-customers
				else if((typeof(MobileOnly)!='undefined') && (MobileOnly == true)) {
					$('div.home_stage_con#loggedInMobileOnly').show();
					$('div.home_stage_con[id!="loggedInMobileOnly"]').hide();
				}

				//	show loggedIn stage for 'MobileBasic'-customers
				else if((typeof(Mobile)!='undefined') && (Mobile == false) && (LoggedIn == true)) {
					$('div.home_stage_con#loggedInMobileBasic').show();
					$('div.home_stage_con[id!="loggedInMobileBasic"]').hide();
				}

				//	show loggedIn stage for 'MobileFlat'-customers
				else if((typeof(Mobile)!='undefined') && (Mobile == true) && (LoggedIn == true)) {
					$('div.home_stage_con#loggedInMobileFlat').show();
					$('div.home_stage_con[id!="loggedInMobileFlat"]').hide();
				}

				else {
				//	show loggedIn stage for 'Residential'-customers
					$('div.home_stage_con#loggedIn').show();
					$('div.home_stage_con[id!="loggedIn"]').hide();
					$('div#home_stage_bot').show();
				}
			}
		}
		else {
			//	show loggedOut stage
			$('div.home_stage_con#loggedOut').show();
			$('div#home_stage_bot').show();

			//	hide loggedIn stages for all customer groups
			$('div.home_stage_con[id!="loggedOut"]').hide();
			
			//	toggle footnotes (always check, if this is necessary!)
			$('#kc_main_left_wrap #kc_center_wrap #kc_center_footer_con ul#kc_footnotes').hide();
		}
	}
);