var privacyPolicyText   = 'By registering, I acknowledge that I have reviewed and agreed to the '+ '<a target="_new" href="/privacy-policy/" rel="external">Privacy Policy</a> and <a target="_new" href="/terms-of-use/" rel="external">Terms of Service</a>' + ', and  I agree to receive marketing messages from Atlantic Records, its affiliates and estellemusic.com with the latest news, updates and information about \'Estelle\'';

$(document).ready(function(){



	$('#rss_in-736845.rss_in .module .content .body h3').remove();




	$('.nav_main ul li.nav-custom a').filter(function(){
	  return (/\Store/i).test($(this).text())
	}).parent()
	  .addClass('nav-store');
	
	$('.nav_main ul li.nav-custom a').filter(function(){
	  return (/\Twitter/i).test($(this).text())
	}).parent()
	  .addClass('nav-twitter');
	
	$('.nav_main ul li.nav-custom a').filter(function(){
	  return (/\Myspace/i).test($(this).text())
	}).parent()
	  .addClass('nav-myspace');
	
	$('.nav_main ul li.nav-custom a').filter(function(){
	  return (/\Email \Signup/i).test($(this).text())
	}).parent()
	  .addClass('nav-email-signup');
	
$(".nav-myspace a").attr("target","_blank"); 
$(".nav-twitter a").attr("target","_blank"); 
$(".nav-store a").attr("target","_blank"); 

//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();   

//$('.photo_thumbnail .photos div.img').css("background-image", $('.photo_thumbnail .photos div.img').css("background-image").replace("_5", "_6"));
$('#photo_thumbnail-736846 .photos div.img').css("background-image", 'none');;
$('#photo_thumbnail-736846 .photos div.img a img').attr("src", $('.photo_thumbnail .photos div.img a img').attr("src").replace("_5", "_6"));
$('#photo_thumbnail-736846 .photos div.img a img').show();

	});
	
function eoscInit(){
	//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();   
}
	
	

renderRSSModule = function(data,format, div) {
	
	if (div.attr("id") == "rss_content-738260") { 
	
		renderTwitterModuleEOS(data, format, div);
		/*	titleDiv = $("#rss_content-738260 h3");
			//$("#rss_content-399814").append($("#rss_content-399814 h3"));
			$("#rss_content-738260 h3").addClass('follow');
			$("#rss_in-738260 div.module div.content div.head h3").after($("#rss_content-738260 h3"));
			
			$("#rss_in-738260 div.module div.content div.head h3.follow a").text(followTwitterText);
			$("#rss_in-738260 div.module div.content div.head h3.follow a").attr("target", "_new");
		
	*/

		
		
	} else if(div.attr("id") == "rss_content-736845") {
	
		renderCellstreamModuleEOS(data, format, div);
	
	}  else {
		/* Default RSS Ingester module functionality */
		//if this isn't the cellstream RSS module then use the EOS default copied and pasted below
		renderRSSModuleEOS(data, format, div);

	}
	
	
}

renderRSSModuleEOS=function(c,a,b){jQuery.getFeed({xml:c,success:function(g){jQuery(b).append('<h3><a href="'+g.link+'">'+g.title+"</a></h3>");var e="";for(var d=0;d<g.items.length&&d<5;d++){var f=g.items[d];e+="<h4>";if(f.link.length>0){e+='<a href="'+f.link+'">'+f.title+"</a>"}else{e+=f.title}e+="</h4>";e+='<div class="updatedd">'+f.updated+"</div>";e+="<div>"+f.description+"</div>";if(f.image){e+='<div class="image"><img src="'+f.image+'"></div>'}}jQuery(b).append(e)}})};

renderCellstreamModuleEOS=function(c,a,b){jQuery.getFeed({xml:c,success:function(g){
	
//	jQuery(b).append('<h3><a href="'+g.link+'">'+g.title+"</a></h3>");

	var e="";

	for(var d=0;d<g.items.length&&d<5;d++){
		
		var f=g.items[d];

		var t = f.description;
		f.description = t.replace('_4','_6').replace('<tr>','').replace('</tr>','').replace('<td>','').replace('</td>','').replace('<tbody>','').replace('</tbody>','');
		
	
		e+=""+f.description+"";
	/*	e+="<h4>";
		
		if(f.link.length>0){
				
			e+='<a href="'+f.link+'">'+f.title+"</a>"
		} else {
			
			e+=f.title}e+="</h4>";*/
			e+='<div class="updated">'+dateFormat(f.updated, "mmmm dS, yyyy, h:MM:ss TT")+"</div>";
		
			
			if(f.image){
				
				e+='<div class="image"><img src="'+f.image+'"></div>';
			}
			
			e+='<div class="view_more_cell"><a href="http://www.estellemusic.com/photo/category/mobile/">View More Cellstream</a></div>'
	}
	
	jQuery(b).append(e)
	
	}})};

renderTwitterModuleEOS=function(c,a,b){jQuery.getFeed({xml:c,success:function(g){

//	jQuery(b).append('<h3><a href="'+g.link+'">'+g.title+"</a></h3>");
	var e="";
	for(var d=0;d<g.items.length&&d<3;d++){
		var f=g.items[d];
	//	e+="<h4>";
		if(f.link.length>0){
			
	
		/*	
			var urlRegExp = "([A-Za-z][A-Za-z0-9+.-]{1,120}:[A-Za-z0-9/](([A-Za-z0-9$_.+!*,;/?:@&~=-])|%[A-Fa-f0-9]{2}){1,333}(#([a-zA-Z0-9][a-zA-Z0-9$_.+!*,;/?:@&~=%-]{0,1000}))?)";
			var matches = f.title.match(urlRegExp);
			
			if(matches != null) {
				var matchLength = matches[0].length;
					
			
				var stringWithUrls = 	f.title.substring(0, f.title.indexOf(matches[0])) +
										"<a href=\"" + matches[0] + "\" target=\"_blank\">" +
										f.title.substring(f.title.search(matches[0]), f.title.search(matches[0]) + matchLength) + 
										"</a>" +
										f.title.substring(f.title.indexOf(matches[0]) + matchLength);

			
				e+="<a href=\"http://www.twitter.com/EstelleDarlings\" target=\"_blank\">" + stringWithUrls.substring(0, 10) + "</a>" + stringWithUrls.substring(10);
			
			
			} else {
					
				e+="<a href=\"http://www.twitter.com/EstelleDarlings\" target=\"_blank\">" + f.title.substring(0, 10) + "</a>" + f.title.substring(10);
			
			}*/
			
			
		
		//	e+=f.title;
			
		
			
		}else{
			
				e+=f.title;
		
		}
		//e+="</h4>";
	
		e+="<div>"+f.description+"</div>";
			e+='<div class="updated">'+dateFormat(f.updated, "mmmm dS, yyyy")+" at "+dateFormat(f.updated, "h:MM:ss TT")+" · <a href=\"http://twitter.com/home/?status=@EstelleDarlings\" target=\"_blank\">REPLY</a></div>";
		if(f.image){
			e+='<div class="image"><img src="'+f.image+'"></div>'
		}
		
		
	} 
	e+="<div class=\"view_more_twitter\"><a href=\"http://www.twitter.com/EstelleDarlings\" target=\"_blank\">Follow Estelle on Twitter</a></div>";
jQuery(b).append(e)}})};