/* 
 * 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);

	var invite_location;
	var invite_title;
	var invite_date;
	var monthNames = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun",
			"Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
			
	var monthJson = {"monthNameToNumMap":  {"some" : [
		{"name": "Jan", "num": "01"},
		{"name": "Feb", "num": "02"},
		{"name": "Mar", "num": "03"},
		{"name": "Apr", "num": "04"},
		{"name": "May", "num": "05"},
		{"name": "Jun", "num": "06"},
		{"name": "Jul", "num": "07"},
		{"name": "Aug", "num": "08"},
		{"name": "Sep", "num": "09"},
		{"name": "Oct", "num": "10"},
		{"name": "Nov", "num": "11"},
		{"name": "Dec", "num": "12"},
	]} };


$(document).ready(function(){
	
	/*comments blog */
	$.each($('.activity .comment'), function(index, value) { 
	var newCommentNo = $('.activity .comment').eq(index).html();
	newCommentNo = newCommentNo.replace("Comments", "").replace("(", "").replace(")", "");
	newCommentNo = newCommentNo.replace("Comment", "");
	$('.activity .comment').eq(index).html(newCommentNo); 

	});


	
		
	/*Highlighting creature club category*/
	$('li .txt .category a').each(function(){
		var comment1 = $(this).html();		
		if(comment1=="Creature Club"){
		$(this).addClass("colour_change");
		var sample=$(this).parents('.txt').find('.author a').html();
		$(this).parents('.txt').find('.author a').addClass("colour_change");
		}
	});
	
	/*Class added to change the colour of category Creature Club*/


	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;
})

	
	/*Tour pages implementation */
 $('#event_listing-1440501.event_listing .body ul.cal_events li.cal_event').each(function(){
          var $buyWrapper = $(this).children().find('.buy').html();
          $buyWrapper = "<div class='buy'>" + $buyWrapper + "</div>";
          var $locationWrapper = $(this).children().find('.event_location').html();
          $locationWrapper = "<div class='event_location'>" + $locationWrapper + "</div>";
          $(this).find('.txt').append("<div class='eventDetails'></div>");
          
          $(this).children().find('.buy').remove();
          $(this).children().find('.event_location').remove();
          
          $(this).children().find('.eventDetails').append($locationWrapper);
          $(this).children().find('.eventDetails').append($buyWrapper);
          
      });
	  
