/* 
 * 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 blogTwitterBlurbText = "<br><br><br> Follow this on Twitter using the tag #";

	
$(document).ready(function(){
	
	/* ******************** Tour page modifications starts ******************** */
	
				
	var clearDivEle='<div class="clear"></div>';
	var horzDivdr='<div class="hd"></div>';
	var currentPageShowUrl=$.urlParam("show");
	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);
  	
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-711067.event').each(function(){
			$(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 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 Tour Archive');
			$(this).find('.nav_meta ul li.more a').attr("href","/event/?show=archive");
			$(eventDate).insertBefore('#event-711067.event .cal_event div.txt .location');	
			
			$(this).find('.cal_event').append(descEle);
			$(this).find('.cal_event').append(clearDivEle);	
			$(clearDivEle).insertAfter('#event-711067.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-711067.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='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');
			$(eventDate).insertBefore('#event-711067.event .cal_event div.txt .location');	
					
			$(this).find('.cal_event').append(mapEle);
			$(clearDivEle).insertAfter('#event-711067.event .cal_event div.txt');
			$(buyLnk).insertAfter('#event-711067.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 .availability').remove();
			$(this).find('.foot .nav_meta ul li.buy').remove();
		});		
	}
}  	
 var venuelocationupload=$('#event-711067.event .module .upcoming .body .cal_event div.txt .venue .val').text();
 if (venuelocationupload.length > 0) {
 	var uploadhref = $('#photo_thumbnail-3016741 .head .nav_meta ul li.new a').attr("href");
 	uploadhref = uploadhref + "&venuenameinfo=" + venuelocationupload;
 	$('#photo_thumbnail-3016741 .head .nav_meta ul li.new a').attr("href", uploadhref);
 	var uploadhref = $('#video_thumbnail-3016742 .head .nav_meta ul li.new a').attr("href");
 	uploadhref = uploadhref + "&venuenameinfo=" + venuelocationupload;
 	$('#video_thumbnail-3016742 .head .nav_meta ul li.new a').attr("href", uploadhref);
 }
 if($('body#upload').length >0){
 	var venuenameinfo=$.urlParam("venuenameinfo");
	if(venuenameinfo.length >0){
		writeToConsole("venuenameinfo"+venuenameinfo);
		$('.media_upload .module .content .head h3 span').text(" - "+decodeURI(venuenameinfo));
	}
 }

	var memGoing2="Fans Going ";
	$('#event_listing-3028772.event_listing ul.cal_events li.cal_event').each(function(){
		var attendeeCount= $(this).find('.attendee_count').html();
		var buyBtn= $(this).find('.buy');
		var eventPath=  $(this).find('.txt .date h4 a').attr('href');

		
		$(this).find('.buy').remove();
		$(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+'" >'+ memGoing2 + attendeeCount +'</a></div></div>';
			$(this).find('.txt').append(member_det);			
		}
		$(this).find('.txt').append(buyBtn);// Just changed the position		
	});	
	
	var memGoing3="Fans Going ";
	$("#event_listing-3063503.event_listing ul.cal_events li.cal_event").each(function(){
		var attendeeCount= $(this).find('.attendee_count').html();
		var buyBtn= $(this).find('.buy');
		var eventPath=  $(this).find('.txt .date h4 a').attr('href');
		
		$(this).find('.buy').remove();
		if (attendeeCount!=null && attendeeCount!=""){
			$(this).find('.attendee_count').remove();
			attendeeCount=attendeeCount.substring((attendeeCount.lastIndexOf(":")+1),attendeeCount.length).trim();
			attendeeCount="("+ attendeeCount +")";
			
			var member_det='<div class="attendee_count"><a href="'+eventPath+'" >'+ memGoing3 + attendeeCount +'</a></div>';
			$(this).find('.txt').append(member_det);
		}
		$(this).find('.txt').append(buyBtn);
	});
	
	if($('body#event').length >0 || $('body#event_detail').length >0 ){	
		var currentpageshow=$.urlParam("show");
		
		if ($('body').attr('id') == 'event') {
			if (currentpageshow == "archive") {
				$('#event_listing-3020097').css("display", "block");
				$('#event_listing-711064').css("display", "none");
				$('#event_listing-3020379').css("display", "none");
				$('#event_listing-3028772').css("display", "block");
			}
			else {
				$('#event_listing-3020097').css("display", "none");
				$('#event_listing-711064').css("display", "block");
				$('#event_listing-3020379').css("display", "block");
				$('#event_listing-3020379 .nav_meta ul li.more a').attr('href', '/event/?show=archive');
				$('#event_listing-711064 .nav_meta ul li.more a').attr('href', '/event/?show=archive');
				$('#event_listing-3028772').css("display", "none");
			}
		}

		if ($('body').attr('id') == 'event_detail') {
			if (currentpageshow == "archive" || offsetdays < -1 ) {
				
				if($('#event-711067 .tools .input.going a').length >0){
				$('#event-711067 .tools .input.going a').text("I Went");
				}
		
				$('#photo_thumbnail-3016741').css("display", "block");
				$('#video_thumbnail-3016742').css("display", "block");		
				$('#event_listing-3020379').css("display", "block");
				$('#event_listing-3020379 .nav_meta ul li.more a').attr('href', '/event/?show=archive');
				$('#event_listing-3028772').css("display", "none");
			}
			else {
				if($('#event-711067 .tools .input.going a').length >0){
				$('#event-711067 .tools .input.going a').text("I am Going");
				}
				$("#event-711067 .module .body .cal_event .rating").css("display","none");
				$('#photo_thumbnail-3016741').css("display", "none");
				$('#video_thumbnail-3016742').css("display", "none");
				$('#event_listing-3020379').css("display", "none");
				$('#event_listing-3028772').css("display", "block");
			}
		}
	}
	
	var eventHead='<div class="uploadMedia"><a class="uploadLink" href="/event/?show=archive" title="Upload now!"></a></div>';	
	$("#event .grid_9 .event_listing .module .content .head").append(eventHead);
	
	$('.event_listing ul.cal_events li.cal_event .buy ul li' ).each(function(){
		var viplink= $(this).find('a').text();
			if(viplink.indexOf("VIP")!= -1 || viplink.indexOf("VIP Access")!= -1){
				$(this).addClass("vipLink");
			}
	});
	
	/*
	var memberGoing="Fans Going ";
	$('#event_listing-711064.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');
		
		$(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+'">'+ 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"><a class="viewmoreinfo" href="'+eventPath+'">More info</a></div>';
			$(this).find('.txt').append(member_det);
		}
		
	});*/ 
	
	/*
	$('#event_listing-3020097.event_listing ul.cal_events li.cal_event').each(function(){
		var memberGoing="Fans Went";
		var eventPath=  $(this).find('.txt .date h4 a').attr('href');
		eventPath=eventPath+"?show=archive";
		$(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();
			attendeeCount="("+ attendeeCount +")";
			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"><a class="viewmoreinfo" href="'+eventPath+'">More info</a></div>';
			$(this).find('.txt').append(member_det);
		}
		
	});*/
	
	var fansWent=" Fans Went";
		$('#event_listing-3020379.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');
			eventPath=eventPath+"?show=archive";
			$(this).find('.attendee_count').remove();
			var venueact=$(this).children('.txt').children('.venue');
			$(this).children('.txt').append(venueact);
			if(attendeeCount!=null && attendeeCount!=""){
				attendeeCount=attendeeCount.substring((attendeeCount.lastIndexOf(":")+1),attendeeCount.length).trim();
				if(attendeeCount=='0' || attendeeCount=="1"){fansWent=" Fan Went";}
				var member_det='<div class="fan_details"><div class="fanWent"><a href="'+eventPath+'">'+ attendeeCount + fansWent +'</a></div></div>';
				$(this).find('.txt').append(member_det);			
			}
			
			var eventPath=  $(this).find('.txt .date h4 a').attr('href');
			eventPath=eventPath+"?show=archive";
			$(this).find('.txt .date h4 a').attr('href',eventPath);	
			var viewEveMedia="<div class='viewMedia'><a class='viewpix' href='"+eventPath+"#photo_thumbnail-3016741"+"'>viewMedia</a></div>"; 
			$(this).append(viewEveMedia);
			
	});
		
	/*$('#event_listing-3020097.event_listing ul.cal_events li.cal_event').each(function(){
		var eventPath=  $(this).find('.txt .date h4 a').attr('href');
		var viewEveMedia="<div class='viewMedia'><a class='viewpix' href='"+eventPath+"#photo_thumbnail-3016741"+"'>viewMedia</a></div>"
		$(this).append(viewEveMedia);			
	});*/
	
	
	$('#event .grid_5 .event_listing .head .nav_meta ul li.more a ').each(function(){
		$(this).html("VIEW MORE");
	});
	
	$('#event_detail .grid_5 .event_listing .head .nav_meta ul li.more a ').each(function(){
		$(this).html("VIEW MORE");
	});
	

	$('#event-711067.event .module .upcoming .body .cal_event div.buyLink ul li' ).each(function(){
		var viplink= $(this).find('a').text();
			if(viplink.indexOf("VIP")!= -1){
				$(this).addClass("vipLink");
			}
	});
	
	
	/* ******************** Tour page modifications ends ******************** */	
	
	
	
	/* UnComment this when you need the thickbox on the home page */
	
	

	var lightboxUrl = "/lightbox-home/?KeepThis=true&TB_iframe=true&height=515&width=787&modal=true";
	if($("body#home").length > 0){
		if (parent.$("#TB_window").html() == null) {
			//tb_show(null,lightboxUrl,false);
		}  
	}
	
    $('#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;
	})		


