/* 
 * 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 prvteCont="<i class='prText'>&nbsp;&nbsp;</i>";

jQuery.fn.makeLinksExternal=function(){return this.each(function(){var a=$(this).attr("href");if(a.indexOf(location.host)==-1&&a.indexOf("/")!=0){$(this).attr("target","_blank")}})};

/* Supplant Function. Remedial JS. Thanks to Douglas Crockford. 
 * Substitues the variables in a string. The variables must be preceded by {}.
*/

if(!String.prototype.supplant){String.prototype.supplant=function(a){return this.replace(/{([^{}]*)}/g,function(d,c){var e=a[c];return typeof e==="string"||typeof e==="number"?e:d})}};

/*Templates for the Merch Module */
var merchModuleTemplate = 
		'<li class="merch small item{index}">\
				<div class="merchImg"><a href="{omnitureLinksPThumb}" title="{merchTitle}"><img src="{merchImage}" alt="{merchTitle}"/></a><div class="merchZoomIcon"></div></div>\
				<div class="merchDetail">\
					<div class="merchPriceWrapper"><div class="merchName"><a href="{omnitureLinksPTitle}" >{merchTitle}</a></div><div class="merchDesc">{merchDesc}</div><div class="merchPrice">{merchPrice}</div></div>\
					<div class="merchBuy"><a href="{omnitureLinksPButton}" class="merchBuyLink">{merchPrice}</a></div>\
				</div>\
				<!-- HOVERCARD -->\
		</li>';

/* Templates for the Hovercard module.*/
var	merchHCTemplate ='<div class="merchHC merchHC{index}">\
							<div class="merchHCWrapper">\
								<div class="merchHCInnerWrapper">\
									<div class="merchHCHead"><a href="{omnitureLinksHTitle}">{merchTitle}</a></div>\
									<div class="merchHCBody">\
										<div class="merchHCLeftCon"><a href="{omnitureLinksHThumb}"  title="{merchTitle}"><img src="{merchImage}" alt="{merchTitle}" width="230px"/></a></div>\
										<div class="merchHCRightCon">\
											<h3 class="merchHCPrice">{merchPrice}</h3>\
											{merchDesc}\
											{merchSizes}\
											<div class="merchHCBuyNowCon"><a class="merchHCBuyNow" href="{omnitureLinksHButton}">Buy Now &raquo;</a></div>\
										</div>\
										<div class="clear"></div>\
									</div>\
									<div class="merchHCFoot"></div>\
								</div>\
							</div>\
						</div>';
			
var merchCountryTemplate = '<li><a class="flag {countryName}" href="{countryLink}" target="_new">{countryText}</a></li>';
var merchHeaderTemplate = '<div class="{positionClass}">\
						   		<div class="visitStore">\
									<a class="visitStoreLink" href="{merchViewAllLink}" rel="external" target="_new">Visit Artist Store</a>\
									<ul style="display: none;" class="visitStoreFlyout">\
										<!-- MERCH COUNTRIES -->\
									</ul>\
								</div>\
						   </div>';

function writeToConsole(obj){
	if (window.console && window.console.log) {
		switch (typeof obj) {
			case 'string':
			case 'integer':
				window.console.log('Eos > ' + obj);
				break;
			default:
				window.console.log(obj);
				break;
		}
	}
}