/* event detail page modification */
	var clearDivEle='<div class="clear"></div>';
	var horzDivdr='<div class="hd"></div>';
	var currentPageShowUrl=$.urlParam("show");
  	
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 == "past-shows"|| offsetdays < -1 ) {
		$('body').addClass('archive');
		var archiveTitle="Past Shows";
		$('#event-707479.event').each(function(){
			$(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 stateVal= $(this).find('.cal_event div.txt .location .region').html();
			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 past shows');
			$(this).find('.nav_meta ul li.more a').attr("href","/tour-archive/");
			$('#event-707479.event .cal_event div.txt .location').insertBefore('#event-707479.event .cal_event div.txt .venue')
			$(eventDate).insertBefore('#event-707479.event .cal_event div.txt .location');
			
			entireDivStr=($(this).find('.cal_event .txt').html());
			 tempvariable=entireDivStr.replace(/([.\n\r]*)>[\s\t\r\n]*-[\s\t\r\n]*<([.\n\r]*)/i,"$1><$2")
			 $(this).find('.cal_event .txt').html(tempvariable);
			
			$(this).find('.cal_event').append(descEle);
			$(this).find('.cal_event').append(clearDivEle);	
			$(clearDivEle).insertAfter('#event-707479.event .cal_event div.txt');	
			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(clearDivEle);
			$(this).find('.cal_event').append(horzDivdr);
			$(this).find('.cal_event').append(toolsData);
			$(this).find('.cal_event .tools').append(goingRnot);
			$(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 .description').remove();
		});	
		
	}else{
		var upcomingTitle="Upcoming Shows";
		$('#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 buyLnk="<div class='buyLnk'>"+$(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');
			$('#event-707479.event .cal_event div.txt .location').insertBefore('#event-707479.event .cal_event div.txt .venue')
			$(eventDate).insertBefore('#event-707479.event .cal_event div.txt .location');	
					
			entireDivStr=($(this).find('.cal_event .txt').html());
			tempvariable=entireDivStr.replace(/([.\n\r]*)>[\s\t\r\n]*-[\s\t\r\n]*<([.\n\r]*)/i,"$1><$2")
			$(this).find('.cal_event .txt').html(tempvariable);
			
					
			$(this).find('.cal_event').append(mapEle);
			$(clearDivEle).insertAfter('#event-707479.event .cal_event div.txt');
			$(buyLnk).insertAfter('#event-707479.event .cal_event div.clear');
			
			$(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(horzDivdr);
			$(this).find('.cal_event').append(toolsData);
			$(this).find('.cal_event .tools').append(goingRnot);
			$(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 .description').remove();
			$(this).find('.cal_event div.txt .rating').remove();
			$(this).find('.cal_event .buyLink').remove();
			$(this).find('.cal_event div.txt .availability').remove();
			$(this).find('.foot .nav_meta ul li.buy').remove();
			
		});		
	}
	var eventWrapper =  $('#event-707479 .module').html();
	$('#event-707479 .module .content').remove();
	$('#event-707479 .module').append('<div class = "eventWrapper"></div>');
	$('#event-707479 .module .eventWrapper').append(eventWrapper);
}  


/* differentiating b/w past shows and upcoming shows and enabling and disabling module display */
	var currentpageshow=$.urlParam("show");
		
		if ($('body').attr('id') == 'event') {
			if (currentpageshow == "past-shows") {
				$('#event_listing-1893249').css("display", "block");
				$('#event_listing-1332878').css("display", "none");
				$('#event_listing-1440501').css("display", "block");
				$('#event_listing-3079888').css("display", "none");
				$('#html-3128964').css("display","none");
				$('#html-1895029').css("top","18px");
			}
			else {
				$('#event_listing-1893249').css("display", "none");
				$('#event_listing-1332878').css("display", "block");
				$('#event_listing-1440501').css("display", "none");
				$('#event_listing-3079888 .nav_meta ul li.more a').attr('href', '/tour-archive/');
				$('#event_listing-3079888').css("display", "block");
				$('#html-3128964').css("display","block");
			}
		}
		
			if ($('body').attr('id') == 'event_detail') {
			if (currentpageshow == "past-shows" || offsetdays < -1 ) {
				
				$('#photo_thumbnail-1372409').css("display", "block");
				$('#video_thumbnail-1372410').css("display", "block");		
				$('#event_listing-1440501').css("display", "none");
				$('#event_listing-3096741').css("display","block");
				$('#event_listing-3096741 .nav_meta ul li.more a').attr('href', '/tour-archive/');
			}
			else {
				
				$('#photo_thumbnail-1372409').css("display", "none");
				$('#video_thumbnail-1372410').css("display", "none");
				$('#event_listing-1440501').css("display", "block");
				$('#event_listing-3096741').css("display","none");
			}
		}
	
	
	$('#event_listing-3079888.event_listing ul.cal_events li.cal_event').each(function(){
		var eventPath=  $(this).find('.txt .date h4 a').attr('href');
		eventPath=eventPath+"?show=past-shows";
		var viewEveMedia="<div class='viewMedia'><a class='viewpix' href='"+eventPath+""+"'>view photos and videos</a></div>"
		$(this).append(viewEveMedia);			
	});
	
	$('#event_listing-3096741.event_listing ul.cal_events li.cal_event').each(function(){
		var eventPath=  $(this).find('.txt .date h4 a').attr('href');
		eventPath=eventPath+"?show=past-shows";
		var viewEveMedia="<div class='viewMedia'><a class='viewpix' href='"+eventPath+""+"'>view photos and videos</a></div>"
		$(this).append(viewEveMedia);			
	});
	

	var memberGoing="&nbsp;Fans Going";
	$('#event_listing-1440501.event_listing ul.cal_events li.cal_event').each(function(){
		var attendeeCount= $(this).find('.attendee_count').html();
		var eventPath=  $(this).find('.txt .date h4 a').attr('href');
		var venuetext= $(this).find('.event_location .venue').text();
		venueanchor='<a href="'+eventPath+'">'+venuetext+'</a>';
		var venuecity=$(this).find('.event_location .location .city').text();	
		venuecityanchor='<a href="'+eventPath+'">'+venuecity+'</a>';	
		var venuestate=$(this).find('.event_location .location .region').text();	
		venuestateanchor='<a href="'+eventPath+'">'+venuestate+'</a>';
		$(this).find('.event_location .venue').html(venueanchor);
		$(this).find('.event_location .city').html(venuecityanchor);
		$(this).find('.event_location .region').html(venuestateanchor);
		$(this).find('.attendee_count').remove()
		if(attendeeCount!=null && attendeeCount!=""){
			attendeeCount=attendeeCount.substring((attendeeCount.lastIndexOf(":")+1),attendeeCount.length).trim();
			
			if(attendeeCount == 1){
				memberGoing="&nbsp;Fan Going"
			}
			var member_det='<div class="member_details"><div class="membrGoing"><a href="'+eventPath+'">'+ attendeeCount + memberGoing +'</a></div></div><div class="moreinfo"><a class="viewmoreinfo" href="'+eventPath+'">More info</a></div>';
			$(this).find('.txt').append(member_det);
		}else{
			var member_det='<div class="moreinfo"><a class="viewmoreinfo" href="'+eventPath+'">More info</a></div>';
			$(this).find('.txt').append(member_det);
		}
	});
	
	$('#event_listing-3096741.event_listing ul.cal_events li.cal_event').each(function(){
		var memberGoing="Fans Went&nbsp;";
		var eventPath=  $(this).find('.txt .date h4 a').attr('href');
		eventPath=eventPath+"?show=past-shows";
		$(this).find('.txt .date h4 a').attr('href',eventPath);
		var attendeeCount= $(this).find('.attendee_count').html();
		$(this).find('.attendee_count').remove();
		if(attendeeCount!=null && attendeeCount!=""){
			attendeeCount=attendeeCount.substring((attendeeCount.lastIndexOf(":")+1),attendeeCount.length).trim();
			if(attendeeCount==1){
				memberGoing="Fan Went&nbsp;"
			}
			var member_det='<div class="member_details"><div class="membrGoing"><a href="' + eventPath + '">' + attendeeCount + " " + memberGoing +'</a></div></div>';
			$(this).find('.txt').append(member_det);
			
		}
		
	});
		$('#event_listing-3079888.event_listing ul.cal_events li.cal_event').each(function(){
		var memberGoing="Fans Went&nbsp;";
		var eventPath=  $(this).find('.txt .date h4 a').attr('href');
		eventPath=eventPath+"?show=past-shows";
		$(this).find('.txt .date h4 a').attr('href',eventPath);
		var attendeeCount= $(this).find('.attendee_count').html();
		$(this).find('.attendee_count').remove();
		if(attendeeCount!=null && attendeeCount!=""){
			attendeeCount=attendeeCount.substring((attendeeCount.lastIndexOf(":")+1),attendeeCount.length).trim();
			if(attendeeCount==1){
				memberGoing="Fan Went&nbsp;"
			}
			var member_det='<div class="member_details"><div class="membrGoing"><a href="' + eventPath + '">' + attendeeCount + " " + memberGoing +'</a></div></div>';
			$(this).find('.txt').append(member_det);
			
		}
		
	});
	
	
var memberCount= $('#member_listing-3158164.member_listing .module .content .head h3 span').text();
	var openparanthesis=memberCount.indexOf("(");
	var closeparanthesis=memberCount.indexOf(")");
	memberCount=memberCount.substring(openparanthesis+1,closeparanthesis);
	var 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 currentpageshowtitle=$.urlParam("show");
	if(currentpageshowtitle=="past-shows" || offsetdays < -1){
	var memberClass='<div class="membersGoing">Fans Went : <span class="membercount"></span></div>';	
	}
	else{
	var memberClass='<div class="membersGoing">Fans Going : <span class="membercount"></span></div>';
	}
	
	$("#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);
	}
	
	var detailPageUrl = window.location.href;
//event_detail
 

	
	var venuelocationupload=$('#event-707479.event .module .archive .body .cal_event div.txt .venue .val').text();
 if (venuelocationupload.length > 0) {
 	var uploadhref = $('#photo_thumbnail-1372409 .head .nav_meta ul li.new a').attr("href");
	uploadhref = uploadhref + "&venuenameinfo=" + venuelocationupload;
 	$('#photo_thumbnail-1372409 .head .nav_meta ul li.new a').attr("href", uploadhref);
 	var uploadhref = $('#video_thumbnail-1372410 .head .nav_meta ul li.new a').attr("href");
 	uploadhref = uploadhref + "&venuenameinfo=" + venuelocationupload;
 	$('#video_thumbnail-1372410 .head .nav_meta ul li.new a').attr("href", uploadhref);
 }
 
  if($('body#upload').length >0){
 	var venuenameinfo=$.urlParam("venuenameinfo");
	if(venuenameinfo.length >0){
		$('.media_upload .module .content .head h3 span').text(" - "+decodeURI(venuenameinfo));
	}
 }
	
	
	
	
	
	 //Badges implementation
$(".badges ul").each(function(){
 if ($(this).find("li").length > 0) {
 $(this).html('<li class="badge"><a class="badgeImageReplace" href="/group/creature-club/"></a></li>');
 }
 });

	
	
	if ($("body#group_detail_4089").length != 0) {
		$("body#group_detail_4089 .module .videos li .txt .title h4").addClass("removeSifr");	
		$("body#blog .blog_listing .module .articles li.category_39286 .title h4").addClass("removeSifr");	
		$("body#group_detail_4089 .articles li.category_39286 .title h4").addClass("removeSifr");
		$("body#group_detail_4089 .photos li.category_24630 .txt .title h4").addClass("removeSifr");			
	}else{
		$("body#blog .blog_listing .module .articles li.category_39286 .title h4").addClass("removeSifr");	
	}
	
	if( ($("body#blog").length != 0)){
		$(".blog_listing li.article.category_39286").append('<div class="blogshinedownlogo" />');
		$(".blog_listing li.article.category_39286 ").css('position','relative');
	}
	
	var postNewBlog;
	var blogdate;
	var blogmonth;
	var regexLocation = /[\d\.]+/g;
	var regexLocationtxt = /[a-zA-Z]+/g;
	var blogpubtxt;
	var blogdatenmonth;
	var blogdatestr;
	var blogmonthNames = new Array("January", "February", "March", "April", "May", "June",
			"July", "August", "September", "October", "November", "December");
	
	$('#blog_listing-2901128.blog_listing .module .articles li.article').each(function(){
		
		blogpubtxt=$(this).children(".date").text(); 
		blogdate=$(this).children(".date");
		blogdate.insertBefore($(this).children(".title"));
		blogdatenmonth = blogpubtxt.match(regexLocation);
		blogpubtxt=blogpubtxt.match(regexLocationtxt);
		 if (blogdatenmonth != null && blogdatenmonth != "") {
		 	blogdate=blogdatenmonth[0];
			blogyear=blogdatenmonth[1];
		 }	
		 constructdate=blogpubtxt[0]+" "+blogdate+","+blogyear;
		date = new Date(constructdate);
		blogmonth = (blogmonth+1); // Added '1' to give correct value, As the array starts from 0.
		blogdatestr=(date.getMonth()+1)+"/"+blogdate;
		$(this).find('.date').text(blogdatestr);
		
	})
	/* Fix for truncating author's name in discussion landing page*/
    var discussionAuthorLen = "12"; 
	$('.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;
			}	
		})	
	/* Suppresses display of empty footers on IE */
    $('.module .foot:empty').addClass('empty');
	$('ul.merchItems li.merch .merchDetail .merchPrice:empty').addClass('empty');
	
	$("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 */
    
    /* 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;
				}	
			})
			
			/* Blog Truncation in homepage*/	
			var blogLen = "400"; 
			$('#home .articles .description p').each(function(){
				var trunc = (this).innerHTML;	
				if (trunc.length > blogLen) {
					trunc = trunc.substring(0, blogLen);
					trunc += '<span>' + '...</span>';
					(this).innerHTML = trunc;
				}	
			})	
	/*END - Fix for truncating author name in the discussions page #698 */
	
		
    $("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
	  var fanClubCell = $(".nav_main ul li.nav-fanclub");
  	  communityNavCell.addClass('dropdown');
 	  communityNavCell.append(communitySubNav);
	  fanClubCell.addClass('dropdown');
	  fanClubCell.append(FCSubNav);
	  tourNavCell.addClass('dropdown');
 	  tourNavCell.append(toursSubNav);
    /* END: Community drop-down for top nav */
    
    /* 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 (/^Tour Archives/i).test($(this).text())
	}).parent()
  	  .addClass('nav-custom')
	  .addClass('nav-tour_archives');
	  
	  $customNavs.filter(function(){
	  return (/^Extra/i).test($(this).text())
	}).parent()
  	  .addClass('nav-custom')
	  .addClass('nav-extra')
	  .addClass('dropdown')
	  .append(extraSubNav);
	  
	  
	  $customNavs.filter(function(){
	  return (/^Fan Club$/i).test($(this).text())
	}).parent()
	  .addClass('nav-custom')	 
	  .addClass('nav-fanclub')
  	  .addClass('dropdown')
	  .append(FCSubNav);
	  
  $customNavs.filter(function(){
	  return (/^Links$/i).test($(this).text())
	}).parent()
	  .addClass('nav-custom')	 
	  .addClass('nav-Links');
/*
	  
  $('.event_listing ul.cal_events li .buy ul li.last a').filter(function(){
	  return (/^Soldout$/i).test($(this).text())
	}).attr('href','http://www.circasurvive.com/tour-dates');
  
  */
 
     
  
	 $customNavs.filter(function(){
		  return (/^Store$/i).test($(this).text())
		}).parent()
    	  .addClass('nav-custom')		  
		  .addClass('nav-store');
	 
	 $('li.nav-store a').attr("target","_blank");
	  
	 $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);
	
	 if (location.href.indexOf("/member/i/1196124/") != -1) {
	 	bioNavCell.addClass("active");
	 	$("#member1").addClass("active");
		communityNavCell.removeClass("active");
	 }
	 else if (location.href.indexOf("/member/i/1196111/") != -1) {
	 		bioNavCell.addClass("active");
	 		$("#member2").addClass("active");
			communityNavCell.removeClass("active");
	 	}
	else if (location.href.indexOf("/member/i/1196119/") != -1) {
	 			bioNavCell.addClass("active");
	 			$("#member3").addClass("active");
				communityNavCell.removeClass("active");
	 		}
	 else if (location.href.indexOf("/member/i/1196122/") != -1) {
	 				bioNavCell.addClass("active");
	 				$("#member4").addClass("active");
					communityNavCell.removeClass("active");
	 			}
	else if (location.href.indexOf("/member/i/1196129/") != -1) {
	 					bioNavCell.addClass("active");
	 					$("#member5").addClass("active");
						communityNavCell.removeClass("active");
	 				}
	 else if (location.href.indexOf("/member/") != -1) {
	 						if (!(location.href.indexOf("/category/member/") != -1)) {
	 							communityNavCell.addClass("active");
	 							$("#memberNav").addClass("active");
	 						}
	 					}
	else if (location.href.indexOf("/group/creature-club/") != -1) {
		fanClubCell.addClass("active");					
	}
	
	

	
	
	 	 
	/* END: Bio drop-down for top nav */
	
	/* END: Custom drop-downs for top nav */
	
	/* ********** Home Page SS3 *********************** */
 	var audiohead=$('<div class="head"><h3>Audio</h3></div>')
	
 	$("#song_playlist-327540 .content").prepend(audiohead);
	/* 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 storeNavCell= $(".nav_main ul li.nav-store"); 
	var tourArchivesCell= $(".nav_main ul li.nav-tour_archives"); 
	
	storeNavCell.addClass('dropdown');
    storeNavCell.append(storeSubNav);
	
    /*Hover event handler for all drop-downs in top nav */
    $(".dropdown").hover(
		function(){$(".flyoutMenu", this).show();}, 
		function(){$(".flyoutMenu", this).hide();}
	);
    

	$(".ukDropdown").hover(
		function(){$(".ukFlyoutMenu", this).show();}, 
		function(){$(".ukFlyoutMenu", this).hide();}
	);
  
	if (location.href.indexOf("/event/") != -1) {
        tourArchivesCell.addClass("active");        
    }
    if (location.href.indexOf("/forums/") != -1) {
        communityNavCell.addClass("active");
        $("#discussionsNav").addClass("active");
    }
    if (location.href.indexOf("/ringtones/") != -1) {
        storeNavCell.addClass("active");
        $("#ringtonesNav").addClass("active");
    }
	
		
	 if (location.href.indexOf("/community_landing/") != -1) {
        communityNavCell.addClass("active");
        $("#communityHomeNav").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");
    }	
    /* ********** ad module code ********* */
	$('#cse').parent(".description").parent(".body").siblings(".head").addClass("displayNone");				
	$('#cse').parent(".description").parent(".body").siblings(".foot").addClass("displayNone");				
    /* ********** 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':'20px'});				
	$('#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");
	  $('#html-1318718 .foot').removeClass("empty");  
	  $('#html-791919 .foot').removeClass("empty"); 
	  $('.grid_5 #rss_in-1332879.rss_in .foot').removeClass("empty"); 
	  
	  
	/* 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 + "px");
            discussionImageElement.css("width", "200px");
        }        
    }    
    
    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+ "px");
            discussionImageElement.css("width", "200px");
        }
        
    }
	
	// 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");
	
	$errmsg = $('.reset_password .module .content .body');
    $errmsg.insertBefore('#errorMsg');
    
    //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*/
	
	 if ($('.blog_listing .module .content .head .title .nav_meta ul').length) {
		if ($('.blog_listing .module .content .head .title .nav_meta ul li.more a').attr('href') == "/blog/new/") {
			$('.blog_listing .module .content .head .title .nav_meta ul li.more').addClass('new');
			$('.blog_listing .module .content .head .title .nav_meta ul li.more').removeClass('more');
		}
		else {
			postNewBlog = $('<li class="new"><a href="/blog/new/">Post A New Blog</a></li>');
			$('.blog_listing .module .content .head .title .nav_meta ul').prepend(postNewBlog);
		}
	}
	
	if ($('.blog_listing .module .content .foot .nav_meta ul').length) {
		if ($('.blog_listing .module .content .foot .nav_meta ul li.more a').attr('href') == "/blog/new/") {
			$('.blog_listing .module .content .foot .nav_meta ul li.more').addClass('new');
			$('.blog_listing .module .content .foot .nav_meta ul li.more').removeClass('more');
		}
		else {
			postNewBlog = $('<li class="new"><a href="/blog/new/">Post A New Blog</a></li>');
			$('.blog_listing .module .content .foot .nav_meta ul').prepend(postNewBlog);
		}
	}
	
	postNewBlog = $('<div class="nav_meta"><ul><li class="new"><a href="/blog/new/">Post A New Blog</a></li></ul></div>');
	$('.blog_entry .module .content .head').append(postNewBlog);
	
	postNewBlog = $('<li class="new"><a href="/blog/new/">Post A New Blog</a></li>');
	$('.blog_entry .module .content .foot .nav_blog ul').prepend(postNewBlog);
	
	viewAllBlogs = $('<div class="newMore"><div class="nav_meta"><ul><li class="postnewBlog"><a href="/news/new">POST A NEW BLOG</a></li><li class="more"><a href="/news/">READ ALL NEWS</a></li></ul></div></div>');
	
	$('#html-1318718.html .module .content .foot').append(viewAllBlogs);
	
  

	tourDateViewMore = $('<div class="nav_meta"><ul><li class="more"><a href="/tour-dates">VIEW MORE</a></li></ul></div>');
	$('#rss_in-1600422.rss_in .module .content .foot').append(tourDateViewMore);

	    
	$('#twitterContainer').parent(".description").parent(".body").siblings(".foot").removeClass("empty");
	$tweetmorelink = $('#twitterContainer').siblings(".twitterFootMeta"); 
    var twitterFoot = $('#twitterContainer').parent(".description").parent(".body").siblings(".foot");
	$tweetmorelink.appendTo(twitterFoot);

/* Home page grid_3 module titles*/
$('#home .grid_3 #video_thumbnail-327534 .module .content .head').insertBefore('#home #video_thumbnail-327534 .module');

$('#home .grid_3 #photo_thumbnail-1318719 .module .content .head').insertBefore('#home #photo_thumbnail-1318719 .module');

$('#home .grid_3 .title.comment').insertBefore('#home #comments-294527 .module .content .body fieldset');

$('#home .grid_3 #html-327531 .module .content .head').insertBefore('#home #html-327531 .module');

$('#home .grid_3 #blog_listing-2901128 .module .content .head').insertBefore('#home #blog_listing-2901128 .module');


	
	//Badges implementation
	$(".badges ul").each(function(){	
		if ($(this).find("li").length > 0) {	
			$(this).html('<li class="badge"><a class="badgeImageReplace" href="/group/creature-club/"></a></li>');
		}
	});
	
	/*--------------facebook connect in profile page--------------------------------------------------*/				

$('#edit_profile-294536.edit_profile .module .content .body').prepend($('#html-3139024.html .module .content .body .description'));

/*-------------------------------------------------------------------------------------------------*/	

	
});