/* 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 */
	$('#blog_listing-714183.blog_listing .module .content .head .nav_meta .more a').href = "/news/";
    $('.module .foot:empty').addClass('empty');
	$('#rss_in-367007 .module .content .foot').removeClass('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;
    });
	
	/* add popup onClick handler for audio player links For pre-order page*/
    $("#player_preorder center a").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;
    });
	
	/* New tour page functionality - Starts */
	
    $("#event_listing-3011760.event_listing .nav_meta ul li.more a").removeAttr("href");
	$("#event_listing-3011762.event_listing .nav_meta ul li.more a").removeAttr("href");
	
	$("#event_listing-3011762.event_listing .nav_meta ul li.more a").click(function(){
		$("#event_listing-3011759.event_listing").css("display","none");
		$("#event_listing-3011762.event_listing").css("display","none");
		$("#event_listing-3011761.event_listing").css("display","block");
		$("#event_listing-3011760.event_listing").css("display","block");		
	});
	
	$("#event_listing-3011760.event_listing .nav_meta ul li.more a").click(function(){
		$("#event_listing-3011759.event_listing").css("display","block");
		$("#event_listing-3011762.event_listing").css("display","block");
		$("#event_listing-3011761.event_listing").css("display","none");
		$("#event_listing-3011760.event_listing").css("display","none");		
	});
	
	var tourmediadiv='<div class="tourmedia"><a>Upload</a></div>';
	$("#event_listing-3011759.event_listing .module .content .head .title").append(tourmediadiv);
	$("#event_listing-3011761.event_listing .module .content .head .title").append(tourmediadiv);
	
	var backtoupcoming='<div class="back"><a>Back to Upcoming</a></div>';
	$("#event_listing-3011761.event_listing .module .content .head .title").prepend(backtoupcoming);
	
	/* New tour page functionality - Ends */
	
    /* Make store top nav link open in a new window */
    $('.nav_main ul li.custom a[href*=amazon.com]').attr("rel", "external");
    
	if(typeof loadSubLinks =='function'){
		loadSubLinks();
	}
	
	$("#rss_in-699306 .module .content .head h3").after('<a class="viewmore"  href="/tour/">View More</a>');
	
  	$("#member_listing-340499.member_listing .module .content .head h3").after('<a href="/member/">View All</a>');
	
   
    var $customNavs = $('.nav_main ul li.nav-custom a');
	
	$customNavs.filter(function(){
	  return (/Music/i).test($(this).text())
	}).parent()
	  .addClass('nav-music');
	  
	$customNavs.filter(function(){
	  return (/Twitter/i).test($(this).text())
	}).parent()
	  .addClass('nav-twitter');
	  
	  	$('.nav_main ul li.nav-custom a').filter(function(){
  			 return (/^Store$/i).test($(this).text())
			}).parent()
		   .addClass('dropdown')  
		   .addClass('nav-store');
		   
	/* END: Store drop-down for top nav */
	
	/* To add the odd class to achieve alternate colouring for the modules */	
	alternateColouringListing();	
			
   
    /* 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 eventNavCell = $(".nav_main ul li.nav-event");
	 eventNavCell.addClass('dropdown');
	eventNavCell.append(eventSubNav);

	
    
    /* START: Store drop-down for top nav */
    //Define XHTML source for the community subnav inn the variable below
	var storeNavCell=$(".nav_main ul li.nav-store");	
	storeNavCell.addClass('dropdown');
	storeNavCell.append(storeSubNav); 
    /* END: Store drop-down for top nav */
    
  	var twitterFollow= $('<div class="nav_meta"><ul><li class="follow3oh3"><a href="http://twitter.com/3oh3" target="_new">Follow 3Oh!3</a></li><li class="followNat"><a href="http://twitter.com/NAT3OH3" target="_new">Follow Nat</a></li><li class="followSean"><a href="http://twitter.com/kidquizine" target="_new">Follow Sean</a></li></ul></div>');
	$('#html-659951.html .module .content .head').append(twitterFollow);
    $("a[href^=http://starterfanclub1.wmg.ciscoeos.com]").parent(".custom").addClass("Fanclub");
    
    /* END: FanClub drop-down for top nav */
	
		
    /*Hover event handler for all drop-downs in top nav */
    $(".dropdown").hover(function(){
        $(".flyoutMenu", this).show();
    }, function(){
        $(".flyoutMenu", this).hide();
    });
    
    /* Flag subnav pages in parent top nav li */
    if (location.href.indexOf("/member/") != -1) {
    if(!(location.href.indexOf("/category/member/") != -1)){ 
         communityNavCell.addClass("active");
         $("#memberNav").addClass("active");
     }  
     }
    if (location.href.indexOf("/forums/") != -1) {
        communityNavCell.addClass("active");
        $("#discussionsNav").addClass("active");
    }
	if (location.href.indexOf("/community_landing/") != -1) {
			communityNavCell.addClass("active");
			$("#communityHomeNav").addClass("active");
		}
    if (location.href.indexOf("/ringtones/") != -1) {
        storeNavCell.addClass("active");
        $("#ringtonesNav").addClass("active");
    }
	
	 if (location.href.indexOf("/twitter/") != -1) {
        $(".nav-twitter").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*/
	 if (location.href.indexOf("/spain/") != -1) {
        globalNavCell.addClass("active");
        $("#spainNav").addClass("active");
    }
	
	 if (location.href.indexOf("/united-kingdom/") != -1) {
        globalNavCell.addClass("active");
        $("#ukNav").addClass("active");
    }
	
	 if (location.href.indexOf("/germany/") != -1) {
        globalNavCell.addClass("active");
        $("#germanyNav").addClass("active");
    }
	
    
    var photoNavCell = $(".nav_main ul li.photo");
    if (location.href.indexOf("/cellstream/") != -1) {
        photoNavCell.addClass("active");
    }
    
    if (location.href.indexOf("/album/") != -1) {
        $("a[href^=/album/]").parent(".nav-custom").addClass("active");
        
    }
    
    if (location.href.indexOf("/music/") != -1) {
        $("a[href^=/album/]").parent(".nav-custom").addClass("active");
    }	
    
    /* START: Merch module drop-downs */
    $(".ArtistStore").hover(function(){
        $(".flyoutMenu", this).show();
    }, function(){
        $(".flyoutMenu", this).hide();
    });
    
    $(".mainAlbumBuyDrop").hover(function(){
        $("#subMainAlbumBuy", this).show();
    }, function(){
        $("#subMainAlbumBuy", this).hide();
    });
    
    $(".productLeftBuyDrop").hover(function(){
        $("#subLeftAlbumBuy", this).show();
    }, function(){
        $("#subLeftAlbumBuy", this).hide();
    });
    
    $(".productRightBuyDrop").hover(function(){
        $("#subRightAlbumBuy", this).show();
    }, function(){
        $("#subRightAlbumBuy", this).hide();
    });
    
    $(".ArtistStoreBottom").hover(function(){
        $(".flyoutMenuFooter", this).show();
    }, function(){
        $(".flyoutMenuFooter", 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");
	
	/* Blog and blog detail external links*/
	$('.blog_entry .article .description p a').attr("target", "_new");
	$('.blog_listing .articles .description p a').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);
        }
        
    }
    
    //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");
	
	
	$("#html-327531 ul.mercList li:first-child").addClass("firstChild");
	$("#html-327531 ul.mercList li:last-child").addClass("lastChild");
	$("#blog_listing-294512.blog_listing .module .content li.article:last-child").addClass("emptybtmborder");	
	$("#list_album-383753.list_album .module .content .body ul.albums li.xs:last-child").addClass("emptybtmborder");
	$("#list_album-407371.list_album .module .content .body ul.albums li:last-child").addClass("emptybtmborder");

	$("	.nav_main ul.flyoutMenu li:first-child").addClass("firstChild");
	$("	.nav_main ul.flyoutMenu li:last-child").addClass("lastChild");
	$("#about_me-294479.about_me .body .about").addClass("clearfix");

	 // Functionality for add new blogs.
    if ($("body").attr("id") == "add_new_blog") {
        blogCookieText = $.cookie("blog_body");
        if (blogCookieText) {
            blogTwitterBlurbText = blogCookieText + blogTwitterBlurbText;
        }
        $.cookie("blog_body", blogTwitterBlurbText, {
            path: "/"
        });
    }
	
    
    //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>');
				}
			}
			j++;		
		});	
		
	/*End - code which obfuscates email addresses #2420*/		
    
});

   $.urlParam = function(name){
        var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
        if (results == null) {
            return 0;
        }
        else {
            return results[1];
        }
    }
	
	function eoscInit(){
	alternateColouringListing();
	
	$('#event_listing-711064.event_listing ul.cal_events li.cal_event').each(function(){
		writeToConsole("event_listing-711064"+$(this).find('.moreinfo').html())
		if($(this).find('.moreinfo').html()!=null){
		}
		else{
			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+'">'+ 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"><a class="viewmoreinfo" href="'+eventPath+'">More info</a></div>';
				$(this).find('.txt').append(member_det);
			}
		}	
	});
	
	$('#event_listing-3020097.event_listing ul.cal_events li.cal_event').each(function(){
		if ($(this).find('.moreinfo').html() != null) {
		}
		else {
			var memberGoing = "Fans Went";
			var eventPath = $(this).find('.txt .date h4 a').attr('href');
			eventPath = eventPath + "?show=archive";
			$(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();
				attendeeCount = "(" + attendeeCount + ")";
				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"><a class="viewmoreinfo" href="' + eventPath + '">More info</a></div>';
				$(this).find('.txt').append(member_det);
			}
		}
	});
	
	$('#event_listing-3020097.event_listing ul.cal_events li.cal_event').each(function(){
		var eventPath=  $(this).find('.txt .date h4 a').attr('href');
		var viewEveMedia="<div class='viewMedia'><a class='viewpix' href='"+eventPath+"#photo_thumbnail-3016741"+"'>viewMedia</a></div>"
		$(this).append(viewEveMedia);			
	});
	
	if ($('body#event').length > 0 || $('body#event_detail').length > 0) {
		var eventdate = $('#event-711067.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;
			 writeToConsole(detailPageUrl);
			var successMsgevent= $('#successMsg').text();
			detailPageUrl = detailPageUrl + "?show=archive"+"?message="+successMsgevent;
			//location.replace(detailPageUrl);
			 writeToConsole(detailPageUrl);
			
		}
	}
	
	$('.event_listing ul.cal_events li.cal_event .buy ul li' ).each(function(){
		var viplink= $(this).find('a').text();
			if(viplink.indexOf("VIP")!= -1 || viplink.indexOf("VIP Access")!= -1){
				$(this).addClass("vipLink");
			}
	});
	 //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();   
	       
	//for the MailingList thickbox
	sIFR.replace(gotham, {
	  selector: '#mailinglist_home #lightBoxCloseContainer h4',
	  css: [
		  	'.sIFR-root { text-transform: uppercase; color: #f9f9f9;font-size:24px; }',
		  	'.sIFR-root a {color:#92abb5; text-decoration:none}',
		  	'.sIFR-root a:hover {color:#FFFFFF}'
	  	],
	  tuneHeight: '-5',
	  wmode: 'transparent'
	});
	
	/* Real Time Sign-Up 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').unbind('click');
	$('.edit_account #accountQuestoins .buttons.input .button.submit input.submit').unbind('click');
	
	$.wmgfeature.spFeatureEditAccountAccData(".edit_account #accountData .buttons.input .button.submit input.submit", "edit_account-294534", true, arrElementIDs, "http://www.3oh3music.com/", "388144");
	$.wmgfeature.spFeatureEditAccountAccQuestions(".edit_account #accountQuestoins .buttons.input .button.submit input.submit", "edit_account-294534", true, arrElementIDs, "http://www.3oh3music.com/", "388144");	
	/* Real Time Sign-Up End */ 	
	
	$(document).ready(function(){	
	var authLength=11;
	$('.grid_5 li.comment .txt .author a').each(function(){
		var trunc = (this).innerHTML;	
		if (trunc.length > authLength) {
					$(this).attr('title',trunc);
					trunc = trunc.substring(0, authLength);
					trunc += '<span>' + '...</span>';
					(this).innerHTML = trunc;
		}		
	});	
	});

}
	
	
function alternateColouringListing(){

	$('#comments-294524 ul li:nth-child(odd)').addClass('odd');
	$('#comments-294525 ul li:nth-child(odd)').addClass('odd');
	$('#comments-294523 ul li:nth-child(odd)').addClass('odd');
	$('#comments-383752 ul li:nth-child(odd)').addClass('odd');
	$('#comments-294522 ul li:nth-child(odd)').addClass('odd');
	$('#comments-711066 ul li:nth-child(odd)').addClass('odd');
	$('#comments-294526 ul li:nth-child(odd)').addClass('odd');
	$('#comments-294527 ul li:nth-child(odd)').addClass('odd');
}


function createCookie(name, value, noOfdays) {
	var expires = "";
	if (noOfdays) {
		var date = new Date();
		date.setTime(date.getTime() + (noOfdays*24*60*60*1000));
		expires = "; expires=" + date.toGMTString();
	} 
	document.cookie = name + "=" + value + "; path=/";
}

function readCookie(name) {
	var searchString = name + "=";
	var cookies = document.cookie.split(';');
	for(var i=0;i < cookies.length;i++) {
		var cookie = jQuery.trim(cookies[i]);
		if (cookie.indexOf(searchString) == 0) {
			return cookie.substring(searchString.length, cookie.length)
		};
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}




