// This file must be included in the header area of the page
var CUSTOMPAGE_BASE_URL = "https://www.gore-tex.com/community/components/custom";
var REACHUS_PAGE_URL = "https://www.gore-tex.com/community/ReachUs.jsp";

var FAQ_PAGE_URL = CUSTOMPAGE_BASE_URL + "/faq.html";
var LEGAL_PAGE_URL = CUSTOMPAGE_BASE_URL + "/legal.html";
var CONTESTRULES_PAGE_URL = CUSTOMPAGE_BASE_URL + "/contest-rules.html";
var TERMS_PAGE_URL = CUSTOMPAGE_BASE_URL + "/terms-conditions.html";
var EXPERIENCES_PAGE_URL = CUSTOMPAGE_BASE_URL + "/experiences.html";
var EXPERIENCEMORE_PAGE_URL = CUSTOMPAGE_BASE_URL + "/experiencemore_poll.jsp";
var MEMBERS_PAGE_URL = CUSTOMPAGE_BASE_URL + "/members.html";
var FOLLOWING_PAGE_URL = CUSTOMPAGE_BASE_URL + "/following.html";
/* Code to show custom pages */
function onCustomPageLoaded(data) {
	
	// Set the container width to full
	$j('#ka_contentContainer').css('width','960px');
	
	switch(data.myPage) {
		// FAQ Page
		case "faq":
			// show the faq iframe
			$j("<iframe frameborder='0' width='960' height='2000' scrolling='no' />")
				.attr("src", FAQ_PAGE_URL + "?user=" + Ka.Info.USERNAME)
				.appendTo("#ka_customPage");
			break;
			
		// "Legal/privacy" page
		case "legal":
			// show the bing iframe
			$j("<iframe frameborder='0' width='960' height='600' scrolling='no' />")
				.attr("src", LEGAL_PAGE_URL + "?user=" + Ka.Info.USERNAME)
				.appendTo("#ka_customPage");
			break;
			
		// "Reach Us" page
		case "reachus":
			// show the bing iframe
			$j("<iframe frameborder='0' width='960' height='500' scrolling='no' />")
				.attr("src", REACHUS_PAGE_URL + "?user=" + Ka.Info.USERNAME)
				.appendTo("#ka_customPage");
			break;
		
		// "Terms & Conditions" page
		case "terms":
			// show the bing iframe
			$j("<iframe frameborder='0' width='960' height='1660' scrolling='no' />")
				.attr("src", TERMS_PAGE_URL + "?user=" + Ka.Info.USERNAME)
				.appendTo("#ka_customPage");
			break;
			
		// "Experience More" page
		
		case "experiencemore": 
			$j("<iframe frameborder='0' width='960' height='1670' scrolling='no' />")
				.attr("src", EXPERIENCEMORE_PAGE_URL + "?user=" + Ka.Info.USERNAME)
				.appendTo("#ka_customPage"); 			 
			break;
			
		// "Contest rules" page
		case "contestrules":		 
			 
			$j("<iframe frameborder='0' width='960' height='2110' scrolling='no' />")
				.attr("src", CONTESTRULES_PAGE_URL + "?user=" + Ka.Info.USERNAME)
				.appendTo("#ka_customPage"); 
			break;
		
		// "Experiences" main page
		case "experiences":
			// show the bing iframe
			$j("<iframe frameborder='0' width='960' height='570' scrolling='no' />")
				.attr("src", EXPERIENCES_PAGE_URL + "?user=" + Ka.Info.USERNAME)
				.appendTo("#ka_customPage"); 
			break;
			
		// "Members" main page
		case "members":
			// show the bing iframe
			$j("<iframe frameborder='0' width='960' height='1110' scrolling='no' />")
				.attr("src", MEMBERS_PAGE_URL + "?user=" + Ka.Info.USERNAME)
				.appendTo("#ka_customPage"); 
			break;
			
		// "following" page
		case "following":
			// show the bing iframe
			$j("<iframe frameborder='0' width='960' height='1250' scrolling='no' />")
				.attr("src", FOLLOWING_PAGE_URL + "?user=" + Ka.Info.USERNAME + "&u=" + $j.query.get("u"))
				.appendTo("#ka_customPage"); 
			break;
			
	default:
		$j("#ka_customPage").html("Oops, this is not a valid page!");
	}
}

if(!window.YUKU) {
	var newEventId = Ka.events.listen('custom-page-loaded', onCustomPageLoaded);
}
