/* 
 * Jquery browser detect plugin to identify browser/os detection.
 * jQuery Browser Plugin - http://jquery.thewikies.com/browser/
 */
(function($){$.browserTest=function(a,z){var u='unknown',x='X',m=function(r,h){for(var i=0;i<h.length;i=i+1){r=r.replace(h[i][0],h[i][1]);}return r;},c=function(i,a,b,c){var r={name:m((a.exec(i)||[u,u])[1],b)};r[r.name]=true;r.version=(c.exec(i)||[x,x,x,x])[3];if(r.name.match(/safari/)&&r.version>400){r.version='2.0';}if(r.name==='presto'){r.version=($.browser.version>9.27)?'futhark':'linear_b';}r.versionNumber=parseFloat(r.version,10)||0;r.versionX=(r.version!==x)?(r.version+'').substr(0,1):x;r.className=r.name+r.versionX;return r;};a=(a.match(/Opera|Navigator|Minefield|KHTML|Chrome/)?m(a,[[/(Firefox|MSIE|KHTML,\slike\sGecko|Konqueror)/,''],['Chrome Safari','Chrome'],['KHTML','Konqueror'],['Minefield','Firefox'],['Navigator','Netscape']]):a).toLowerCase();$.browser=$.extend((!z)?$.browser:{},c(a,/(camino|chrome|firefox|netscape|konqueror|lynx|msie|opera|safari)/,[],/(camino|chrome|firefox|netscape|netscape6|opera|version|konqueror|lynx|msie|safari)(\/|\s)([a-z0-9\.\+]*?)(\;|dev|rel|\s|$)/));$.layout=c(a,/(gecko|konqueror|msie|opera|webkit)/,[['konqueror','khtml'],['msie','trident'],['opera','presto']],/(applewebkit|rv|konqueror|msie)(\:|\/|\s)([a-z0-9\.]*?)(\;|\)|\s)/);$.os={name:(/(win|mac|linux|sunos|solaris|iphone)/.exec(navigator.platform.toLowerCase())||[u])[0].replace('sunos','solaris')};if(!z){$('html').addClass([$.os.name,$.browser.name,$.browser.className,$.layout.name,$.layout.className].join(' '));}};$.browserTest(navigator.userAgent,true);})(jQuery);

/*
 * Jquery Plugin - opens external links in a new window.  
 * Checks if the links are relative, and are of the same domain.
 * Sampe Usage - $("#someDiv a").makeLinksExternal();
 */
jQuery.fn.makeLinksExternal=function(){return this.each(function(){var a=$(this).attr("href");if(a.indexOf(location.host)==-1&&a.indexOf("/")!=0){$(this).attr("target","_blank")}})};


/* Supplant Function. Remedial JS. Thanks to Douglas Crockford. 
 * Substitues the variables in a string. The variables must be preceded by {}.
*/


if(!String.prototype.supplant){String.prototype.supplant=function(a){return this.replace(/{([^{}]*)}/g,function(d,c){var e=a[c];return typeof e==="string"||typeof e==="number"?e:d})}};

/*Templates for the Merch Module */
var merchModuleTemplate = 
		'<li class="merch small item{index}">\
				<div class="merchImg"><a href="{omnitureLinksPThumb}" title="{merchTitle}"><img src="{merchImage}" alt="{merchTitle}"/></a><div class="merchZoomIcon"></div></div>\
				<div class="merchDetail">\
					<div class="merchPriceWrapper"><div class="merchName"><a href="{omnitureLinksPTitle}" >{merchTitle}</a></div><div class="merchPrice">{merchPrice}</div></div>\
					<div class="merchBuy"><a href="{omnitureLinksPButton}" class="merchBuyLink">{merchPrice}</a></div>\
				</div>\
				<!-- HOVERCARD -->\
		</li>';

/* Templates for the Hovercard module.*/
var	merchHCTemplate ='<div class="merchHC merchHC{index}">\
							<div class="merchHCWrapper">\
								<div class="merchHCInnerWrapper">\
									<div class="merchHCHead"><a href="{omnitureLinksHTitle}">{merchTitle}</a></div>\
									<div class="merchHCBody">\
										<div class="merchHCLeftCon"><a href="{omnitureLinksHThumb}"  title="{merchTitle}"><img src="{merchImage}" alt="{merchTitle}" width="230px"/></a></div>\
										<div class="merchHCRightCon">\
											<h3 class="merchHCPrice">{merchPrice}</h3>\
											{merchDesc}\
											<div class="merchHCBuyNowCon"><a class="merchHCBuyNow" href="{omnitureLinksHButton}">Buy Now &raquo;</a></div>\
										</div>\
										<div class="clear"></div>\
									</div>\
									<div class="merchHCFoot"></div>\
								</div>\
							</div>\
						</div>';
			
var merchCountryTemplate = '<li><a class="flag {countryName}" href="{countryLink}" target="_new">{countryText}</a></li>';
var merchHeaderTemplate = '<div class="{positionClass}">\
						   		<div class="visitStore">\
									<a class="visitStoreLink" href="{merchViewAllLink}" rel="external" target="_new">View More</a>\
								</div>\
						   </div>';