$(document).ready(function(){
	
	
	$("html").addClass($.os.name);
	$("body").addClass($.browser.className);
	$("body").addClass($.browser.name);
	
	$('.edit_account #accountData .buttons.input .button.submit input.submit').die();
	$('.edit_account #accountQuestoins .buttons.input .button.submit input.submit').die();					       
	
    /* Suppresses display of empty footers on IE */
    $('.module .foot:empty').addClass('empty');
	$('#rss_in-327532 .module .content .foot').removeClass('empty');
	
	$('#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;
		});
		
		
	$(".song_playlist .playlist .info li.xs .img a").each(function(){    	
		
			/* Disabling anchor tag  - Start*/
			$(this).attr("href","javascript:void(0)");
			/* Disabling anchor tag  - End*/						

	});

	$("#accountQuestoins.settings li.input.annotation").each(function(){
		if(($(this).find('span.private')).length == 0){
			$(this).append('<span class="private">Visible only to site administrators</span>');
		}
	});	
	modifyMediaSize("#video_thumbnail-890493.video_thumbnail .videos li .img a img","_6","display:block !important;width:182px !important;height: 171px !important;","display:block !important;width:182px !important;height: 171px !important;cursor:pointer !important;",true);	
	modifyMediaSize("#video_thumbnail-294593.video_thumbnail .videos li .img a img","_6","display:block !important;width:182px !important;height: 171px !important;","display:block !important;width:182px !important;height: 171px !important;cursor:pointer !important;",true);
	modifyMediaSize("#photo_thumbnail-294569.photo_thumbnail .photos li .img a img","_6","display:block !important;width:182px !important;height: 171px !important;","display:block !important;width:182px !important;height: 171px !important;cursor:pointer !important;",false);
	modifyMediaSize("#photo_thumnail-294571.photo_thumnail .photos li .img a img","_6","display:block !important;width:182px !important;height: 171px !important;","display:block !important;width:182px !important;height: 171px !important;cursor:pointer !important;",false);
	modifyMediaSize("#photo_thumbnail-5242231.photo_thumbnail .photos li .img a img","_6","display:block !important;width:181px !important;height: 172px !important;","display:block !important;width:181px !important;height: 172px !important;cursor:pointer !important;",false);
	modifyMediaSize("#video_thumbnail-5242232.video_thumbnail .videos li .img a img","_6","display:block !important;width:181px !important;height: 172px !important;","display:block !important;width:181px !important;height: 172px !important;cursor:pointer !important;",true);
	modifyMediaSize("#photo_thumbnail-5242067.photo_thumbnail .photos li .img a img","_6","display:block !important;width:181px !important;height: 172px !important;","display:block !important;width:181px !important;height: 172px !important;cursor:pointer !important;",false);
	modifyMediaSize("#video_thumbnail-5242229.video_thumbnail .videos li .img a img","_6","display:block !important;width:181px !important;height: 172px !important;","display:block !important;width:181px !important;height: 172px !important;cursor:pointer !important;",true);
	$( 'div.article div.meta div.category ul li a').each(function(){
		$(this).attr({
	  href: 'javascript:void(0);',
	  style: 'cursor:default'});
	});		
	
	$( 'ul.articles li.article div.category ul li a').each(function(){	   		
		$(this).attr({
	  href: 'javascript:void(0);',
	  style: 'cursor:default'});
	});
		

	
	
	
	    $('#blog_detail div.article').each(function(){
    	var imgElem = $(this).find('div.img');
    	var titleElem = $(this).find('div.title');
    	var authorElem = $(this).find('div.author');
    	var dateElem = $(this).find('div.date');
    	var newElem = document.createElement('div');
    	var newElem1 = document.createElement('div');
    	$(this).find('div.img').remove();
    	$(this).find('div.title').remove();
    	$(this).find('div.author').remove();
    	$(this).find('div.date').remove();
    	var newElem = document.createElement('div');
    	$(newElem).attr('class','articleTitleCont');
    	$(newElem1).attr('class','articleTitleTextCont');
    	$(newElem).append(imgElem);
    	$(newElem1).append(titleElem);
    	$(newElem1).append(authorElem);
    	$(newElem1).append(dateElem);
    	$(newElem).append(newElem1);
    	$(this).prepend(newElem);
    });
    $('#blog_detail .blog_entry .foot').each(function(){
    	var articleborder = document.createElement('div');
    	$(articleborder).attr('class','articlebottomborder');
    	$(this).append(articleborder);
    });
	$('#blog_detail .blog_entry .foot').each(function(){
	 	var dummyli="<div class='empty'></div>";
		$(dummyli).insertAfter($(this));
	 });
		/* Official Twitter Button & fLike Button implementation */
			var listing='moduleListing';
			var detail='moduleDetail';
			var detailPageValue = window.location.href;
			if(detailPageValue.indexOf('.wmg') != -1){
				var len = detailPageValue.length;
				var dot = detailPageValue.indexOf('.com/');
				var detailPageValue = detailPageValue.substring(dot+5, len);
				detailPageValue = 'http://www.mynameisrickyblaze.com/' + detailPageValue;
			}

	if (($('body').attr('id') == "blog_detail")) {
						var twitterObj = {
							blockSelector: '.blog_entry .body .article .meta',
							detailPageUrl: detailPageValue,
							insertionSelector: '.activity a.comment',
							siteUrl: 'http://www.mynameisrickyblaze.com',
							viaParam: '&amp;via=rickyblaze',
							relatedParam: '&amp;related=rickyblaze,rickyblaze',
							fanclubviaParam: '&amp;via=rickyblaze',
							fanclubrelatedParam: '&amp;related=rickyblaze,rickyblaze',
							detailPageName: 'blogDetail'
						}
						var fbLikeObj = {
							blockSelector: '.blog_entry .body .article .meta',
							detailPageUrl: detailPageValue,
							insertionSelector: '.activity a.comment',
							siteUrl: 'http://www.mynameisrickyblaze.com'
						}
						$.wmgfeature.twttrButton(twitterObj, detail);
						$.wmgfeature.fbLike(fbLikeObj, detail);
						
					}
					else if (($('body').attr('id') == "photo_detail")) {
			var twitterObj = {
				blockSelector:'.photo_viewer .body .photo',
				detailPageUrl:detailPageValue,
				insertionSelector:'.rating',
				siteUrl:'http://www.mynameisrickyblaze.com',
				viaParam:'&amp;via=rickyblaze',
				relatedParam:'&amp;related=rickyblaze,rickyblaze',				
				detailPageName:'photoDetail'
			}
			var fbLikeObj = {
				blockSelector:'.photo_viewer .body .photo',
				detailPageUrl:detailPageValue,
				insertionSelector:'.rating',
				siteUrl:'http://www.mynameisrickyblaze.com'			
			}
			$.wmgfeature.twttrButton(twitterObj, detail);
			$.wmgfeature.fbLike(fbLikeObj, detail);
			
			}/* Implementation of the buttons in video detail */ 
			else if (($('body').attr('id') == "video_detail")) {
			var twitterObj = {
				blockSelector:'.video_player .body .video',
				detailPageUrl:detailPageValue,
				insertionSelector:'.rating',
				siteUrl:'http://www.mynameisrickyblaze.com',
				viaParam:'&amp;via=rickyblaze',
				relatedParam:'&amp;related=rickyblaze,rickyblaze',
				fanclubviaParam:'&amp;via=rickyblaze',
				fanclubrelatedParam:'&amp;related=rickyblaze,rickyblaze',
				detailPageName:'videoDetail'
			}					
			var fbLikeObj = {
				blockSelector:'.video_player .body .video',
				detailPageUrl:detailPageValue,
				insertionSelector:'.rating',
				siteUrl:'http://www.mynameisrickyblaze.com'
			}	
			$.wmgfeature.twttrButton(twitterObj, detail);
			$.wmgfeature.fbLike(fbLikeObj, detail);
			
			}
/* 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;
    });
    
	  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);
		
	/*Custom drop-downs for top nav */
	$('.nav_main ul li.nav-custom a').each(function(){
		var customUrl=$(this).html().trim();
		if(customUrl=="Blog")
		{
			$(this).parent().addClass("nav-news");
		}
	});
    /* Make store top nav link open in a new window */
    $('.nav_main ul li.custom a[href*=amazon.com]').attr("rel", "external");

	
/* 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 (/^Fan Club$/i).test($(this).text())
	}).parent()
	  .addClass('nav-custom')
	  .addClass('dropdown')
	  .removeClass('nav-home');	  
	  
	 $customNavs.filter(function(){
		  return (/^Store$/i).test($(this).text())
		}).parent()
    	  .addClass('nav-custom')
		  .addClass('dropdown')
		  .addClass('nav-store');	
	  
	 $customNavs.filter(function(){
		  return (/^Global$/i).test($(this).text())
		 }).parent()
 		  .addClass('nav-custom')
		  .addClass('dropdown')
		  .addClass('nav-global_int');
		  
/* END: Custom drop-downs for top nav */
	
	var storeNavCell= $(".nav_main ul li.nav-store"); 
	
    /*Hover event handler for all drop-downs in top nav */
    $(".dropdown").hover(
		function(){$(".flyoutMenu", this).show();}, 
		function(){$(".flyoutMenu", this).hide();}
	);
    
  
	
    if (location.href.indexOf("/forums/") != -1) {        
        $("#discussionsNav").addClass("active");
    }
    if (location.href.indexOf("/ringtones/") != -1) {
        storeNavCell.addClass("active");
        $("#ringtonesNav").addClass("active");
    }
		
	 if (location.href.indexOf("/community_landing/") != -1) {
        
        $("#communityNav").addClass("active");
    }
	
	 if (location.href.indexOf("/extras/") != -1) {
        
        $("#extrasNav").addClass("active");
    }
	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");
    }

	/*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");
    }
    	
    var albumNavCell = $(".nav_main ul li.nav-album");
	 if (location.href.indexOf("/music/") != -1) {
        albumNavCell.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");
    }
	
	/*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);	
			});
			$.each($('div.article .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);	
			});
	var merchtitle = 30;
	$('li.merch .merchDesc div').each(function(){
		var trunc = (this).innerHTML;
		if (trunc.length > merchtitle) {
			trunc = trunc.substring(0, merchtitle);
			trunc += '<span>' + '...</span>';
			(this).innerHTML = trunc;
		}
	});
	$('.grid_3 li.merch .merchName a').each(function(){
		var trunc = (this).innerHTML;
		if (trunc.length >15) {
			trunc = trunc.substring(0, 15);
			trunc += '<span>' + '...</span>';
			(this).innerHTML = trunc;
		}
	});
//	var blogtitle = 30;
//	$('.blog_listing .articles li .title h4 a').each(function(){
//		var trunc = (this).innerHTML;
//		if (trunc.length >blogtitle) {
//			trunc = trunc.substring(0,blogtitle);
//			trunc += '<span>' + '...</span>';
//			(this).innerHTML = trunc;
//		}
//	});
//	$('.blog_entry .article .title h4').each(function(){
//		var trunc = (this).innerHTML;
//		if (trunc.length >blogtitle) {
//			trunc = trunc.substring(0,blogtitle);
//			trunc += '<span>' + '...</span>';
//			(this).innerHTML = trunc;
//		}
//	});
	
    /* ********** Merch module code ********* */
	$('#merchContainer').parent(".description").parent(".body").siblings(".head").addClass("clearfix");				
	$('#merchContainer').parent(".description").parent(".body").siblings(".head").children("h3").css({'border':'none','font-size':'25px'});				
	$('#merchContainer').parent(".description").parent(".body").siblings(".head").css({'position': 'relative','z-index': '100'});
	$('#merchContainer').parent(".description").parent(".body").siblings(".foot").css({'z-index': '98','overflow': 'visible'});
	$('#merchContainer').parent(".description").parent(".body").css({'position': 'relative','clear': 'both','z-index': '99'});

	var	visitStorehead = $('#merchContainer').parent(".description").parent(".body").siblings(".head");
	$('#merchContainer .merchHead').appendTo(visitStorehead);

	var	visitStoreFoot = $('#merchContainer').parent(".description").parent(".body").siblings(".foot");
	$('#merchContainer .merchFoot').appendTo(visitStoreFoot);

	$('#merchContainer').parent(".description").parent(".body").siblings(".foot.empty").addClass("emptyfix");
    
    /* START: Merch module drop-downs */
	$(".merchHead .visitStore").hover (
			function() { $(".visitStoreFlyout", this).show(); },
			function() { $(".visitStoreFlyout", this).hide(); }
		);
	$(".merchFoot .visitStore").hover (
		function() { $(".visitStoreFlyout", this).show(); },
		function() { $(".visitStoreFlyout", this).hide(); }		
	);
	$(".firstitem .merchBuy").hover (
		function() { $(".merchBuyFlyout", this).show(); },
		function() { $(".merchBuyFlyout", this).hide(); }		
	);
	$(".seconditem .merchBuy").hover (
		function() { $(".merchBuyFlyout", this).show(); },
		function() { $(".merchBuyFlyout", this).hide(); }		
	);
	$(".thirditem .merchBuy").hover (
		function() { $(".merchBuyFlyout", this).show(); },
		function() { $(".merchBuyFlyout", this).hide(); }		
	);
    /* END: Merch module drop-downs */
    
	
	if($("#sign_up-294578 li.input input").attr('class')== "focused"){		
		$descriptionDisplay = $("#sign_up-294578 li.input input.focused").parent().contents().filter(".message").children();
		if ($descriptionDisplay.css("display") == "inline" ||$descriptionDisplay.css("display") == "none"  ){
			$descriptionDisplay.css("display","block");
		}
	} 
	
	$("#sign_up-294578 li.input input").click( function() {
		// In this check for the corresponding description div. 		
		 $descriptionDisplay = $(this).next().filter(".message").children();
		if ($descriptionDisplay.css("display") == "inline"){
			$descriptionDisplay.css("display","block");
		}
	});
	
	$("#sign_up-294578 li.select input").click( function() {
		// In this check for the corresponding description div. 
		$descriptionDisplay = $(this).parent().contents().filter(".message").children();
		if ($descriptionDisplay.css("display") == "inline"){
			$descriptionDisplay.css("display","block");
		}
	});
	
	/* Fixing the target for the myspace link */
    $(".nav_main ul li a[href^=http://www.myspace.com/]").attr("target", "_new");

   /* Make rel="external" links open in a new window */
    $("a[rel=external]").attr("target", "_new");
	
	$(".nav_main li.nav-store a").attr("target", "_new");
	$(".nav_main li.nav-news a").attr("target", "_new");
		
	/* Fixing the target for the Street Team link */
    $("#FooterLinks1 ul li a.streetteam").attr("target", "_new");
	
    /* Fixing the target for the digg link */
    $(".shareweb .digg a").attr("target", "_new");
    
    /* Append labels to elements in discussion module */
    $(".topics li.list .category li:first-child").prepend("Category: ");
    $(".topics li.list .activity").prepend("Replies: ");
    $(".topics li.list .date").prepend("Last Reply: ");
    
    /* Add "Close" text to close link in social media sharebox on photo and video detail pages */
    $(".sharebox .sb_head .sb_title a.shareclose").prepend("Close");
    
    var noOfImageDscDtl = $("#discussion_entry-294529 .topic .description img").length;
    for (i = 0; i < noOfImageDscDtl; i++) {
        var discussionImageElement = $("#discussion_entry-294529 .topic .description img:eq(" + i + ")");
        var imgHeight = discussionImageElement.height();
        var imgWidth = discussionImageElement.width();
        if (imgHeight > 200 && imgWidth > 200) {
            var calcheight = (imgHeight / imgWidth) * 200;
            discussionImageElement.css("height", calcheight);
            discussionImageElement.css("width", 200);
        }        
    }    
	

	 	


    var noOfImageDscDtl = $("#discussion_listing-340654  .topic .description img").length;
    for (i = 0; i < noOfImageDscDtl; i++) {
        var discussionImageElement = $("#discussion_listing-340654 .topic .description img:eq(" + i + ")");
        var imgHeight = discussionImageElement.height();
        var imgWidth = discussionImageElement.width();
        if (imgHeight > 200 && imgWidth > 200) {
            var calcheight = (imgHeight / imgWidth) * 200;
            discussionImageElement.css("height", calcheight);
            discussionImageElement.css("width", 200);
        }
        
    }
	
	// Functionality for add new blogs.
    $(".blog_listing .nav_meta .more a").bind("click", function(e){
		
		$.cookie("blog_body", blogTwitterBlurbText, {
            path: "/"
        });
    });
	    if ($("body").attr("id") == "add_new_blog") {        
        $.cookie("blog_body", blogTwitterBlurbText, {
            path: "/"
        });
    }

	/*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*/	
	