function populateInviteData(iTitle,iLocation,iDate) {

		//all the possible fields in this json object
		json = {		
		widget_version:"2.0",
		widget_skin:"button_square_small",
		partner_id:"149", 			//Do not change this id. This is unique
		title:iTitle,
		location:iLocation,
		date:iDate
		}

		//replace any current invite data using the json object
	    	inviteButtons[0].setOptions(json);

		//refresh the html to reflect new data
	    	inviteButtons[0].refresh();
			
	   // launch the invite
	   loadInviteInModal(0);
}

function eoscInit(){
	
	
$('.module .foot .nav_page').each(function(){
if($(this).find('ul').length == 0)
{
$(this).addClass('empty');
}
});

$('.module .foot').each(function(){
if($(this).find('div').length == 0)
{
$(this).addClass('empty');
}
});

$('#member_listing-666354 .module').each(function(){
if($(this).find('.foot .nav_meta ul li').length == 0)
{
$(this).find('.body').addClass('joinedMember');
}
});

	/* for adding wrapper to blog - Starts */
$('#blog_listing-294510.blog_listing .module .articles li.article').each(function(){
var blogContent = $(this).html();
var blogContentWrapper = "<div class= 'blogWrapper'>" + $(this).html() + "</div>";
$(this).html(blogContentWrapper);
});
/* for adding wrapper to blog - Ends */
	
	var memberAuthorLen = "10"; 
$('.members li.member .txt a').each(function(){
		var trunc = (this).innerHTML;	
		if (trunc.length > memberAuthorLen) {
			trunc = trunc.substring(0, memberAuthorLen);
			trunc += '<span>' + '...</span>';
			(this).innerHTML = trunc;
		}	
	})

	$('.articles li.article').each(function(){			
			var plusone = document.createElement("g:plusone");
			var tumblr_link_url = "http://circasurvive.wmg.ciscoeos.com" + $(this).find(".title a").attr("href");
			plusone.setAttribute("href", tumblr_link_url);
			plusone.setAttribute("size", "medium");
			$(this).find('.category').before('<div class="gPlus"></div>');
			$(this).find('.gPlus').append(plusone);
	});
	
	
	if (($('body').attr('id') == "blog_detail")) {
	$('#blog_entry-294508 .category').before('<div class="gPlus"><g:plusone size="medium"></g:plusone></div>');
	}

	
			// plus one button implementation - Starts 
		window.___gcfg = {
			lang: 'en-US'
		};
		(function(){
			var po = document.createElement('script');
			po.type = 'text/javascript';
			po.async = true;
			po.src = 'https://apis.google.com/js/plusone.js';
			var s = document.getElementsByTagName('script')[0];
			s.parentNode.insertBefore(po, s);
		})();
		
		// plus one button implementation - Ends 
	
		/*comments blog */
	$.each($('.activity .comment'), function(index, value) { 
	var newCommentNo = $('.activity .comment').eq(index).html();
	newCommentNo = newCommentNo.replace("Comments", "").replace("(", "").replace(")", "");
	newCommentNo = newCommentNo.replace("Comment", "");
	$('.activity .comment').eq(index).html(newCommentNo); 

	});

			
	/*Highlighting creature club category*/
	$('li .txt .category a').each(function(){
		var comment1 = $(this).html();		
		if(comment1=="Creature Club"){
		$(this).addClass("colour_change");
		var sample=$(this).parents('.txt').find('.author a').html();
		$(this).parents('.txt').find('.author a').addClass("colour_change");
		}
	});
	
	
	
	// Appending Anchor tag to event module image
	if ($("html body").attr("id") == "event") {	
	var ahcHrefVal;	
		$('#event_listing-1893249.event_listing ul.cal_events li.cal_event.list').each(function(){	
			var ahcHrefVal="";	 
			var ancNew="";
			var spanVal=$(this).find("div.img.noborder");
			var spanValHtml=spanVal.html();			
			ahcHrefVal=	$(this).find(".txt .date a").attr("href")
			ancNew="<a class='newAnc' href='"+ahcHrefVal+"'>";
			ancNew= ancNew + spanValHtml + "</a>";
			$(this).find("div.img.noborder").html(ancNew);
		})	
	} 

$('#event_listing-1893249.event_listing ul.cal_events li .txt').each(function() {
			    if($(this).find('div.buy').length) {
				var eventsBuy = $(this).find('div.buy').html();
	            $($(this).find('div.buy')).remove();
	 			var divBuy = '<div class="buy">' + eventsBuy + '</div> '
				$($(this).find('div.date')).prepend(divBuy);
				}
			
				});				
/* for events landing page - Ends */


	
	/* Tour Pages Implementation - Pagination Issue */
	$('#event_listing-1893249.event_listing ul.cal_events li.cal_event').each(function(){
		var eventPath=  $(this).find('.txt .date h4 a').attr('href');
		eventPath=eventPath+"?show=past-shows";
		var viewEveMedia="<div class='viewMedia'><a class='viewpix' href='"+eventPath+""+"'>view photos and videos</a></div>"
		$(this).append(viewEveMedia);			
	});
	
	/* Members who went for past shows */
		$('#event_listing-1893249.event_listing ul.cal_events li.cal_event').each(function(){
		var memberGoing="Fans Went&nbsp;";
		var eventPath=  $(this).find('.txt .date h4 a').attr('href');
		eventPath=eventPath+"?show=past-shows";
		$(this).find('.txt .date h4 a').attr('href',eventPath);
		var venuetext= $(this).find('.event_location .venue').text();
		venueanchor='<a href="'+eventPath+'">'+venuetext+'</a>';
		var venuecity=$(this).find('.event_location .location .city').text();	
		venuecityanchor='<a href="'+eventPath+'">'+venuecity+'</a>';	
		var venuestate=$(this).find('.event_location .location .region').text();	
		venuestateanchor='<a href="'+eventPath+'">'+venuestate+'</a>';
		$(this).find('.event_location .venue').html(venueanchor);
		$(this).find('.event_location .city').html(venuecityanchor);
		$(this).find('.event_location .region').html(venuestateanchor);
		var attendeeCount= $(this).find('.attendee_count').html();
		$(this).find('.attendee_count').remove();
		if(attendeeCount!=null && attendeeCount!=""){
			attendeeCount=attendeeCount.substring((attendeeCount.lastIndexOf(":")+1),attendeeCount.length).trim();
			attendeeCount="("+ attendeeCount +")";
			if(attendeeCount==1){
				memberGoing="Fan Went&nbsp;"
			}
			var member_det='<div class="member_details"><div class="membrGoing"><a href="'+eventPath+'">'+ memberGoing + attendeeCount +'</a></div></div><div class="moreinfo"><a class="viewmoreinfo" href="'+eventPath+'">More info</a></div>';
			$(this).find('.txt').append(member_det);
			
		}else{
			var member_det='<div class="moreinfo" style="margin-left:0px"><a class="viewmoreinfo" href="'+eventPath+'">More info</a></div>';
			$(this).find('.txt').append(member_det);
		}
		
		
	});	
	
	
	// Appending Anchor tag to event module image
	if ($("html body").attr("id") == "event") {	
	var ahcHrefVal;	
		$('#event_listing-1332878.event_listing ul.cal_events li.cal_event.list').each(function(){	
			var ahcHrefVal="";	 
			var ancNew="";
			var spanVal=$(this).find("div.img.noborder");
			var spanValHtml=spanVal.html();			
			ahcHrefVal=	$(this).find(".txt .date a").attr("href")
			ancNew="<a class='newAnc' href='"+ahcHrefVal+"'>";
			ancNew= ancNew + spanValHtml + "</a>";
			$(this).find("div.img.noborder").html(ancNew);
		})	
	}
	
		/* for events landing page - Starts */
$('#event_listing-1332878.event_listing ul.cal_events li .txt').each(function() {
			    if($(this).find('div.buy').length) {
				var eventsBuy = $(this).find('div.buy').html();
	            $($(this).find('div.buy')).remove();
	 			var divBuy = '<div class="buy">' + eventsBuy + '</div> '
				$($(this).find('div.date')).prepend(divBuy);
				}
			
				});
	/*Member going for upcoming shows */
		var memberGoing="Fans Going&nbsp;";
	$('#event_listing-1332878.event_listing ul.cal_events li.cal_event').each(function(){
		var attendeeCount= $(this).find('.attendee_count').html();
		var eventPath=  $(this).find('.txt .date h4 a').attr('href');
		var venuetext= $(this).find('.event_location .venue').text();
		venueanchor='<a href="'+eventPath+'">'+venuetext+'</a>';
		var venuecity=$(this).find('.event_location .location .city').text();	
		venuecityanchor='<a href="'+eventPath+'">'+venuecity+'</a>';	
		var venuestate=$(this).find('.event_location .location .region').text();	
		venuestateanchor='<a href="'+eventPath+'">'+venuestate+'</a>';
		$(this).find('.event_location .venue').html(venueanchor);
		$(this).find('.event_location .city').html(venuecityanchor);
		$(this).find('.event_location .region').html(venuestateanchor);
		$(this).find('.attendee_count').remove()
		if(attendeeCount!=null && attendeeCount!=""){
			attendeeCount=attendeeCount.substring((attendeeCount.lastIndexOf(":")+1),attendeeCount.length).trim();
			
			attendeeCount="("+ attendeeCount +")";
			if(attendeeCount==1){
				memberGoing="Fan Going&nbsp;"
			}
			var member_det='<div class="member_details"><div class="membrGoing"><a href="'+eventPath+'">'+ memberGoing + attendeeCount +'</a></div></div><div class="moreinfo"><a class="viewmoreinfo" href="'+eventPath+'">More info</a></div>';
			$(this).find('.txt').append(member_det);
			
		}else{
			var member_det='<div class="moreinfo" style="margin-left:0px;"><a class="viewmoreinfo" href="'+eventPath+'">More info</a></div>';
			$(this).find('.txt').append(member_det);
			$(this).find('.txt').append('<div class="clear"></div>');
		}
		
		
	});
	
	
	if ( $('body#event_detail').length > 0) {
		var eventdate = $('#event-707479.event .module .upcoming .body .cal_event div.txt .date .val').text();
		eventdateobj = new Date(eventdate);
		currentDate = new Date();
		offset = eventdateobj.getTime() - currentDate.getTime();
		offsetdays= (offset/ 86400000);
		if (offsetdays < -1) {
			var detailPageUrl = window.location.href;
			var successMsgevent= $('#successMsg').text();
			detailPageUrl = detailPageUrl + "?show=past-shows"+"?message="+successMsgevent;
			
			
		}
	}
	
	
	//Badges implementation
	$(".badges ul").each(function(){	
		if ($(this).find("li").length > 0) {	
			$(this).html('<li class="badge"><a class="badgeImageReplace" href="/group/creature-club/"></a></li>');
		}
	});
	
	
	if ($("body#group_detail_4089").length != 0) {
		$("body#group_detail_4089 .module .videos li .txt .title h4").addClass("removeSifr");		
		$("body#group_detail_4089 .articles li.category_39286 .title h4").addClass("removeSifr");
		$("body#group_detail_4089 .photos li.category_24630 .txt .title h4").addClass("removeSifr");
	}else{
		$("body#blog .blog_listing .module .articles li.category_39286 .title h4").addClass("removeSifr");	
	}
	
	
	
	
	
		
	//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(); 		
	
	/*reset password screen*/	
	$('.reset_password .module .content .body').insertBefore('#errorMsg');
	
	//for page headers and module headers

	

	/* Tour Pages Implementation - Pagination Issue - End */
	
	/* Tour Dates - Date Formatting - Starts*/
    $('.event_listing ul.cal_events li.cal_event').each(function(){
		if($(this).find('.eventdate').length == 0){
        var date1 = $(this).find('.txt .date h4 a');
        var date2 = date1.text().split("\,");
        var montharray = date2[0];
        var montharray = montharray.split(" ");
        var tmonth = montharray[0];
        var temonth = tmonth.slice(0, 3);
        if ((temonth.toLowerCase()) == 'sep') {
            temonth = temonth + 't';
        }
        var tdate = montharray[1];
        var eventPath = $(this).find('.txt .date h4 a').attr('href');
        var eventdates = '<div class="eventdate"><a><ul><li class="emonth">' + temonth + '</li><li class="edate">' + tdate + '</li><li class="eyear">' + date2[1] + '</li></ul></a></div>';
        $(eventdates).insertBefore($(this).find('.txt .date'));
        $(this).find('.txt .eventdate a').attr('href', eventPath);
		}
    });
	/* Tour Dates - Date Formatting - Ends*/

}

   $.urlParam = function(name){
        var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
        if (results == null) {
            return 0;
        }
        else {
            return results[1];
        }
    }	
	
	


