/* 
 * 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);



function eoscInit(){	  

alternateColouringListing();
$('#moduleForm294541 .note').html(forgotPasswordText);		

}
function alternateColouringListing(){
	
}		
$(document).ready(function(){
	
	/* 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=345,height=270,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no"); 
			return false;
	});
	
	var prvtLegend='<span class="private">Visible only to site adminstrators</span>';
    
    $('.edit_account li.input.annotation').append(prvtLegend);
	
	/* Setting the browser name and classname in the top */
	$("html").addClass($.os.name);
	$("body").addClass($.browser.className);
	
	/* Suppresses display of empty footers on IE */
	$('.module .foot:empty').addClass('empty');
	
	//Modifying the legal text in the log in and sign up pages.
		$("body#sign_up #cmsgData\\[agreeToTerms\\]").next().html(privacyPolicyText + "")
		.show();
		$("body#join #cmsgData\\[agreeToTerms\\]").next().html(privacyPolicyText + "")
		.show();
		
	/* START: Community drop-down for top nav */
	//Define XHTML source for the community subnav inn the variable below
	var communitySubNav = '<ul class="flyoutMenu" id="communitySubNav" style="display:none">\
		<li id="memberNav"><a href="http://www.jasoncastromusic.com/member/">Fans</a></li>\
		<li id="discussionsNav"><a href="http://www.jasoncastromusic.com/talk/">Discussions</a></li>\
		<li id="chatNav"><a href="http://www.jasoncastromusic.com/community_landing/">Chat</a></li>\
		<li><a href="http://www.streetpropaganda.net/jasoncastro" target="_blank">Street Team</a></li>';
	
	var FCSubNav = '<ul class="flyoutMenu" id="FCSubNav" style="display:none">\
			<li id="FCBlog"><a href="/blog/" >Fan Club Blog</a></li>\
			<li id="FCMemberNav"><a href="/member/" >Fan Club Members</a></li>\
			<li id="FCVideo"><a href="/video/" >Fan Club videos</a></li>\
			<li id="FCPhoto"><a href="/photo/" >Fan Club Photos</a></li>\
			<li id="FCForumNav"><a href="/talk/" >Fan Club Forum</a></li>';		
	
	var $customNavs = $('.nav_main ul li.nav-custom a');

	$customNavs.filter(function(){
	  return (/^Home$/i).test($(this).text())
	}).parent()
	  .addClass('nav-home');	
	
	$customNavs.filter(function(){
	  return (/^Videos$/i).test($(this).text())
	}).parent()
	  .addClass('nav-video');
	
	$customNavs.filter(function(){
	  return (/^Blogs$/i).test($(this).text())
	}).parent()
	  .addClass('nav-blog');
	
	$customNavs.filter(function(){
	  return (/^Photos$/i).test($(this).text())
	}).parent()
	  .addClass('nav-photo');	  
	  
	  	$customNavs.filter(function(){
	  return (/^Tour Dates$/i).test($(this).text())
	}).parent()
	  .addClass('nav-tour_dates');
	  
	  	$customNavs.filter(function(){
	  return (/^Bio$/i).test($(this).text())
	}).parent()
	  .addClass('nav-bio');
	  
	  	$customNavs.filter(function(){
	  return (/^Community$/i).test($(this).text())
	}).parent()
	  .addClass('dropdown')
	  .addClass('nav-community_landing')
	  .append(communitySubNav);
	  
  
	  var $homeNavs = $('.nav_main ul li.nav-home a');
	  
	  	$homeNavs.filter(function(){
	  return (/^Fan Club$/i).test($(this).text())
	}).parent()
	  .addClass('nav-fanclub')
	  .addClass('dropdown')
	  .removeClass('nav-home')
	  .append(FCSubNav);
	  
	  
	$customNavs.filter(function(){
	  return (/Music/i).test($(this).text())
	}).parent()
	  .addClass('nav-music');
	
	$customNavs.filter(function(){
	  return (/^Store$/i).test($(this).text())
	}).parent()
	  .addClass('nav-store');	

	$customNavs.filter(function(){
	  return (/Contacts/i).test($(this).text())
	}).parent()
	  .addClass('nav-contacts');
	
	
	
	$('.nav_main ul li.nav-custom a').filter(function(){
		 return (/^Store$/i).test($(this).text())
		}).attr("rel", "external");
		

		
	/* END: Community drop-down for top nav */
	
	
	/* START: Store drop-down for top nav */
	//Define XHTML source for the community subnav inn the variable below
	var storeSubNav = '<ul class="flyoutMenu" id="storeSubNav" style="display:none">\
		<li><a href="http://www.amazon.com" class="flag us" rel="external">Visit US Store</a></li>\
		<li><a href="http://www.amazon.co.uk" class="flag uk" rel="external">Visit UK Store</a></li>';