/*-------------------------------------------------------------------------------------------------*/		
//Album detail stuff 
    $buylinks = $('#album_info-383751 .foot .nav_meta ul');
    $buylinks.insertBefore('#album_info-383751 .album .txt div.description');
    $('#album_info-383751.album_info .module .content .foot .nav_meta ul').css("display", "block");
	
/*-------------------------------------------------------------------------------------------------*/	
    
//Modifying the legal text in the log in and sign up pages.
if (typeof privacyPolicyText != 'undefined') {
	$("body#sign_up #cmsgData\\[agreeToTerms\\]").next().html(privacyPolicyText + "").show();
	$("body#join #cmsgData\\[agreeToTerms\\]").next().html(privacyPolicyText + "").show();
}	
/*-------------------------------------------------------------------------------------------------*/	
	
//Add facebook share to Blog detail
	
/*-------------------------------------------------------------------------------------------------*/			

//buy track
	$.each($('.list ul li .buy'),function(index,value){
		var buytrack = $('.list ul li .buy').eq(index).html().replace("Buy", "");
		$('.list ul li .buy').eq(index).html(buytrack); 		
		$('.list ul li .buy a').eq(index).html("BUY");
	});

/*--------------facebook connect in profile page--------------------------------------------------*/				

$('#edit_profile-294536.edit_profile .module .content .body').prepend($('#html-1985014.html .module .content .body .description'));