$(document).ready(function(){
	
	$("html").addClass($.os.name);
    $("body").addClass($.browser.className);
    $("body").addClass($.browser.name);
	
	/* Events page*/
	var clearDivEle='<div class="clear"></div>';
	var horzDivdr='<div class="hd"></div>';
	
	var currentPageShowUrl=$.urlParam("show");
	
	$('#group_detail_6397 #video_thumbnail-4283365 .videos li.video:last').addClass('lastvideo');

if($('#community_landing #video_thumbnail-340502.video_thumbnail .module .content .body p').length >0){
	$('#community_landing #video_thumbnail-340502.video_thumbnail .module .content .body p').parents('.content').addClass('empty_video');
}

	$('#event_listing-3952222.event_listing .module .content .body ul li.cal_event:last').addClass('lastevent');
	$('body#home #html-683925.html .module .content .body div.twitterContainer:last').addClass('lasttwitter');

		
if ($('body').attr('id') == 'event_detail') {
	var eventdate = $(this).find('.head h3 .date').text();
	eventdateobj = new Date(eventdate);
	currentDate = new Date();
	offset = eventdateobj.getTime() - currentDate.getTime();		
	offsetdays=offset/ 86400000
	var maprequesthref=$('.cal_event div.txt .location .maplink a').attr("href");	
		
if (currentPageShowUrl == "archive"|| offsetdays < -1 ) {
		var archiveTitle="Tour Archives";
		$('#event-707479.event').each(function(){

			var horzDivdr='<div class="hd"></div>';

			$(this).find('.content').addClass('upcoming');
			$(this).find('.content').addClass('archive');
			$(this).find('.head h3').append(archiveTitle);
			var eventDate= $(this).find('.head h3 .date');
			var goingRnot= $(this).find('.cal_event .going.input');
			var txtDiv= $(this).find('.cal_event div.txt');
			var mapEle=$(this).find('.cal_event div.txt .location .maplink');
			var descEle=$(this).find('.cal_event div.txt .description');
			var venueEle=$(this).find('.cal_event div.txt .venue');
			var stateVal= $(this).find('.cal_event div.txt .location .region').html();
			
			var buy = $(this).find('.foot .nav_meta ul li.buy').html();
			if(buy != null){
				var buyLnk="<div class='buyLink'>"+$(this).find('.foot .nav_meta ul li.buy').html()+"</div>";
			}
			
			
			var toolsData="<div class='tools'></div>";
			

			$(this).find('.nav_meta ul li.more a').html('Back to Tour Archive');
			$(this).find('.nav_meta ul li.more a').attr("href","/event/?show=archive");
			
		
			$(this).find('.cal_event').append(descEle);
			$(this).find('.cal_event').append(clearDivEle);	
	
			$(clearDivEle).insertBefore('#event-707479.event .cal_event div.txt .location');	
			$(eventDate).insertBefore('#event-707479.event .cal_event div.txt .location');
			$(venueEle).insertBefore('#event-707479.event .cal_event div.txt .location');	
			if(maprequesthref != null){
				
				maprequesthrefarry=maprequesthref.split("?q=");
				var maprequest="<a href='"+maprequesthref+"' target='_blank'><img src='http://maps.google.com/maps/api/staticmap?center="+maprequesthrefarry[1]+"&zoom=15&size=300x250&maptype=roadmap&markers=color:red|size:small|"+maprequesthrefarry[1]+"&sensor=false'/></a>";
				$(this).find('.cal_event').append(maprequest);	
			}		
			
			$(this).find('.cal_event div.txt .location .city').append(stateVal);
			$(this).find('.cal_event').append(toolsData);
			$(this).find('.cal_event .tools').append(goingRnot);
			$(this).find('.cal_event').append(clearDivEle);
			$(this).find('.cal_event').append(clearDivEle);
			
			
			
			if($(this).find('.cal_event .tools .input.going a').attr('onclick')!=null){
				$(this).find('.cal_event .tools .input.going .button.submit input').hide();
			}
			var eventsuccessmsg=$("#successMsg").text();
			if(($(this).find('.cal_event .tools .input.going a').attr('onclick')!=null && eventsuccessmsg=="I didn't Go")||($(this).find('.cal_event .tools .input.going a').attr('onclick')!=null && eventsuccessmsg=="I am not going") ){
				$(this).find('.cal_event .tools .input.going a').hide();
				$(this).find('.cal_event .tools .input.going .button.submit input').show();
			}
			
			$(this).find('.head h3 .date').remove();
			$(this).find('.head h3 .time').remove();
			$(this).find('.cal_event div.txt .location .maplink').remove();

			$(this).find('.cal_event div.txt .location .address').remove();
			$(this).find('.cal_event div.txt .location .country').remove();
			$(this).find('.cal_event div.txt .location .region').remove();;
			$(this).find('.cal_event div.txt .title').remove();
			$(this).find('.cal_event div.txt .availability').remove();
			$(this).find('.foot .nav_meta ul li.buy').remove();			
			$(this).find('.cal_event .description').remove();
		});	
		
	}else{
		var upcomingTitle="Upcoming Shows";
		var horzDivdr='<div class="hd"></div>';

		$('#event-707479.event').each(function(){

			$(this).find('.content').addClass('upcoming');
			
			$(this).find('.head h3').append(upcomingTitle);
			var eventDate= $(this).find('.head h3 .date');
			var goingRnot= $(this).find('.cal_event .going.input');
			var txtDiv= $(this).find('.cal_event div.txt');
			var mapEle=$(this).find('.cal_event div.txt .location .maplink');
			var stateVal= $(this).find('.cal_event div.txt .location .region').html();
			var venueEle=$(this).find('.cal_event div.txt .venue');
			var buy = $(this).find('.foot .nav_meta ul li.buy').html();
			if(buy != null){
				var buyLnk="<div class='buyLink'>"+$(this).find('.foot .nav_meta ul li.buy').html()+"</div>";
			}
			var toolsData="<div class='tools'></div>";
			

			$(this).find('.nav_meta ul li.more a').html('Back to upcoming SHOWS');
			
			

			$(clearDivEle).insertBefore('#event-707479.event .cal_event div.txt .location');	
			$(eventDate).insertBefore('#event-707479.event .cal_event div.txt .location');
			$(buyLnk).insertBefore('#event-707479.event .cal_event div.txt .location');
			$(venueEle).insertBefore('#event-707479.event .cal_event div.txt .location');	

			$(this).find('.cal_event').append(mapEle);
			$(clearDivEle).insertAfter('#event-707479.event .cal_event div.txt');
			$(this).find('.cal_event').append(toolsData);
			$(this).find('.cal_event .tools').append(goingRnot);
			$(this).find('.cal_event div.txt .location .city').append(stateVal);
			$(this).find('.cal_event div.maplink a').html('VIEW MAP');
			$(this).find('.cal_event').append(clearDivEle);
		
			
			$(this).find('.cal_event').append(clearDivEle);
			
			if($(this).find('.cal_event .tools .input.going a').attr('onclick')!=null){
				$(this).find('.cal_event .tools .input.going .button.submit input').hide();
			}
			var eventsuccessmsg=$("#successMsg").text();
			if(($(this).find('.cal_event .tools .input.going a').attr('onclick')!=null && eventsuccessmsg=="I didn't Go")||($(this).find('.cal_event .tools .input.going a').attr('onclick')!=null && eventsuccessmsg=="I am not going") ){
				$(this).find('.cal_event .tools .input.going a').hide();
				$(this).find('.cal_event .tools .input.going .button.submit input').show();
			}
			
			
			$(this).find('.head h3 .date').remove();
			$(this).find('.head h3 .time').remove();
			$(this).find('.cal_event div.txt .location .maplink').remove();

			$(this).find('.cal_event div.txt .location .address').remove();
			$(this).find('.cal_event div.txt .location .country').remove();
			$(this).find('.cal_event div.txt .location .region').remove();;
			$(this).find('.cal_event div.txt .title').remove();
			$(this).find('.cal_event div.txt .availability').remove();
			$(this).find('.foot .nav_meta ul li.buy').remove();
			$(this).find('.cal_event div.txt .rating').remove();
		});		
	}
}  	
	///Fans going or fans went header in event detila page
 	var eventdate = $('#event-707479.event .head h3 .date span').text();
	eventdate = $('#event-707479.event .module .cal_event div.txt div.date').text();
	var eventdateobj = new Date(eventdate);
	currentDate = new Date();
	offset = eventdateobj.getTime() - currentDate.getTime();		
	offsetdays=offset/ 86400000;  
  
  	var memberCount= $('#member_listing-3824953.member_listing .module .content .head h3 span').text();
	var openparanthesis=memberCount.indexOf("(");
	var closeparanthesis=memberCount.indexOf(")");
	memberCount=memberCount.substring(openparanthesis+1,closeparanthesis);
	
	var currentpageshowtitle=$.urlParam("show");
	
	if(currentpageshowtitle=="archive" || offsetdays < -1 ){
		
	var memberClass='<div class="membersGoing"> <span class="membercount"></span> Fans Went </div>';
	var currentText = $('#member_listing-3824953.member_listing .module .content .head h3').text().trim().toUpperCase();	
	var memberTitleReplace= currentText.replace("FANS GOING","Fans Went");
	$('#member_listing-3824953.member_listing .module .content .head h3').text(memberTitleReplace);
	//$('#member_listing-3824953.member_listing .module .content .head h3').append(memberClass);
	}
	
	else{
		
	var memberClass='<div class="membersGoing"> <span class="membercount"></span> Fans Going</div>';
	
	}
	$('#member_listing-3824953.member_listing .module .content .head .title').css("display","block"); 
	//$("#event-707479.event .module .content .body .cal_event .tools").append(memberClass);
	//if(memberCount !=null && memberCount !=" ");{
	//	$("#event-707479.event .module .content .body .cal_event .tools .membersGoing span.membercount").text(memberCount);
	//}

if($('body#event').length >0 || $('body#event_detail').length >0 ){	
		var currentpageshow=$.urlParam("show");
		
		if ($('body').attr('id') == 'event') {
			if (currentpageshow == "archive") {
				$('#event_listing-707476').css("display", "none");
				$('#event_listing-4084683').css("display", "block");
				$('#event_listing-4084684').css("display", "block");
				$('#event_listing-4084685').css("display", "none");
			}
			else {
				$('#event_listing-707476').css("display", "block");
				$('#event_listing-4084683').css("display", "none");
				$('#event_listing-4084684').css("display", "none");
				$('#event_listing-4084685').css("display", "block");
				$('#event_listing-707476 .nav_meta ul li.more a').attr('href', '/event/?show=archive');
				$('#event_listing-4084685 .nav_meta ul li.more a').attr('href', '/event/?show=archive');
				
			}
		}

		if ($('body').attr('id') == 'event_detail') {
			if (currentpageshow == "archive" || offsetdays < -1 ) {
				
				if($('#event_listing-4084683 .tools .input.going a').length >0){
				$('#event_listing-4084683 .tools .input.going a').text("I Went");
				}
		
				$('#photo_thumbnail-3824954').css("display", "block");
				$('#video_thumbnail-3824955').css("display", "block");		
				$('#event_listing-4084688').css("display", "block");
				$('#event_listing-4084688 .nav_meta ul li.more a').attr('href', '/event/?show=archive');
				$('#event_listing-4084687').css("display", "none");
			}
			else {
				if($('#event-707479 .tools .input.going a').length >0){
				$('#event-707479 .tools .input.going a').text("I am Going");
				}
				
				$('#photo_thumbnail-3824954').css("display", "block");
				$('#video_thumbnail-3824955').css("display", "block");		
				$('#event_listing-4084688').css("display", "block");
				$('#event_listing-4084687').css("display", "none");
				
			}
		}
	}
	

	
	//member listing foe event_detail page	
	var detailPageValue = window.location.href;
	var listing='moduleListing';
	var detail='moduleDetail';
	
	 
	
	/* Move Home Page VideoPlaylist 'View more' to Header */
	var moreVideoCell='<div class="viewAll"><a href="/video/">View More</a></div>';
	$('#html-3951472 .module .head').append(moreVideoCell);
	var viewAllBlog='<div class="viewAll"><a href="/blog/">View All</a></div>';
	$('#blog_listing-327529 .module .head').append(viewAllBlog);
	
	var viewAllVideo='<div class="nav_meta"><div class="viewAll"><a href="/blog/">View More</a></div></div>';
	$('#event_listing-4147656 .module .foot').append(viewAllVideo);
	
	var viewAllPhoto='<div class="nav_meta"><div class="viewAll"><a href="/blog/">View More</a></div></div>';
	$('#event_listing-4043332 .module .foot').append(viewAllPhoto);
	
	var viewAllBlog='<li class="viewAll"><a href="/discussion/">View All</a></li>';
	$('#discussion_listing-294531 .module .foot .nav_meta ul').append(viewAllBlog);
	
	var moreTwitter='<div class="more"><a href="/twitter/">View More</a></div>';
	//var twitterfoot=$('#html-683925.html .foot');
	
	var morePhotoCell='<div class="viewAll"><a href="/photo/">View More</a></div>';
	$('#event_detail .photo_thumbnail .module .content .foot .nav_meta ul').append(morePhotoCell);
	
	$('#event_detail .video_thumbnail .module .content .foot .nav_meta ul').append(moreVideoCell);
	
	$('#html-683925.html .foot').append(moreTwitter);
   // $('.twitterContainerMore').appendTo(twitterfoot);
	
    
	/* Suppresses display of empty footers on IE */	
	
	$('.module .content .foot .nav_page').each(function() {

		var nav_page = $(this);
		/* Add empty class if nav page is empty */
		if (nav_page.children().size() == 0){
	    	nav_page.addClass('emptypage'); 
			$('.blog_listing .module .content .foot').addClass('emptyfoot')
		} else {
			
			var elementVisible = false;
			nav_page.children().each(function() {
				var child = $(this);
	        	if (child.is(":visible")) {
					elementVisible = true;
				}
			});
			if(!elementVisible) {
				 nav_page.addClass('emptypage'); 
			}
		}
	});
		
	
	
	$('#event-707479.event').each(function(){
	var eventsuccessmsg=$("#successMsg").text();
	if(($(this).find('.cal_event .tools .input.going a').attr('onclick')!=null && eventsuccessmsg=="I didn't Go")||($(this).find('.cal_event .tools .input.going a').attr('onclick')!=null && eventsuccessmsg=="I am not going") ){
				$(this).find('.cal_event .tools .input.going a').hide();
				$(this).find('.cal_event .tools .input.going .button.submit input').addClass('iWent');
			}
	});
	
	//adding the past concerts details to the tour landing page
   	$('#event_listing-707476.event_listing .module .content .head .title').append('<div class="pastConcert"><a href="/event/?show=archive" id="pastConcertTag">PAST CONCERTS</a></div>');
	
   
	$("html").addClass($.os.name);
	$("body").addClass($.browser.className);
    $("body").addClass($.browser.name);
	
    /* START Add "Launch Player" links to footer nav of all audio playlist modules */
    var launchLink = $('<li class="launchPlayer"><a href="/music-player/" class="launchPlayerLink">Launch Player</a></li>');
    $(".song_playlist .module .content .nav_meta ul").prepend(launchLink);
    /* END Add "Launch Player" links to footer nav of all audio playlist modules */
    
	//The var "chatEnabled" is declared in subnav links html module
	//Initially this module is set to display:none using css.
	if(chatEnabled.toLowerCase()=="true"){
		$("#html-2050856.html").css("display","block");
	}
	//inserts the merch module into left wrapper
	$('#html-2050857.html .module .content .body .description .chatContainer #leftWrap').append($('#html-327531.html .module .content .body .description #merchContainer'));
		
    /* add popup onClick handler for audio player links */
    $("a.launchPlayerLink").click(function(){
        window.open("/music-player/", "Window2", "width=368,height=270,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no");
        return false;
    });
    
    /* Make store top nav link open in a new window */
    $('.nav_main ul li.custom a[href*=amazon.com]').attr("rel", "external");
    
	/*START - Fix for truncating author name in the discussions page #698 */
			$('.discussion_listing .topics li .author a').each(function(){
				var trunc = (this).innerHTML;
				if (trunc.length > discussionAuthorLen) {
					trunc = trunc.substring(0, discussionAuthorLen);
					trunc += '<span>' + '...</span>';
					(this).innerHTML = trunc;
				}	
			})		
	/*END - Fix for truncating author name in the discussions page #698 */
	
	    /* Blog title Truncation*/
		var blogLen = 40;
		$('.articles li .title h4 a').each(function(){
				var trunc = (this).innerHTML;
				if (trunc.length > blogLen) {
					trunc = trunc.substring(0, blogLen);
					trunc += '<span>' + '...</span>';
					(this).innerHTML = trunc;
				}	
			})
			
		
	
		
    $("a[href^=http://starterfanclub1.wmg.ciscoeos.com]").parent(".custom").addClass("Fanclub");
	
	/* START: Community drop-down for top nav */
    //Define XHTML source for the community subnav inn the variable below	
  	  var communityNavCell = $(".nav_main ul li.nav-community_landing"); //change this selector to target a diffent cell in the top nav
  	  communityNavCell.addClass('dropdown');
 	  communityNavCell.append(communitySubNav);
    /* END: Community drop-down for top nav */
    
	  	  var fanClubNavCell = $(".nav_main ul li.nav-group_detail_6397"); //change this selector to target a diffent cell in the top nav
  	  fanClubNavCell.addClass('dropdown');
 	  fanClubNavCell.append(FCSubNav);
	
	
    /* START: Custom drop-downs for top nav */
	var $customNavs = $('.nav_main ul li.nav-custom a');
	
	
	
  
	  $customNavs.filter(function(){
	  return (/^Music/i).test($(this).text())
	}).parent()
  	  .addClass('nav-custom')
	  .addClass('nav-music');
	  
	  

	  
	 $customNavs.filter(function(){
		  return (/^Store$/i).test($(this).text())
		}).parent()
    	  .addClass('nav-custom')
		  .addClass('nav-store');
		 
	
	  
	 $customNavs.filter(function(){
		  return (/^Global$/i).test($(this).text())
		 }).parent()
 		  .addClass('nav-custom')
		  .addClass('dropdown')
		  .addClass('nav-global_int')
		  .append(globalSubNav);
		  
	/* START: Bio drop-down for top nav */

 	var bioNavCell = $(".nav_main ul li.nav-bio"); //change this selector to target a diffent cell in the top nav
 	bioNavCell.addClass('dropdown');
 	bioNavCell.append(bioSubNav);
	/* END: Bio drop-down for top nav */
	
	/* END: Custom drop-downs for top nav */
	
	$("body#bio #bioLinks").delegate ("a","click",function(){
		$($(this).attr("href")).scrollToViewPort();
		return false;
	})
	
	$("body#bio .bioBack").click (function(){
		$($(this).attr("href")).scrollToViewPort();
		return false;
	}); 
	
	/* ********** Home Page SS3 *********************** */
	
	/* Removing the upload from the top, and adding at the bottom; */
	var uploadDiv = $("#homepage_ss3 .nav_main ul li.upload");
	$("#homepage_ss3 .nav_main div > ul").append(uploadDiv);
	
	/* Carousel Button */
	/* algo 
	 * Have an event handler for the click of the buttons.
	 * Have global variables like currentActiveCaros
	 * 
	 * 
	 */	
	 var carosActiveCurrent = 0;
	 var carosTotal = $("#carosUnitWrapper .carosUnit").length;

	 if (carosTotal > 1){
	 	$("#rightCarosButton").addClass('active');
	 	$("#carosUnitWrapper .carosUnit:eq("+ carosActiveCurrent +")").toggle(100);
	 }
	 	 
	 $("#rightCarosButton").click(function (event){
	 	 if (carosTotal-carosActiveCurrent != 1){
		 	$("#carosUnitWrapper .carosUnit:eq("+ carosActiveCurrent +")").toggle(100);
			carosActiveCurrent++;
		 	$("#carosUnitWrapper .carosUnit:eq("+ carosActiveCurrent +")").toggle(100);
		 }
		 setCarosButtonsState();
		 
		});
	 $("#leftCarosButton").click(function (event){
	 	 if (carosActiveCurrent > 0 ){
		 	$("#carosUnitWrapper .carosUnit:eq("+ carosActiveCurrent +")").toggle();
			carosActiveCurrent--;
		 	$("#carosUnitWrapper .carosUnit:eq("+ carosActiveCurrent +")").toggle();
		 }
		 setCarosButtonsState();
		});
		function setCarosButtonsState(){
			
			 if (carosActiveCurrent == carosTotal-1 ){
				 	$("#rightCarosButton").removeClass('active');
			 }else {
				 	$("#rightCarosButton").addClass('active');
			 }
			 if (carosActiveCurrent == 0){
				 $("#leftCarosButton").removeClass('active');
			 }else {
		   	 	 $("#leftCarosButton").addClass('active');
			 }
		};
		
		/* ********** Home Page SS3 ends *********************** */	 	  

	var blogcomment;
	$("ul.articles li.article").each(function(){
		if($(this).find(".activity .comment").html()!=null){
			blogComment = $(this).find(".activity .comment").html().replace("Comments", "").replace("Comment", "").replace(")", "").replace("(", "");
			$(this).find(".activity .comment").html(blogComment);
		}	
	});
	
	var blogDetailcomment;
	$(".blog_entry .article").each(function(){
		if($(this).find(".activity .comment").html()!=null){
			blogDetailcomment = $(this).find(".activity .comment").html().replace("Comments", "").replace("Comment", "").replace(")", "").replace("(", "");
			$(this).find(".activity .comment").html(blogDetailcomment);
		}	
	});
	
	var storeNavCell= $(".nav_main ul li.nav-store"); 
	var musicNavCell= $(".nav_main ul li.nav-music"); 
	
    $(".dropdown").hover(
			function() { $(".flyoutMenu", this).show(); },
			function() { $(".flyoutMenu", this).hide(); }
	);

    
  
	
    if (location.href.indexOf("/forums/") != -1) {
        communityNavCell.addClass("active");
        $("#discussionsNav").addClass("active");
    }
    if ((location.href.indexOf("/music/") != -1) || (location.href.indexOf("/album/") != -1)) {
        musicNavCell.addClass("active");       
    }
	
	if (location.href.indexOf("/ringtones/") != -1) {
        storeNavCell.addClass("active");
        $("#ringtonesNav").addClass("active");
    }
		
	 if (location.href.indexOf("/community_landing/") != -1) {
        communityNavCell.addClass("active");
        $("#communityNav").addClass("active");
    }
	
	 if (location.href.indexOf("/extras/") != -1) {
        communityNavCell.addClass("active");
        $("#extrasNav").addClass("active");
    }
	/*For international pages*/
	var globalNavCell=$(".nav_main ul li.nav-global");
	
	 if (location.href.indexOf("/es/") != -1) {
		globalNavCell.addClass("active");
		$("#esNav").addClass("active");
		}
		if (location.href.indexOf("/jp/") != -1) {
		globalNavCell.addClass("active");
		$("#jpNav").addClass("active");
		} 
		
		if (location.href.indexOf("/gb/") != -1) {
		globalNavCell.addClass("active");
		$("#gbNav").addClass("active");
		} 
		 if (location.href.indexOf("/de/") != -1) {
		globalNavCell.addClass("active");
		$("#deNav").addClass("active");
		}
	
    var photoNavCell = $(".nav_main ul li.photo");
    if (location.href.indexOf("/cellstream/") != -1) {
        photoNavCell.addClass("active");
    }
    
    if (location.href.indexOf("/music/") != -1) {
        $("a[href^=/album/]").parent(".nav-custom").addClass("active");
        
    }
    
    if (location.href.indexOf("/album/") != -1) {
        $("a[href^=/album/]").parent(".nav-custom").addClass("active");
    }	
    /* ********** Merch module code ********* */
	$('#merchContainer').parent(".description").parent(".body").siblings(".head").addClass("clearfix");				
		$('#merchContainer').parent(".description").parent(".body").siblings(".head").children("h3").css({'border':'none','font-size':'25px'});				
	$('#merchContainer').parent(".description").parent(".body").siblings(".head").css({'position': 'relative','z-index': '100'});
	$('#merchContainer').parent(".description").parent(".body").siblings(".foot").css({'z-index': '98','overflow': 'visible'});
	$('#merchContainer').parent(".description").parent(".body").css({'position': 'relative','clear': 'both','z-index': '99'});

	var	visitStorehead = $('#merchContainer').parent(".description").parent(".body").siblings(".head");
	$('#merchContainer .merchHead').appendTo(visitStorehead);

	var	visitStoreFoot = $('#merchContainer').parent(".description").parent(".body").siblings(".foot");
	$('#merchContainer .merchFoot').appendTo(visitStoreFoot);

	$('#merchContainer').parent(".description").parent(".body").siblings(".foot.empty").addClass("emptyfix");
	    
	/* START: Merch module drop-downs */	
	$(".merchHead .visitStore").hover (
			function() { $(".visitStoreFlyout", this).show(); },
			function() { $(".visitStoreFlyout", this).hide(); }
		);
	$(".merchFoot .visitStore").hover (
		function() { $(".visitStoreFlyout", this).show(); },
		function() { $(".visitStoreFlyout", this).hide(); }		
	);
	$(".firstitem .merchBuy").hover (
		function() { $(".merchBuyFlyout", this).show(); },
		function() { $(".merchBuyFlyout", this).hide(); }		
	);
	$(".seconditem .merchBuy").hover (
		function() { $(".merchBuyFlyout", this).show(); },
		function() { $(".merchBuyFlyout", this).hide(); }		
	);
	$(".thirditem .merchBuy").hover (
		function() { $(".merchBuyFlyout", this).show(); },
		function() { $(".merchBuyFlyout", this).hide(); }		
	);
	/* END: Merch module drop-downs */	
	
	if($("#sign_up-294578 li.input input").attr('class')== "focused"){		
		$descriptionDisplay = $("#sign_up-294578 li.input input.focused").parent().contents().filter(".message").children();
		if ($descriptionDisplay.css("display") == "inline" ||$descriptionDisplay.css("display") == "none"  ){
			$descriptionDisplay.css("display","block");
		}
	} 
	
	$("#sign_up-294578 li.input input").click( function() {
		// In this check for the corresponding description div. 		
		 $descriptionDisplay = $(this).next().filter(".message").children();
		if ($descriptionDisplay.css("display") == "inline"){
			$descriptionDisplay.css("display","block");
		}
	});
	
	$("#sign_up-294578 li.select input").click( function() {
		// In this check for the corresponding description div. 
		$descriptionDisplay = $(this).parent().contents().filter(".message").children();
		if ($descriptionDisplay.css("display") == "inline"){
			$descriptionDisplay.css("display","block");
		}
	});

   /* Make rel="external" links open in a new window */
    $("a[rel=external]").attr("target", "_new");
    
    /* Fixing the target for the digg link */
    $(".shareweb .digg a").attr("target", "_new");
	
    
    /* Append labels to elements in discussion module */
    $(".topics li.list .category li:first-child").prepend("Category: ");
    $(".topics li.list .activity").prepend("Replies: ");
    $(".topics li.list .date").prepend("Last Reply: ");
    
    /* Add "Close" text to close link in social media sharebox on photo and video detail pages */
    $(".sharebox .sb_head .sb_title a.shareclose").prepend("Close");
    
    var noOfImageDscDtl = $("#discussion_entry-294529 .topic .description img").length;
    for (i = 0; i < noOfImageDscDtl; i++) {
        var discussionImageElement = $("#discussion_entry-294529 .topic .description img:eq(" + i + ")");
        var imgHeight = discussionImageElement.height();
        var imgWidth = discussionImageElement.width();
        if (imgHeight > 200 && imgWidth > 200) {
            var calcheight = (imgHeight / imgWidth) * 200;
            discussionImageElement.css("height", calcheight);
            discussionImageElement.css("width", 200);
        }        
    }    
    
    var noOfImageDscDtl = $("#discussion_listing-340654  .topic .description img").length;
    for (i = 0; i < noOfImageDscDtl; i++) {
        var discussionImageElement = $("#discussion_listing-340654 .topic .description img:eq(" + i + ")");
        var imgHeight = discussionImageElement.height();
        var imgWidth = discussionImageElement.width();
        if (imgHeight > 200 && imgWidth > 200) {
            var calcheight = (imgHeight / imgWidth) * 200;
            discussionImageElement.css("height", calcheight);
            discussionImageElement.css("width", 200);
        }
        
    }
	
	// Functionality for add new blogs.
    $(".blog_listing .nav_meta .more a").bind("click", function(e){
		
		$.cookie("blog_body", blogTwitterBlurbText, {
            path: "/"
        });
    });
	    if ($("body").attr("id") == "add_new_blog") {        
        $.cookie("blog_body", blogTwitterBlurbText, {
            path: "/"
        });
    }

	
    //Album detail stuff 
    $buylinks = $('#album_info-383751 .foot .nav_meta ul');
    $buylinks.insertBefore('#album_info-383751 .album .txt div.description');
    $('#album_info-383751.album_info .module .content .foot .nav_meta ul').css("display", "block");
	
	    
    //Modifying the legal text in the log in and sign up pages.
    $("body#sign_up #cmsgData\\[agreeToTerms\\]").next().html(privacyPolicyText + "").show();
    $("body#join #cmsgData\\[agreeToTerms\\]").next().html(privacyPolicyText + "").show(); 	
	
	/*START- code which obfuscates email addresses #2420*/	
		var m_ = "mailto:";
		var a_ = "@";
		var d_ = ".";
		var i = 0;
		var j  = 0;
		var q_ = "?";
		var e_ = "=";
		
		$('span.ciReplace').each(function(){	
			if(cId[i].format == ""){
				$(this).html('<a href="'+m_+cId[i].name+a_+cId[i].domain+d_+cId[i].tld+'">'+ cId[i].name + a_+ cId[i].domain + d_+ cId[i].tld +'</a>');
			}
			else{
				if(cId[i].param == ""){
					$(this).html('<a href="'+m_+cId[i].name+a_+cId[i].domain+d_+cId[i].tld+'">'+ cId[i].format+'</a>');
				}
				else{
					$(this).html('<a href="'+m_+cId[i].name+a_+cId[i].domain+d_+cId[i].tld+q_+'subject'+e_+cId[i].param+'">'+cId[i].format+'</a>');
				}
			}
		i++;				
		});
		
		
		$('span.footReplace').each(function(){
					if(fId[j].format == ""){
				$(this).html('<a href="'+m_+fId[j].name+a_+fId[j].domain+d_+fId[j].tld+'">'+ fId[j].name + a_+ fId[j].domain + d_+ fId[j].tld +'</a>');
			}
			else{
				if(fId[j].param == ""){
					$(this).html('<a href="'+m_+fId[j].name+a_+fId[j].domain+d_+fId[j].tld+'">'+ fId[j].format+'</a>');
				}
				else{
					$(this).html('<a href="'+m_+fId[j].name+a_+fId[j].domain+d_+fId[j].tld+q_+'subject'+e_+fId[j].param+'">'+fId[j].format+'</a>');
				}
			}			
		});	
		
	/*End - code which obfuscates email addresses #2420*/
	
	var prvteCont="<i class='prText'>&nbsp;&nbsp;</i>";
	
	var prvtLegend='<span class="private">Visible only to site adminstrators</span>';
    
    $('.edit_account li.input.annotation').append(prvtLegend);


	$('#join-294550.join .annotation span.private').each(function(){
		var cont = (this).innerHTML;		
		(this).innerHTML= prvteCont+cont;
	})
	
	$('li.input.private').each(function(){
		var liCont = (this).innerHTML;		
		(this).innerHTML= liCont+prvteCont;
	});
	
	

	
});

