// JS Layout code
// 2010.02.25

//remove page checkbox
$j('#ka_searchAdv_pages').remove();

function uploadedProfileImg(json) {
	if (json.status == 1) {
		alert("Your profile image has been updated and will appear on the site shortly.");
	}
	else {
		//alert("An error occurred while trying to update your profile image: " + json.error);
	}
}

if(!window.YUKU) {
	if (Ka.Info.PAGE == 'pages/myPlace.jsp') {
		// if (document.referrer.indexOf('user/register_user.jsp') != -1) {
        		if (window.location.href.indexOf("register=1") != -1) {
				// Force a push of the profile image if this is a new registration
				aObj = new JSONscriptRequest("https://www.gore-tex.com/community/uploadprofilephoto?username=" + Ka.Info.USERNAME + "&callback=uploadedProfileImg");
				aObj.buildScriptTag();
				aObj.addScriptTag();
			}
		// }
	}
}

function getUserAdminTags() {
	//var profilename = ((typeof Ka.Info.PROFILENAME != 'undefined') ? Ka.Info.PROFILENAME : '') + ((typeof Ka.Info.Profile.PROFILENAME != 'undefined') ? Ka.Info.Profile.PROFILENAME : '');
	//var profileid = ((typeof Ka.Info.PROFILEID != 'undefined') ? Ka.Info.PROFILEID : '') + ((typeof Ka.Info.Profile.PROFILEID != 'undefined') ? Ka.Info.Profile.PROFILEID : '');
	aObj = new JSONscriptRequest("http://clientapps.kickapps.com/gore/admintags.php?userid=" + Ka.Info.USERID + "&username=" + Ka.Info.USERNAME + "&asid=" + Ka.Info.AFFILIATESITEID);
	aObj.buildScriptTag();
	aObj.addScriptTag();
}

function gotUserAdminTags(json) {
	var admintags = json.admintags;
	//alert(admintags);
	if(admintags.match('huntingtech')) {
		$j('<div id="mountaintech"><h3 style="background-image: url(http://www.gore-tex.com/resources/goretex/community/kickapps/images/mtechs_badge_bar2.jpg);">MountainTech Links</h3><ul><li><a href="/page/mountaintechs-welcome-page.html">Welcome Center</a></li><li><a href="/page/mountaintechs-m-points.html">M-Points</a></li><li><a href="/page/how-to-request-product.html">Products</a></li><li><a href="/page/hunting-techs-product-request.html">HuntingTech Products</a></li><li><a href="http://community.gore-tex.com/directory/">Forums</a></li><li><a href="/page/this-months-newsletter.html">Newsletter</a></li><li><a href="/page/mountaintechs-learning-center.html">Learning Center</a></li><li><a href="/page/mountaintechs-buddy-map.html">Buddy Map</a></li><li>Points: '+Ka.Info.CurrentMember.POINTS+'</li></ul></div>').insertBefore('#facebookStatus');
	}
	else if(admintags.match('mountaintech')) {
		$j('<div id="mountaintech"><h3 style="background-image: url(http://www.gore-tex.com/resources/goretex/community/kickapps/images/mtechs_badge_bar2.jpg);">MountainTech Links</h3><ul><li><a href="/page/mountaintechs-welcome-page.html">Welcome Center</a></li><li><a href="/page/mountaintechs-m-points.html">M-Points</a></li><li><a href="/page/how-to-request-product.html">Products</a></li><li><a href="http://community.gore-tex.com/directory/">Forums</a></li><li><a href="/page/this-months-newsletter.html">Newsletter</a></li><li><a href="/page/mountaintechs-learning-center.html">Learning Center</a></li><li><a href="/page/mountaintechs-buddy-map.html">Buddy Map</a></li><li>Points: '+Ka.Info.CurrentMember.POINTS+'</li></ul></div>').insertBefore('#facebookStatus');
		//$j('#sidebarLeft').append('<p><a href="/page/mountaintechs-learning-center.html">Learning Center</a></p>');
		//$j('#sidebarLeft').append('<div id="mypoints">Points: '+Ka.Info.CurrentMember.POINTS+'</div>');	
	}
}

function uploadedProfileImg(json) {
  if (json.status == 1) {
   alert("Your profile image has been updated and will appear on the site shortly.");
  }
  else {
   alert("An error occurred while trying to update your profile image: " + json.error);
  };
};

