/* 
 * 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 Plugin - opens external links in a new window.  
 * Checks if the links are relative, and are of the same domain.
 * Sampe Usage - $("#someDiv a").makeLinksExternal();
 */
jQuery.fn.makeLinksExternal=function(){return this.each(function(){var a=$(this).attr("href");if(a.indexOf(location.host)==-1&&a.indexOf("/")!=0){$(this).attr("target","_blank")}})};


$(document).ready(function(){

	$('.twitterContainer li:first').css('border','none');
	/* Move Home Page VideoPlaylist 'View more' to Header */
	var moreVideoCell='<div class="viewMoreVideos"><a href="/video/">View All Videos</a></div>';
	$('#html-3276557 .module .head').append(moreVideoCell);
	
    /* Suppresses display of empty footers on IE */
    $('.module .foot:empty').addClass('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;
	});		
	
	$("#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>');
    }
    }); 

	/* This code to avoid pagination if there are no tweets */
	
	if (typeof($('.tweets'))=="undefined") 
	{
		$('.tc_nav_page').css("display","none");
	}	
$("html").addClass($.os.name);
$("body").addClass($.browser.className);
$("body").addClass($.browser.name);
	
	//The var "chatEnabled" is declared in navigational links html module
	//Initially this module is set to display:none using css.
	
	if(chatEnabled.toLowerCase()=="true"){
		$("#html-2052580.html").css("display","block");
	}
	
	//this inserts the merch module into leftwrap 
	
	$('#html-2054007.html .module .content .body .description .chatContainer div#leftWrap').append($('#html-327531.html .module .content .body .description div#merchContainer'));
	
    /* 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;
				}	
			})		
	/*END - Fix for truncating author name in the discussions page #698 */
	
	/*START - Fix for truncating Discussion Title in the Community page  */
			$('#discussion_listing-3260081.discussion_listing .topics li.topic .title h4 a').each(function(){
				var trunc = (this).innerHTML;	
				if (trunc.length > CommPageDiscusTitle) {
					trunc = trunc.substring(0, CommPageDiscusTitle);
					trunc += '<span>' + '...</span>';
					(this).innerHTML = trunc;
				}	
			})		
	/*END - Fix for truncating Discussion Description in the Community page */
	
	/*START - Fix for truncating Discussion Title in the Community page  */
			$('#discussion_listing-3260081.discussion_listing .topics li.list .description').each(function(){
				var trunc = (this).innerHTML;	
				if (trunc.length > CommPageDiscusDesc) {
					trunc = trunc.substring(0, CommPageDiscusDesc);
					trunc += '<span>' + '...</span>';
					(this).innerHTML = trunc;
				}	
			})		
	/*END - Fix for truncating Discussion Description in the Community page */
	
	/*START - Fix for truncating Discussion Title in the Discussion page  */
			$('#discussion_listing-294531.discussion_listing .topics li.topic .title h4 a').each(function(){
				var trunc = (this).innerHTML;	
				if (trunc.length > DiscusPageDiscusTitle) {
					trunc = trunc.substring(0, DiscusPageDiscusTitle);
					trunc += '<span>' + '...</span>';
					(this).innerHTML = trunc;
				}	
			})		
	/*END - Fix for truncating Discussion Title in the Discussion page */
	
	/*START - Fix for truncating Discussion Description in the Discussion page  */
			$('#discussion_listing-294531.discussion_listing .topics li.list .description').each(function(){
				var trunc = (this).innerHTML;	
				if (trunc.length > DiscusPageDiscusDesc) {
					trunc = trunc.substring(0, DiscusPageDiscusDesc);
					trunc += '<span>' + '...</span>';
					(this).innerHTML = trunc;
				}	
			})		
	/*END - Fix for truncating Discussion Description in the Discussion page */
	
	
	
		
    $("a[href^=http://starterfanclub1.wmg.ciscoeos.com]").parent(".custom").addClass("Fanclub");
	
	/* START: Community drop-down for top nav */
    //Define XHTML source for the community subnav inn the variable below	
  	  var communityNavCell = $(".nav_main ul li.nav-community_landing"); //change this selector to target a diffent cell in the top nav
  	  communityNavCell.addClass('dropdown');
 	  communityNavCell.append(communitySubNav);
    /* END: Community drop-down for top nav */
    
    /* 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')
	  .append(FCSubNav);
	  
	 $customNavs.filter(function(){
		  return (/^Store$/i).test($(this).text())
		}).parent()
    	  .addClass('nav-custom')
		  .addClass('nav-store');
		  
	$('.nav-store a').attr("target","_new");
		 
	 $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 mediaNavCell = $(".nav_main ul li.nav-photo"); //change this selector to target a diffent cell in the top nav
 	mediaNavCell.addClass('dropdown');
 	mediaNavCell.append(mediaSubNav);*/
	/* END: Bio drop-down for top nav */
	
	var bioNavCell = $(".nav_main ul li.nav-bio"); //change this selector to target a diffent cell in the top nav
 	//bioNavCell.addClass('dropdown');
 	//bioNavCell.append(bioSubNav); 	  

	/* END: 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) {
        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("/member/") != -1) {
        communityNavCell.addClass("active");
        $("#memberNav").addClass("active");
    }
	/*if (location.href.indexOf("/photo/") != -1) {
        mediaNavCell.addClass("active");
        $("#photosNav").addClass("active");
    }
	if (location.href.indexOf("/video/") != -1) {
        mediaNavCell.addClass("active");
        $("#videosNav").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 musicNavCell = $(".nav_main ul li.nav-audio");
    if (location.href.indexOf("/album/") != -1) {
        musicNavCell.addClass("active");
    }
		
    
    if (location.href.indexOf("/music/") != -1) {
        $("a[href^=/album/]").parent(".nav-custom").addClass("active");
        
    }
    
    if (location.href.indexOf("/album/") != -1) {
        $("a[href^=/album/]").parent(".nav-custom").addClass("active");
    }	
    /* ********** Merch module code ********* */
	$('#merchContainer').parent(".description").parent(".body").siblings(".head").addClass("clearfix");				
		$('#merchContainer').parent(".description").parent(".body").siblings(".head").children("h3").css({'border':'none','font-size':'25px'});				
	$('#merchContainer').parent(".description").parent(".body").siblings(".head").css({'position': 'relative','z-index': '100'});
	$('#merchContainer').parent(".description").parent(".body").siblings(".foot").css({'z-index': '98','overflow': 'visible'});
	$('#merchContainer').parent(".description").parent(".body").css({'position': 'relative','clear': 'both','z-index': '99'});

	var	visitStorehead = $('#merchContainer').parent(".description").parent(".body").siblings(".head");
	$('#merchContainer .merchHead').appendTo(visitStorehead);

	var	visitStoreFoot = $('#merchContainer').parent(".description").parent(".body").siblings(".foot");
	$('#merchContainer .merchFoot').appendTo(visitStoreFoot);

	$('#merchContainer').parent(".description").parent(".body").siblings(".foot.empty").addClass("emptyfix");
    
    /* START: Merch module drop-downs */
	$(".merchHead .visitStore").hover (
			function() { $(".visitStoreFlyout", this).show(); },
			function() { $(".visitStoreFlyout", this).hide(); }
		);
	$(".merchFoot .visitStore").hover (
		function() { $(".visitStoreFlyout", this).show(); },
		function() { $(".visitStoreFlyout", this).hide(); }		
	);
	$(".firstitem .merchBuy").hover (
		function() { $(".merchBuyFlyout", this).show(); },
		function() { $(".merchBuyFlyout", this).hide(); }		
	);
	$(".seconditem .merchBuy").hover (
		function() { $(".merchBuyFlyout", this).show(); },
		function() { $(".merchBuyFlyout", this).hide(); }		
	);
	$(".thirditem .merchBuy").hover (
		function() { $(".merchBuyFlyout", this).show(); },
		function() { $(".merchBuyFlyout", this).hide(); }		
	);
    /* END: Merch module drop-downs */
    
	
	if($("#sign_up-294578 li.input input").attr('class')== "focused"){		
		$descriptionDisplay = $("#sign_up-294578 li.input input.focused").parent().contents().filter(".message").children();
		if ($descriptionDisplay.css("display") == "inline" ||$descriptionDisplay.css("display") == "none"  ){
			$descriptionDisplay.css("display","block");
		}
	} 
	
	$("#sign_up-294578 li.input input").click( function() {
		// In this check for the corresponding description div. 		
		 $descriptionDisplay = $(this).next().filter(".message").children();
		if ($descriptionDisplay.css("display") == "inline"){
			$descriptionDisplay.css("display","block");
		}
	});
	
	$("#sign_up-294578 li.select input").click( function() {
		// In this check for the corresponding description div. 
		$descriptionDisplay = $(this).parent().contents().filter(".message").children();
		if ($descriptionDisplay.css("display") == "inline"){
			$descriptionDisplay.css("display","block");
		}
	});
	
	/* 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");
	
		
	/* 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.
    $("body#sign_up #cmsgData\\[agreeToTerms\\]").next().html(privacyPolicyText + "").show();
    $("body#join #cmsgData\\[agreeToTerms\\]").next().html(privacyPolicyText + "").show(); 	
	
	
       
});

function eoscInit(){	
$(document).ready(function(){

	
    var blogDate;
    var blogAuthor;
    var blogCategory;
    var blogComment;
    $("ul.articles li.article").each(function(){
        blogDate = $(this).find(".date");
        blogAuthor = $(this).find(".author");
        blogCategory = $(this).find(".category");
        blogComment = $(this).find(".activity .comment").html().replace("Comments", "").replace("Comment", "").replace(")", "").replace("(", "");
        $(this).find(".title").append(blogAuthor);
        $(this).find(".title").append(blogDate);
        $(this).find(".activity").append(blogCategory);
        $(this).find(".activity .comment").html(blogComment);
        $(this).append('<div style="float:none; clear:both;"></div>');
        $(this).find(".author").css("display", "inline");
        $(this).find(".date").css("display", "inline");
        $(this).find(".category").css("display", "inline");
        $(this).find(".activity .comment").css("display", "inline");
    });
    
    var $customNewClass = $('.blog_listing .nav_meta ul li a');
    $customNewClass.filter(function(){
        return (/^Post a new blog/i).test($(this).text())
    }).parent().addClass('newer');
    
    var $customReadMoreClass = $('.blog_listing .description a');
    $customReadMoreClass.filter(function(){
        return (/^Read more/i).test($(this).text())
    }).addClass('readMore');
	
    //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");
    });
})
	$("#member_listing-850114.member_listing .head .title").append($("#member_listing-850114.member_listing .foot .nav_meta"));
	$(".edit_profile .body").prepend($("#html-2251204.html .module .content .body .description"));
	$(".edit_account .body").prepend($(".edit_account .head .title .nav_meta"));
	$(".edit_profile .body").prepend($(".edit_profile .head .title .nav_meta"));
    //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");
    });
    
	/*START - Fix for truncating Discussion Title in the Community page  */
			$('#discussion_listing-3260081.discussion_listing .topics li.topic .title h4 a').each(function(){
				var trunc = (this).innerHTML;	
				if (trunc.length > CommPageDiscusTitle) {
					trunc = trunc.substring(0, CommPageDiscusTitle);
					trunc += '<span>' + '...</span>';
					(this).innerHTML = trunc;
				}	
			})		
	/*END - Fix for truncating Discussion Description in the Community page */
	
	/*START - Fix for truncating Discussion Title in the Community page  */
			$('#discussion_listing-3260081.discussion_listing .topics li.list .description').each(function(){
				var trunc = (this).innerHTML;	
				if (trunc.length > CommPageDiscusDesc) {
					trunc = trunc.substring(0, CommPageDiscusDesc);
					trunc += '<span>' + '...</span>';
					(this).innerHTML = trunc;
				}	
			})		
	/*END - Fix for truncating Discussion Description in the Community page */
	
	/*START - Fix for truncating Discussion Title in the Discussion page  */
			$('#discussion_listing-294531.discussion_listing .topics li.topic .title h4 a').each(function(){
				var trunc = (this).innerHTML;	
				if (trunc.length > DiscusPageDiscusTitle) {
					trunc = trunc.substring(0, DiscusPageDiscusTitle);
					trunc += '<span>' + '...</span>';
					(this).innerHTML = trunc;
				}	
			})		
	/*END - Fix for truncating Discussion Title in the Discussion page */
	
	/*START - Fix for truncating Discussion Description in the Discussion page  */
			$('#discussion_listing-294531.discussion_listing .topics li.list .description').each(function(){
				var trunc = (this).innerHTML;	
				if (trunc.length > DiscusPageDiscusDesc) {
					trunc = trunc.substring(0, DiscusPageDiscusDesc);
					trunc += '<span>' + '...</span>';
					(this).innerHTML = trunc;
				}	
			})		
	/*END - Fix for truncating Discussion Description in the Discussion page */
	
	
    var blogComment;
    $("ul.articles li.article").each(function(){
        blogComment = $(this).find(".activity .comment").html().replace("Comments", "").replace("Comment", "").replace(")", "").replace("(", "");
        ;
        $(this).find(".activity .comment").html(blogComment);
    });

	$("#member_listing-3260082.member_listing .members li .img a img").each(function(){    	
		var photoImageSrc=$(this).attr("src");
		var photoImageSrcNew="";
		if(null!=photoImageSrc){			
			/* for Image size modifications -Start*/
			var slashpoint=photoImageSrc.lastIndexOf("/");
			var uspoint=photoImageSrc.lastIndexOf("_");
			var dotpoint=photoImageSrc.lastIndexOf(".");
			var srcLength=photoImageSrc.length;
			var thumbSize="_6";
			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).attr("src",photoImageSrcNew);
			$(this).attr("width","290");
			$(this).attr("height","180");
			var avatarAncStyle="display:block !important;width:283px !important;height: 300px !important;";
			var avatarImgStyle="display:block !important;width:283px !important;height: 300px !important;cursor:pointer !important;";
			$(this).parent("a").attr("style",avatarAncStyle);		
			$(this).attr("style",avatarImgStyle);							
	}
	});	
	$("#photo_thumbnail-3366290.photo_thumbnail .photos li .img a img").each(function(){    	
		var photoImageSrc=$(this).attr("src");
		var photoImageSrcNew="";
		if(null!=photoImageSrc){			
			/* for Image size modifications -Start*/
			var slashpoint=photoImageSrc.lastIndexOf("/");
			var uspoint=photoImageSrc.lastIndexOf("_");
			var dotpoint=photoImageSrc.lastIndexOf(".");
			var srcLength=photoImageSrc.length;
			var thumbSize="_6";
			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).attr("src",photoImageSrcNew);
			$(this).attr("width","320");
			$(this).attr("height","330");
			var avatarAncStyle="display:block !important;width:320px !important;height: 330px !important;";
			var avatarImgStyle="display:block !important;width:320px !important;height: 330px !important;cursor:pointer !important;";
			$(this).parent("a").attr("style",avatarAncStyle);
			$(this).attr("style",avatarImgStyle);							
	}
	});	
	$("#photo_thumbnail-3260080.photo_thumbnail .photos li .img a img").each(function(){    	
		var photoImageSrc=$(this).attr("src");
		var photoImageSrcNew="";
		if(null!=photoImageSrc){			
			/* for Image size modifications -Start*/
			var slashpoint=photoImageSrc.lastIndexOf("/");
			var uspoint=photoImageSrc.lastIndexOf("_");
			var dotpoint=photoImageSrc.lastIndexOf(".");
			var srcLength=photoImageSrc.length;
			var thumbSize="_6";
			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).attr("src",photoImageSrcNew);
			$(this).attr("width","290");
			$(this).attr("height","180");
			var avatarAncStyle="display:block !important;width:106px !important;height: 106px !important;";
			var avatarImgStyle="display:block !important;width:106px !important;height: 106px !important;cursor:pointer !important;";
			$(this).parent("a").attr("style",avatarAncStyle);
			$(this).attr("style",avatarImgStyle);							
	}
	});
	
	$("#video_thumbnail-3260079.video_thumbnail .videos li .img a img").each(function(){    	
		var photoImageSrc=$(this).attr("src");
		var photoImageSrcNew="";
		if(null!=photoImageSrc){			
			/* for Image size modifications -Start*/
			var slashpoint=photoImageSrc.lastIndexOf("/");
			var uspoint=photoImageSrc.lastIndexOf("_");
			var dotpoint=photoImageSrc.lastIndexOf(".");
			var srcLength=photoImageSrc.length;
			var thumbSize="_6";
			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).attr("src",photoImageSrcNew);
			$(this).attr("width","290");
			$(this).attr("height","180");
			var avatarAncStyle="display:block !important;width:289px !important;height: 180px !important;";
			var avatarImgStyle="display:block !important;width:289px !important;height: 180px !important;cursor:pointer !important;";
			$(this).parent("a").attr("style",avatarAncStyle);		
			$(this).attr("style",avatarImgStyle);							
	}
	});
	$("#video_thumbnail-890493.video_thumbnail ul.videos li .img a img").each(function(){    	
		var photoImageSrc=$(this).attr("src");
		var photoImageSrcNew="";
		if(null!=photoImageSrc){			
			/* for Image size modifications -Start*/
			var slashpoint=photoImageSrc.lastIndexOf("/");
			var uspoint=photoImageSrc.lastIndexOf("_");
			var dotpoint=photoImageSrc.lastIndexOf(".");
			var srcLength=photoImageSrc.length;
			var thumbSize="_6";
			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).attr("src",photoImageSrcNew);
			$(this).attr("width","290");
			$(this).attr("height","180");
			var avatarAncStyle="display:block !important;width:118px !important;height: 76px !important;";
			var avatarImgStyle="display:block !important;width:118px !important;height: 76px !important;cursor:pointer !important;";
			$(this).parent("a").attr("style",avatarAncStyle);		
			$(this).attr("style",avatarImgStyle);							
	}
	});
	$("#video_thumbnail-890493.video_thumbnail ul.videos li .img a img").each(function(){    	
		var photoImageSrc=$(this).attr("src");
		var photoImageSrcNew="";
		if(null!=photoImageSrc){			
			/* for Image size modifications -Start*/
			var slashpoint=photoImageSrc.lastIndexOf("/");
			var uspoint=photoImageSrc.lastIndexOf("_");
			var dotpoint=photoImageSrc.lastIndexOf(".");
			var srcLength=photoImageSrc.length;
			var thumbSize="_6";
			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).attr("src",photoImageSrcNew);
			$(this).attr("width","290");
			$(this).attr("height","180");
			var avatarAncStyle="display:block !important;width:118px !important;height: 76px !important;";
			var avatarImgStyle="display:block !important;width:118px !important;height: 76px !important;cursor:pointer !important;";
			$(this).parent("a").attr("style",avatarAncStyle);		
			$(this).attr("style",avatarImgStyle);							
	}
	});
	
	
	$("#photo_thumbnail-294569.photo_thumbnail .photos li .img a img").each(function(){    	
		var photoImageSrc=$(this).attr("src");
		var photoImageSrcNew="";
		if(null!=photoImageSrc){			
			/* for Image size modifications -Start*/
			var slashpoint=photoImageSrc.lastIndexOf("/");
			var uspoint=photoImageSrc.lastIndexOf("_");
			var dotpoint=photoImageSrc.lastIndexOf(".");
			var srcLength=photoImageSrc.length;
			var thumbSize="_6";
			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).attr("src",photoImageSrcNew);
			$(this).attr("width","290");
			$(this).attr("height","180");
			var avatarAncStyle="display:block !important;width:106px !important;height: 106px !important;";
			var avatarImgStyle="display:block !important;width:106px !important;height: 106px !important;cursor:pointer !important;";
			$(this).parent("a").attr("style",avatarAncStyle);
			$(this).attr("style",avatarImgStyle);							
	}
	});
	

	$("#photo_thumnail-294571.photo_thumnail .photos li .img a img").each(function(){    	
		var photoImageSrc=$(this).attr("src");
		var photoImageSrcNew="";
		if(null!=photoImageSrc){			
			/* for Image size modifications -Start*/
			var slashpoint=photoImageSrc.lastIndexOf("/");
			var uspoint=photoImageSrc.lastIndexOf("_");
			var dotpoint=photoImageSrc.lastIndexOf(".");
			var srcLength=photoImageSrc.length;
			var thumbSize="_6";
			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).attr("src",photoImageSrcNew);
			$(this).attr("width","290");
			$(this).attr("height","180");
			var avatarAncStyle="display:block !important;width:106px !important;height: 106px !important;";
			var avatarImgStyle="display:block !important;width:106px !important;height: 106px !important;cursor:pointer !important;";
			$(this).parent("a").attr("style",avatarAncStyle);
			$(this).attr("style",avatarImgStyle);							
	}
	});
	
	$("#video_thumbnail-294593.video_thumbnail .videos li .img a img").each(function(){    	
		var photoImageSrc=$(this).attr("src");
		var photoImageSrcNew="";
		if(null!=photoImageSrc){			
			/* for Image size modifications -Start*/
			var slashpoint=photoImageSrc.lastIndexOf("/");
			var uspoint=photoImageSrc.lastIndexOf("_");
			var dotpoint=photoImageSrc.lastIndexOf(".");
			var srcLength=photoImageSrc.length;
			var thumbSize="_6";
			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).attr("src",photoImageSrcNew);
			$(this).attr("width","290");
			$(this).attr("height","180");
			var avatarAncStyle="display:block !important;width:118px !important;height: 76px !important;";
			var avatarImgStyle="display:block !important;width:118px !important;height: 76px !important;cursor:pointer !important;";
			$(this).parent("a").attr("style",avatarAncStyle);		
			$(this).attr("style",avatarImgStyle);							
	}
	});		
	//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 SP and EOS integration */
	
	$(".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.officialflo.com/", "2170734");
	$.wmgfeature.spFeatureEditAccountAccQuestions(".edit_account #accountQuestoins .buttons.input .button.submit input.submit", "edit_account-294534", true, arrElementIDs, "http://www.officialflo.com/", "2170734");
	
	/* For SP and EOS integration */
}

   $.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;
	}
	/*
	 * 
	 * This function generates the structure of the merch module. 
	 * The structure is just a javascript variables interspersed with html.  
	 * 
	 * Huge scope for refactoring here. 
	 * 
	 */ 
	function generateMerchStructure (){
		var $merchData = $("#merchData");
		var $merchItem = $merchData.children(".merchItems")
		var merchViewAllLink = $merchData.children(".merchViewAll").html();
		var merchHoverCardPresent = $merchData.children(".merchHoverCardPresent").html().trim();
		merchHoverCardPresent = !!merchHoverCardPresent;

		/* Code for the Merch Head */
		var merchHead = '<div class="merchHead"><div class="visitStore"><a href="'+ merchViewAllLink +'" class="visitStoreLink"  >ALL</a></div></div><div class="clear"></div>'
		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 merchImage = $(this).children(".merchImage").html();
			var merchTitle = $(this).children(".merchTitle").html();
			var merchBuyNow = $(this).children(".merchBuyNow").html();
			var merchDesc = $(this).children(".merchDesc").html();
			var merchSizes = $(this).children(".merchSizes").html();
			var merchPrice = $(this).children(".merchPrice").html();
			var omnitureArrayLinks = getMerchOmnitureArray(merchBuyNow);
			
			
				merchBody += '<li class="merch small item'+(i+1)+'">\
				<div class="merchImg"><a href="'+ omnitureArrayLinks["page-thumb"] +'"><img src="'+ merchImage +'"/></a><div class="merchZoomIcon"></div></div>\
				<div class="merchDetail">\
					<div class="merchPriceWrapper"><div class="merchName"><a href="'+ omnitureArrayLinks["page-title"]+'" >'+ merchTitle +'</a></div><div class="merchPrice">'+ merchPrice +'</div></div>\
					<div class="merchBuy"><a href="'+omnitureArrayLinks["page-button"]+'" class="merchBuyLink">' + merchPrice + '</a></div>\
				</div>'
				if (merchHoverCardPresent){
				merchBody +='<div class="merchHC merchHC'+ (i + 1) +'">\
								<div class="merchHCWrapper">\
									<div class="merchHCInnerWrapper">\
										<div class="merchHCHead"><a href="'+ omnitureArrayLinks["hovercard-title"] +'">'+ merchTitle +'</a></div>\
										<div class="merchHCBody">\
											<div class="merchHCLeftCon"><a href="'+ omnitureArrayLinks ["hovercard-thumb"]+ '"><img src="'+merchImage+'" width="230px"/></a></div>\
											<div class="merchHCRightCon">\
												<h3 class="merchHCPrice">'+merchPrice+ '</h3>';
												if (merchDesc != "" && merchDesc != null){
													merchBody += '<h3>Description</h3><div>'+ merchDesc +'</div>';	
												}
												if (merchSizes !="" && merchSizes !=null){
													merchBody += '<h3>Sizes</h3><div>'+merchSizes+'</div>';	
												}
												
												merchBody += '<div class="merchHCBuyNowCon"><a class="merchHCBuyNow" href="'+ omnitureArrayLinks ["hovercard-button"] +'">Buy Now &raquo;</a></div>\
											</div>\
											<div class="clear"></div>\
										</div>\
										<div class="merchHCFoot"></div>\
									</div>\
								</div>\
							</div>';
				}/* End of the Merch Hovercard Body */
			merchBody += '</li>';
		});
		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><div class="clear"></div>';
		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);
		});
	}
	
	/* The piece of code which generates the merch, adds the dom and registers the events. */
	
	$(document).ready(function(){

		if($('#html-327531.html').attr('class')=='html'){			
			$("#merchContainer").html(generateMerchStructure());
			$("#merchData").empty();
			registerMerchHoverEvents();
			$("#merchContainer a").makeLinksExternal();	
		}		
	});
    /* End of Functions for New Merch */
	
	