/*-------------------------------------------------------------------------------------------------*/

					       
});

/*-------------------------------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------------------------------*/
function eoscInit(){
	
	$('#member_listing-850114.member_listing .module .content .foot .nav_meta').insertBefore('#member_listing-850114.member_listing .module .content .foot .nav_page');
	
	/*******************Blog module html code Start*************************/
    $('.grid_9 ul.articles li.article').each(function(){
    	var imgElem = $(this).find('div.img');
    	var titleElem = $(this).find('div.title');
    	var authorElem = $(this).find('div.author');
    	var dateElem = $(this).find('div.date');
    	var newElem = document.createElement('div');
    	var newElem1 = document.createElement('div');
    	$(this).find('div.img').remove();
    	$(this).find('div.title').remove();
    	$(this).find('div.author').remove();
    	$(this).find('div.date').remove();
    	var newElem = document.createElement('div');
    	$(newElem).attr('class','articleTitleCont');
    	$(newElem1).attr('class','articleTitleTextCont');
    	$(newElem).append(imgElem);
    	$(newElem1).append(titleElem);
    	$(newElem1).append(authorElem);
    	$(newElem1).append(dateElem);
    	$(newElem).append(newElem1);
    	var articleborder = document.createElement('div');
    	$(articleborder).attr('class','articlebottomborder');
    	$(this).prepend(newElem);
    	$(this).append(articleborder);
    });
	 $('.grid_9 ul.articles li.article').each(function(){
	 	var dummyli="<div class='empty'></div>";
		$(dummyli).insertAfter($(this));
	 	});
    /*******************Blog module html code End***************************/

	/* Official Twitter Button & fLike Button implementation */
			var listing='moduleListing';
			var detail='moduleDetail';
			var detailPageValue = window.location.href;
			if(detailPageValue.indexOf('.wmg') != -1){
				var len = detailPageValue.length;
				var dot = detailPageValue.indexOf('.com/');
				var detailPageValue = detailPageValue.substring(dot+5, len);
				detailPageValue = 'http://www.mynameisrickyblaze.com/' + detailPageValue;
			}

		/* Implementation of the buttons in home */
			if ($('body').attr('id') == "home") {
				var twtrScript = document.createElement('script');
				twtrScript.type = 'text/javascript';
				twtrScript.src = "http://platform.twitter.com/widgets.js";
				$(".blog_listing").append(twtrScript);
				
				var twitterObj = {
					blockSelector: '#home .articles li.article',
					insertionSelector: '.activity',
					siteUrl: 'http://www.mynameisrickyblaze.com',
					urlSelector: '.title h4 a',
					viaParam: '&amp;via=rickyblaze',
					relatedParam: '&amp;related=rickyblaze,rickyblaze'
				}
				var fbLikeObj = {
					blockSelector: '#home .articles li.article',
					insertionSelector: '.activity',
					urlSelector: '.title h4 a',
					siteUrl: 'http://www.mynameisrickyblaze.com'
				}
				$.wmgfeature.twttrButton(twitterObj, listing);
				$.wmgfeature.fbLike(fbLikeObj, listing);
			}
			
			
			/* Implementation of the buttons in blog page */
			else 
				if ($('body').attr('id') == "blog") {
					var twitterObj = {
						blockSelector: '#blog .articles li.article',
						insertionSelector: '.activity a.comment',
						siteUrl: 'http://www.mynameisrickyblaze.com',
						urlSelector: '.title h4 a',
						viaParam: '&amp;via=rickyblaze',
						relatedParam: '&amp;related=rickyblaze,rickyblaze',
						fanclubviaParam: '&amp;via=rickyblaze',
						fanclubrelatedParam: '&amp;related=rickyblaze,rickyblaze'
					}
					var fbLikeObj = {
						blockSelector: '#blog .articles li.article',
						insertionSelector: '.activity a.comment',
						urlSelector: '.title h4 a',
						siteUrl: 'http://www.mynameisrickyblaze.com'
					}
					$.wmgfeature.twttrButton(twitterObj, listing);
					$.wmgfeature.fbLike(fbLikeObj, listing);
				}
				
					
			/* Thumbnail size change on pagination */
	modifyMediaSize("#video_thumbnail-890493.video_thumbnail .videos li .img a img","_6","display:block !important;width:182px !important;height: 171px !important;","display:block !important;width:182px !important;height: 171px !important;cursor:pointer !important;",true);	
	modifyMediaSize("#video_thumbnail-294593.video_thumbnail .videos li .img a img","_6","display:block !important;width:182px !important;height: 171px !important;","display:block !important;width:182px !important;height: 171px !important;cursor:pointer !important;",true);
	modifyMediaSize("#photo_thumbnail-294569.photo_thumbnail .photos li .img a img","_6","display:block !important;width:182px !important;height: 171px !important;","display:block !important;width:182px !important;height: 171px !important;cursor:pointer !important;",false);
	modifyMediaSize("#photo_thumnail-294571.photo_thumnail .photos li .img a img","_6","display:block !important;width:182px !important;height: 171px !important;","display:block !important;width:182px !important;height: 171px !important;cursor:pointer !important;",false);
	modifyMediaSize("#photo_thumbnail-5242231.photo_thumbnail .photos li .img a img","_6","display:block !important;width:181px !important;height: 172px !important;","display:block !important;width:181px !important;height: 172px !important;cursor:pointer !important;",false);
	modifyMediaSize("#video_thumbnail-5242232.video_thumbnail .videos li .img a img","_6","display:block !important;width:181px !important;height: 172px !important;","display:block !important;width:181px !important;height: 172px !important;cursor:pointer !important;",true);
	modifyMediaSize("#photo_thumbnail-5242067.photo_thumbnail .photos li .img a img","_6","display:block !important;width:181px !important;height: 172px !important;","display:block !important;width:181px !important;height: 172px !important;cursor:pointer !important;",false);
	modifyMediaSize("#video_thumbnail-5242229.video_thumbnail .videos li .img a img","_6","display:block !important;width:181px !important;height: 172px !important;","display:block !important;width:181px !important;height: 172px !important;cursor:pointer !important;",true);
		

	/*START - Fix for truncating height of blogs in home page */
	$('#home .blog_listing .articles .title h4').each(function(){
var hgt = $(this).height();
if(hgt > 35 )
{
var articleDiv = $(this).parents('.article');
articleDiv.children('.img').css('margin-bottom', '30px');
$(this).css('height', '70px');
}
});


	
	if(($('body.m32').find('.errorInput')).length > 0){
		    $('#TB_closeAjaxWindow').css('right','10px');
		}
		if(($('body.m32').find('#errorMsg')).length > 0){
		    $('#TB_closeAjaxWindow').css('right','10px');
	}
	
		$( 'div.article div.meta div.category ul li a').each(function(){
		$(this).attr({
	  href: 'javascript:void(0);',
	  style: 'cursor:default'});
	});
	
	modifyMediaSize("#photo_thumbnail-5242231.photo_thumbnail .photos li .img a img","_6","display:block !important;width:181px !important;height: 172px !important;","display:block !important;width:181px !important;height: 172px !important;cursor:pointer !important;",false);
	modifyMediaSize("#video_thumbnail-5242232.video_thumbnail .videos li .img a img","_6","display:block !important;width:181px !important;height: 172px !important;","display:block !important;width:181px !important;height: 172px !important;cursor:pointer !important;",true);
	modifyMediaSize("#photo_thumbnail-5242067.photo_thumbnail .photos li .img a img","_6","display:block !important;width:181px !important;height: 172px !important;","display:block !important;width:181px !important;height: 172px !important;cursor:pointer !important;",false);
	modifyMediaSize("#photo_thumnail-294571.photo_thumnail .photos li .img a img","_6","display:block !important;width:181px !important;height: 172px !important;","display:block !important;width:181px !important;height: 172px !important;cursor:pointer !important;",false);
	modifyMediaSize("#video_thumbnail-5242229.video_thumbnail .videos li .img a img","_6","display:block !important;width:181px !important;height: 172px !important;","display:block !important;width:181px !important;height: 172px !important;cursor:pointer !important;",true);
	//Commenting lines below since its already called in mlist.js
	/* 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 #accountData .buttons.input .button.submit input.submit").click( function(event) {
		event.preventDefault();
		var isUpdateReal = true;
		replaceContentRealSignUp('edit_account-294534', 'edit_account-294534', isUpdateReal);
	});
	
	$('.edit_account #accountQuestoins .buttons.input .button.submit input.submit').unbind('click');
	$(".edit_account #accountQuestoins .buttons.input .button.submit input.submit").click( function(event) {
		event.preventDefault();
		var isUpdateReal = true;
		isAccountQuestions = true;
		replaceContentRealSignUp('edit_account-294534', 'edit_account-294534', isUpdateReal);
	});
	/* Real Time Sign-Up End */

	/*START - Fix for truncating title of blogs in home page */
	
	/*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);	
			});
			$.each($('div.article .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);	
			});
	var merchtitle = 30;
	$('li.merch .merchDesc div').each(function(){
		var trunc = (this).innerHTML;
		if (trunc.length > merchtitle) {
			trunc = trunc.substring(0, merchtitle);
			trunc += '<span>' + '...</span>';
			(this).innerHTML = trunc;
		}
	});

	$('.grid_3 li.merch .merchName a').each(function(){
		var trunc = (this).innerHTML;
		if (trunc.length >15) {
			trunc = trunc.substring(0, 15);
			trunc += '<span>' + '...</span>';
			(this).innerHTML = trunc;
		}
	});
//	var blogtitle = 30;
//	$('.blog_listing .articles li .title h4 a').each(function(){
//		var trunc = (this).innerHTML;
//		if (trunc.length >blogtitle) {
//			trunc = trunc.substring(0,blogtitle);
//			trunc += '<span>' + '...</span>';
//			(this).innerHTML = trunc;
//		}
//	});
//	$('.blog_entry .article .title h4').each(function(){
//		var trunc = (this).innerHTML;
//		if (trunc.length >blogtitle) {
//			trunc = trunc.substring(0,blogtitle);
//			trunc += '<span>' + '...</span>';
//			(this).innerHTML = trunc;
//		}
//	});
var authorofpost;
var dateofpost;	

	$('.blog_listing .articles li.article').each(function(){	
		authorofpost = $(this).children(".author");
		dateofpost = $(this).children(".date");		
		$(this).children(".title").append(authorofpost);
		$(this).children(".title").append(dateofpost);	
	})

	var songtitle=25;
	$('.playlist .info .txt .title h3').each(function(){
		var trunc = (this).innerHTML;
		trunc=trunc.trim();
		if (trunc.length > songtitle) {
			
			trunc = trunc.substring(0, songtitle);
			
			trunc += '<span>' + '...</span>';
			(this).innerHTML = trunc;
		}
	})
	var modHead = $('body#home .blog_listing');
	var modHeadoffset = modHead.offset();
	if(modHeadoffset != null){
		var modHeadTop= modHeadoffset.top;	
	}

	$('body#home .blog_listing .foot .nav_page ul li a').click(function(){
		$('html, body').animate({scrollTop:modHeadTop}, 'slow');
	    return false;
	});
	

	
	
	/*END - Fix for truncating title of blogs in home page */
	
	/*-------------------------------------------------------------------------------------------------*/
	
	//Modifying the legal text in the log in and sign up pages.
	if (typeof privacyPolicyText != 'undefined') {
		$("body#sign_up #cmsgData\\[agreeToTerms\\]").next().html(privacyPolicyText + "").show();
		$("body#join #cmsgData\\[agreeToTerms\\]").next().html(privacyPolicyText + "").show();
	}
	/*-------------------------------------------------------------------------------------------------*/
	
	/*facebook language change */
	$('#edit_account #fbcLoginButton p').remove();
	$('#edit_account #facebookSettings .title').append('<p>Click on the Facebook Connect button to share your comments, photos, videos and discussion posts with your Facebook friends.</p>');
	
	/*-------------------------------------------------------------------------------------------------*/
	
	//Add facebook share to homepage blog and Blog landing
	
	
	/*-------------------------------------------------------------------------------------------------*/
	
	//reformat Comments copy - MIKE - 04-28-2010
	//$.each($('.activity .comment'), function(index, value){
	//	var newCommentNumber = $('.activity .comment').eq(index).html().replace("Comment (", "").replace("Comments (", "").replace(")", "");
	//	$('.activity .comment').eq(index).html(newCommentNumber);
	//});
	
	/*-------------------------------------------------------------------------------------------------*/
}
/*-------------------------------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------------------------------*/

   $.urlParam = function(name){
        var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
        if (results == null) {
            return 0;
        }
        else {
            return results[1];
        }
    }	