/*
	var storeNavCell = $('.nav_main ul li.custom:has(a[href*=amazon.com])');   //change this selector to target a different cell in the top nav
	storeNavCell.addClass('dropdown');
	storeNavCell.append(storeSubNav);
	
		$('.nav_main ul li.nav-custom a').filter(function(){
  			 return (/^Store$/i).test($(this).text())
			}).parent()
		   .addClass('dropdown')  
		   .addClass('nav-store')
		   .append(storeSubNav);
*/	
	/* END: Store drop-down for top nav */
	
		
	
	/* END: country drop-down for top nav */
	
	
	
	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");
		}
	});
	/* Flag subnav pages in parent top nav li */
	
	
	if (location.href.indexOf("/member/") != -1) {
			$(".nav-fanclub").addClass("active");
			$("#FCMemberNav").addClass("active");
		}	
		
	if (location.href.indexOf("/talk/") != -1) {
			$(".nav-fanclub").addClass("active");
			$("#FCForumNav").addClass("active");
		}
		
	if (location.href.indexOf("/blog/") != -1) {
		$(".nav-fanclub").addClass("active");
		$("#FCBlog").addClass("active");
		}
	if (location.href.indexOf("/photo/") != -1) {
	$(".nav-fanclub").addClass("active");
		$("#FCPhoto").addClass("active");
		}	
	if (location.href.indexOf("/video/") != -1) {
		$(".nav-fanclub").addClass("active");
		$("#FCVideo").addClass("active");
		}		
	
	var photoNavCell = $(".nav_main ul li.photo");
	if (location.href.indexOf("/cellstream/") != -1) {
		photoNavCell.addClass("active");
	}
	
	
	

	/* START: Merch module drop-downs */
	$(".ArtistStore").hover (
			function() { $(".flyoutMenu", this).show(); },
			function() { $(".flyoutMenu", this).hide(); }
		);
			
	$(".mainAlbumBuyDrop").hover (
		function() { $("#subMainAlbumBuy", this).show(); },
		function() { $("#subMainAlbumBuy", this).hide(); }		
	);

	$(".productLeftBuyDrop").hover (
		function() { $("#subLeftAlbumBuy", this).show(); },
		function() { $("#subLeftAlbumBuy", this).hide(); }		
	);

	$(".productRightBuyDrop").hover (
		function() { $("#subRightAlbumBuy", this).show(); },
		function() { $("#subRightAlbumBuy", this).hide(); }		
	);

	$(".ArtistStoreBottom").hover (
		function() { $(".flyoutMenuFooter", this).show(); },
		function() { $(".flyoutMenuFooter", this).hide(); }		
	);
	/* END: Merch module drop-downs */
	
	
	/* Make rel="external" links open in a new window */
	$("a[rel=external]").attr("target", "_new");
	
	/* Fixing the target for the digg link */
	$(".shareweb .digg a").attr("target", "_new");
	
	/* Append labels to elements in discussion module */
	$(".topics li.list .category li:first-child").prepend("Category: ");
	$(".topics li.list .activity").prepend("Replies: ");
	$(".topics li.list .date").prepend("Last Reply: ");
	
	/* Add "Close" text to close link in social media sharebox on photo and video detail pages */
	$(".sharebox .sb_head .sb_title a.shareclose").prepend("Close");
	
	
	/* ********************* Code for Extras Module ************** */


	
			