function eoscInit(){
	
	/* fan club specific scripts - Starts */
	
	
	
	resizeHomeBlogEmbed();
	
	$("#blog_listing-327529.blog_listing .module ul.articles li.article.fanClub .description").customTruncate({max_length:200});
	$("#blog_listing-294510.blog_listing .module ul.articles li.article.fanClub .description").customTruncate({max_length:200});

	
	var blogLength = $('#blog_listing-327529.blog_listing .module ul.articles li.article').length;		
	for(var j=0; j<= blogLength; j++)
	{			
			
var blogContent = $('#blog_listing-327529.blog_listing .module ul.articles li.article.fanClub:nth-child('+j+')');
			
			
if (blogContent && blogContent.length != 0) {
var blogdesc = $('#blog_listing-327529.blog_listing .module ul.articles li.article.fanClub:nth-child(' + j + ') .description');
var blogtitle1 = $('#blog_listing-327529.blog_listing .module ul.articles li.article.fanClub:nth-child(' + j + ') .title');

var blogLength = blogdesc.text().trim().length > 200 ? 200 : blogdesc.text().trim().length; 
blogdesc.html(blogdesc.text().trim().substring(0, blogLength) + "... " + '<a class="readmore" href="'+ blogtitle1.find("a").attr("href") +'">Read More</a>');
//blogContent.addClass('fanclub');
}
}



var blogLength = $('#blog_listing-294510.blog_listing .module ul.articles li.article').length;		
	for(var j=0; j<= blogLength; j++)
	{			
			
var blogContent = $('#blog_listing-294510.blog_listing .module ul.articles li.article.fanClub:nth-child('+j+')');
			
			
if (blogContent && blogContent.length != 0) {
var blogdesc = $('#blog_listing-294510.blog_listing .module ul.articles li.article.fanClub:nth-child(' + j + ') .description');
var blogtitle1 = $('#blog_listing-294510.blog_listing .module ul.articles li.article.fanClub:nth-child(' + j + ') .title');

var blogLength = blogdesc.text().trim().length > 200 ? 200 : blogdesc.text().trim().length; 
blogdesc.html(blogdesc.text().trim().substring(0, blogLength) + "... " + '<a class="readmore" href="'+ blogtitle1.find("a").attr("href") +'">Read More</a>');
//blogContent.addClass('fanclub');
}
}

/* fan club specific scripts - Ends */

/* Tour page styling*/
    var eventdate = $('#event-707479.event .head h3 .date span').text();
	eventdate = $('#event-707479.event .module .cal_event div.txt div.date').text();
	var eventdateobj = new Date(eventdate);
	currentDate = new Date();
	offset = eventdateobj.getTime() - currentDate.getTime();		
	offsetdays=offset/ 86400000;  
  
  	var memberCount= $('#member_listing-3824953.member_listing .module .content .head h3').text();
	var openparanthesis=memberCount.indexOf("(");
	var closeparanthesis=memberCount.indexOf(")");
	memberCount=memberCount.substring(openparanthesis+1,closeparanthesis);
	
	var currentpageshowtitle=$.urlParam("show");
	
	if(currentpageshowtitle=="archive" || offsetdays < -1 ){
		
	var memberClass='<div class="membersGoing"> <span class="membercount"></span> Fans Went </div>';
	var currentText = $('#member_listing-3824953.member_listing .module .content .head h3').text().trim().toUpperCase();	
	var memberTitleReplace= currentText.replace("FANS GOING","Fans Went");
	$('#member_listing-3824953.member_listing .module .content .head h3').text(memberTitleReplace);
	if(memberCount !=null && memberCount !=" "){		
		$("#event-707479.event .module .content .body .cal_event .tools .membersGoing span.membercount").text(memberCount);
	}
      
	}
	else{
		
	var memberClass='<div class="membersGoing"> <span class="membercount"></span> Fans Going</div>';
	}
	$('#member_listing-3824953.member_listing .module .content .head .title').css("display","block"); 
	$("#event-707479.event .module .content .body .cal_event .tools").append(memberClass);
	if(memberCount !=null && memberCount !=" "){
		$("#event-707479.event .module .content .body .cal_event .tools .membersGoing span.membercount").text(memberCount);
	}

	/* Tour page styling Ends*/
	//Modifying the legal text in the log in and sign up pages.
	$("body#sign_up #cmsgData\\[agreeToTerms\\]").next().html(privacyPolicyText + "").show();
	$("body#join #cmsgData\\[agreeToTerms\\]").next().html(privacyPolicyText + "").show(); 		
	
	
	$('ul.cal_events li .txt').each(function() {
		var url = $(this).find("h4 a").attr("href");
		var found = $(this).find(".eventDownload");
		if($(found).length == 0){
			$(this).append('<div class="eventDownload"><a href="' + url + '">More Info</a></div>');
		}
		
	});

$('.grid_6 .blog_listing .articles li:first-child').addClass('first');
if ($('.grid_6 .blog_listing .articles li.article:last').hasClass('fanClub')) {
}
else {
	$('.grid_6 .blog_listing .articles li.article:last').addClass('lastblog');
}

$('.grid_9 .blog_listing .articles li:first-child').addClass('first');
$('.grid_9 .blog_listing .articles li.article:last').addClass('lastblog');

	/* Addition of Fanclub class - remove if there is no fanclub pages in the site  */
	if(fanclubNotifier != null && fanclubNotifier){
	
		$('.photo_thumbnail li.photo').each(function(){
				for (count = 0; count < photoFCCategories.length; count++) {
					$(".photo_thumbnail li." + photoFCCategories[count] + ".photo").addClass("fanClub");
				}
		});
		
		$('.photo_thumnail li.photo').each(function(){
				for (count = 0; count < photoFCCategories.length; count++) {
					$(".photo_thumnail li." + photoFCCategories[count] + ".photo").addClass("fanClub");
				}
		});
		
		$('.discussion_listing li.topic').each(function(){
				for (count = 0; count < forumFCCategories.length; count++) {
					$(".discussion_listing li." + forumFCCategories[count] + ".topic").addClass("fanClub");
				}
		});
		
		$('.video_thumbnail li.video').each(function(){
				for (count = 0; count < videoFCCategories.length; count++) {
					$(".video_thumbnail li." + videoFCCategories[count] + ".video").addClass("fanClub");
				}
		});
		
		$('.video_thumnail li.video').each(function(){
				for (count = 0; count < videoFCCategories.length; count++) {
					$(".video_thumnail li." + videoFCCategories[count] + ".video").addClass("fanClub");
				}
		});		
		
		
		$('.grid_9 .blog_listing li.article').each(function(){
				for (count = 0; count < blogFCCategories.length; count++) {
					var blogFcLi = $(".grid_9 .blog_listing li." + blogFCCategories[count] + ".article");
					var blogPageFcLi = $(".grid_9 #blog .blog_listing li." + blogFCCategories[count] + ".article");
					blogFcLi.addClass("fanClub");					
					blogFcLi.parent(".articles").addClass("fanClub");
				}
		});
		
		$('.grid_6 .blog_listing li.article').each(function(){
				for (count = 0; count < blogFCCategories.length; count++) {
					var blogFcLi = $(".grid_6 .blog_listing li." + blogFCCategories[count] + ".article");
					var blogPageFcLi = $(".grid_6 #blog .blog_listing li." + blogFCCategories[count] + ".article");
					blogFcLi.addClass("fanClub");					
					blogFcLi.parent(".articles").addClass("fanClub");
					
				}
		});
		
		$('.content .division .category').each(function(){
				for (count = 0; count < forumFCCategories.length; count++) {
					$(".content .division li." + forumFCCategories[count] + ".category").addClass("fanClub");
				}
				for (count = 0; count < videoFCCategories.length; count++) {
					$(".content .division li." + videoFCCategories[count] + ".category").addClass("fanClub");
				}
				for (count = 0; count < blogFCCategories.length; count++) {
					$(".content .division li." + blogFCCategories[count] + ".category").addClass("fanClub");
				}
				for (count = 0; count < photoFCCategories.length; count++) {
					$(".content .division li." + photoFCCategories[count] + ".category").addClass("fanClub");
				}
		});
			
	}
	/*tour module changes*/
	$('#event_listing-5621898.event_listing ul.cal_events li.cal_event').each(function(){
			var memberGoing="Fans Going ";
			var attendeeCount= $(this).find('.attendee_count').html();
			var eventPath=  $(this).find('.txt .date h4 a').attr('href');
			
			$(this).find('.attendee_count').remove();
			if(attendeeCount!=null && attendeeCount!=""){
				attendeeCount=attendeeCount.substring((attendeeCount.lastIndexOf(":")+1),attendeeCount.length).trim();
				attendeeCount= attendeeCount +" ";
				var member_det='<div class="member_details"><div class="membrGoing"><a href="'+eventPath+'">'+ attendeeCount + memberGoing  +'</a></div></div>';
				$(member_det).insertBefore($(this).find('.eventDownload'));
			}
		
	});
		$('#event_listing-4084688.event_listing ul.cal_events li.cal_event').each(function(){
			var memberGoing="Fans Went ";
			var attendeeCount= $(this).find('.attendee_count').html();
			var eventPath=  $(this).find('.txt .date h4 a').attr('href');
			
			$(this).find('.attendee_count').remove();
			if(attendeeCount!=null && attendeeCount!=""){
				attendeeCount=attendeeCount.substring((attendeeCount.lastIndexOf(":")+1),attendeeCount.length).trim();
				attendeeCount= attendeeCount +" ";
				var member_det='<div class="member_details"><div class="membrGoing"><a href="'+eventPath+'">'+ attendeeCount + memberGoing  +'</a></div></div>';
				$(member_det).insertBefore($(this).find('.eventDownload'));
			}
		
	});
	
		$('#event_listing-4084687.event_listing ul.cal_events li.cal_event').each(function(){
			var memberGoing="Fans Going ";
			var attendeeCount= $(this).find('.attendee_count').html();
			var eventPath=  $(this).find('.txt .date h4 a').attr('href');
			
			$(this).find('.attendee_count').remove();
			if(attendeeCount!=null && attendeeCount!=""){
				attendeeCount=attendeeCount.substring((attendeeCount.lastIndexOf(":")+1),attendeeCount.length).trim();
				attendeeCount= attendeeCount +" ";
				var member_det='<div class="member_details"><div class="membrGoing"><a href="'+eventPath+'">'+ attendeeCount + memberGoing  +'</a></div></div>';
				$(member_det).insertBefore($(this).find('.eventDownload'));
			}
		
	});
	
		$('#event_listing-4084685.event_listing ul.cal_events li.cal_event').each(function(){
			var memberGoing="Fans Went ";
			var attendeeCount= $(this).find('.attendee_count').html();
			var eventPath=  $(this).find('.txt .date h4 a').attr('href');
			
			$(this).find('.attendee_count').remove();
			if(attendeeCount!=null && attendeeCount!=""){
				attendeeCount=attendeeCount.substring((attendeeCount.lastIndexOf(":")+1),attendeeCount.length).trim();
				attendeeCount= attendeeCount +" ";
				var member_det='<div class="member_details"><div class="membrGoing"><a href="'+eventPath+'">'+ attendeeCount + memberGoing  +'</a></div></div>';
				$(member_det).insertBefore($(this).find('.eventDownload'));
			}
		
	});
	
	$('#event_listing-4043332.event_listing ul.cal_events li.cal_event').each(function(){
			var memberGoing="Fans Went ";
			var attendeeCount= $(this).find('.attendee_count').html();
			var eventPath=  $(this).find('.txt .date h4 a').attr('href');
			
			$(this).find('.attendee_count').remove();
			if(attendeeCount!=null && attendeeCount!=""){
				attendeeCount=attendeeCount.substring((attendeeCount.lastIndexOf(":")+1),attendeeCount.length).trim();
				attendeeCount= attendeeCount +" ";
				var member_det='<div class="member_details"><div class="membrGoing"><a href="'+eventPath+'">'+ attendeeCount + memberGoing  +'</a></div></div>';
				$(member_det).insertBefore($(this).find('.eventDownload'));
			}
		
	});
	
		$('#event_listing-4084684.event_listing ul.cal_events li.cal_event').each(function(){
			var memberGoing="Fans Going ";
			var attendeeCount= $(this).find('.attendee_count').html();
			var eventPath=  $(this).find('.txt .date h4 a').attr('href');
			
			$(this).find('.attendee_count').remove();
			if(attendeeCount!=null && attendeeCount!=""){
				attendeeCount=attendeeCount.substring((attendeeCount.lastIndexOf(":")+1),attendeeCount.length).trim();
				attendeeCount= attendeeCount +" ";
				var member_det='<div class="member_details"><div class="membrGoing"><a href="'+eventPath+'">'+ attendeeCount + memberGoing  +'</a></div></div>';
				$(member_det).insertBefore($(this).find('.eventDownload'));
			}
		
	});
	
	
	
	
		$('#event_listing-4084683.event_listing ul.cal_events li.cal_event').each(function(){
			var memberGoing="Fans Went ";
			var attendeeCount= $(this).find('.attendee_count').html();
			var eventPath=  $(this).find('.txt .date h4 a').attr('href');
			
			$(this).find('.attendee_count').remove();
			if(attendeeCount!=null && attendeeCount!=""){
				attendeeCount=attendeeCount.substring((attendeeCount.lastIndexOf(":")+1),attendeeCount.length).trim();
				attendeeCount= attendeeCount +" ";
				var member_det='<div class="member_details"><div class="membrGoing"><a href="'+eventPath+'">'+ attendeeCount + memberGoing  +'</a></div></div>';
				$(member_det).insertBefore($(this).find('.eventDownload'));
			}
		
	});
	
			$('#event_listing-4147656.event_listing ul.cal_events li.cal_event').each(function(){
			var memberGoing="Fans Went ";
			var attendeeCount= $(this).find('.attendee_count').html();
			var eventPath=  $(this).find('.txt .date h4 a').attr('href');
			
			$(this).find('.attendee_count').remove();
			if(attendeeCount!=null && attendeeCount!=""){
				attendeeCount=attendeeCount.substring((attendeeCount.lastIndexOf(":")+1),attendeeCount.length).trim();
				attendeeCount= attendeeCount +" ";
				var member_det='<div class="member_details"><div class="membrGoing"><a href="'+eventPath+'">'+ attendeeCount + memberGoing  +'</a></div></div>';
				$(member_det).insertBefore($(this).find('.eventDownload'));
			}
		
	});
	
	$('#event_listing-707476.event_listing ul.cal_events li.cal_event').each(function(){
			var memberGoing="Fans Going ";
			var attendeeCount= $(this).find('.attendee_count').html();
			var eventPath=  $(this).find('.txt .date h4 a').attr('href');
			
			$(this).find('.attendee_count').remove();
			if(attendeeCount!=null && attendeeCount!=""){
				attendeeCount=attendeeCount.substring((attendeeCount.lastIndexOf(":")+1),attendeeCount.length).trim();
				attendeeCount= attendeeCount +" ";
				var member_det='<div class="member_details"><div class="membrGoing"><a href="'+eventPath+'">'+ attendeeCount + memberGoing  +'</a></div></div>';
				$(member_det).insertBefore($(this).find('.eventDownload'));
			}
		
	});	
	/* Addition of Fanclub class - Ends */	
	
	
	
	var $readMe = $('.blog_listing .content .articles li.article .description a');
      $readMe.filter(function(){
  		return (/^Read More/i).test($(this).text())
	}).addClass('readmore');
	
	/* SP Start */
	$(".edit_account #accountData .buttons.input .button.submit input.submit").removeAttr("onclick");
	$(".edit_account #accountQuestoins .buttons.input .button.submit input.submit").removeAttr("onclick");
	
	$('.edit_account #accountData .buttons.input .button.submit input.submit').die();
	$('.edit_account #accountQuestoins .buttons.input .button.submit input.submit').die();
	
	$.wmgfeature.spFeatureEditAccountAccData(".edit_account #accountData .buttons.input .button.submit input.submit", "edit_account-294534", true, arrElementIDs, "http://www.startersite1.wmg.ciscoeos.com", "9752");
	$.wmgfeature.spFeatureEditAccountAccQuestions(".edit_account #accountQuestoins .buttons.input .button.submit input.submit", "edit_account-294534", true, arrElementIDs, "http://www.startersite1.wmg.ciscoeos.com", "9752");
	/* SP End */
	
	/* adding home page social buttons on pagination - Starts */	
		var listing='moduleListing';	
		if ($('body').attr('id') == "home") {
		var twtrScript=document.createElement('script');
		twtrScript.type = 'text/javascript';
		twtrScript.src = "http://platform.twitter.com/widgets.js";
		$(".blog_listing").append(twtrScript);
		
		var twitterObj = {
			blockSelector: '#home .articles li.article',
			insertionSelector: '.activity',
			siteUrl: 'http://www.skillet.com',
			urlSelector:'.title h4 a',
			viaParam: '&amp;via=skilletmusic',
			relatedParam: '&amp;related=skilletmusic',
			fanclubviaParam: '&amp;via=skilletmusic',
			fanclubrelatedParam: '&amp;related=skilletmusic,skilletmusic'
		}
		var fbLikeObj = {
			blockSelector: '#home .articles li.article',
			insertionSelector: '.activity',
			urlSelector:'.title h4 a',
			siteUrl: 'http://www.skillet.com'
		}
		var fbShareObj = {
			blockSelector: '#home .articles li.article',
			insertionSelector: '.activity',
			urlSelector:'.title h4 a',
			siteUrl: 'http://www.skillet.com'
		}
		if (($("#home .articles li.article").find('.twitter-share-button').length == 0)) {
			$.wmgfeature.twttrButton(twitterObj, listing);
		}
		$.wmgfeature.fbLike(fbLikeObj, listing);
	}
		
		/* adding home page social buttons on pagination - Ends */
		
        $(".msie7 #footer").css("background", "none repeat scroll 0 0 transparent");
		customTruncateBlog("#blog_listing-327529.blog_listing .module ul.articles li.article.fanClub");
		customTruncateBlog("#blog_listing-294510.blog_listing .module ul.articles li.article.fanClub");
		lastBlogGrad('#blog .grid_9 .blog_listing .module .content .body ul li.article.lastblog.fanClub', '#blog .grid_9 .blog_listing .module .content .body ul.articles');
		
		/* badges - Starts */
		$(".badges ul").each(function(){	
		if ($(this).find("li").length > 0) {	
			$(this).html('<li class="badge"><a class="badgeImageReplace" href="/group/the-panheads/"></a></li>');
		}
		
		/* Suppresses display of empty footers on IE */	
		
		$('.module .content .foot .nav_page').each(function() {

		var nav_page = $(this);
		/* Add empty class if nav page is empty */
		if (nav_page.children().size() == 0){
	    	nav_page.addClass('emptypage'); 
			$('.blog_listing .module .content .foot').addClass('emptyfoot')
		} else {
			
			var elementVisible = false;
			nav_page.children().each(function() {
				var child = $(this);
	        	if (child.is(":visible")) {
					elementVisible = true;
				}
			});
			if(!elementVisible) {
				 nav_page.addClass('emptypage'); 
			}
		}
	});

	});
	
	/* badges - Ends */	
	
	var blogcomment;
	$("ul.articles li.article").each(function(){
		if($(this).find(".activity .comment").html()!=null){
			blogComment = $(this).find(".activity .comment").html().replace("Comments", "").replace("Comment", "").replace(")", "").replace("(", "");
			$(this).find(".activity .comment").html(blogComment);
		}	
	});
	
	var blogDetailcomment;
	$(".blog_entry .article").each(function(){
		if($(this).find(".activity .comment").html()!=null){
			blogDetailcomment = $(this).find(".activity .comment").html().replace("Comments", "").replace("Comment", "").replace(")", "").replace("(", "");
			$(this).find(".activity .comment").html(blogDetailcomment);
		}	
	});
	
	eoscInitcallback();
	


}

   $.urlParam = function(name){
        var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
        if (results == null) {
            return 0;
        }
        else {
            return results[1];
        }
    }	
	
	
	/* Functions for New Merch.*/

	/*
	 * This function is used to tag store links with different omniture tags, 
	 * to track them. This will enable us to track which links the user clicked. 
	 * 
	 * */
	function getMerchOmnitureArray(omnitureString){
		var omnitureArrayLinks = new Array();
		var omnitureStrRegex = /intcmp=(.*)(&.*|\/)$/;
		omnitureString = $.trim(omnitureString);
		if (omnitureString.charAt(omnitureString.length-1) != "/" ){omnitureString += "/";}
		writeToConsole ("This is the omnitureString " + omnitureString);
		regExCapture = omnitureString.match(omnitureStrRegex);
		//A JSON object could be used and a fuction to populate that could be used. 
		if (regExCapture != null && regExCapture != ""){
			var regularExpCapture = regExCapture[1]; 
			omnitureString = omnitureString.replace(/\/$/,'');
			omnitureArrayLinks["page-title"] = omnitureString.replace(regularExpCapture,regularExpCapture+'-page-title');
			omnitureArrayLinks["page-button"] = omnitureString.replace(regularExpCapture,regularExpCapture+'-page-button');
			omnitureArrayLinks["page-thumb"] = omnitureString.replace(regularExpCapture,regularExpCapture+'-page-thumb');
			omnitureArrayLinks["hovercard-title"] = omnitureString.replace(regularExpCapture,regularExpCapture+'-hovercard-title');
			omnitureArrayLinks["hovercard-thumb"] = omnitureString.replace(regularExpCapture,regularExpCapture+'-hovercard-thumb');
			omnitureArrayLinks["hovercard-button"] = omnitureString.replace(regularExpCapture,regularExpCapture+'-hovercard-button');
		}else{
			omnitureArrayLinks["page-title"] = omnitureString.replace(/\/$/,'?intcmp=page-title');
			omnitureArrayLinks["page-button"] = omnitureString.replace(/\/$/,'?intcmp=page-button');
			omnitureArrayLinks["page-thumb"] = omnitureString.replace(/\/$/,'?intcmp=page-thumb');
			omnitureArrayLinks["hovercard-title"] = omnitureString.replace(/\/$/,'?intcmp=hovercard-title');
			omnitureArrayLinks["hovercard-thumb"] = omnitureString.replace(/\/$/,'?intcmp=hovercard-thumb');
			omnitureArrayLinks["hovercard-button"] = omnitureString.replace(/\/$/,'?intcmp=hovercard-button');
		}				 
		return omnitureArrayLinks;
	}
	
	/*
	 * Function to add the hovercard to the template,
	 * if set in the config xml.
	 * 
	 * */
	function prepareMerchTemplate (merchHoverCardPresent){
		if (merchHoverCardPresent){
			merchModuleTemplate = merchModuleTemplate.replace("<!-- HOVERCARD -->",merchHCTemplate);
		}else{
			merchModuleTemplate = merchModuleTemplate.replace("<!-- HOVERCARD -->","");
		}
		
	}
	
	function getMerchHeader ($merchCountries,merchViewAllLink,positionClass){
		var merchHeaderString = "";
		var merchCountryString = "";
		var countryParams;
		var merchParams = {
							merchViewAllLink : merchViewAllLink,
							positionClass : positionClass};
			$merchCountries.each (function(){

				countryParams = {
					countryName : $(this).children(".countryName").html(),
					countryLink : $(this).children(".countryLink").html(),
					countryText : $(this).children(".countryText").html()
				};
				merchCountryString += merchCountryTemplate.supplant(countryParams);
				
			})

			merchViewAllLink ="javscript:void(0)"; 	
		
		merchHeaderString = merchHeaderTemplate.supplant(merchParams);
		merchHeaderString = merchHeaderString.replace("<!-- MERCH COUNTRIES -->",merchCountryString);
		return merchHeaderString;
	}
	
	/*
	 * This function generates the structure of the merch module. 
	 * The structure is created using templates defined earlier in the page.  
	 */ 
	function generateMerchStructure (){
		var $merchData = $("#merchData");
		var $merchItem = $merchData.children(".merchItems")
		var merchViewAllLink = $merchData.children(".merchViewAll").html();
		var merchHoverCardPresent = $merchData.children(".merchHoverCardPresent").html().trim();
		merchHoverCardPresent = !!merchHoverCardPresent;
		prepareMerchTemplate (merchHoverCardPresent);
		
		/* Code for the Merch Head */
		var merchHead = '<div class="merchHead"><div class="visitStore"><a href="'+ merchViewAllLink +'" class="visitStoreLink"  >ALL</a></div></div>'
		merchHead = getMerchHeader($("#merchInternational .country"),merchViewAllLink,"merchHead");
		var visitStorehead = $('#merchContainer').parent(".description").parent(".body").siblings(".head");
	        $(merchHead).appendTo(visitStorehead);
		$(visitStorehead).find("a").makeLinksExternal();
		/* End of Code for Merch Module */
		
		var merchBody='<ul class="merchItems">';
		$.each($merchItem.children(".merchItem"), function (i){
			var merchBuyNow = $(this).children(".merchBuyNow").html(); 			
			var omnitureLinks = getMerchOmnitureArray(merchBuyNow);
			//var merchSizes = $(this).children(".merchSizes").html();
			//if (merchSizes !="" && merchSizes !=null){merchSizes = '<h3>Sizes</h3><div>'+merchSizes+'</div>';}
			var merchDesc = $(this).children(".merchDesc").html();
			if (merchDesc != "" && merchDesc != null){merchDesc = '<h3>Description</h3><div>'+ merchDesc +'</div>';}
			var merchParsedData = {
				             index:(i+1),
							 merchImage:$(this).children(".merchImage").html(),
							 merchTitle:$(this).children(".merchTitle").html(),
							 merchDesc:merchDesc,
							// merchSizes:merchSizes,
							 merchPrice:$(this).children(".merchPrice").html(),
							 omnitureLinksPTitle:omnitureLinks["page-title"],
							 omnitureLinksPThumb:omnitureLinks["page-thumb"],
							 omnitureLinksPButton:omnitureLinks["page-button"],
							 omnitureLinksHTitle:omnitureLinks["hovercard-title"],
							 omnitureLinksHThumb:omnitureLinks["hovercard-thumb"],
							 omnitureLinksHButton:omnitureLinks["hovercard-button"]
							 }
			merchBody = merchBody + merchModuleTemplate.supplant(merchParsedData);
		});
		merchBody += '</ul><div class="clear"></div>';
	
		var merchFoot = '<div class="clear"></div><div class="merchFoot"><div class="visitStore"><a href="'+ merchViewAllLink +'" class="visitStoreLink" >View ALL</a></div></div>';
		merchFoot = '<div class="clear"></div>';
		merchFoot += getMerchHeader($("#merchInternational .country"),merchViewAllLink,"merchFoot");
		var visitStoreFoot = $('#merchContainer').parent(".description").parent(".body").siblings(".foot");
	        $(merchFoot).appendTo(visitStoreFoot);
		$(visitStoreFoot).find("a").makeLinksExternal();

		return merchBody;
	}
	
	
	
	/*These functions are used by the merch HC so that casual hovers less than 300 seconds
	 * are omitted. 
	 */
	function bringMerchHCOn(merchImg){
		merchImg.showTimer = window.setTimeout(function(){
			$(merchImg).siblings(".merchHC").fadeIn(300);
		},300);
	}
	function killMerchHC(merchImg){
		if (merchImg.showTimer){
			window.clearTimeout(merchImg.showTimer);
		}
	}
	
	/* Registereing the hover events */
	function registerMerchHoverEvents(){
		$(".merchImg").hover(function(){
			bringMerchHCOn(this);
		},function(){
			killMerchHC(this);
		});
		$(".merchHC").hover(function(){
		},function(){
			$(this).fadeOut(300);
		});
		
		$(".visitStore").hover (
			function() { $(".visitStoreFlyout", this).show(); },
			function() { $(".visitStoreFlyout", this).hide(); }
		);
	}
	
	/* The piece of code which generates the merch, adds the dom and registers the events. */
	
	$(document).ready(function(){
		if ($("#merchContainer").length > 0){
			$("#merchContainer").html(generateMerchStructure());
			$("#merchData").empty();
			$("#merchContainer a").makeLinksExternal();
			registerMerchHoverEvents();
			
			
		}
	
	});
    /* End of Functions for New Merch */
	
	