/*-------------------------------------------------------------------------------------------------*/	
/*-------------------------------------------------------------------------------------------------*/
/* Functions for New Merch.*/

	/*
	 * This function is used to tag store links with different omniture tags, 
	 * to track them. This will enable us to track which links the user clicked. 
	 * 
	 * */
	function getMerchOmnitureArray(omnitureString){
		var omnitureArrayLinks = new Array();
		var omnitureStrRegex = /intcmp=(.*)(&.*|\/)$/;
		omnitureString = $.trim(omnitureString);
		if (omnitureString.charAt(omnitureString.length-1) != "/" ){omnitureString += "/";}
		writeToConsole ("This is the omnitureString " + omnitureString);
		regExCapture = omnitureString.match(omnitureStrRegex);
		//A JSON object could be used and a fuction to populate that could be used. 
		if (regExCapture != null && regExCapture != ""){
			var regularExpCapture = regExCapture[1]; 
			omnitureString = omnitureString.replace(/\/$/,'');
			omnitureArrayLinks["page-title"] = omnitureString.replace(regularExpCapture,regularExpCapture+'-page-title');
			omnitureArrayLinks["page-button"] = omnitureString.replace(regularExpCapture,regularExpCapture+'-page-button');
			omnitureArrayLinks["page-thumb"] = omnitureString.replace(regularExpCapture,regularExpCapture+'-page-thumb');
			omnitureArrayLinks["hovercard-title"] = omnitureString.replace(regularExpCapture,regularExpCapture+'-hovercard-title');
			omnitureArrayLinks["hovercard-thumb"] = omnitureString.replace(regularExpCapture,regularExpCapture+'-hovercard-thumb');
			omnitureArrayLinks["hovercard-button"] = omnitureString.replace(regularExpCapture,regularExpCapture+'-hovercard-button');
		}else{
			omnitureArrayLinks["page-title"] = omnitureString.replace(/\/$/,'?intcmp=page-title');
			omnitureArrayLinks["page-button"] = omnitureString.replace(/\/$/,'?intcmp=page-button');
			omnitureArrayLinks["page-thumb"] = omnitureString.replace(/\/$/,'?intcmp=page-thumb');
			omnitureArrayLinks["hovercard-title"] = omnitureString.replace(/\/$/,'?intcmp=hovercard-title');
			omnitureArrayLinks["hovercard-thumb"] = omnitureString.replace(/\/$/,'?intcmp=hovercard-thumb');
			omnitureArrayLinks["hovercard-button"] = omnitureString.replace(/\/$/,'?intcmp=hovercard-button');
		}				 
		return omnitureArrayLinks;
	}
	
	/*
	 * Function to add the hovercard to the template,
	 * if set in the config xml.
	 * 
	 * */
	function prepareMerchTemplate (merchHoverCardPresent){
		if (merchHoverCardPresent){
			merchModuleTemplate = merchModuleTemplate.replace("<!-- HOVERCARD -->",merchHCTemplate);
		}else{
			merchModuleTemplate = merchModuleTemplate.replace("<!-- HOVERCARD -->","");
		}
		
	}
	
	function getMerchHeader ($merchCountries,merchViewAllLink,positionClass){
		var merchHeaderString = "";
		var merchCountryString = "";
		var countryParams;
		var merchParams = {
							merchViewAllLink : merchViewAllLink,
							positionClass : positionClass};
			$merchCountries.each (function(){

				countryParams = {
					countryName : $(this).children(".countryName").html(),
					countryLink : $(this).children(".countryLink").html(),
					countryText : $(this).children(".countryText").html()
				};
				merchCountryString += merchCountryTemplate.supplant(countryParams);
				
			})

			merchViewAllLink ="javscript:void(0)"; 	
		
		merchHeaderString = merchHeaderTemplate.supplant(merchParams);
		merchHeaderString = merchHeaderString.replace("<!-- MERCH COUNTRIES -->",merchCountryString);
		return merchHeaderString;
	}
	
	/*
	 * This function generates the structure of the merch module. 
	 * The structure is created using templates defined earlier in the page.  
	 */ 
	function generateMerchStructure (){
		var $merchData = $("#merchData");
		var $merchItem = $merchData.children(".merchItems")
		var merchViewAllLink = $merchData.children(".merchViewAll").html();
		var temp1 = $merchData.children(".merchHoverCardPresent").html();
		var merchHoverCardPresent = temp1.trim();
		merchHoverCardPresent = !!merchHoverCardPresent;
		prepareMerchTemplate (merchHoverCardPresent);
		
		/* Code for the Merch Head */
		var merchHead = '<div class="merchHead"><div class="visitStore"><a href="'+ merchViewAllLink +'" class="visitStoreLink"  >ALL</a></div></div>'
		merchHead = getMerchHeader($("#merchInternational .country"),merchViewAllLink,"merchHead");
		var visitStorehead = $('#merchContainer').parent(".description").parent(".body").siblings(".head");
	        $(merchHead).appendTo(visitStorehead);
		$(visitStorehead).find("a").makeLinksExternal();
		/* End of Code for Merch Module */
		
		var merchBody='<ul class="merchItems">';
		$.each($merchItem.children(".merchItem"), function (i){
			var merchBuyNow = $(this).children(".merchBuyNow").html(); 			
			var omnitureLinks = getMerchOmnitureArray(merchBuyNow);
			var merchSizes = $(this).children(".merchSizes").html();
			if (merchSizes !="" && merchSizes !=null){merchSizes = '<h3>Sizes</h3><div>'+merchSizes+'</div>';}
			var merchDesc = $(this).children(".merchDesc").html();
			if (merchDesc != "" && merchDesc != null){merchDesc = '<h3>Description</h3><div>'+ merchDesc +'</div>';}
			var merchParsedData = {
				             index:(i+1),
							 merchImage:$(this).children(".merchImage").html(),
							 merchTitle:$(this).children(".merchTitle").html(),
							 merchDesc:merchDesc,
							 merchSizes:merchSizes,
							 merchPrice:$(this).children(".merchPrice").html(),
							 omnitureLinksPTitle:omnitureLinks["page-title"],
							 omnitureLinksPThumb:omnitureLinks["page-thumb"],
							 omnitureLinksPButton:omnitureLinks["page-button"],
							 omnitureLinksHTitle:omnitureLinks["hovercard-title"],
							 omnitureLinksHThumb:omnitureLinks["hovercard-thumb"],
							 omnitureLinksHButton:omnitureLinks["hovercard-button"]
							 }
			merchBody = merchBody + merchModuleTemplate.supplant(merchParsedData);
		});
		merchBody += '</ul><div class="clear"></div>';
	
		var merchFoot = '<div class="clear"></div><div class="merchFoot"><div class="visitStore"><a href="'+ merchViewAllLink +'" class="visitStoreLink" >View ALL</a></div></div>';
		merchFoot = '<div class="clear"></div>';
		merchFoot += getMerchHeader($("#merchInternational .country"),merchViewAllLink,"merchFoot");
		var visitStoreFoot = $('#merchContainer').parent(".description").parent(".body").siblings(".foot");
	        $(merchFoot).appendTo(visitStoreFoot);
		$(visitStoreFoot).find("a").makeLinksExternal();

		return merchBody;
	}
	
	
	
	/*These functions are used by the merch HC so that casual hovers less than 300 seconds
	 * are omitted. 
	 */
	function bringMerchHCOn(merchImg){
		merchImg.showTimer = window.setTimeout(function(){
			$(merchImg).siblings(".merchHC").fadeIn(300);
		},300);
	}
	function killMerchHC(merchImg){
		if (merchImg.showTimer){
			window.clearTimeout(merchImg.showTimer);
		}
	}
	
	/* Registereing the hover events */
	function registerMerchHoverEvents(){
		$(".merchImg").hover(function(){
			bringMerchHCOn(this);
		},function(){
			killMerchHC(this);
		});
		$(".merchHC").hover(function(){
		},function(){
			$(this).fadeOut(300);
		});
		
		$(".visitStore").hover (
			function() { $(".visitStoreFlyout", this).show(); },
			function() { $(".visitStoreFlyout", this).hide(); }
		);
	}
	
	/* The piece of code which generates the merch, adds the dom and registers the events. */