/*	$("a.copyButton.active").click(function(){
		$(this).parents(".copyHtmlBox").css("display","none");
		return false}); */
		
	$("a.popupclose").click(function(){
		$(".imgSrcEmbed").css("visibility", "hidden");
	});	
	
	if ($("#home").length > 0) {
	
		$('#html-450137 .copyThisButton').attr("id", "button450137");
		$("#html-450137 .imgSrcEmbed").css("display", "block");
		/** commenting out these things temporarily Due to extras page absence */
		/*clipClient450137 = new ZeroClipboard.Client();
		clipClient450137.setHandCursor(true);
		clipClient450137.glue('button450137');
		clipClient450137.addEventListener('onMouseDown', buttonMouseDown450137);
		clipClient450137.addEventListener('complete', buttonCopyCmpltd450137);*/
		
		$("#html-450137 .homepage_extras img").click(function(){
			$("#html-450137 .imgSrcEmbed").css("visibility", "visible");
		});
		
		$("#html-450137 a.copyButton").click(function(){
			$("#html-450137 .imgSrcEmbed").css("visibility", "visible");
		});
		
	}
	else if ($("#extras").length > 0) {
		
			$('#html-450138 .copyThisButton').attr("id", "button450138");
			/** commenting out these things temporarily Due to extras page absence */
			/*clipClient450138 = new ZeroClipboard.Client();
			clipClient450138.setHandCursor(true);
			clipClient450138.glue('button450138');
			clipClient450138.addEventListener('onMouseDown', buttonMouseDown450138);
			clipClient450138.addEventListener('complete', buttonCopyCmpltd450138);*/
			
			$("#html-450138 .extrasUnitContainer .image img").click(function(){
				$("#html-450138 .imgSrcEmbed").css("visibility", "visible");
			});
			
			$("#html-450138 a.copyButton").click(function(){
				$("#html-450138 .imgSrcEmbed").css("visibility", "visible");
			});
			
			
			$('#html-440663 .copyThisButton').attr("id", "button440663");
			/** commenting out these things temporarily Due to extras page absence */
			/*clipClient440663 = new ZeroClipboard.Client();
			clipClient440663.setHandCursor(true);
			clipClient440663.glue('button440663');
			clipClient440663.addEventListener('onMouseDown', buttonMouseDown440663);
			clipClient440663.addEventListener('complete', buttonCopyCmpltd440663);*/
			
			$("#html-440663 .extrasUnitContainer .image img").click(function(){
				$("#html-440663 .imgSrcEmbed").css("visibility", "visible");
			});
			
			$("#html-440663 a.copyButton").click(function(){
				$("#html-440663 .imgSrcEmbed").css("visibility", "visible");
			});
			
			
			$('#html-440664 .copyThisButton').attr("id", "button440664");
			/** commenting out these things temporarily Due to extras page absence */
			/*clipClient440664 = new ZeroClipboard.Client();
			clipClient440664.setHandCursor(true);
			clipClient440664.glue('button440664');
			clipClient440664.addEventListener('onMouseDown', buttonMouseDown440664);
			clipClient440664.addEventListener('complete', buttonCopyCmpltd440664);*/
			
			$("#html-440664 .extrasUnitContainer .image img").click(function(){
				$("#html-440664 .imgSrcEmbed").css("visibility", "visible");
			});
			
			$("#html-440664 a.copyButton").click(function(){
				$("#html-440664 .imgSrcEmbed").css("visibility", "visible");
			});
			
			
			$('#html-440665 .copyThisButton').attr("id", "button440665");
			/** commenting out these things temporarily Due to extras page absence */
			/*clipClient440665 = new ZeroClipboard.Client();
			clipClient440665.setHandCursor(true);
			clipClient440665.glue('button440665');
			clipClient440665.addEventListener('onMouseDown', buttonMouseDown440665);
			clipClient440665.addEventListener('complete', buttonCopyCmpltd440665);*/
			
			$("#html-440665 .badgeContainer .image img").click(function(){
				$("#html-440665 .imgSrcEmbed").css("visibility", "visible");
			});
			
			$("#html-440665 a.copyButton").click(function(){
				$("#html-440665 .imgSrcEmbed").css("visibility", "visible");
			});
			
		}
		
		/* Hiding the fan categories in photos and videos */
		
		$('body#photo #category-list .division .title').filter (function(){
			return (/Fan/i).test($(this).text())
		}).parents(".division")
		  .hide();
		$('body#photo #category-list').show();

		$('body#photo_detail #category-list .division .title').filter (function(){
			return (/Fan/i).test($(this).text())
		}).parents(".division")
		  .hide();
		$('body#photo_detail #category-list').show();

		$('body#video #category-list .division .title').filter (function(){
			return (/Fan/i).test($(this).text())
		}).parents(".division")
		  .hide();
		$('body#video #category-list').show();

		$('body#video_detail #category-list .division .title').filter (function(){
			return (/Fan/i).test($(this).text())
		}).parents(".division")
		  .hide();
		$('body#video_detail #category-list').show();
		
			$customNavs.filter(function(){
	  return (/^Photos$/i).test($(this).text())
	}).parent()
	  .addClass('nav-photo');	  

		
		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-440467  .topic .description img").length;
		for(i=0;i<noOfImageDscDtl;i++){
			var discussionImageElement = $("#discussion_listing-440467 .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);	
			}
			
		}	
		
	
	
	function buttonMouseDown450137(client) {	
	client.setText( $('#moduleForm450137 .copyTxtArea').val());
	}
	
	function buttonCopyCmpltd450137(client){
	$("#html-450137 .copyTxtArea").focus().select();
	writeToConsole("This is a dummy text for the future.");
	}
	
	function buttonMouseDown450138(client) {
		
	client.setText( $('#moduleForm450138 .copyTxtArea').val());
	}
	
	function buttonCopyCmpltd450138(client){
				$("#html-450138 .copyTxtArea").focus().select();	
	writeToConsole("This is a dummy text for the future.");
	}
	
	function buttonMouseDown440663(client) {
			
	client.setText( $('#moduleForm440663 .copyTxtArea').val());
	}
	
	function buttonCopyCmpltd440663(client){
	$("#html-440663 .copyTxtArea").focus().select();
	writeToConsole("This is a dummy text for the future.");
	}
	
	function buttonMouseDown440664(client) {
		
	client.setText( $('#moduleForm440664 .copyTxtArea').val());
	}
	
	function buttonCopyCmpltd440664(client){
	$("#html-440664 .copyTxtArea").focus().select();	
	writeToConsole("This is a dummy text for the future.");
	}
	
	function buttonMouseDown440665(client) {
			
	client.setText( $('#moduleForm440665 .copyTxtArea').val());
	}
	
	function buttonCopyCmpltd440665(client){
	$("#html-440665 .copyTxtArea").focus().select();
	writeToConsole("This is a dummy text for the future.");
	}	
	
	/* Adding class names for custom drop downs, to implement handdrawn navigation */
				  	
	
	/*Hover event handler for all drop-downs in top nav */
	$(".dropdown").hover(
			function() { $(".flyoutMenu", this).show(); },
			function() { $(".flyoutMenu", this).hide(); }
	);
	
	$('[href=/upload/]').attr("href", "http://jasoncastromusic.com/upload/");
	$('[href=/store/]').attr("href", "http://jasoncastro.hasawebstore.com/");
	
	