if (!window.YUKU) {
// Constants
$j('#ka_profileSets, #ka_profileMessageboard').show();
var USERNAME_FOR_TESTING = "Jwachtman"; // Username to use when sandboxing features for testing

var GORESITE_BASE_URL = "https://www.gore-tex.com/community"; // Goresite application base
//var GORESITE_BASE_URL = "https://www.gore-tex.com/community-test";
var COMMUNITY_BASE_URL = "http://media.community.gore-tex.com"; // Community site base url
if (Ka.Info.AFFILIATESITEID === '154524'){
	COMMUNITY_BASE_URL = "http://affiliate.kickapps.com"; // Community site base url
}

var AS_ID = Ka.Info.AFFILIATESITEID; // Affiliate ID from kickapps
var MEMBER_INFO_URL_BASE = GORESITE_BASE_URL + "/WelcomePanelHTML.jsp";
var MEMBER_INFO_URL = MEMBER_INFO_URL_BASE + "?user=" + Ka.Info.USERNAME;

var FEATURED_PROFILE_URL = GORESITE_BASE_URL + "/FeaturedProfile.jsp";
var FEATURED_GEAR_URL = "https://www.gore-tex.com/remote/Satellite?c=fabrics_content_c&cid=1251582857752&pagename=goretex_en_US%2Ffabrics_content_c%2FExperienceMore_FeaturedProduct";
var PARTNER_OFFER_URL = GORESITE_BASE_URL + "/components/partneroffer/partneroffer.html";

var EXPERIENCE_MORE_URL = GORESITE_BASE_URL + "/ExperienceMoreHTML_MeetJudges.jsp?user=" + Ka.Info.USERNAME; 

var MY_EXPERIENCES_URL = COMMUNITY_BASE_URL + "/view/displayManageSet.kickAction?as="+AS_ID;
//var MEMBERS_PAGE_URL = COMMUNITY_BASE_URL + "/service/openCustomPage.kickAction?myPage=members&title=Members&as="+AS_ID;
var MEMBERS_PAGE_URL = COMMUNITY_BASE_URL + "/service/searchEverything.kickAction?as="+AS_ID+"&mediaType=user&sortType=popular"

var CHALLENGE_CALLOUT_IMG_URL = "https://www.gore-tex.com/resources/goretex/community/kickapps/images/photo_experience_home.jpg";
var CHALLENGE_DETAILS_URL = COMMUNITY_BASE_URL + "/service/openCustomPage.kickAction?as="+AS_ID+"&myPage=experiencemore&title=Experience%20More%20Challenge";
var EXPERIENCE_SEARCH_URL = COMMUNITY_BASE_URL + "/service/searchEverything.kickAction?mediaType=set&as="+AS_ID;
var CONTEST_SEARCH_URL = COMMUNITY_BASE_URL + "/service/searchEverything.kickAction?mediaType=photo&meta=contest&as="+AS_ID;
//var MEMBER_SEARCH_URL = COMMUNITY_BASE_URL + "/service/searchEverything.kickAction?mediaType=user&as="+AS_ID;
var EDIT_PROFILE_URL = GORESITE_BASE_URL + "/user/edit_profile.jsp";
var HOME_LOGGEDIN = COMMUNITY_BASE_URL + "/service/displayMyPlace.kickAction?as="+AS_ID;
var HOME_LOGGEDOUT = GORESITE_BASE_URL + "/home.jsp"
var MY_PROFILE_URL = COMMUNITY_BASE_URL + "/service/displayKickPlace.kickAction?u="+Ka.Info.USERID+"&as="+AS_ID;
//var LOGOUT_URL = GORESITE_BASE_URL + "/user/logout_user.jsp";

var MEDIA_SET_THUMBNAIL_DATA; // Object that holds information about the media set thumbnail
var MEDIA_SET_THUMBNAIL_ID; // Object that holds information about the current set thumbnail
var META_TAG_ADD_PAGE_COMMAND; // The constructed URL that is loaded into an iframe when adding a meta tag to a media set thumbnails
var META_TAG_DEL_PAGE_COMMAND; // The constructed URL that is loaded into an iframe when deleting a meta tag to a media set thumbnails
var META_TAG_IFRAME_LOAD_NUM = 0; // Number of times the contest tagging iframe loads.


var EXPERIENCE_CALLOUT = "<div id='experienceCallout'><h4>Create New Experiences</h4><div class='inner'><p>To create an experience, you first need to upload your pictures and/or videos and create captions for them. Once you have done this, you can share your story and complete your experience.</p><ol><li class='one'><a href='/service/displayPhotoUpload.kickAction?as=" + AS_ID + "'><b>Add Photos</b></a><br />(or <a href='/view/displayManagePhoto.kickAction?as="+ AS_ID +"'>click here</a> to manage existing photos)</li><li class='two'><a href='/service/displayVideoUpload.kickAction?as=" + AS_ID + "'><b>Add Videos</b></a><br />(or <a href='/view/displayManageVideo.kickAction?as=" + AS_ID +"'>click here</a> to manage existing videos)</li><li class='three'><strong><a href='/service/displayCreateMediaSet.kickAction?as=" + AS_ID +"'>Create an Experience</a></strong><br/>Organize your photos and/or experiences, tell your story, and share it with the community. Don't forget to enter the Experience More Challenge.</li></div></div>"
// "goreSite" Object to sandbox all gore site layout update functions
var goreSite = {

    start: function() {
        goreSite.logData();
		
 	
	goreSite.setupMembersTab(); // Sets up members navigation tab
        goreSite.addExperienceTab(); // Experience menu tab
        goreSite.addMyProfileTab(); // My Profile menu tab
	goreSite.setupLoginArea();  // Sets up home page login form
	goreSite.configHomeTabs(); // Set up the Home link properly
	goreSite.setupBreadCrumbs(); // Sets up breadcrumbs
        goreSite.moveSearchField(); // Moves search field to proper position
        goreSite.hideAdminButton(); // Hides admin button for "EDITORS"
        goreSite.addColumns(); // Add 2/3 column layouts for specified pages
        goreSite.addMemberInfoPanel(); // Adds the "Member Info" panel 
        goreSite.addFeaturedProfileCallout(); // Adds "Feature Profile" callout
        goreSite.addFeaturedGearCallout(); // Adds "Featured Gear" callout
        goreSite.addPartnerOfferCallout(); // Adds "Partner Offer" callout
	goreSite.addExperienceChallengeCallout(); // Adds the "Experience More Challenge" callout
	goreSite.addVisitUsCallout(); // Adds the "Visit us on Facebook..." callout
	goreSite.setupMemberSearchPage(); // Sets up "Members" search pages
	goreSite.setupSubmissionsPage(); // Sets up the "Contest Submission" search page
	goreSite.setupExperiencesPage(); // Set up "Experiences" main page
 	goreSite.setupExperiencesDisplay(); // Sets up "Experience" display page			
	goreSite.setupMediaDisplay(); // Sets up "Photos" and "Video" display pages
	goreSite.setupMyProfileSubNav(); //Sets up the subNav for My Profile
	goreSite.fixCopy(); // Fixes copy to correct some terms
	goreSite.setupManagePhotoPage(); // Update Manage Photo Page
	goreSite.setupManageVideoPage(); // Update Manage Video Page
	goreSite.setupAddVideoPage(); // Update Add Video Page 
	goreSite.setupEditVideoPage(); // Update Edit Video Page
	goreSite.setupAddPhotoPage(); // Update Add Photo Page 		
	goreSite.setupEditPhotoPage(); // Update Edit Photo Page 		 
	goreSite.setupMyExperiencePage(); // Update My Experiences Page		
	goreSite.setupAddExperiencePage(); // Update Add Photo Page 
	goreSite.setupEditExperiencePage(); // Update Add Photo Page 
	goreSite.setupMemberPage(); // Sets up Member Profile Pages
	goreSite.setupMyProfilePage(); // Sets up My Profile Page
	goreSite.setupGATracking(); // Sets up special GA tracking
	goreSite.showContent();  // Show content hidden with CSS, after DOM is updated
	goreSite.hideEmptySubmenu(); // Hide empty submenus
	goreSite.listenForEvents(); // Listen for special KA events
	goreSite.browserFixes();
 

	 	
        //goreSite.fixIE(); // Fixes IE layout issues 

    } // END start: function() {...
	,

    // Output information to console
    logData: function() {
        
			
	sconsole("Ka.Info.USERNAME " + Ka.Info.USERNAME); // Display page
	sconsole("Ka.Info.USERID " + Ka.Info.USERID); // Display page
	sconsole("Ka.Info.PAGE " + Ka.Info.PAGE); // Display page
	sconsole("Ka.Info.PAGETYPE " + Ka.Info.PAGETYPE); // Display page
 


    } // END logData: function() {...

	,

	// Sets up expanding global navigation
	setupExpandNav: function () {
		
		
		var iHeaderHeight = $j("#header").height(); // Get header closed height;
		var bExpanded = false;
		var iDuration = 350;
		var sExpandHeight = "200px";
		
		$j("div#nav2 ul li.btn-expand").click(function(){
		
			if(bExpanded) {
				// If the nav is expanded
				
				var sHeight = iHeaderHeight + "px";				 
				// Show logo via opacity
				/*
				$j("#logo").animate({ 
					opacity: 1		 
				  }, iDuration );
				*/
								
				// Shrink header height
				$j("#header").animate({ 
					height: sHeight		 
				  }, iDuration, 'linear', showLogo );
				 
				bExpanded = false;
				
			} else {				
			  // Else the nav is shrunk
			  
			  // Hide logo via opacity (doesn't work in IE)
			  /*
			  $j("#logo").animate({ 
					opacity: 0		 
				  }, iDuration );
			  */
			 
			  $j("#logo").css('visibility','hidden');
			  
			  // Expand the height
			  $j("#header").animate({ 
					height: sExpandHeight			 
				  }, iDuration, 'linear' );
			  bExpanded = true;
			}
		  
		  
		});

	} // END setupExpandNav: function() {...
	
	,
	
	// Sets up breadcrumbs
    setupBreadCrumbs: function() {
		
		 if (Ka.Info.PAGE == 'pages/addMediaSet.jsp')  {
			$j("#ka_contentContainer").prepend("<div class='gemBreadcrumbs'><a href='"+EXPERIENCE_SEARCH_URL+"'>Experiences</a> &gt; Add New Experience</div>");
		 } else if (Ka.Info.PAGE == 'search/searchPage.jsp') {
			if ($j.query.get("mediaType") == 'user')
			{
				if ($j.query.get("keywords") != '' )
				{
					$j("#ka_contentContainer").prepend("<div class='gemBreadcrumbs'><a href='"+MEMBERS_PAGE_URL+"'>Members</a> &gt; Search Results</div>");
				} else if ($j("#ka_listPage.recent").length > 0){
					$j("#ka_contentContainer").prepend("<div class='gemBreadcrumbs'><a href='"+MEMBERS_PAGE_URL+"'>Members</a> &gt; Most Recent</div>");
				} else if ($j("#ka_listPage.popular").length > 0) {
					$j("#ka_contentContainer").prepend("<div class='gemBreadcrumbs'><a href='"+MEMBERS_PAGE_URL+"'>Members</a> &gt; Most Viewed</div>");
				} else if ($j("#ka_listPage.commented").length > 0) {
					$j("#ka_contentContainer").prepend("<div class='gemBreadcrumbs'><a href='"+MEMBERS_PAGE_URL+"'>Members</a> &gt; Most Commented</div>");
				} else if ($j("#ka_listPage.rating").length > 0) {
					$j("#ka_contentContainer").prepend("<div class='gemBreadcrumbs'><a href='"+MEMBERS_PAGE_URL+"'>Members</a> &gt; Highest Rated</div>");
				}
			} else if ($j.query.get("mediaType") == 'set' && $j.query.get("keywords") != '') {
				$j("#ka_contentContainer").prepend("<div class='gemBreadcrumbs'><a href='"+EXPERIENCE_SEARCH_URL+"'>Experiences</a> &gt; Search Results</div>");
			}
		 } else if (Ka.Info.PAGE == 'pages/manageFriends.jsp') {
			 $j("#ka_contentContainer").prepend("<div class='gemBreadcrumbs'><a href='"+MEMBERS_PAGE_URL+"'>Members</a> &gt; My Friends</div>");
		 } else if (Ka.Info.PAGE == 'pages/customPage.jsp') {
			var home_link;
			if (Ka.Info.USERID != "")
				home_link = HOME_LOGGEDIN;
			else
			 	home_link = HOME_LOGGEDOUT;
			 
			if ($j.query.get('myPage') == 'faq') {
				$j("#ka_contentContainer").prepend("<div class='gemBreadcrumbs'><a href='"+home_link+"'>Home</a> &gt; Help</div>");
			} else if ($j.query.get('myPage') == 'reachus') {
				$j("#ka_contentContainer").prepend("<div class='gemBreadcrumbs'><a href='"+home_link+"'>Home</a> &gt; Reach Us</div>");
			} else if ($j.query.get('myPage') == 'terms') {
				$j("#ka_contentContainer").prepend("<div class='gemBreadcrumbs'><a href='"+home_link+"'>Home</a> &gt; Terms of Use</div>");
			} else if ($j.query.get('myPage') == 'contestrules') {
				$j("#ka_contentContainer").prepend("<div class='gemBreadcrumbs'><a href='"+EXPERIENCE_SEARCH_URL+"'>Experiences</a> &gt; Challenge Rules</div>");
			} else if ($j.query.get('myPage') == 'experiencemore') {
				$j("#ka_contentContainer").prepend("<div class='gemBreadcrumbs'><a href='"+EXPERIENCE_SEARCH_URL+"'>Experiences</a> &gt; Experience More Challenge</div>");
			}
		 } else if (Ka.Info.PAGE == 'pages/mediaPlayPage.jsp') {
		 
		 
		 	
			if ($j("body#ka_playPage.set").length > 0){
				$j("#ka_contentContainer").prepend("<div class='gemBreadcrumbs'><a href='"+EXPERIENCE_SEARCH_URL+"'>Experiences</a> &gt; </div>");
			}
			
			// If linked from the contest page, set the breadcrumb
			if ($j.query.get("contest") == 'true') {
				if ($j("body#ka_playPage.set").length > 0){
					$j("div.gemBreadcrumbs").remove();
					$j("#ka_contentContainer").prepend("<div class='gemBreadcrumbs'><a href='http://community.gore-tex.com/service/openCustomPage.kickAction?as=98605&myPage=experiencemore&title=Experience%20More%20Challenge'>Contest</a> &gt; </div>");
				}
			}
			
		 }

    } // END setupBreadCrumbs: function() {...

	,
	
	setupMembersTab: function() {
		$j("#ka_memberTab a").attr("href",MEMBERS_PAGE_URL);	
		if (Ka.Info.PAGE == 'pages/customPage.jsp' && $j.query.get("myPage") == 'members')
		{
			$j("#ka_memberTab").attr("class","current");	
		}
	}

	,
	// Configure Home and My Home tabs on main nav for logged in / logged out users
    configHomeTabs: function() {
         var sCurrentUserId = Ka.Info.USERID;
		 
		 if(sCurrentUserId != "") {
			 // if the user is logged in, remove the standard "Home" tab
			 $j("#ka_homeTab").css("display","none");
			 $j("#ka_myhomeTab").css("display","inline");
			 
			 
		 } else {
			 // if the user is NOT logged in, remove the "My Home" tab
			 $j("#ka_myhomeTab").css("display","none");
			 $j("#ka_homeTab").css("display","inline");
		 }
		 
		 var sKaPage = Ka.Info.PAGE; 
		 
		 
		 if(sKaPage == "pages/myPlace.jsp") {
			// If we are on the "logged in" Home Page, hide the submenu
			$j("#ka_headerSubNav_list li").css("display","none"); 
		 } else {
			// If we are NOT on the logged in home
			var sCheckHomeCurrent = $j("#ka_myhomeTab").attr("class");
			
			
			if(sCheckHomeCurrent == "current"){
				// If the "Home" tab is set to class="current" && the current 
				$j("#ka_myhomeTab").attr("class", ""); // Take current off of the home tab
				$j("#MyProfile").attr("class","current");	 // Set the "My Profile" menu item to current
			}
			
			
			if(sKaPage == "pages/kickPlaceServerSide.jsp" || sKaPage == 'pages/profilePage.jsp'){
				// If we are on the profile display page 
				 
				var sCurrentUserId = Ka.Info.USERID; // Get logged in User ID
				var sProfilePageUser = $j.query.get('u'); // Get ID of profile page user
				if(sCurrentUserId != sProfilePageUser) {
					// if the current user does not equal the profile page user
			 		// TODO: This is not working...classes not being set but the code reaches here properly!!!
					$j("#MyProfile").attr("class", ""); // Take current off of the My Profile
					$j("#ka_memberTab").attr("class","current");	 // Set the "Profiles" menu item to current
				}
			
			}
		 }
		 

    } // END configHomeTabs: function() {...

	,
 
	
    // Add "Experiences" Tab
    addExperienceTab: function() {
        if ($('ka_messageBoardsTab')) {
            /* add a new <li> to the main navbar */
            var NewTab = document.createElement('li');
            NewTab.id = 'Experiences';
            $('ka_messageBoardsTab').parentNode.appendChild(NewTab);
            /* write the link into the new <li> */
             $('Experiences').innerHTML = '<a href="'+EXPERIENCE_SEARCH_URL+'"><span>Experiences</span></a>';
 
        }


    } // END addExperienceTab: function() {...	

	,
	 
    // Add "Setup Login Area" Tab
    setupLoginArea: function() {
        if ($('ka_username_welcome')) {
            $j("#ka_username_welcome").css("display","none");
        }
		
		//$j("li.ka_signout_auth a:contains('log out')").attr("href",LOGOUT_URL);

    } // END setupLoginArea: function() {...	

	,
	
    // Add "My Profile" tab
    addMyProfileTab: function() {
        var sCurrentUserId = Ka.Info.USERID;
        // If the messageboards tab exists AND the current userid is not empty
        if ($('ka_messageBoardsTab') && (sCurrentUserId != "")) {
            /* add a new <li> to the main navbar */
            var NewTab = document.createElement('li');
            NewTab.id = 'MyProfile';
            $('ka_messageBoardsTab').parentNode.appendChild(NewTab);
            /* write the link into the new <li> */

            $('MyProfile').innerHTML = '<a href="/service/displayKickPlace.kickAction?u=' + sCurrentUserId + '&as=' + AS_ID + '" title="My Profile">My Profile</a>';			
			//$('MyProfile').innerHTML = '<a href="/view/manageProfileQuestions.kickAction?as=' + AS_ID + '" title="My Profile">My Profile</a>';
		 	
        }
    } // END addMyProfileTab: function() {...	

	,

    // Moves the "Search" field 
    moveSearchField: function() {
        if ($j('#ka_headerSearch')) {

            var elemTopNavBar = $j('#ka_headerTopNav');
            var elemSearch = $j('#ka_headerSearch');
            elemTopNavBar.append(elemSearch); // Move search form into main nav
            elemSearch.css('display', 'block');

			//add validation
			$j("form:[name='ka_search']").submit(function(){
														  sSearchValue = $j("#ka_headerSearch input:[name='keywords']").attr("value");
														  if(sSearchValue == "SEARCH COMMUNITY" || sSearchValue == '') {
															alert("Please enter a keyword.");	
															return false;
														  }});

            //$j(".ka_addMedia.ka_addMedia_friend.ka_sprite_media").css('display','none'); // Hide "invite friends" link

        }
    } // END moveSearchField: function() {	...

	,

    // Hide admin button (for editors)
    hideAdminButton: function() {
        var sCurrentRole = Ka.Info.ROLENAME;

        if (sCurrentRole == "EDITOR") {
            $j("li.ka_manage_auth").css("display", "none");

        }

    } // END hideAdminButton: function() {	...

	,

    // Add the Member Information Panel
    addMemberInfoPanel: function() {
        var sKaPage = Ka.Info.PAGE;

        // If we are on the "My Home" page
        if (sKaPage == "pages/myPlace.jsp") {
            $j("#sidebarHomeLeft").append('<iframe id="miFrame" frameborder="0" width="265" height="380" scrolling="no" />');  // Append iFrame to left column
            $j('#miFrame').attr('src', MEMBER_INFO_URL); // Add src attribute
            
            
			$j('#sidebarHomeLeft').append('<div id="facebookStatus">\
				<h3>Facebook Status</h3>\
					<label for="statusUpdate">Update your Facebook Status:</label>\
					<input type="test" name="statusUpdate" value="" id="statusUpdate" />\
					<input type="submit" name="submitStatus" value="Update" id="submitStatus" onClick="updateStatusProfile(); return false;"/>\
				<p id="statusStatus"></p>\
			</div><!-- #facebookStatus -->');
        }

        /*If we are on the "Profiles" page...
        if (sKaPage == "search/searchPage.jsp") {
            // If we are on the search pages
            if ($j.query.get('mediaType') == "user") {
                // If the "mediaType" is "user" AND "includeUser" is "On"
                $j("#sidebarSearchLeft").append('<iframe id="miFrame" frameborder="0" width="265" height="440" scrolling="no" />');  // Append iFrame to left column
				$j('#miFrame').attr('src', MEMBER_INFO_URL); // Add src attribute  				
				
            }
        }*/
		
		// If we are on the "Message Board" page...
        if (sKaPage == "pages/messageBoard.jsp") {
            // If we are on the search pages
            if ($j.query.get('mediaType') == "messageBoards") {
                // If the "mediaType" is "user" AND "includeUser" is "On"
                $j("#sidebarMessageBoardLeft").append('<iframe id="miFrame" frameborder="0" width="265" height="410" scrolling="no" />');  // Append iFrame to left column
                $j('#miFrame').attr('src', MEMBER_INFO_URL); // Add src attribute  				
            }
        }



		// If we are on "My Profile" page...
		if(sKaPage == "pages/kickPlaceServerSide.jsp" || sKaPage == 'pages/profilePage.jsp') {
			if($j("#sidebarLeft")) {
			 	$j("#sidebarLeft").append('<iframe id="miFrame" frameborder="0" width="265" height="440" scrolling="no" />');  // Append iFrame to left column
				var profilename = ((typeof Ka.Info.PROFILENAME != 'undefined') ? Ka.Info.PROFILENAME : '') + ((typeof Ka.Info.Profile.PROFILENAME != 'undefined') ? Ka.Info.Profile.PROFILENAME : '');
				var profileid = ((typeof Ka.Info.PROFILEID != 'undefined') ? Ka.Info.PROFILEID : '') + ((typeof Ka.Info.Profile.PROFILEID != 'undefined') ? Ka.Info.Profile.PROFILEID : '');
            	$j('#miFrame').attr('src', MEMBER_INFO_URL_BASE + "?user=" +profilename+ "&profileid=" +profileid+ "&userid=" + Ka.Info.USERID); // Add src attribute  	
				
				//30-MAR-2011: Shannon Cord - MTECH BADGE 
				var mtflag = ((Ka.Info.PROFILEADMINTAGS == 'mountaintech' || Ka.Info.Profile.PROFILEADMINTAGS == 'mountaintech') ? 'yes' : 'no');
        
        // Add src attribute 
        $j('#miFrame').attr('src', MEMBER_INFO_URL_BASE + "?user=" +profilename+ "&profileid=" +profileid+ "&userid=" + Ka.Info.USERID + "&mtflag=" + mtflag); 
				//***
				
				$j("h5:contains('Sets')").text('Recent Experiences');
				$j("h5:contains('Message Board Posts')").text('Recent Conversations');
				
				//DISPLAY POINTS TO MOUNTAINTECH USERS
				
//test
				
				
				

				
				


				
				//getUserAdminTags(userid, username);
				
				/*if(Ka.Info.PROFILEADMINTAGS == 'mountaintech' || Ka.Info.Profile.PROFILEADMINTAGS == 'mountaintech') {
    				$j('#sidebarLeft').append('<div id="mypoints">Points: '+Ka.Info.CurrentMember.POINTS+'</div>');
				}
				if(Ka.Info.PROFILEADMINTAGS == 'mountaintech' && Ka.Info.PROFILEID == Ka.Info.USERID || Ka.Info.Profile.PROFILEADMINTAGS == 'mountaintech' && Ka.Info.Profile.PROFILEID == Ka.Info.USERID) {
					$j('#sidebarLeft').append('<a href="/page/mountaintechs-learning-center.html">Learning Center</a>');
				}*/
															
			}
		}
		
		/*
		// If we are on the "Experiences" page
		if((Ka.Info.PAGE == 'search/searchPage.jsp') && ($j.query.get('includeSets') == 'on')) {		 	
			
			 
			// If the "mediaType" is "user" AND "includeUser" is "On"
			$j("#sidebarSearchLeft").append('<iframe id="miFrame" frameborder="0" width="265" height="410" />');  // Append iFrame to left column
			$j('#miFrame').attr('src', MEMBER_INFO_URL); // Add src attribute  				
		
			
		} */

    } // END addMemberInfoPanel: function() {	...

	,

    // Add the Featured profile callout
    addFeaturedProfileCallout: function() {
        var sKaPage = Ka.Info.PAGE;

        // If we are on the "profiles" page...
        if (sKaPage == "search/searchPage.jsp") {
            // If we are on the search pages
            if ($j.query.get('mediaType') == "user") {
                // If the "mediaType" is "user" AND "includeUser" is "On"
                //$j("#sidebarSearchRight").append('<iframe id="fmFrame" frameborder="0" width="220" height="205" scrolling="no"/>');  // Append iFrame to left column
                //$j('#fmFrame').attr('src', FEATURED_PROFILE_URL); // Add src attribute  				
              	$j("#sidebarSearchRight").append('<div id="featuredProfile"><h3>Featured Profile</h3><object width="218" height="155" id="kickWidget_98605_360338" ><param name="movie" value="http://serve.a-widget.com/service/getWidgetSwf.kickAction"></param><param name="FlashVars" value="affiliateSiteId=98605&amp;widgetId=360338&amp;width=218&amp;height=155&amp;revision=22" ></param><param name="wmode" value="transparent" ></param><param name="allowFullScreen" value="true" ></param><param name="allowScriptAccess" value="always" ></param><embed src="http://serve.a-widget.com/service/getWidgetSwf.kickAction" name="kickWidget_98605_360338" width="218" height="155" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" allowScriptAccess="always" allowFullScreen="true" FlashVars="affiliateSiteId=98605&amp;widgetId=360338&amp;width=218&amp;height=155&amp;revision=22"></embed></object></div><!--#featuredProfile-->');  // Append KA widget to left column
            }
        }

    } // END addFeaturedProfileCallout: function() {	...

	,

    // Add the featured Gear Callout
    addFeaturedGearCallout: function() {
        var sKaPage = Ka.Info.PAGE;

        try {

            // If we are on the "My Home" page
            if (sKaPage == "pages/myPlace.jsp") {
	    	
		  $j("#sidebarHomeLeft").append('<iframe id="fgFrame" frameborder="0" width="220" height="205" scrolling="no" />');  // Append iFrame to right column
		
                
                $j('#fgFrame').attr('src', FEATURED_GEAR_URL + "&user=" + Ka.Info.USERNAME); // Add src attribute for Featured Gear 					
            }
			
			

        } catch (ex) {
            // Fail silently
        }

    } // END addFeaturedGearCallout: function() {	...

	,

    // Add the featured Gear Callout
    addPartnerOfferCallout: function() {
        var sKaPage = Ka.Info.PAGE;

		// If we are on the "My Home" page
		        if (sKaPage == "pages/myPlace.jsp") {
		            $j("#sidebarHomeRight").append('<iframe id="poFrame" frameborder="0" width="220" height="205" scrolling="no" />');  // Append iFrame to right column
		            $j('#poFrame').attr('src', PARTNER_OFFER_URL); // Add src attribute for Featured Promotion		
					
					getUserAdminTags();
		        }      

    } // END addPartnerOfferCallout: function() {	...
	
	,
	
	// Add the Experience More Callout
    addExperienceChallengeCallout: function() {
	    var sKaPage = Ka.Info.PAGE;

	    // If we are on the "My Home" page
	    if (sKaPage == "pages/myPlace.jsp") {
			//Add Facebook Like Box to User home. SKC 23-JUN-2010
			$j("#sidebarHomeRight").prepend('<iframe src="http://www.facebook.com/plugins/likebox.php?id=331436701202&amp;width=218&amp;connections=0&amp;stream=true&amp;header=true&amp;height=427" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:250px; height:427px; margin-bottom:50px;" allowTransparency="true"/>');  // Append iFrame to right column			    
	        //$j('#emcFrame').attr('src', EXPERIENCE_MORE_URL); // Add src attribute for Featured Gear 					

			$j('#ka_newestModule, #ka_newestModulePhoto').prependTo('#ka_leftColumn'); // add photo and video boxes

			/* Add Contest Has Ended callout */
				    //remove Contest Has Ended callout. SKC 24-JUN-2010
				 //$j("#sidebarHomeRight").prepend("<div id='challengeCallout' style='margin-bottom: 20px; background-color: #F7F7F7; border: 1px solid #E3E3E3; color: #666666; width: 218px'></div>");
				 //$j("#challengeCallout").append("<h3  style='border-bottom: 0; font-size: 12px; padding: 5px 0 5px 10px;'>Experience More Challenge</h3>");				

				 //$j("#challengeCallout").append("<img style='padding: 0' src='https://www.gore-tex.com/resources/goretex/community/kickapps/images/em_callout_winner.jpg' width='218' height='260' border='0'/>");				
				 //$j("#challengeCallout").append("<p style='margin-bottom: 6px; text-align: center;'><br/><br/>Thanks to your votes, <i>teamsightunseen</i> is now <br/>planning the adventure <br/>of a lifetime!<br/><br/></p>");		   
				 //$j("#challengeCallout").append("<div style='text-align:center; padding: 5px 0px;'><a href='http://community.gore-tex.com/service/openCustomPage.kickAction?as=98605&myPage=experiencemore&title=Experience%20More%20Challenge' target='_top'><img src='https://www.gore-tex.com/resources/goretex/community/kickapps/images/btn_see_exp.gif' width='154' height='18' border='0'/></a></div>");	    			  	    	    	   
	    }

		//If we are on Experiences page
				//Facebook Like Box
				if (sKaPage == "search/searchPage.jsp") {
					if ($j.query.get('mediaType') == "set" || ($j.query.get('mediaType') == "photo" && $j.query.get('meta') == "contest")) {


						 $j("#sidebarLeft").append('<iframe src="http://www.facebook.com/plugins/likebox.php?id=331436701202&amp;width=218&amp;connections=0&amp;stream=true&amp;header=true&amp;height=427" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:250px; height:427px; margin-top:75px;" allowTransparency="true"/>');  // Append iFrame to left column			    

		            			//$j('#emcFrame').attr('src', EXPERIENCE_MORE_URL); // Add src attribute for Featured Gear
					}
				}

	} // END addExperienceChallengeCallout: function() {	...

	,
	
	// Add the "Visit Us" on Facebook, etc. callout
    addVisitUsCallout: function() {
         var sKaPage = Ka.Info.PAGE;

        // If we are on the "profiles" page...
        if (sKaPage == "search/searchPage.jsp") {
            // If we are on the search pages
             
        }

    } // END addVisitUsCallout: function() {	...

	,

    // Add the extra columns for special layout pages
    addColumns: function() {
		
		// "My Home Page
        if (Ka.Info.PAGE == 'pages/myPlace.jsp') {
            // If we are on the "My Home" page
            $j("#ka_leftColumn").before("<div id='sidebarHomeLeft'></div>"); // Add left column
            $j("#ka_rightColumn").after("<div id='sidebarHomeRight'></div>"); // Add right column
        }
        
		// "My Profile" Page
		if (Ka.Info.PAGE == 'pages/kickPlaceServerSide.jsp' || Ka.Info.PAGE == 'pages/profilePage.jsp') {
            // If we are on the "My Profile" page
			
            $j("#ka_profileContainer").before("<div id='sidebarLeft'></div>");
			
			if(Ka.Info.USERID == Ka.Info.PROFILEID)
				goreSite.setupMyProfileMenu();			
			
        }
        
		// Search page for "Profiles"
		if (Ka.Info.PAGE == 'search/searchPage.jsp') {
		
		$j("div.pagination_info strong:contains('1 - 0')").text("0 - 0");
		
            // If we are on the "Search" page
			 if ($j.query.get('mediaType') == "user") {
				// The above querystring fields indicate we are on the "profiles" page
    	        //$j("#ka_contentContainer").before("<div id='sidebarSearchLeft'></div>");
	            $j("#ka_contentContainer").before("<div id='sidebarSearchRight'></div>");
			 } else if ($j.query.get('mediaType') == "set" || ($j.query.get('mediaType') == "photo" && $j.query.get('meta') == "contest")) {
				$j("#ka_contentContainer").before("<div id='sidebarLeft'></div>"); 
			 }
        }
		
		 
		
		/*
		if((Ka.Info.PAGE == 'search/searchPage.jsp') && ($j.query.get('includeSets') == 'on')) {
			$j("#ka_contentContainer").before("<div id='sidebarSearchLeft'></div>");
		 
		}
		*/
    } // END addColumns: function() {	...

	,
	
	
	setupMemberSearchPage: function () {
		
		
		if (Ka.Info.PAGE == 'search/searchPage.jsp') {
            // If we are on the "Search" page
			 if ($j.query.get('mediaType') == "user") {
				// The above querystring fields indicate we are on the "profiles" page
    	        //$j("#ka_contentContainer h3").after("<a href='/view/displayInviteFriends.kickAction?as=" + AS_ID + "'>Invite Friends</a>");
				// $j("#ka_contentContainer h3").css("margin-top","10px"); // Update margin top
				
				if ($j.query.get('keywords') != ''){
					$j("#ka_contentContainer h3").eq(0).text("Member Search Results for \""+$j.query.get("keywords")+"\""); // Update header
				} else if($j.query.get('sortType') == 'recent') {				
					$j("#ka_contentContainer h3:contains('Most Recent Members')").text("Meet the Newest Members"); // Update header
				} 
				 
				$j("#ka_contentContainer h3").before("<div id='memSearch'><input type='text' class='ka_searchField' id='txtProfileSearchCustom' value='search profiles' onclick='clearCustomSearchField();' /><button title='Keyword Search' type='button' class='ka_searchButton ka_sprite_search' onclick='customProfileSearch(\"user\");'>Search</button></div>");	
				
				//bind enter key press to trigger search
				$j("#txtProfileSearchCustom").keydown(function(event){if(event.keyCode == 13){customProfileSearch('user'); } });
				
				$j("#memSearch").prepend("<div id='inviteFriends' class='roundedCalloutButton' style='float: right'><a href='/view/displayInviteFriends.kickAction?as=" + AS_ID + "'>Invite a Friend</a></div>");
				 
				$j("#memSearch").before("<h1>Members</h1>");
				
				$j("ul.ka_searchList li.ka_list div.ka_searchListDetails").each(function (i){
																				var details = $j(this).find("ul.ka_listDetails");
																				var aLink = $j(this).find("h4 a");
																				var uid = aLink.attr("href").match(/u=(\d+)/)[0].substr(2);
																				if (uid != Ka.Info.USERID)
																				{
																					details.append("<li><a href='/view/displayNewMessage.kickAction?as="+AS_ID+"&name="+aLink.text().replace(/^\s+|\s+$/g, "")+"'>send private message</a></li>");
																					
																					if(checkIfFollowed(uid) == false) {
																						details.append("<li><a href='/update/addWatchMe.kickAction?u="+uid+"&as="+AS_ID+"'>+follow</a></li>");
																					}
																				}
																				});
				
				/*
				if($j("body.recent.ka_listResults").html()) {
					// If we are on the "Most popular" page
					  
					 
					// Remove extra items from the most view members
					 
					$j("ul.ka_searchList li.ka_member").each(function (i) {
								if(i > 2) {
									this.style.display = "none";
								}
					
							});
					
					$j("div.ka_pagination_wrapper").css('display','none');
					$j("ul.ka_searchList.clearfix").css('height','250px');
					var elemPopularList = $j("ul.ka_searchList.clearfix").clone();
					$j("ul.ka_searchList.clearfix").after("<h3>Most Visited Members</h3>" + elemPopularList.outerHTML());
			 		 
				 	// Add the custom rss feed for "Most popular" members		
					var sFeedUrl = "http://serve.a-feed.com/service/getFeed.kickAction?feedId=557594&as=98605";
					
					/*
					jQuery.getFeed({
					   url: sFeedUrl,
					   success: function(feed) {
						   alert("hello");
					   },
					   failure: function() {
							alert("Failed to retrieve " + sFeedUrl);   
					   }
				   });
					
					/
					
				}*/
	             
			 }
        }
	}
	,
	
	// Setup "Experiences" page layout
	setupExperiencesPage: function() {
	 	// If we are on the "Experiences" page
		if((Ka.Info.PAGE == 'search/searchPage.jsp') && ($j.query.get('mediaType') == 'set')) {	 	
			//make it look like we are on the experiences page
			selectExperienceMenu();
			
			//Add in the div that will contain the header, search box, and category drop down
			$j("#ka_contentContainer h3").before("<div id='expSearch'></div>");
			//Add the header
			$j("#expSearch").append("<h1>Experiences</h1>");
			//add the search box
			$j("#expSearch").append("<input type='text' class='ka_searchField' id='txtProfileSearchCustom' value='search experiences' onclick='clearCustomSearchField();' /><button title='Keyword Search' type='button' class='ka_searchButton ka_sprite_search' onclick='customProfileSearch(\"set\");'>Search</button>");	
			//add the category drop down
			$j("#expSearch").append("<select id='categories' onchange='activityTypeFilter(this.value);' onfocus='$j(\"#txtProfileSearchCustom\").attr(\"value\",\"\");'><option value=''>Filter List by Activity Type</option><option value='backpacking'>Backpacking</option><option value='climbing'>Climbing</option><option value='cycling'>Cycling</option><option value='hiking'>Hiking</option><option value='\"ice climbing\"'>Ice Climbing</option><option value='kayaking'>Kayaking</option><option value='\"mountain biking\"'>Mountain Biking</option><option value='running'>Running</option><option value='skiing'>Skiing</option><option value='snowboarding'>Snowboarding</option><option value='snowmobiling'>Snowmobiling</option></select>");
			
			//Find out if the keywords match any of the drop down list
			//kill quotes
			var option = $j.query.get('keywords').replace(/\"/g, "");
			var o = option.split(" ");
			var option = "";
			//capitalize first characters of words
			for (var i = 0; i < o.length; i++)
			{
				option +=	o[i].charAt(0).toUpperCase() + o[i].substr(1).toLowerCase()+" ";
			}
			
			option = option.substr(0,option.length-1);
			//see if there's an option that matches, if so, select it
			if (option.length > 0)
			{
				
				var selOption;				
			 
			 	// Loop through the options and find a match
				$j("#categories option").each(function(i) {
				 
					var sCheck = $j(this).text();
					if(sCheck == option) {
						selOption = $j(this);
					}
				});
				
				if (selOption)
					selOption.attr("selected","selected");
			}
			
			if (Ka.Info.USERNAME == 'Jwachtman')
			{
				selectReplacement($j("#categories").get(0));	
			}
			
			//bind enter key press to trigger search
			$j("#txtProfileSearchCustom").keydown(function(event){if(event.keyCode == 13){customProfileSearch('set'); } });
			
			//check to see if we have a keyword search currently
			var kw = '';
			if ($j.query.get('keywords') != '')
			{
				//if we do, keep track of it
				kw = '&keywords='+$j.query.get('keywords');
				//add it search box
				if (!selOption)
					$j("#expSearch #txtProfileSearchCustom").attr("value",$j.query.get('keywords'));
				
			}
			
			//remove double quotes from search results header
			var resultsh3 = $j("h3:contains('Search Results')");
			if (resultsh3.length > 0)
			{
				resultsh3.text(resultsh3.text().replace(/\"\"/g,"\""));
			}
			
			
			//Add the sort by text and prep it for the links
			$j("#ka_contentContainer h3").after("<div id='sortMethods'>Sort By: <a id='resort'></a></div>");
			
			//check our sort type and display the links properly
			if ($j.query.get('sortType') != '')
			{
				if ($j.query.get('sortType') == 'popular')
				{
					//if we're sorting by rating, display it
					$j("#ka_contentContainer #resort").after("&nbsp;|&nbsp;Most Viewed");
					$j("#ka_contentContainer #resort").append("Most Recent");
					$j("#ka_contentContainer #resort").attr("href",EXPERIENCE_SEARCH_URL+"&sortType=recent"+kw);
				} else {
					//otherwise assume we're sorting by date
					$j("#ka_contentContainer #resort").before("Most Recent&nbsp;|&nbsp;");
					$j("#ka_contentContainer #resort").append("Most Viewed");
					$j("#ka_contentContainer #resort").attr("href",EXPERIENCE_SEARCH_URL+"&sortType=popular"+kw);
				}
			} else {
				//no sort specified in url, default by date
				$j("#ka_contentContainer #resort").before("Most Recent&nbsp;|&nbsp;");
				$j("#ka_contentContainer #resort").append("Most Viewed");
				$j("#ka_contentContainer #resort").attr("href",EXPERIENCE_SEARCH_URL+"&sortType=popular"+kw);
			}
			
			//add link to view contest submissions
			$j("#sortMethods").prepend("<a id='contestSubLink' href='"+CONTEST_SEARCH_URL+"'>Experience More Challenge Photos</a>");
					 
			 
			/* ************************************** */
						// For AFTER the contest display this callout!!!
						//Removed 24-JUN-2010 SKC			 

							 //$j("#sidebarLeft").prepend("<div id='challengeCallout' style='margin-bottom: 50px; background-color: #F7F7F7; border: 1px solid #E3E3E3; color: #666666; width: 218px'></div>");
							 //$j("#challengeCallout").append("<h3  style='border-bottom: 0; font-size: 12px; padding: 5px 0 5px 10px;'>Experience More Challenge</h3>");				

							 //$j("#challengeCallout").append("<img style='padding: 0' src='https://www.gore-tex.com/resources/goretex/community/kickapps/images/em_callout_winner.jpg' width='218' height='260' border='0'/>");				
							 //$j("#challengeCallout").append("<p style='margin-bottom: 6px; text-align: center;'><br/><br/>Thanks to your votes, <i>teamsightunseen</i> is now <br/>planning the adventure <br/>of a lifetime!<br/><br/></p>");		   
							 //$j("#challengeCallout").append("<div style='text-align:center; padding: 5px 0px;'><a href='http://community.gore-tex.com/service/openCustomPage.kickAction?as=98605&myPage=experiencemore&title=Experience%20More%20Challenge' target='_top'><img src='https://www.gore-tex.com/resources/goretex/community/kickapps/images/btn_see_exp.gif' width='154' height='18' border='0'/></a></div>");
		}
		
		
		// Setup Experience Contest Rules menu 
		if((Ka.Info.PAGE == 'pages/customPage.jsp') && ($j.query.get('myPage') == 'experiencemore')) {
			selectExperienceMenu();
		
		}
		
		// Setup Experience Contest Rules menu 
		if((Ka.Info.PAGE == 'pages/customPage.jsp') && ($j.query.get('myPage') == 'contestrules')) {
			selectExperienceMenu();
		
		}
		
		
	} // END setupExperiencesPage: function() {	...
	
	,
	
	setupSubmissionsPage: function() {
		if ($j.query.get('mediaType') == 'photo' && $j.query.get('meta') == 'contest')
		{
			//make it look like we are on the experiences page
			selectExperienceMenu();
			
			//Add in the div that will contain the header, search box, and category drop down
			$j("#ka_contentContainer h3").before("<div id='expSearch'></div>");
			//Add the header
			$j("#expSearch").append("<h1>Experience More Challenge Photos</h1>");
			//add the search box
			$j("#expSearch").append("<input type='text' class='ka_searchField' id='txtProfileSearchCustom' value='search challenge photos' onclick='clearCustomSearchField();' /><button title='Keyword Search' type='button' class='ka_searchButton ka_sprite_search' onclick='customProfileSearch(\"photo&meta=contest\");'>Search</button>");	
			
			//bind enter key press to trigger search
			$j("#txtProfileSearchCustom").keydown(function(event){if(event.keyCode == 13){customProfileSearch('photo&meta=contest'); } });
			
			//check to see if we have a keyword search currently
			var kw = '';
			if ($j.query.get('keywords') != '')
			{
				//if we do, keep track of it
				kw = '&keywords='+$j.query.get('keywords');
				//add it search box
				$j("#expSearch #txtProfileSearchCustom").attr("value",$j.query.get('keywords'));
				
			}
			
			//Add the sort by text and prep it for the links
			$j("#ka_contentContainer h3").after("<div id='sortMethods'>Sort By: <a id='resort'></a></div>");
			
			//check our sort type and display the links properly
			if ($j.query.get('sortType') != '')
			{
				if ($j.query.get('sortType') == 'rating')
				{
					//if we're sorting by rating, display it
					$j("#ka_contentContainer #resort").after("&nbsp;|&nbsp;Highest Rated");
					$j("#ka_contentContainer #resort").append("Most Recent");
					$j("#ka_contentContainer #resort").attr("href",CONTEST_SEARCH_URL+"&sortType=recent"+kw);
				} else {
					//otherwise assume we're sorting by date
					$j("#ka_contentContainer #resort").before("Most Recent&nbsp;|&nbsp;");
					$j("#ka_contentContainer #resort").append("Highest Rated");
					$j("#ka_contentContainer #resort").attr("href",CONTEST_SEARCH_URL+"&sortType=rating"+kw);
				}
			} else {
				//no sort specified in url, default by date
				$j("#ka_contentContainer #resort").before("Most Recent&nbsp;|&nbsp;");
				$j("#ka_contentContainer #resort").append("Highest Rated");
				$j("#ka_contentContainer #resort").attr("href",CONTEST_SEARCH_URL+"&sortType=rating"+kw);
			}
			
			
			//add the win your dream experience callout
			 
				 $j("#sidebarLeft").prepend("<div id='challengeCallout' style='margin-bottom: 20px; background-color: #F7F7F7; border: 1px solid #E3E3E3; color: #666666; width: 218px'></div>");
				 $j("#challengeCallout").append("<h3  style='border-bottom: 0; font-size: 12px; padding: 5px 0 5px 10px;'>Experience More Challenge</h3>");				
		  
				 $j("#challengeCallout").append("<img style='padding: 0' src='https://www.gore-tex.com/resources/goretex/community/kickapps/images/em_callout_winner.jpg' width='218' height='260' border='0'/>");				
				 $j("#challengeCallout").append("<p style='margin-bottom: 6px; text-align: center;'><br/><br/>Thanks to your votes, <i>teamsightunseen</i> is now <br/>planning the adventure <br/>of a lifetime!<br/><br/></p>");		   
				 $j("#challengeCallout").append("<div style='text-align:center; padding: 5px 0px;'><a href='http://community.gore-tex.com/service/openCustomPage.kickAction?as=98605&myPage=experiencemore&title=Experience%20More%20Challenge' target='_top'><img src='https://www.gore-tex.com/resources/goretex/community/kickapps/images/btn_see_exp.gif' width='154' height='18' border='0'/></a></div>");
	     
		}
	}
	
	,
	
	// Adds custom search - only called from search pages
	getCustomSearchHTML: function(mediaType,searchText) {
		// Insert search field				
		
	}
	
	,
	
	//setup page that displays an experience
	setupExperiencesDisplay: function() {
		
		
		if((Ka.Info.PAGE == 'pages/mediaPlayPage.jsp') && ($j('body.set').length > 0) && ($j.query.get("displayKADefault") != "yes")) {
			// If we are on a the mediaPlayPage and the body has the class 'set', we are on an Experience detail page
			
			// Set experiences menu
			selectExperienceMenu();
			
			// update breadcrumb
			$j("#ka_contentContainer div.gemBreadcrumbs").append(Ka.Info.MEDIANAME);
			
			//add view all link
			$j("#ka_contentContainer div.gemBreadcrumbs").append("<a id='viewAllExperiences' href='"+EXPERIENCE_SEARCH_URL+"&keywords="+Ka.Info.Media.CONTRIBUTER+"'>VIEW ALL</a>");
			
			 
	 		// Display the "View all finalists" button on contest Experiences
			var sTitle = $j("title").html().toLowerCase();
				
			var bDisplayButton = false;
				
			var aContentItems=new Array();
			aContentItems[0] = "trout creek";
			aContentItems[1] = "climb for captives";
			aContentItems[2] = "high and light in the sierra nevada";
			aContentItems[3] = "more with team sight unseen";
			aContentItems[4] = "lost and found on the long trail";
			aContentItems[5] = "the time i almost died";
				
			for (var i=0; i < aContentItems.length; i++) {
				if(sTitle.indexOf(aContentItems[i]) != -1) {
					bDisplayButton = true;
					break;
				}
			}
				 
			if(bDisplayButton) {
				if(i == 3) {
					 
					$j("#viewAllExperiences").before("<div id='viewAllFinalists' style='float: right; padding-right: 70px;'><a href='http://community.gore-tex.com/service/openCustomPage.kickAction?as=98605&myPage=experiencemore&title=Experience%20More%20Challenge' target='_top'><img src='https://www.gore-tex.com/resources/goretex/community/kickapps/images/btn_view_finalists.gif' width='140' height='18' border='0'/></a></div>");
					if($j.browser.msie) {
						 
						$j("#viewAllFinalists").css("margin-top", "-13px");
					}
				} else {
					$j("#ka_contentContainer h2").after("<div style='padding-top: 5px'><a href='http://community.gore-tex.com/service/openCustomPage.kickAction?as=98605&myPage=experiencemore&title=Experience%20More%20Challenge' target='_top'><img src='https://www.gore-tex.com/resources/goretex/community/kickapps/images/btn_view_finalists.gif' width='140' height='18' border='0'/></a></div>");
				}
			}	 
			    
			   
			// Update title
			var eH2 = $j("div#ka_contentContainer h2:first");	
			if(eH2.length > 0) {
				eH2.append(" <span class='gray'>by</span> <a href='" + COMMUNITY_BASE_URL + "/service/displayKickPlace.kickAction?u=" + Ka.Info.MEDIAOWNERID + "&as=" + AS_ID + "'>" + Ka.Info.Media.CONTRIBUTER + "</a>");	 
			}
			
			// Add Follow link
			
			if(checkIfFollowed(Ka.Info.MEDIAOWNERID) == false) {
				if(Ka.Info.USERID != "" && Ka.Info.USERID != Ka.Info.MEDIAOWNERID) {
					var strFM = '<div id="follow"><a target="_parent" href="' + COMMUNITY_BASE_URL + '/update/addWatchMe.kickAction?u='+ Ka.Info.MEDIAOWNERID +'&as=98605">+ Follow</a></div>';
					$j("div#ka_contentContainer h2:first").after(strFM);
				}
			}
			
			//add the info container
			$j("#ka_leftColumn").before("<div id='experienceInfo'></div>");
			//add the cover photo
			$j("#experienceInfo").append("<img id='coverPhoto' border='0' src='" + Ka.Info.STATICSERVERIMAGES + "/" + Ka.Info.MEDIAPATHTOPREVIEW + "' />");
			//move the rating system
			$j("#experienceInfo").append($j("li#ka_statsRate div.ka_rate"));
			//move the description
			$j("#experienceInfo").append($j("div#ka_descriptionText").html());
			
			
			//sort photos and videos
			if ($j("#ka_mediaSet ul li.photo").length > 0)
				$j("#ka_mediaSet").before("<h3>Photos</h3>");
			
			$j("#ka_mediaSet ul li a").wrap("<div class='expThumb'></div>");
			
			$j("#ka_mediaSet ul li div.expThumb").each(function (i) {
														var title = $j(this).next().text();
														if (title.length > 40)
														{
															title = title.substr(0,40).replace(/^\s+|\s+$/g, "")+"..";
														}
												   		$j(this).after("<a href='"+$j(this).children().attr("href")+"'>"+title+"</a>");
														
												   
												   });
			
			
			$j("#ka_mediaSet ul li").each(function (i) { $j(this).attr("onmouseout",""); $j(this).attr("onmouseover",""); });
			
			if ($j("#ka_mediaSet ul li.video").length > 0)
			{
				$j("#ka_mediaSet").after("<div id='videoSet' class='clearfix'><ul></ul></div>");
				$j("#videoSet").before("<h3>Videos</h3>");
				$j("#ka_mediaSet ul li.video").each(function(i) {	$j("#videoSet ul").append(this); });
			}
			
			//move some stuff around in the bottom panel
			$j("#ka_statsFlag").append($j("div.ka_share_add"));
			$j("#ka_editLinkDiv").append($j("div.ka_stats"));
			
			
			/*sconsole($j("#ka_inappropriate p input").eq(0).attr("onclick"));
			$j("#ka_inappropriate p input").eq(0).attr("onclick","");
			$j("#ka_inappropriate p input").eq(0).click(function(){ka_hideInappro('ka_inappropriateDiv'); flagInappropriateMedia(); $j("#ka_flagSuccess").html("The Experience More Community staff has been notified. Thanks for helping us maintain the Experience More Community."); alert("text changed");});*/
			
		}
	} // END setupExperiencesDisplay: function() {	...
	
	,
	
	//sets up the photo and video display pages
	setupMediaDisplay: function() {
		if((Ka.Info.PAGE == 'pages/mediaPlayPage.jsp') && ($j('body.photo, body.video').length > 0)) {
			$j("#ka_uploadedby").append($j("#ka_statsRate div.ka_rate"));
												
			//move some stuff around in the bottom panel
			$j("#ka_statsFlag").append($j("div.ka_share_add"));
			$j("#ka_editLinkDiv").append($j("div.ka_stats"));
		}
	}
	
	,
	
	hideEmptySubmenu: function() {
	
		var iCount = 0;
		 
		$j("#ka_headerSubNav ul li").each(function (i) {
							 
							var sItemText = $j(this).text();
							
							var sTrimmedText = $j.trim(sItemText);
							 
							if((this.style.display != "none") && (sTrimmedText != "")) {
									iCount += 1;
								}
							});	
		
		//alert("iCount = " + iCount);
		
		if(iCount == 0) {
			$j("#ka_headerSubNav").css("visibility","hidden");
		}
	}
	
	,
	
	// Fixes copy in various places
	fixCopy: function() {
	 
		// Fix "My Sets" tab
		var aAnchorMySet = $j("a:contains('My Sets')");
		aAnchorMySet.text("My Experiences");			
		 
		
		// Fix "My Sets" Header
		var aH3MySets = $j("h3:contains('My Sets')");		 		  
		aH3MySets.text("My Experiences");
		
		
		// Fix "Create New Set" Header
		var aH3CreateSet = $j("h3:contains('Create New Set')");		 		  
		aH3CreateSet.text("My Experiences");
		
		
		// Fix "Create a Set" link
		var aAnchorCreateSet = $j("a:contains('Create New Set')");
		aAnchorCreateSet.text("Add a New Experience");
		
		//Fix "Delete Set" link
		var aAnchorCreateSet = $j("a:contains('Delete Set')");
		aAnchorCreateSet.text("Delete Experience");
		
		//Fix "Edit Set" link
		var aAnchorCreateSet = $j("a:contains('Edit Set')");
		aAnchorCreateSet.text("Edit Experience");
		
		//Fix "Create a Set" link
		var aAnchorCreateSet = $j("a:contains('Create a Set')");
		aAnchorCreateSet.text("Add an Experience");
		
		/*Handled in photo/video setup functions
		var aDivNoSets = $j("#ka_manageContent div.ka_Help:contains('sets')");
		if (aDivNoSets.length > 0)
			aDivNoSets.html(aDivNoSets.html().replace(/set/g,"experience"));*/
		
		// Fix "Set" in Experience List Set Num
		$j("li.ka_setNum").each(function (i) {
									var setNumTxt = $j(this).text().replace(/Set/, "Experience");
									$j(this).text(setNumTxt); 
								});
		
		// Fix "Add to Set" in Photos/Videos
		var aAnchorAddToSet = $j("a:contains('Add To Set')");
		aAnchorAddToSet.text("Add To Experience");
		
		
		// Add special copy to "My Photos" page
		if(Ka.Info.PAGE == 'pages/managePhoto.jsp') {
			var aH3MyPhotos = $j("h3:contains('My Photos')");	
			aH3MyPhotos.after("<p>You can manage your photos by renaming a photo, deleting an existing photo, or changing your profile photo using the links below. To change your profile photo, click Add Photo. When the photo appears in My Photos, click \"Use as my profile\" photo.</p><p>Except for your profile photo, other members will only be able to see your photos if you <a href='/service/displayCreateMediaSet.kickAction?as=" + AS_ID + "'>create an experience</a> and add the photos to it.</p><p>The <a href='/service/displayPhotoUpload.kickAction?as="+AS_ID+"'>Add Photos form</a> enables you to upload up to five photos to the site at one time.</p>");
		}
		
		// Add special copy to "My Videos" page
		if(Ka.Info.PAGE == 'pages/manageVideo.jsp') {
			var aH3MyPhotos = $j("h3:contains('My Videos')");	
			aH3MyPhotos.after("<p>You can manage your videos by renaming a video or deleting an existing video using the links below.</p><p>Other members will only be able to see your videos if you <a href='/service/displayCreateMediaSet.kickAction?as=" + AS_ID + "'>create an experience</a> and add the videos to it.</p><p>The <a href='/service/displayVideoUpload.kickAction?as="+AS_ID+"'>Add Videos form</a> enables you to upload up to five videos to the site at one time.</p>");
		}
		
		// Add copy to user logged in Home Page
		if(Ka.Info.PAGE == 'pages/myPlace.jsp') {
		
			// Add copy
			$j("#ka_myhomeUpdates h3").after("<p class='feedCopy'>Recent posts and experiences from your friends as well as special offers and site news.</p>");			
			
			// Remove feed messages containing info about "points"
			$j("li.ka_myHomeMedia:contains('points')").css("display","none");
							
		}
		
		// Replace "set" with Experience -- also have to widen the container that holds the search options.
		var elSearchSet = $j('li#ka_searchAdv_set');
		//if (elSearchSet.text().indexOf('set') > -1) { 
		//	var outerdivSearch = $j('div#ka_searchAdv1'); outerdivSearch.width(outerdivSearch.width() + 100); 
		//}
		if (elSearchSet.length > 0)
			elSearchSet.html(elSearchSet.html().replace(/set/g, "experience"));
		
		//fix breadcrumbs on conversations
		if ($j("#ka_firstBC").length > 0)
		{
			//try{sconsole($j("#ka_firstBC").next());}catch(e){}
			$j("#ka_firstBC").next().attr("class","fixFirstBC");
		}
		
		//fix header for # of threads
		$j("body.ka_messageBoards div.ka_bumperTop span.ka_forumDiscussions").text("# of Threads");
		
		//fix some stuff on conversations
		$j("body#ka_discussions div#ka_PageController1 form input.ka_memberAction").attr("value","Add New Thread");
		
		$j("body#ka_discussions #ka_discussionsContainer div.ka_contentTitle span.title").text("Threads");
		
		$j("body#ka_replies #ka_discussionsContainer div.ka_contentTitle span.title").text("Thread");
		
		$j("body#ka_replies div#ka_PageController1 form input.ka_memberAction").attr("value","Reply To This Thread");
		
		$j("body#ka_newDiscussion ul#ka_breadcrumbs li:contains('Start a new Conversation')").text("Add New Thread");
		
		//fix error messages
		$j("body#ka_generalId h3:contains('Error')").css("display","none");
		if ($j("body#ka_generalId h3 p:contains('has been removed')").length > 0)
		{
			$j("body#ka_generalId h3 p:contains('has been removed')").html("This "+$j("body#ka_generalId h3 p").html().split(" ")[1]+" has been removed from the site. You can find more <a href='"+EXPERIENCE_SEARCH_URL+"'>experiences here</a>.");
			$j("body#ka_generalId h3 p:contains('has been removed')").css("margin-top","30px");
			$j("body#ka_generalId h3 p:contains('has been removed')").css("width","700px");
		}
		
		//change edit photo to rename photo
		$j("body#ka_playPage.photo div#ka_editLink a:contains('Edit Photo')").text("Rename Photo");
		
		//change edit video to rename video
		$j("body#ka_playPage.video div#ka_editLink a:contains('Edit Video')").text("Rename Video");
		
		//change text on compose page
		$j("div.ka_Help:contains('Enter comma-separated usernames')").text("Enter comma-separated Email addresses or usernames (e.g., GORETEX_admin, SampleUser)");
		
		//Fix page titles
		sconsole(document.title);
		if (document.title)
		{
			if (document.title.indexOf("Message Board") > -1)
				document.title = document.title.replace(/Message Board/,"Conversations");
			else if (document.title.indexOf("Experience More Community media") > -1)
				document.title = "Experiences - Experience More Community";
			else if ($j("body#ka_mkp_manageSentMessages").length > 0)
				document.title = document.title.replace(/Mailbox/,"Sent Messages");
			else if ($j("body#ka_mkp_manageTrashedMessages").length > 0)
				document.title = document.title.replace(/Mailbox/,"Trash");
				
		}
		
	} // End fixCopy: function() { ....
	
	,
	
	// Sets up Manage Photo page
	setupManagePhotoPage: function() {
		
		// If we are on Manage Photo page
		if(Ka.Info.PAGE == 'pages/managePhoto.jsp') {
			// kill add to experience link and pipe
			//$j("li.ka_listEditDelete a.ka_addToSet").css("display","none"); - handled in css
			var pipes = $j("li.ka_listEditDelete span.ka_pipe");
			for (var i = 0; i < pipes.length; i++)
			{
				if ((i+1) % 2 == 0)
				pipes.eq(i).css("display","none");
			}
			$j("div.ka_gen_upphoto").css("display","none");
			
			$j("li.ka_listEditDelete a:contains('Edit')").text("Rename");
			 
			$j("#ka_manageContent").before(EXPERIENCE_CALLOUT);
		}
	}
	
	,
	
	// Sets up Manage Video page
	setupManageVideoPage: function() {
		
		// If we are on Manage Video page
		if(Ka.Info.PAGE == 'pages/manageVideo.jsp') {
			
			try{sconsole("yes?");}catch(e){}
			
			//fix success alert
			if ($j("#successUpload").length > 0)
			{
				$j("#successUpload").html($j("#successUpload").html().replace(/blog post/, "video"));
			}
			
			// kill add to experience link and pipe
			var pipes = $j("li.ka_listEditDelete span.ka_pipe");
			for (var i = 0; i < pipes.length; i++)
			{
				if ((i+1) % 2 == 0)
				pipes.eq(i).css("display","none");
			}
			
			$j("div.ka_gen_upvid").css("display","none");
			
			$j("li.ka_listEditDelete a:contains('Edit')").text("Rename");
		 
			$j("#ka_manageContent").before(EXPERIENCE_CALLOUT);
		}
	}
	
	,
	
	// Sets up Add Video Page
	setupAddVideoPage: function() {
		
		// If we are on Add Video page
		if(Ka.Info.PAGE == 'pages/newVideoUpload.jsp') {
			
			var cbRightsChecked = true;
			var cbTermsChecked = true;
			
			$j("#ka_fileTr").after($j("#ka_mediaDetailsSets")); // Move "Add to sets" field to after image chooser
			
			$j("#ka_fileTr").after($j("#ka_singleTitle")); // Move title to "Required Area"
									  
			/*$j("#ka_singleTitle").after($j("#ka_descWrap")); // Move description to "Required Area"
			
			$j("#ka_singleTitle").after($j("#mediaDescription_parent")); // Move description to "Required Area"*/
			
			$j("#ka_fileTr").after($j("#ka_singleScreen")); // Move thumbnail up to "Required Area"
			
			$j("#ka_singleScreen label strong").text("Video Thumbnail (Optional):");
				
			var btnUpload = $j("#uploadbutton");
								  
			// Add disclaimer checkboxes 			
			$j("#ka_singleScreen").after("<div id='goreCbRightsDiv'><input id='cbGoreRights' type='checkbox' checked='checked' > I certify that I have the rights to these multimedia files.*</div>");
			
			// Make checkbox disable button
			$j("#cbGoreRights").click(function () { 
							      if(cbRightsChecked) {
							      	cbRightsChecked = false;
								btnUpload.attr("disabled","disabled");	
								btnUpload.css("background-color","#CCCCCC");							
							      } else {
							         
							      	cbRightsChecked = true;
								if(cbRightsChecked && cbTermsChecked) {
									btnUpload.attr("disabled","");
									btnUpload.css("background-color","#325A7A");							
							      	}
							      }
							    });
			
			
			$j("#goreCbRightsDiv").after("<div id='goreCbTOSDiv'><input id='cbGoreTOS' type='checkbox' checked='checked'> I have read and agree to the <a href='http://affiliate.kickapps.com/service/openCustomPage.kickAction?as="+AS_ID+"&myPage=terms&title=Terms%20&%20Conditions'>Gore Terms of Use</a></div>");
			
			// Make checkbox disable button
			$j("#cbGoreTOS").click(function () { 
							      if(cbTermsChecked) {
							      	cbTermsChecked = false;
								btnUpload.attr("disabled","disabled");	
								btnUpload.css("background-color","#CCCCCC");							
							      } else {
							      	cbTermsChecked = true;
								if(cbRightsChecked && cbTermsChecked) {
									btnUpload.attr("disabled","");
									btnUpload.css("background-color","#325A7A");
								}							
							      }
							    });
			
			$j("#goreCbTOSDiv").after("<div id='goreRightsDisclaimer'>*By submitting your multimedia to this website, you agree to give Gore the rights of usage.</div>");
			
			// Update copy
			$j("#ka_liveHelp").text("A caption is required for live video recordings.");
			
			$j("#ka_mediaDetailsSets label:contains('Add to Sets:')").text("Add to Experience:"); // Update copy	
			$j("#ka_mediaDetailsSets div.ka_Help:contains('Enter a name to create a new set, or click \"My Sets\" to select one or more of your current sets.')").text("Enter a name to create a new Experience, or click \"My Experiences\" to select one or more of your current Experiences."); // Update copy
			
			$j("#ka_mediaDetailsSets label:contains('Create a new set:')").text("Create a new Experience:"); // Update copy
			
			$j("#fieldVideoUpReq ol li:contains('I accept the Experience More Community')").html('<input type="checkbox" checked="checked" name="termsOfUse" id="termsOfUse" errorkey="termsOfService" required="true" style="display: none;"/>'); // Hide TOS checkbox
		
			$j("#ka_singleTitle label:contains('Title')").text("Caption:"); // Update 'Title' to 'Caption'
			
			ka_setVideoMultiple(true);
			
			// Change copy
			$j("#ka_multiple0").html("(from your computer):");
			 
			$j("span.ka_uploadHelpMultipleVideoThumbnails").css("font-style","italic");
			// Update copy
			$j("td.ka_formLabel:contains('Title')").text("Add a Caption (127-character limit):");
			$j("td.ka_formLabel:contains('*File')").text("");
			
			$j("#uploadbutton").attr("value", "Add Videos");
			$j("#uploadbutton").after("<p>Don't forget to add these videos to an experience.</p>");
			
			// Add layout boxes
			$j("#fieldVideoUpReq").prepend("<div id='goreFormBox3' class='goreFormBox'></div>");
			$j("#fieldVideoUpReq").prepend("<div id='goreFormBox2' class='goreFormBox'></div>");
			$j("#fieldVideoUpReq").prepend("<div id='goreFormBox1' class='goreFormBox'></div>");
			 
			// Move "Add Videos" up to box
			$j("#goreFormBox1").append($j("<span><b style='font-size: 12px'>Add Videos</b> (from your computer):</span>"));
			$j("#goreFormBox1").append($j("fieldset#fieldVideoUpReq ol li label:first"));
			$j("#goreFormBox1").append($j("fieldset#fieldVideoUpReq div.ka_Help:first"));
			
			$j("#multiple_screenShot_lable").text("Select Video Thumbnail:");
				
			// Move File chooser table up to box
			$j("#goreFormBox2").append($j("fieldset#fieldVideoUpReq table:first"));
			
			// Move rest of visible items to box
			$j("#goreFormBox3").append($j("fieldset#fieldVideoUpReq div#goreCbRightsDiv"));
			$j("#goreFormBox3").append($j("fieldset#fieldVideoUpReq div#goreCbTOSDiv"));
			$j("#goreFormBox3").append($j("fieldset#fieldVideoUpReq div#goreRightsDisclaimer"));
			$j("#goreFormBox3").append($j("p#ka_videoSubmit"));
			
			$j("#goreFormBox1").before($j("div#checkError-error"));
		}
			
		 
	} // End setupAddVideoPage: function() {...


	,
	
	// Sets up Edit Video Page
	setupEditVideoPage: function() {
		
		// If we are on Edit Video page
		if(Ka.Info.PAGE == 'pages/editVideo.jsp') {
			$j("#editVideo fieldset").eq(0).attr("id","fieldVideoUpReq");
			$j("#editVideo fieldset").eq(1).attr("id","fieldVideoUpOpt");
			
			/*$j("#watchVideo").after("<div id='ka_descWrap'></div>");
			$j("#ka_descWrap").append($j("#mediaDescription"));
			$j("#ka_descWrap #mediaDescription").before("<label><strong>Description:</strong></label>");
			$j("#ka_descWrap #mediaDescription").after($j("#mediaDescription_parent"));*/
					
			$j("#watchVideo").after($j("#ka_mediaDetailsSets")); // Move "Add to sets" field to after image chooser
			
			// Update copy
			$j("#ka_mediaDetailsSets label:contains('Add to Sets:')").text("Add to Experience:"); // Update copy
			
			$j("#ka_mediaDetailsSets div.ka_Help:contains('Enter a name to create a new set, or click \"My Sets\" to select one or more of your current sets.')").text("Enter a name to create a new Experience, or click \"My Experiences\" to select one or more of your current Experiences."); // Update copy
			
			$j("#ka_mediaDetailsSets label:contains('Create a new set:')").text("Create a new Experience:"); // Update copy
			
			$j("#fieldVideoUpReq ol li:contains('I accept the Experience More Community')").html('<input type="checkbox" checked="checked" name="termsOfUse" id="termsOfUse" errorkey="termsOfService" required="true" style="display: none;"/>'); // Hide TOS checkbox
		
			$j("#fieldVideoUpReq label strong:contains('Title')").text("Caption (127-character limit):"); // Update 'Title' to 'Caption'
			
			$j("#ka_manageContent h3:contains('Edit Video')").text("Rename Video");
			
		}
			
		 
	} // End setupEditVideoPage: function() {...

	,
 
	// Sets up Add Photo Page
	setupAddPhotoPage: function() {
		
		
		// If we are on Add Photo page
		if(Ka.Info.PAGE == 'pages/newPhotoUpload.jsp') {
			
			var cbRightsChecked = true;
			var cbTermsChecked = true;
		
			$j("#ka_fileTr").after($j("#ka_mediaDetailsSets")); // Move "Add to sets" field to after image chooser
			
			$j("#ka_fileTr").after($j("#ka_singleTitle")); // Move title to "Required Area"
			 
			var btnUpload = $j("#uploadbutton");
		  
			
		  	// Add disclaimer checkboxes 			
			$j("#ka_fileTr").after("<div id='goreCbRightsDiv'><input id='cbGoreRights' type='checkbox' checked='checked' > I certify that I have the rights to these multimedia files.*</div>");
			
			// Make checkbox disable button
			$j("#cbGoreRights").click(function () { 
							      if(cbRightsChecked) {
							      	cbRightsChecked = false;
								btnUpload.attr("disabled","disabled");	
								btnUpload.css("background-color","#CCCCCC");							
							      } else {
							         
							      	cbRightsChecked = true;
								if(cbRightsChecked && cbTermsChecked) {
									btnUpload.attr("disabled","");
									btnUpload.css("background-color","#325A7A");							
							      	}
							      }
							    });
			
			$j("#goreCbRightsDiv").after("<div id='goreCbTOSDiv'><input id='cbGoreTOS' type='checkbox' checked='checked'> I have read and agree to the <a href='http://affiliate.kickapps.com/service/openCustomPage.kickAction?as="+AS_ID+"&myPage=terms&title=Terms%20&%20Conditions'>Gore Terms of Use</a></div>");
			
			// Make checkbox disable button
			$j("#cbGoreTOS").click(function () { 
							      if(cbTermsChecked) {
							      	cbTermsChecked = false;
								btnUpload.attr("disabled","disabled");	
								btnUpload.css("background-color","#CCCCCC");							
							      } else {
							      	cbTermsChecked = true;
								if(cbRightsChecked && cbTermsChecked) {
									btnUpload.attr("disabled","");
									btnUpload.css("background-color","#325A7A");
								}							
							      }
							    });
			
			$j("#goreCbTOSDiv").after("<div id='goreRightsDisclaimer'>*By submitting your multimedia to this website, you agree to give Gore the rights of usage.</div>");
			
			// Update copy
			$j("#ka_mediaDetailsSets label:contains('Add to Sets:')").text("Add to Experience:"); // Update copy
			
	 		$j("#ka_mediaDetailsSets div.ka_Help:contains('Enter a name to create a new set, or click \"My Sets\" to select one or more of your current sets.')").text("Enter a name to create a new Experience, or click \"My Experiences\" to select one or more of your current Experiences."); // Update copy		
			$j("#ka_mediaDetailsSets label:contains('Create a new set:')").text("Create a new Experience:"); // Update copy
			$j("#fieldVideoUpReq ol li:contains('I accept the Experience More Community')").html('<input type="checkbox" checked="checked" name="termsOfUse" id="termsOfUse" errorkey="termsOfService" required="true" style="display: none;"/>'); // Hide TOS checkbox
			
			$j("#ka_mediaDetailsSets label:contains('Create a new set:')").text("Create a new Experience:"); // Update copy
			
			
			$j("#ka_singleTitle label strong:contains('Title')").text("Caption"); // Update 'Title' to 'Caption' for single
			
			$j("#ka_multiple1 td:contains('Title')").text("Caption:"); // Update 'Title' to 'Caption' for multiple upload
			
			
			// Display multiple photo upload
			
			ka_setVideoMultiple(true,'photo');
			
			// Change copy
			 			
			
			
			
			// Update copy
			$j("td.ka_formLabel:contains('Caption:')").text("Add a Caption (127-character limit):");
			$j("td.ka_formLabel:contains('*File')").text("Choose a File");
			
			$j("#uploadbutton").attr("value", "Add Photos");
			$j("#uploadbutton").after("<p>Don't forget to add these photos to an experience.</p>");
			 
			// Add layout boxes
			$j("#ka_fieldPhotoUpReq").prepend("<div id='goreFormBox3' class='goreFormBox'></div>");
			$j("#ka_fieldPhotoUpReq").prepend("<div id='goreFormBox2' class='goreFormBox'></div>");
			$j("#ka_fieldPhotoUpReq").prepend("<div id='goreFormBox1' class='goreFormBox'></div>");
			 
			// Move "Add photos up to box
			$j("#goreFormBox1").append($j("fieldset#ka_fieldPhotoUpReq label:first"));
			$j("#goreFormBox1").append($j("fieldset#ka_fieldPhotoUpReq div.ka_Help:first"));
			
			
				
			// Move File chooser table up to box
			$j("#goreFormBox2").append($j("fieldset#ka_fieldPhotoUpReq table:first"));
			
			// Add Multiple Toggle
			
			// hide multiple by default
			$j('#ka_multiple3,#ka_multiple4,#ka_multiple5,#ka_multiple6,#ka_multiple7,#ka_multiple8,#ka_multiple9,#ka_multiple10,#ka_multiple11,#ka_multiple12,#ka_multiple13,#ka_multiple14,#ka_multiple15,#ka_multiple16,#ka_multiple17,#ka_multiple18,#ka_multiple19,#ka_multiple20,#ka_multiple21,#ka_multiple22,#ka_multiple23,#ka_multiple24,#ka_multiple25,#ka_multiple26').hide();
			
			window.showSingleField = function(){
				$j('#ka_multiple3,#ka_multiple4,#ka_multiple5,#ka_multiple6').hide();
				$j('#uploadMultipleToggle').removeClass('singleUpload').addClass('multipleUpload').text('Upload Multiple Images?');				
				$j('#ka_fieldPhotoUpOpt label:first').text('Description:');
			}
			
			window.showMultipleFields = function(){
				$j('#ka_multiple3,#ka_multiple4,#ka_multiple5,#ka_multiple6').show();
				$j('#uploadMultipleToggle').removeClass('multipleUpload').addClass('singleUpload').text('Upload Single Image?');
				$j('#ka_fieldPhotoUpOpt label:first').text('Description (will be applied to all images):');
			}
			
			$j('#goreFormBox2').append('<p><a href="#" id="uploadMultipleToggle" class="multipleUpload">Upload Multiple Photos?</a></p>');
			
			$j('#uploadMultipleToggle').click(function(){
				if($j(this).hasClass('singleUpload')){
					showSingleField();
				}else{
					showMultipleFields();
				}
				return false;				
			});
		
			
			// Move rest of visible items to box
			$j("#goreFormBox3").append($j("fieldset#ka_fieldPhotoUpReq div#goreCbRightsDiv"));
			$j("#goreFormBox3").append($j("fieldset#ka_fieldPhotoUpReq div#goreCbTOSDiv"));
			$j("#goreFormBox3").append($j("fieldset#ka_fieldPhotoUpReq div#goreRightsDisclaimer"));
			$j("#goreFormBox3").append($j("p#ka_photoSubmit")); 
			 
			$j("#goreFormBox1").before($j("div#checkError-error"));
			
			$j("#goreFormBox1 label").html("Add photos (from your computer):");
		}
			
		 
	} // End setupAddPhotoPage: function() {...
	
	,
	
	// Sets up Edit Photo Page
	setupEditPhotoPage: function() {
		
		
		// If we are on Edit Photo page
		if(Ka.Info.PAGE == 'pages/editPhoto.jsp') {
	 
			$j("#ka_viewPhoto").after($j("#ka_mediaDetailsSets")); // Move "Add to sets" field to after image chooser
					  
			
			 
			/* Don't need these on the edit form
			// Add disclaimer checkboxes 			
			$j("#goreCbEnterContestDiv").after("<div id='goreCbRightsDiv'><input id='cbGoreRights' type='checkbox' checked='checked' > I certify that I have the rights to these multimedia files.*</div>");
			
			$j("#goreCbRightsDiv").after("<div id='goreCbTOSDiv'><input id='cbGoreTOS' type='checkbox' checked='checked'> I have read and agree to the <a href='http://affiliate.kickapps.com/service/openCustomPage.kickAction?as="+AS_ID+"&myPage=terms&title=Terms%20&%20Conditions'>Gore Terms of Use</a></div>");
			
			$j("#goreCbTOSDiv").after("<div id='goreRightsDisclaimer'>*By submitting your multimedia to this website, you agree to give Gore the rights of usage.</div>");*/
			
			// Update copy
			$j("#ka_mediaDetailsSets label:contains('Add to Sets:')").text("Add to Experience:"); // Update copy
			
			$j("#ka_mediaDetailsSets div.ka_Help:contains('Enter a name to create a new set, or click \"My Sets\" to select one or more of your current sets.')").text("Enter a name to create a new Experience, or click \"My Experiences\" to select one or more of your current Experiences."); // Update copy
			
			$j("#ka_mediaDetailsSets label:contains('Create a new set:')").text("Create a new Experience:"); // Update copy
			
			$j("#fieldVideoUpReq ol li:contains('I accept the Experience More Community')").html('<input type="checkbox" checked="checked" name="termsOfUse" id="termsOfUse" errorkey="termsOfService" required="true" style="display: none;"/>'); // Hide TOS checkbox
			
			$j("fieldset label strong:contains('Title')").text("Caption (127-character limit):"); // Update 'Title' to 'Caption'
			
			$j("label:contains('This image is:')").css("display","none");
			
			var sTags = $j("#mediaTags").attr("value")
			 
			if(sTags.trim() == "contest") {
			 
				$j("#cbGoreContest").attr("checked","checked");
			}
			
			$j("#ka_manageContent h3:contains('Edit Photo')").text("Rename Photo");
			
		}
			
		 
	} // End setupEditPhotoPage: function() {...
	
	/*,
	
	fixATSPopUp: function() {
		alert("hey");
	}*/
	
	,
	
	// Sets up My Experiences Page
	setupMyExperiencePage: function() {
			// Update title
			
			if (Ka.Info.PAGE == 'pages/manageSet.jsp')
			{
				document.title = Ka.Info.USERNAME + "'s home - Experiences - Experience More Community";
				 
				//Fix help copy
				$j("div.ka_Help").html("You have not created any experiences yet. To create an experience, first <a href='/service/displayPhotoUpload.kickAction?as="+AS_ID+"'>add photos</a> or <a href='/service/displayVideoUpload.kickAction?as="+AS_ID+"'>add videos</a>, then <a href='/service/displayCreateMediaSet.kickAction?as="+AS_ID+"'>create your experience</a>.");
				
				// Add special copy for My Experiences page			 
				var aH3MySets = $j("#ka_manageContent h3:contains('My Experiences')");
				
				//aH3MySets.after("<div id='experienceCopy'><p>To create an Experience, you will need to first<br /> upload the photos and videos to your profile.</p></div><div id='experienceMediaButtons'><a href='/service/displayPhotoUpload.kickAction?as=" + AS_ID + "'>Add New Photos</a> <a href='/service/displayVideoUpload.kickAction?as=" + AS_ID + "'>Add New Videos</a> <a href='/view/displayManagePhoto.kickAction?as="+ AS_ID +"'>Manage Photos</a> <a href='/view/displayManageVideo.kickAction?as=" + AS_ID +"'>Manage Videos</a></div><div style='clear:both'></div>");
				
				$j("div.ka_gen_upset").css("display","none");
				 
				
				aH3MySets.after("<div id='experienceCopy'><p>An experience is a group of photos and/or videos related to one experience or trip. To create an experience, follow the steps at right.</p></div>");
				
				$j("#ka_manageContent").before(EXPERIENCE_CALLOUT);
				
				$j("li.ka_listEditDelete a:contains('Delete')").click(function () {
											      $j("div.popup_mainBody p:contains('Are you sure you want to delete this media set?')").text("Are you sure you want to delete this experience?");
											    });

				
			 
			}
			 
	}
	
	,
	
	// Sets up Add Experience Set Page
	setupAddExperiencePage: function() {
		 
		// If we are on Add Media Set
		if(Ka.Info.PAGE == 'pages/addMediaSet.jsp') {
		
			 document.title = Ka.Info.USERNAME + "'s home - Add an Experience - Experience More Community";
			  
			 // Update copy
			 $j("#ka_mediaSet_description_wrapper label:contains('Name:')").text("Title:");
			 
			 // Update copy
			 $j("#ka_mediaSet_contents_wrapper label:contains('Contents:')").text("Experience Media:");
			 
			 // Update copy
			 $j("#ka_mediaSet_thumbnail_helper").text("Drag an image here that best represents your experience.");		 

			 // Update copy
			 $j("#ka_mediaSet_contents_wrapper div.inner span:contains('Drag and drop media here to create a set')").text("Drag and drop your photos and videos from above to create an experience");
			
			 // Update button copy
			 $j("#ka_mediaSet_save").attr("value","Save This Experience");
			 
			 // Update copy in drag box
			 $j("#ka_mediaSet_remove span").text("Drop media item here to remove it from this experience");
			 
			 // Add checkboxes
			 $j("#ka_mediaSet_panel").after("<div id='cbGoreExpDiv'><table width='100%'><tr><td><input type='checkbox' onclick='addCheckboxTag(\"skiing\")'> Skiing</td><td><input type='checkbox' onclick='addCheckboxTag(\"cycling\")'> Cycling</td><td><input type='checkbox' onclick='addCheckboxTag(\"running\")'> Running</td></tr><tr><td><input type='checkbox' onclick='addCheckboxTag(\"snowboarding\")'> Snowboarding</td><td><input type='checkbox' onclick='addCheckboxTag(\"backpacking\")'> Backpacking</td><td><input type='checkbox' onclick='addCheckboxTag(\"snowmobiling\")'> Snowmobiling</td></tr><tr><td><input type='checkbox' onclick='addCheckboxTag(\"hiking\")'> Hiking</td><td><input type='checkbox' onclick='addCheckboxTag(\"ice climbing\")'> Ice Climbing</td><td><input type='checkbox' onclick='addCheckboxTag(\"kayaking\")'> Kayaking</td></tr><tr><td><input type='checkbox' onclick='addCheckboxTag(\"mountain biking\")'> Mountain Biking</td><td><input type='checkbox' onclick='addCheckboxTag(\"rock climbing\")'> Rock Climbing</td></tr></table></div>");
			  
			 // Add contest checkbox				
			 //$j("#cbGoreExpDiv").before("<div id='goreCbContestDiv'><input id='cbGoreContest' type='checkbox' > Enter this photo in the Experience More Challenge.</div>");
			
			 //$j("#goreCbContestDiv").after("<div>Note: Once you enter a photo in the contest, it will remain in the contest even if you change your thumbnail photo. The only way to remove it from the contest is to delete the photo.</div>");
						
			// Add contest meta tagging iFrame				
			 $j("#cbGoreExpDiv").before("<iframe id='ifGoreMetaTag' src='' frameborder='1' width='500' height='180' scrolling='no' style='display: none' onload='metaTagIframeLoaded();'  ></iframe>");
			 
		
			$j("#ka_mediaSet_save").css("display", "none");

			 $j('#ka_mediaSet_save').before('<input id="ka_mediaSet_save2" class="ka_button" type="button" onclick="" value="Save This Experience" name="ka_mediaSet_save2"/>');
			  
			 $j("#ka_mediaSet_save2").click(function () {			 
			 	submitMediaSetContestMeta();			 	
			 });
			 
			 
			 // Adjust layout
						 
			$j("#ka_mediaSet_description_wrapper").after($j("#ka_mediaSet_source_wrapper")); // Move media picker to be next to media drop area
			$j("#ka_mediaSet_description_wrapper").before("<div  class='expInstructions'><b>Step 1: Enter a Title and Description</b></div>");
			$j("#ka_mediaSet_description_wrapper").after("<div  class='expInstructions'><b>Step 2: Select Photos and Videos*</b> Select the photos and videos that are part of this experience. </div>");
			$j("#ka_mediaSet_source_items_wrapper").after("<div class='expFinePrint'>*Photos and videos may take a few minutes to appear after you have uploaded them. If you do not see your photos and videos yet, please wait a minute then refresh this page.</div>");
			$j("#ka_mediaSet_contents_wrapper").after($j("#ka_mediaSet_thumbnail_wrapper"));
			$j("#ka_mediaSet_thumbnail_wrapper").before("<div class='expInstructions'><b>Step 3: Choose a Thumbnail</b> Choose an image to represent this experience.</div>");			
			$j("#cbGoreExpDiv").before("<div class='expInstructions'><b>Step 4: Choose Activities and Save</b> Select the activities that best describe your experience.</div>");
			 
			$j("#ka_mediaSet_description_wrapper label:contains('Title:')").text("Title (50-character limit):");
			$j("#ka_mediaSet_description_wrapper input#mediaName").attr("maxlength","50");

			// Add arrow
			$j("#ka_mediaSet_source_wrapper").after("<div class='downArrow'></div>");
			
			//28-MAR-2011: Shannon Cord - removed these because they don't make any sense without the original names...
			// Update dropdowns
			//$j("#mediaSearchWithin option:contains('All of My Media')").text("View All My Media");
			//$j("#mediaSearchWithin option:contains('My Videos')").text("View My Videos Only");
			//$j("#mediaSearchWithin option:contains('My Photos')").text("View My Photos Only");
			
			$j("#ka_manageContent h3:contains('My Experience')").text("Add an Experience");
			$j("#ka_mediaSet_contents_wrapper label:contains('Experience Media:')").text("Experience Photos and Videos:");
			
			//28-MAR-2011: Shannon Cord - removed this because it was being used as search criteria and causing problems...
			//$j("#mediaSearchKeywords").attr("value","My photos and videos");
			
			// Remove copy from field
			 $j("#mediaSearchKeywords").click(function() {
			 	 if(this.value == "My photos and videos") {
					 this.value = "";				  
				 }
				 });
				 
		 
			 
			$j("#ka_mediaSet_thumbnail_wrapper label").text("");
		}
			
		 
	} // End setupAddPhotoPage: function() {...
	
	,
	
	
	// Sets up Add Experience Set Page
	setupEditExperiencePage: function() {
		
		// If we are on Add Media Set
		if(Ka.Info.PAGE == 'pages/editSet.jsp') {
		
			 // Update title
			 var sPageTitle = $j("html head title").text();
			 sPageTitle = sPageTitle.replace(/My Sets/, "My Experiences");
			 //$j("html head title").text(sPageTitle); // Causing error in IE
			 
			 // Update copy
			 $j("#ka_manageContent h3").text("Edit Experience");
			 
			 // Update copy
			 $j("#ka_mediaSet_contents_wrapper div.ka_Help").text("Add items to this Experience by dragging them from the search results above.");
			  
			 // Update copy
			 $j("#ka_mediaSet_description_wrapper label:contains('Name:')").text("Title:");
			 
			 // Update copy
			 $j("#ka_mediaSet_contents_wrapper label:contains('Contents:')").text("Experience Media:");
			 
			 // Update copy
			 $j("#ka_mediaSet_thumbnail_helper").text("Drag an image here that best represents your experience.");		 
 
			 // Update copy
			 $j("#ka_mediaSet_contents_wrapper div.inner span:contains('Drag and drop media here to create a set')").text("Drag and drop your photos and videos from above to create an Experience");
			
			 // Update button copy
			 $j("#ka_mediaSet_save").attr("value","Save This Experience");
			 
			 // Update copy in drag box
			 $j("#ka_mediaSet_remove span").text("Drop media item here to remove it from this experience");
			 			 
			 // Add checkboxes
			 $j("#ka_mediaSet_panel").after("<div id='cbGoreExpDiv'><table width='100%'><tr><td><input id='cbskiing' type='checkbox' onclick='addCheckboxTag(\"skiing\")'> Skiing</td><td><input id='cbcycling' type='checkbox' onclick='addCheckboxTag(\"cycling\")'> Cycling</td><td><input id='cbrunning' type='checkbox' onclick='addCheckboxTag(\"running\")'> Running</td></tr><tr><td><input id='cbsnowboarding'type='checkbox' onclick='addCheckboxTag(\"snowboarding\")'> Snowboarding</td><td><input id='cbbackpacking' type='checkbox' onclick='addCheckboxTag(\"backpacking\")'> Backpacking</td><td><input id='cbsnowmobiling' type='checkbox' onclick='addCheckboxTag(\"snowmobiling\")'> Snowmobiling</td></tr><tr><td><input id='cbhiking' type='checkbox' onclick='addCheckboxTag(\"hiking\")'> Hiking</td><td><input id='cbiceclimbing' type='checkbox' onclick='addCheckboxTag(\"ice climbing\")'> Ice Climbing</td><td><input id='cbkayaking' type='checkbox' onclick='addCheckboxTag(\"kayaking\")'> Kayaking</td></tr><tr><td><input id='cbmountainbiking' type='checkbox' onclick='addCheckboxTag(\"mountain biking\")'> Mountain Biking</td><td><input id='cbrockclimbing' type='checkbox' onclick='addCheckboxTag(\"rock climbing\")'> Rock Climbing</td></tr></table></div>");
			 
			 
			 
			 // Add contest checkbox				
			 //$j("#cbGoreExpDiv").before("<div id='goreCbContestDiv'><input id='cbGoreContest' type='checkbox' > Enter this photo in the Experience More Challenge.</div>");
			
			 //$j("#goreCbContestDiv").after("<div>Note: Once you enter a photo in the contest, it will remain in the contest even if you change your thumbnail photo. The only way to remove it from the contest is to delete the photo.</div>");
			
			// Add contest meta tagging iFrame				
			 $j("#cbGoreExpDiv").before("<iframe id='ifGoreMetaTag' src='' frameborder='1' width='500' height='180' scrolling='no' style='display: none' onload='metaTagIframeLoaded();' ></iframe>");
			 
	 
	 		 // Set this variable to be the current thumbnail ID
			 MEDIA_SET_THUMBNAIL_ID = Ka.mediaSets.currentSet.currentThumbnailMediaId.split("_")[1]; // Get current thumbnail	
			
			 $j("#ka_mediaSet_edit").css("display", "none");

			 $j('#ka_mediaSet_edit').before('<input id="ka_mediaSet_edit2" class="ka_button" type="button" onclick="" value="save edits" name="ka_mediaSet_edit2"/>');
			  
			 $j("#ka_mediaSet_edit2").click(function () {			 
			 	submitMediaSetContestMeta();			 	
			 });
			 
			 // Adjust layout 			 
			$j("#ka_mediaSet_description_wrapper").after($j("#ka_mediaSet_source_wrapper")); // Move media picker to be next to media drop area 			 
			$j("#ka_mediaSet_description_wrapper").before("<div  class='expInstructions'><b>Step 1: Enter a Title and Description</b></div>");
			$j("#ka_mediaSet_description_wrapper").after("<div  class='expInstructions'><b>Step 2: Select Photos and Videos*</b> Select the photos and videos that are part of this experience. </div>");
			$j("#ka_mediaSet_source_items_wrapper").after("<div class='expFinePrint'>*Photos and videos may take a few minutes to appear after you have uploaded them. If you do not see your photos and videos yet, please wait a minute then refresh this page.</div>");
			$j("#ka_mediaSet_contents_wrapper").after($j("#ka_mediaSet_thumbnail_wrapper"));
			$j("#ka_mediaSet_thumbnail_wrapper").before("<div class='expInstructions'><b>Step 3: Choose a Thumbnail</b> Choose an image to represent this experience.</div>");
						$j("#cbGoreExpDiv").before("<div class='expInstructions'><b>Step 4: Choose Activities and Save</b> Select the activites that best describe your experience.</div>");
			 
			$j("#ka_mediaSet_description_wrapper label:contains('Title:')").text("Title (30-character limit):");

			// Add arrow
			$j("#ka_mediaSet_source_wrapper").after("<div class='downArrow'></div>");
						
			// Update dropdowns
			$j("#mediaSearchWithin option:contains('All of My Media')").text("View All");
			$j("#mediaSearchWithin option:contains('My Videos')").text("View Videos Only");
			$j("#mediaSearchWithin option:contains('My Photos')").text("View Photos Only");$j("#mediaSearchWithin option:first").text("View All");
			
			
			$j("#ka_manageContent h3:contains('Edit Experience')").text("Edit Experience");
			$j("#ka_mediaSet_contents_wrapper label:contains('Experience Media:')").text("Experience Photos and Videos:");
			$j("#mediaSearchKeywords").attr("value","My photos and videos");			
			// Remove copy from field
			 $j("#mediaSearchKeywords").click(function() {
			 	 if(this.value == "My photos and videos") {
					 this.value = "";				  
				 }
				 });
				 
				 
			$j("#ka_mediaSet_thumbnail_wrapper label").text("");
				
			 // Check off selected checkboxes		 
			 var sTags = $j("#mediaTags").attr("value");
		 
			 sTags = sTags.replace(/(\s)(?=\w+\")/g, "");
			 sTags = sTags.replace(/\"/g, "");
			 var cboxes = sTags.split(" ");
			 for (var i = 0; i < cboxes.length; i++)
			 {
				try{ $j("#cb"+cboxes[i]).attr("checked","yes"); }catch(e){}
			 }
			 try{sconsole(sTags);}catch(e){}
			 //alert(sTags);
		}
			
		 
	} // End setupAddPhotoPage: function() {...
	
	,
	
	// set up all member profile pages, including our own
	setupMemberPage: function() {
		
		// If we are on a Profile Page
		if(Ka.Info.PAGE == 'pages/kickPlaceServerSide.jsp' || Ka.Info.PAGE == 'pages/profilePage.jsp') {
			
			//if there are no recent experiences, put in a block that says so rather than displaying nothing
			if ($j("#ka_profileSets ul.ka_profileMediaList li").html() == '')
			{
				$j("#ka_profileSets").html("<div class='ka_profileSegHeader ka_contentTitle'><h5>Recent Experiences</h5></div><div class='ka_profileSegCont ka_contentBody'>This member has not recently created any Experiences.</div><div class='ka_profileSegFooter'></div></div>");	
			}
			
			//if there are no recent conversations, put in a block that says so rather than displaying nothing
			if ($j("#ka_profileMessageboard").length == 0)
			{
				// This line causes the page to not render in IE
				$j("#ka_profileRight").append("<div class='ka_profileSeg' id='ka_profileMessageboard'><div class='ka_profileSegHeader ka_contentTitle'><h5>Recent Conversations</h5></div><div class='ka_profileSegCont ka_contentBody'>This member has not recently participated in any Conversations.</div><div class='ka_profileSegFooter'></div></div>"); 
			}		
			
			//kill mouseover and mouseout on the experience items
			$j("#ka_profileSets ul li a").each(function (i) { $j(this).attr("onmouseout",""); $j(this).attr("onmouseover",""); });
			
			//add button
			if (Ka.Info.USERID != Ka.Info.PROFILEID && Ka.Info.USERID != Ka.Info.Profile.PROFILEID) {
				$j("#ka_profileSets").append("<div id='viewAllExperiences' class='roundedCalloutButton alignLeft'><a href='/service/searchEverything.kickAction?mediaType=set&as="+AS_ID+"&keywords="+Ka.Info.PROFILENAME+"'>View All</a></div>");
			}
			//redo recent experiences
			//replace image
			$j("body#ka_profilePage ul.ka_profileMediaList li a span").each(function(i){
																					 var newBg = $j(this).css("background-image").replace("48X48","160X120");
																					 $j(this).css("background-image",newBg);
																					 });
			//kill 5+ experiences
			$j("body#ka_profilePage ul.ka_profileMediaList li").each(function(i){
                                    var test = $j(this).children();
                                    var test2 = test.eq(1);
                                    var test3 = test2.eq(0).attr("id");
                                    
																		if(test3.search("profileSetMeta") < 0)
																		{
																			$j(this).css("display","none");
																		} else {
																		
                                      if (test3.search("profileSetMeta1") > 0 || test3.search("profileSetMeta2") > 0 || test3.search("profileSetMeta3") > 0 || test3.search("profileSetMeta4") > 0) {
                                        var children = $j(this).children();
                                        var metaName = children.eq(1).find("div.ka_profileMediaMetaName");
                                        metaName.html("<a href='"+children.eq(0).attr("href")+"'>"+metaName.text()+"</a>");
																			} else {
                                        $j(this).css("display","none");
																			}
																		}
																	});
			
			
			
			
			//fix experiences descriptions
			/*$j("#ka_profileSets ul.ka_profileMediaList li div.ka_profileMediaMetaDesc").each(function (i) {
														var title = $j(this).text();
														if (title.length > 80)
														{
															title = title.substr(0,80).replace(/^\s+|\s+$/g, "")+"..";
															$j(this).text(title);
														}
												   });*/
			
			if (Ka.Info.USERID !== Ka.Info.PROFILEID){
				$j("#ka_headerSubNav").css("visibility", "visible");
			}
		} // End if Profile Page
		
	}
	
	,
	
	// Sets up My Profile page
	setupMyProfilePage: function() {
		 
		// If we are on a Profile Page
		if(Ka.Info.PAGE == 'pages/kickPlaceServerSide.jsp' || Ka.Info.PAGE == 'pages/profilePage.jsp') {
			//if it's our profile page
			if (Ka.Info.USERID == Ka.Info.PROFILEID || Ka.Info.USERID == Ka.Info.Profile.PROFILEID) 
			{
					  
					$j("#ka_profileSets").append("<div id='goToMyExperiences' class='roundedCalloutButton alignLeft'><a href='/view/displayManageSet.kickAction?as=98605'>Go to My Experiences</a></div>");
					goreSite.setupMyProfileMenu();
					$j("#ka_headerSubNav").css("visibility", "visible");
					
					document.title = Ka.Info.USERNAME + "'s home - Profile - Experience More Community";
					
			}
		}
			
		 
	} // End setupMyProfilePage: function() {...
	
	,
	
	// Sets up GA tracking on special objects
	setupGATracking: function() {
		 
	        pageTracker._initData();
		 
		// If we are on a Message Board Posting page
		if(Ka.Info.PAGE == 'pages/newDiscussion.jsp') {
			var button = $j("#ka_msgb_newForm input.ka_button");
			   
			button.mousedown(function() {
				pageTracker._trackEvent('Post', 'New', Ka.Info.USERNAME );
				sconsole('tracked');
			});				
			  
		}
			
		// If we are on a Message Board Posting page
		if(Ka.Info.PAGE == 'pages/newDiscussionThread.jsp') {
			 var button = $j("#ka_msgb_newForm input.ka_button");
			  
			 button.mousedown(function() {
				pageTracker._trackEvent('Post', 'Reply', Ka.Info.USERNAME );
				sconsole('tracked');
			});
		}		
		
		// If we are on a Add photo page
		if(Ka.Info.PAGE == 'pages/newPhotoUpload.jsp') {			 
			 var button = $j("#uploadbutton");
			 //var event = "pageTracker._trackEvent('Experiences', 'add photo','" + Ka.Info.USERNAME + "');";
			 //button.attr('onmousedown', event);
			 button.mousedown(function() {
				pageTracker._trackEvent('Experiences', 'add photo', Ka.Info.USERNAME);
				sconsole('tracked');
			});
		}
		
		// If we are on a Add video page
		if(Ka.Info.PAGE == 'pages/newVideoUpload.jsp') {
			 var button = $j("#uploadbutton");
			 //var event = "pageTracker._trackEvent('Experiences', 'add video','" + Ka.Info.USERNAME + "')";
			 //button.attr('onmousedown',event);
			 button.mousedown(function() {
				pageTracker._trackEvent('Experiences', 'add video', Ka.Info.USERNAME);
				sconsole('tracked');
			});
		}
		
		// If we are on a Add Set page
		if(Ka.Info.PAGE == 'pages/addMediaSet.jsp') {
			 var button = $j("#ka_mediaSet_save2");
			 //var event = "pageTracker._trackEvent('Experiences', 'create new experience','" + Ka.Info.USERNAME + "')";
			 //button.attr('onmousedown',event);
			 button.mousedown(function() {
				pageTracker._trackEvent('Experiences', 'create new experience',Ka.Info.USERNAME);
				sconsole('tracked');
			 });
		}
		
		// If we are on photo manage page
		if (Ka.Info.PAGE == 'pages/managePhoto.jsp')
		{
			var button = $j("ul.ka_listDetails a:contains('Use as my profile photo')");
			//var event = "pageTracker._trackEvent('Registration', 'set profile photo', '" + Ka.Info.USERNAME + "')";
			//button.attr('onmousedown',event);
			button.mousedown(function() {
				pageTracker._trackEvent('Registration', 'set profile photo',  Ka.Info.USERNAME );
				sconsole('tracked');
			 });
		}
		
		
	} // End setupGATracking: function() {...
	
	,
	
	setupMyProfileSubNav: function() {
		
		
		// if we are on the My Profile Page and see the sub nav items
		if ($j("#ka_subMemberMessaging").length > 0 && $j("#ka_subMyMedia").length > 0)
		{
			//swap the mailbox and my experiences subnavs
			$j("#ka_subMemberMessaging").before($j("#ka_subMyMedia"));
			
			//add my photos link
			$j("#ka_subMyMedia").after("<li id='subMyPhotos'><a href='/view/displayManagePhoto.kickAction?as="+AS_ID+"'>my photos</a></li><li id='subMyVideos'><a href='/view/displayManageVideo.kickAction?as="+AS_ID+"'>my videos</a></li>");
			
			
			//and point the my experiences subnav to the proper URL
			$j("#ka_subMyMedia a").attr("href",MY_EXPERIENCES_URL);
			
			//and point the edit profile to the proper URL
			$j("#ka_subEditProfile a").attr("href",EDIT_PROFILE_URL);
			
			//and if we're viewing my experiences, make the subnav reflect that
			if (Ka.Info.PAGE == 'pages/manageSet.jsp')
			{	$j("#ka_subMyMedia").attr("class","current");	}
				
			//if we're viewing my photos, make the subnav reflect that
			if (Ka.Info.PAGE == 'pages/managePhoto.jsp')
			{
				$j("#ka_subMyMedia").removeClass("current");
				$j("#subMyPhotos").attr("class","current");
				//fix stars on my photo page
				$j('.ka_listRating').each(function() {
					$j(this).find('.ka_starSystemS').eq(1).remove();
					$j(this).find('.ka_starsNumRatingsS').eq(1).remove();
				});
			}
				
			//if we're viewing my videos, make the subnav reflect that
			if (Ka.Info.PAGE == 'pages/manageVideo.jsp')
			{
				$j("#ka_subMyMedia").removeClass("current");
				$j("#subMyVideos").attr("class","current");
			}
			
			//remove white space
			$j('ul#ka_headerSubNav_list > li').not(':hidden').each(function() {
				li = $j(this).html();
				$j(this).html(jQuery.trim(li));
			});
		}
		
		
	}
	
	,
	// Fix menu for "My Profile"
	setupMyProfileMenu: function() {
				
		$j("#ka_memberTab").attr("class","");
		$j("#MyProfile").attr("class","current");				
		$j("#ka_subMyFriend").css("display","none");
		$j("#ka_subMostRecent").css("display","none");
		$j("#ka_subMostView").css("display","none");
		$j("#ka_subMostComment").css("display","none");
		$j("#ka_subHighRate").css("display","none");
						 
		 var sSubMenu = '<ul id="ka_headerSubNav_list"><li class="current" id="ka_subViewProfile"><a href="/service/displayKickPlace.kickAction?u=' + Ka.Info.USERID + '&amp;as=' + AS_ID + '">overview</a></li><li id="ka_subEditProfile"><a href="'+EDIT_PROFILE_URL+'">edit profile</a></li><li id="ka_subMyMedia"><a href="/view/displayManageMyMedia.kickAction?as=' + AS_ID + '">my experiences</a></li><li id="subMyPhotos"><a href="/view/displayManagePhoto.kickAction?as='+AS_ID+'">my photos</a></li><li id="subMyVideos"><a href="/view/displayManageVideo.kickAction?as='+AS_ID+'">my videos</a></li><li class="" id="ka_subMemberMessaging"><a href="/view/displayManageMessages.kickAction?as=' + AS_ID + '&amp;folder=INBOX">mailbox</a></li><li id="ka_subForumSettings"><a href="http://community.gore-tex.com/account/prefs">forum settings</a></ul>';
		 
		$j("#ka_headerSubNav_list").html(sSubMenu);
		$j('#ka_headerSubNav').show();
		  
		   
	}  // END setupMyProfileMenu: function() {	...
	
	,
	
	// Display the ka_contentContainer container
	showContent: function() {
		$j("#ka_contentContainer").css("visibility", "visible");
		
		$j("#ka_headerTopNav_ul").css("visibility","visible");
			
	} // End showContent: function() { ...
	
	,
	
	    // listen for special KA events
	    listenForEvents: function() {

		 // Listen for media set page load event	
		 Ka.events.listen("media-sets-page-load", mediaSetsPageLoad);
		 
	         // Listen for setting thumbnail on media set
	         Ka.events.listen("media-sets-set-thumbnail", getMediaSetThumbnailData);
						
		 // Listen for removing thumbnail on media set
 	         Ka.events.listen("media-sets-remove-thumbnail", removeMediaSetThumbnailData);
		 
		 // Listen for submitting media set (NOT USING THIS);
		 //Ka.events.listen("media-sets-before-submit", setMediaSetContestMeta);
		
		 		
	    } // END listenForEvents: function() {...	
	
	,
	 
	    // fix browsers
	    browserFixes: function() {

	        if ($j.browser.safari) {
	 	 
	            $j('<style type="text/css">div.ka_metaPopup  { margin-left: -50px }</style>').appendTo('head');
	        }
		
		if ($j.browser.msie) {	            		     		    
			// Fix for IE 7 layout bug after a forum message is posted and the Confirmation display disappears
			setTimeout("$j('body.ka_messageBoards ul.ka_mbList div.ka_genForumItemWrap').css('display', 'block');", 6500)		    
		    	
			// Fix height of media filter drop down on Experience Add/Edit page
			$j('select#mediaSearchWithin').css("font-size","18px");
			$j('select#mediaSearchWithin').css("color","#999999");
		 
		 	// Fix display of "Search" input button
		 	$j("input[value='Search']").css("color","#999999");
			$j("input[value='Search']").css("font-weight","bold");
			
		 	/* Below I am trying to customize the "Experience more" media search filter dropdown with jQUery */			
			/*
			$j('select#mediaSearchWithin').combobox( 
				{ 
				comboboxContainerClass: "comboboxContainer", 
				comboboxValueContainerClass: "comboboxValueContainer", 
				comboboxValueContentClass: "comboboxValueContent", 
				comboboxDropDownClass: "comboboxDropDownContainer", 
				comboboxDropDownButtonClass: "comboboxDropDownButton", 
				comboboxDropDownItemClass: "comboboxItem", 
				comboboxDropDownItemHoverClass: "comboboxItemHover", 

				comboboxDropDownGroupItemHeaderClass: "comboboxGroupItemHeader", 
				comboboxDropDownGroupItemContainerClass: "comboboxGroupItemContainer", 
				animationType: "fade", 
				height: "150px" 
				}
			); */
			 
		 	  
	        }

	    } // END fixIE: function() {...	
    
	    ,
    
	    // fix IE layout issue on the nav (function not used)
	    fixIE: function() {

	        if ($j.browser.msie) {
	            $j("#ka_headerTopNav_ul").css('top', '-14px');
	            $j("#ka_headerSearch").css('top', '-15px');
	        }


	    } // END fixIE: function() {...	
    
     	

}
 
// When the DOM is loaded, call the "start" function
Ka.addDOMLoadEvent(goreSite.start); 

function selectReplacement(obj)
{
	var ul = document.createElement("ul");
	ul.id = "categories_faux";
	ul.className = 'closed';
	//get options
	var opts = obj.options;
	var selectedOpt = obj.selectedIndex;
	
	//display the selected object as the box
	
	var first = document.createElement("li");
	var first_txt = document.createTextNode(opts[selectedOpt].text);
	first.appendChild(first_txt);
	first.id = "first_child";
	first.parent = ul;
	first.onclick = function(){
		if (this.parent.className == 'closed'){
			this.parent.className = 'open';
		} else {
			this.parent.className = 'closed';
		}
	}
	ul.appendChild(first);
	
	//loop through options
	for(var s=0; s<opts.length; s++)
	{
		sconsole(s+" - "+opts[s].text);
		var li = document.createElement("li");
		var txt = document.createTextNode(opts[s].text);
		li.appendChild(txt);
		li.val = opts[s].value;
		li.onclick = function(){	
			this.parentNode.className = 'closed';
			if (this.val != '')
				this.parentNode.childNodes[0].innerHTML = this.innerHTML;
			activityTypeFilter(this.val);
		}
		if (s == selectedOpt)
		{
			li.className = "selected";
		}
		ul.appendChild(li);
	}
	obj.parentNode.appendChild(ul);
}

function selectExperienceMenu() {
	
		/*if($j("#ka_headerSubNav_list")) {
				// Inject a link to edit the user's experiences
				 
			if(Ka.Info.USERID != "") {
				$j("#ka_headerSubNav_list").append('<li><a href="/view/displayManageSet.kickAction?as=' + AS_ID + '">my experiences</a><li>');
			}
			$j("#ka_headerSubNav_list").append('<li><a href="/service/openCustomPage.kickAction?as=' + AS_ID + '&myPage=experiencemore&title=Experience%20More%20Challenge">experience more challenge</a><li>');
			
			$j("#Experiences").attr("class","current"); // Set menu item "Experiences" to current
			
			 
		}	*/
		$j("#Experiences").attr("class","current"); // Set menu item "Experiences" to current
		
}

// Custom profile search on profile page
function customProfileSearch(mediaType) {
	
	var sSearchValue = $j("#txtProfileSearchCustom").attr('value');
	
	var sortType = '';
	if ($j.query.get('sortType') != '')
		sortType = '&sortType='+$j.query.get('sortType');
	
	if(sSearchValue != "search profiles" && sSearchValue != "search experiences" && sSearchValue != '') {
		var sSearchURL = "/service/searchEverything.kickAction?mediaType="+mediaType+"&as=" + AS_ID + "&keywords=" + sSearchValue + sortType;
		document.location.href = sSearchURL;
	} else {
		alert("Please enter a keyword.");	
	}
		
}

// Clear the profile search field
function clearCustomSearchField() {
	
	var sSearchValue = $j("#txtProfileSearchCustom").attr('value');
	if (sSearchValue.indexOf("search ") >= 0)
	{
		$j("#txtProfileSearchCustom").attr('value','');
	}
}

//check to toggle the filter select
function checkCustomSearchEmpty(eventObject) {
	if ($j("#expSearch #txtProfileSearchCustom").val() == '')
		$j("#expSearch #categories").removeAttr("disabled"); 
	else
		$j("#expSearch #categories").attr("disabled","disabled"); 
}

//filter by activity type
function activityTypeFilter(activityType) {
	if (activityType != '')
	{
		var kw = '';
		kw = '&keywords=' + activityType;
		
		var sortType = '';
		if ($j.query.get('sortType') != '')
			sortType = '&sortType='+$j.query.get('sortType');
		
		document.location.href = EXPERIENCE_SEARCH_URL+sortType+kw;
	}
}

// Show logo div 
function showLogo() {	 
	$j("#logo").css('visibility','visible');	
}

// For "Add Experiences" and "Edit Experiences" pages, add tags when checkboxes are clicked
function addCheckboxTag(sValue) {
	
	// if argument has a space, add quotes
	if(sValue.search(" ") != -1) {
		sValue = '"' + sValue + '"';	
	}

	var sTagFieldValue = $j("#mediaTags").attr("value");
	 
	if(sTagFieldValue.search(sValue) != -1) {
		// If the string is found, remove it
		sTagFieldValue = sTagFieldValue.replace(sValue, "");
	} else {
		// Else, add the tag
		sTagFieldValue += " " + sValue;
	}
	 
	// Update the field value
	$j("#mediaTags").attr("value", sTagFieldValue);
	
}

// Handler for when a thumbnail is added to a media set
function mediaSetsPageLoad() {	 
	
	// Event does not fire
}

// Handler for when a thumbnail is added to a media set
function getMediaSetThumbnailData(dataObject) {	 
	
	//sconsole("Ka.mediaSets.currentSet.currentThumbnailMediaId = " + Ka.mediaSets.currentSet.currentThumbnailMediaId);

	MEDIA_SET_THUMBNAIL_DATA = dataObject.thumbnail;
	
	// When the thumb is changed set the meta
	setMediaSetContestMeta();
	
}

// Handler for when a thumbnail is added to a media set
function removeMediaSetThumbnailData() {
	
	// Event does not fire

}

// Function to set the meta tags on Media Set thumbnail images that are entered into the contents
function setMediaSetContestMeta() {

	var sTagFieldValue = $j("#mediaTags").attr("value"); // Get the tags for this experience
	
	sconsole("TAGS = " + sTagFieldValue);
	
	if(MEDIA_SET_THUMBNAIL_DATA != null) {
		// If the MEDIA_SET_THUMBNAIL_DATA is not null, set the URLs for tagging the thumbnail
		META_TAG_ADD_PAGE_COMMAND = GORESITE_BASE_URL + "/MetaTag.jsp?oldid=" + MEDIA_SET_THUMBNAIL_ID + "&newid=" + MEDIA_SET_THUMBNAIL_DATA.mediaId + "&tags=" + sTagFieldValue;
		META_TAG_DEL_PAGE_COMMAND = GORESITE_BASE_URL + "/MetaTag.jsp?oldid=" + MEDIA_SET_THUMBNAIL_DATA.mediaId + "&newid=";
	} else {
		// Else, MEDIA_SET_THUMBNAIL_DATA is null, the page must have just loaded, set the URLs for tagging the thumbnail
		META_TAG_ADD_PAGE_COMMAND = GORESITE_BASE_URL + "/MetaTag.jsp?oldid=&newid=" + MEDIA_SET_THUMBNAIL_ID  + "&tags=" + sTagFieldValue;;
	}	META_TAG_DEL_PAGE_COMMAND = GORESITE_BASE_URL + "/MetaTag.jsp?oldid=" + MEDIA_SET_THUMBNAIL_ID + "&newid=";
	
	
	sconsole("META_TAG_ADD_PAGE_COMMAND = " + META_TAG_ADD_PAGE_COMMAND);
	sconsole("META_TAG_DEL_PAGE_COMMAND = " + META_TAG_DEL_PAGE_COMMAND);
		 
	
}

// Function called when save button is clicked to submit meta data
function submitMediaSetContestMeta() {
	$j("body").css("cursor","wait");
	sconsole("submitMediaSetContestMeta()");
	setMediaSetContestMeta();	 	
	var enterContestValue = $j("#cbGoreContest").attr("checked"); // Determine whether the contest checkbox is checked
	
	
	
	if(enterContestValue) {
		var metaTagFrame = $j("#ifGoreMetaTag");
	 	metaTagFrame.attr("src", META_TAG_ADD_PAGE_COMMAND);
		sconsole("ADDING CONTEST META TAG! > gore" + META_TAG_ADD_PAGE_COMMAND);	 
	} else {
		saveSet();
		/*var metaTagFrame = $j("#ifGoreMetaTag");
	 	metaTagFrame.attr("src", META_TAG_DEL_PAGE_COMMAND);
		sconsole("REMOVING CONTEST META TAG! > " + META_TAG_DEL_PAGE_COMMAND);*/
	}
}

// Called when the meta Tagging Iframe is loaded
function metaTagIframeLoaded() {
	sconsole("Meta tag frame loaded!");	
	var metaTagFrame = $j("#ifGoreMetaTag");
	var metaTagFrameSrc = metaTagFrame.attr("src");
	
	if(metaTagFrameSrc != "") {
		sconsole("Meta tag frame saving!");
		META_TAG_IFRAME_LOAD_NUM++;
		if (META_TAG_IFRAME_LOAD_NUM >= 2)
		{
			//after the second time the iFrame loads with a proper src set, save the set
			saveSet();
		}
		//saveSet();
		// Fire off functions previously on the "Edit Set" button	
		//setTimeout("checkSave()", 1000);
		
	}
}

// Check if the logged in user is following the specified userID
function checkIfFollowed(userID) {
	
	// The variable "aFollowing" is generate in the custom app and included
	// Via the file "https://www.gore-tex.com/community/scripts/followers.jsp"
  
	for(var i = 0; i < aFollowing.length; i++) {
		if(aFollowing[i] == parseInt(userID)) {
			return true;
		}
	}
	return false;
	 
}

// Save a media set
function saveSet() {
	sconsole("Loaded Twice!");
	Ka.mediaSets.currentSet.validateAndSave(); 
	return false;
}

// Safe way to use "console.log"
function sconsole(output) {
	try{console.log(output);} catch(e) {}
}

// Add OuterHTML to jquery
jQuery.fn.outerHTML = function(s) {
return (s)
? this.before(s).remove()
: jQuery("<p>").append(this.eq(0).clone()).html();
}

//applies to both classic KA & non classic KA pages
/*if (!window.YUKU) {
     //applies to classic KA pages
	if ($j('#ka_mainContainer').length != 0) {
	
	}
} */


}
//applies to YUKU Message Board Pages
else {
	$j('body').addClass('advanced-boards');
	//nav
	$j('<li id="Experiences"><a href="http://media.community.gore-tex.com/service/searchEverything.kickAction?mediaType=set&amp;as='+Ka.Info.AFFILIATESITEID+'"><span>Experiences</span></a></li>').insertAfter('#ka_messageBoardsTab');
	$j('#ka_messageBoardsTab').addClass('current');
	
	
	var url =  'http://media.community.gore-tex.com/service/isUserLoggedIn.kickAction?callback=?';
	function ka_isUserLoggedInKASideCallback(json){	
		var ka_userid = json.userid;
		
		if(json.isLoggedIn=="false"){
			$j('#ka_myhomeTab').hide();
		} else {
			$j('#ka_homeTab').hide();
			//NEED TO UPDATE URL AND ASID!!!!!!!!
			$j('<li id="MyProfile"><a title="My Profile" href="http://media.community.gore-tex.com/service/displayKickPlace.kickAction?u='+ka_userid+'&amp;as='+Ka.Info.AFFILIATESITEID+'">My Profile</a></li>').appendTo('#ka_headerTopNav_ul');
		}	
	}		
	jQuery.ajax({
		dataType: 'json',
		data: {as:98605},
		jsonp: 'ka_isUserLoggedInKASideCallback',
		url: url,
		success: ka_isUserLoggedInKASideCallback
	});
	

	
	
	/*if(Ka.Info.USERID == '') {
		$j('#ka_myhomeTab').hide();
	} else {
		$j('#ka_homeTab').hide();
		
		//NEED TO UPDATE URL AND ASID!!!!!!!!

		$j('<li id="MyProfile"><a title="My Profile" href="http://media.community.windstopper.com/service/displayKickPlace.kickAction?u='+Ka.Info.USERID+'&amp;as='+Ka.Info.AFFILIATESITEID+'">My Profile</a></li>').appendTo('#ka_headerTopNav_ul');
	}*/
	$j('#ka_headerTopNav_ul').css('visibility', 'visible');
	$j('.tool-box .subscription-links').append('<li class="kudo-link"></li>');
	$j('.tool-box .kudos').appendTo('.kudo-link');
	$j('.advanced-search').appendTo('#f_search, #search_form');
	//$j('#search_form').prependTo('.control-box .clear-container');
	//$j('.top.control-box').appendTo('.tool-box');
	if( $j('.advanced-search').length == 0 ) {
		$j('<p class="advanced-search"><a href="/search/advanced">advanced search</a></p>').appendTo('#search_form');
	}
	
	$j('.advanced-search').show();
	$j('.ka_signout_auth a').text('log out');
	$j('.ka_signout_auth').show();
	
	$j('#search_text #search_form div:first-child').remove();
	
	$j('.tool-box .bread-crumbs').insertBefore('.topic-pagejump.top');
	$j('.control-box.top .bread-crumbs').after('<div class="clear"></div>');
	
	//advanced search page
	$j('#advanced .extra-content .boxheading').append('<h2>Advanced Search</h2>');
	
	//remove post-body
	$j('.scrolling').each(function() {
		$j(this).parent().parent().append(this);
		$j(this).siblings('.post-body').remove();
	});
	
	$j('#account_timezone #footer').appendTo('#page');
	$j('body#account_prefs .mgr-boxheading h2').text('Advanced');
	$j('body#account_prefs .mgr-boxheading h2').show();
	$j('.mgr-tab-sub-menu li:eq(1) a span span span').text('Advanced');
			  
}