$(document).ready(function(){
		if ($("#merchContainer").length > 0){
			$("#merchContainer").html(generateMerchStructure());
			$("#merchData").empty();
			$("#merchContainer a").makeLinksExternal();
			registerMerchHoverEvents();
		}
});
function modifyMediaSize(cssSelector, thumbSize, avatarAncStyle, avatarImgStyle, isVideo){
	$(cssSelector).each(function(){
		var photoImageSrc = $(this).attr("src");
		var photoImageSrcNew = "";
		var anchorRef = "";
		if (null != photoImageSrc) {
			var slashpoint = photoImageSrc.lastIndexOf("/");
			var uspoint = photoImageSrc.lastIndexOf("_");
			var dotpoint = photoImageSrc.lastIndexOf(".");
			var srcLength = photoImageSrc.length;
			var imgPath_1 = photoImageSrc.substring(0, slashpoint);
			var imgPath_2 = photoImageSrc.substring(slashpoint, uspoint);
			var imgPath_3 = photoImageSrc.substring(dotpoint, (srcLength));
			photoImageSrcNew = imgPath_1 + imgPath_2 + thumbSize + imgPath_3;
			$(this).parent().attr("style", avatarAncStyle);
			anchorRef = $(this).parent().attr("href");
			$(this).attr("style", avatarImgStyle);
			var avatarDivStyle = "background:transparent url(" + photoImageSrcNew + ") no-repeat 0px 0px;";
			$(this).attr("src", photoImageSrcNew);
			$(this).parent().parent().attr("style", avatarDivStyle);
			if (isVideo) {
				$(this).parent().parent().append("<a class='preplayIcon' " + "href = '" + anchorRef + "'></a>");
			}
			
			
		}
	});
}