/*START- code which obfuscates email addresses #2420*/	
		var m_ = "mailto:";
		var a_ = "@";
		var d_ = ".";
		var i = 0;
		var j  = 0;
		var q_ = "?";
		var e_ = "=";
		
		$('span.ciReplace').each(function(){	
			if(cId[i].format == ""){
				$(this).html('<a href="'+m_+cId[i].name+a_+cId[i].domain+d_+cId[i].tld+'">'+ cId[i].name + a_+ cId[i].domain + d_+ cId[i].tld +'</a>');
			}
			else{
				if(cId[i].param == ""){
					$(this).html('<a href="'+m_+cId[i].name+a_+cId[i].domain+d_+cId[i].tld+'">'+ cId[i].format+'</a>');
				}
				else{
					$(this).html('<a href="'+m_+cId[i].name+a_+cId[i].domain+d_+cId[i].tld+q_+'subject'+e_+cId[i].param+'">'+cId[i].format+'</a>');
				}
			}
		i++;				
		});
		
		
		$('span.footReplace').each(function(){
					if(fId[j].format == ""){
				$(this).html('<a href="'+m_+fId[j].name+a_+fId[j].domain+d_+fId[j].tld+'">'+ fId[j].name + a_+ fId[j].domain + d_+ fId[j].tld +'</a>');
			}
			else{
				if(fId[j].param == ""){
					$(this).html('<a href="'+m_+fId[j].name+a_+fId[j].domain+d_+fId[j].tld+'">'+ fId[j].format+'</a>');
				}
				else{
					$(this).html('<a href="'+m_+fId[j].name+a_+fId[j].domain+d_+fId[j].tld+q_+'subject'+e_+fId[j].param+'">'+fId[j].format+'</a>');
				}
			}
			j++;		
		});	
		
	/*End - code which obfuscates email addresses #2420*/	
	
});
