
$(document).ready(function() {  
						   
	$("div#snow-sand-temp").each(function(){
										  
		var element = this;
		var temp = 'xx';
		$.ajax({
			type: "GET",
			url: "http://www.ilikebenfm.com/_Shared/Channels/Public/RSS/GetXMLDataForRSS.ashx?ChannelID=3168",
			dataType: "xml",
			success: function(xml) {		
				temp = $(xml).find("item:eq(0)").find("title").text();
				//console.log(temp);
				$(element).append("<a href='http://www.ilikebenfm.com/contests/2010/snow-for-sand/'>"+ temp + "&#176;</a>");		
				$(element).bind("click", function(){
					window.location.href = $(this).children("a").attr("href");
				});
			}		
		});
	});
						   
	// Do Image Thumbnails 
	/*$("div.blogteaser ul li").each(function() {
			var postProperties = {	"obj": $(this),
													"title" : $(this).find("h4 a").html(),
													"href"  : $(this).find("h4 a").attr("href"),
													"blog": $(this).find("h4 a").attr("href").split("/")[4] ,
                    								"entryID" : $(this).find("h4 a").attr("href").split("=")[1]  };

			//console.log(postProperties.title + " , " +  postProperties.href + " , " +postProperties.blog + " , " +postProperties.entryID);
			var path = "http://www.ilikebenfm.com/Pics/Blogs/";

			if (postProperties.title.search('DID YOU KNOW') != -1) {
				$(this).find("span.teaserimage img").attr("src", path + "Thumbnails/Common/bt-dyk-100sq.gif");
			}
			
			else {
						if(postProperties.blog == "ben") {
							path =  path + "1000867/";
						}
						else if (postProperties.blog == "woman-of-the-week") {	
							path = path + "1001131/";
						}
						else if (postProperties.blog == "interviews") {
							path = path + "1001132/";
						}			
			var imgURL =  path + postProperties.entryID + "-001.jpg";

					$.ajax({
						type: "GET",
  						url: imgURL,
						timeout: 1000,
						success: function(msg){
							$(postProperties.obj).find("span.teaserimage img").attr("src", imgURL);
   						}
						});		
				
					// see if there's a jpg with the blogID as filename
					// if there is crop it up and shit, replace as src of img
			}
			
			
				
	});*/
	
	
	/*ILikeBenFM.com Email Subscription
	****************************/
	var emailValue;
	//$("div#email-subscribe p#no-java").remove();
	//$("input#es-input:disabled, input#subscribe-button:disabled").removeAttr("disabled");
	
	$("input#es-input").focus(function(){
		$("input#es-input").val("");
    });
	$("input#es-input").blur(function(){
		emailValue = $("input#es-input").val();
		$("input#es-input").val(emailValue);
    });
	
	$("input#subscribe-button").click(function(){
		formEmail = "http://www.feedburner.com/fb/a/mailverify?uri=BEN-FM/all&email=" + $("input#es-input").val();
		window.open(formEmail , "", "scrollbars=yes,width=550,height=520");								   
    });
	
	
	var emailSubscribe = {    
     sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
     interval: 100, // number = milliseconds for onMouseOver polling interval    
     over: function() {	
				var $menu = $(this);
				//$(this).animate({ height: parseInt($(this).css('height'),10) == 56 ? 280 : 56});
				$menu.animate({ top: parseInt($menu.css('top'),10) == -25 ? -$menu.outerHeight() + -10 : -25}); }, // function = onMouseOver callback (REQUIRED)    
     timeout: 800, // number = milliseconds delay before onMouseOut    
     out: function() {	
				var $menu = $(this);
				//$(this).animate({ height: parseInt($(this).css('height'),10) == 56 ? 280 : 56});
				$menu.animate({ top: parseInt($menu.css('top'),10) == -180 ? -$menu.outerHeight() + -10 : -180}); } // function = onMouseOut callback (REQUIRED)    
	};
	
	$('div#email-subscribe').hoverIntent(emailSubscribe);
	
	
						   
						      // WRITE ADS - LEADERBOARD
   /*$('div#top_ad_right').html("<iframe id=\'aa6db5a9\' name=\'aa6db5a9\' src=\'http://banners.andomedia.com/openx_gm/www/delivery/afr.php?n=aa6db5a9&amp;zoneid=319&amp;cb=INSERT_RANDOM_NUMBER_HERE\' framespacing=\'0\' frameborder=\'no\' scrolling=\'no\' width=\'728\' height=\'90\'><a href=\'http://banners.andomedia.com/openx_gm/www/delivery/ck.php?n=a10d0ee9&amp;cb=INSERT_RANDOM_NUMBER_HERE\' target=\'_blank\'><img src=\'http://banners.andomedia.com/openx_gm/www/delivery/avw.php?zoneid=319&amp;cb=INSERT_RANDOM_NUMBER_HERE&amp;n=a10d0ee9\' border=\'0\' alt=\'\' /></a></iframe><script type=\'text/javascript\' src=\'http://banners.andomedia.com/openx_gm/www/delivery/ag.php\'></script>");*/
   
   $("div#bottom_ad").html("<iframe id='aaf73d7f' name='aaf73d7f' src='http://banners.andomedia.com/openx_gm/www/delivery/afr.php?n=aaf73d7f&amp;zoneid=318&amp;cb=INSERT_RANDOM_NUMBER_HERE' framespacing='0' frameborder='no' scrolling='no' width='468' height='60'><a href='http://banners.andomedia.com/openx_gm/www/delivery/ck.php?n=ac98335f&amp;cb=INSERT_RANDOM_NUMBER_HERE' target='_blank'><img src='http://banners.andomedia.com/openx_gm/www/delivery/avw.php?zoneid=318&amp;cb=INSERT_RANDOM_NUMBER_HERE&amp;n=ac98335f' border='0' alt='' /></a></iframe><script type='text/javascript' src='http://banners.andomedia.com/openx_gm/www/delivery/ag.php'></script>");
   
   $('div#medium_ad').html("<iframe id='aba3f44c' name='aba3f44c' src='http://banners.andomedia.com/openx_gm/www/delivery/afr.php?n=aba3f44c&amp;zoneid=320&amp;cb=INSERT_RANDOM_NUMBER_HERE' framespacing='0' frameborder='no' scrolling='no' width='300' height='250'><a href='http://banners.andomedia.com/openx_gm/www/delivery/ck.php?n=ac6ccf68&amp;cb=INSERT_RANDOM_NUMBER_HERE' target='_blank'><img src='http://banners.andomedia.com/openx_gm/www/delivery/avw.php?zoneid=320&amp;cb=INSERT_RANDOM_NUMBER_HERE&amp;n=ac6ccf68' border='0' alt='' /></a></iframe><script type='text/javascript' src='http://banners.andomedia.com/openx_gm/www/delivery/ag.php'></script>");
   
   $('div#listen_ad').html("<iframe id='afe6e875' name='afe6e875' src='http://banners.andomedia.com/openx_gm/www/delivery/afr.php?n=afe6e875&amp;zoneid=321&amp;cb=INSERT_RANDOM_NUMBER_HERE' framespacing='0' frameborder='no' scrolling='no' width='120' height='60'><a href='http://banners.andomedia.com/openx_gm/www/delivery/ck.php?n=a12ddbc1&amp;cb=INSERT_RANDOM_NUMBER_HERE' target='_blank'><img src='http://banners.andomedia.com/openx_gm/www/delivery/avw.php?zoneid=321&amp;cb=INSERT_RANDOM_NUMBER_HERE&amp;n=a12ddbc1' border='0' alt='' /></a></iframe><script type='text/javascript' src='http://banners.andomedia.com/openx_gm/www/delivery/ag.php'></script>");
						   
// ALERT VIP MEMBERS TO FIND THEIR PASSWORD
	$('.button_memberlogin').after("<div id=\"vip-help\" class=\"button_memberlogin\"><a href=\"#\"><span class=\"question\">Already a member, but no password?</span> Help!</a></div><div class=\"friendly-warning\"><p>We've got your password waiting for you! We'll deliver it to your email inbox right away, in three easy steps:<ol><li>Enter your email address in the field above. In the password field, enter \"BEN-FM\", and click \"Login\".</li><li>You'll get an error saying this password is incorrect. Don't worry! Click \"Send Reminder\" and we'll give you the real one.</li><li>Once you've checked your email and you've got your new password, come back here and log in with it.</li></ol></p><p>If you've got any problems, please don't hesitate to drop <a href=\"mailto:webmaster@ilikebenfm.com?Subject=Trouble logging in to the new ILIKEBENFM.com!\">tech support</a> an email.</p></div>");
	
	$('#vip-help').bind("click", function() {
		var warningDisplay = $("div.friendly-warning").css("display");
				if (warningDisplay == "none") {
					$("div.friendly-warning").slideDown("slow");
				}
				else {
					$("div.friendly-warning").slideUp("slow");
				}		
			return false;
		});


	$("input[ id *= 'AddCommentButton' ]").bind("click", function() {
			var comment = $('textarea.blogleavecomment').val();
			var naughtyWords =["4r5e", "5h1t", "5hit", "a55", "anal", "ar5e", "arrse", "arse", "ass", "ass-fucker", "assfucker", "assfukka", "asshole", "asswhole", "b!tch", "b00bs", "b17ch", "b1tch", "ballbag", "balls", "ballsack", "bastard", "beastiality", "bi+ch", "bitch", "bloody", "blowjob", "boiolas", "boobs", "booobs", "boooobs", "booooobs", "booooooobs", "breasts", "buceta", "bunny fucker", "buttmuch", "c0ck", "c0cksucker", "cawk", "chink", "cipa", "cl1t", "clit", "clit", "clits", "cnut", "cock", "cock-sucker", "cockface", "cockhead", "cockmunch", "cockmuncher", "cocksucker", "cocksuka", "cocksukka", "cok", "cokmuncher", "coksucka", "cox", "cum", "cunt", "cyalis", "d1ck", "dick", "dickhead", "dildo", "dirsa", "dlck", "dog-fucker", "doggin", "dogging", "donkeyribber", "doosh", "duche", "ejakulate", "f u c k e r", "f4nny", "fag", "faggitt", "faggot", "fanny", "fannyflaps", "fannyfucker", "fanyy", "fatass", "fcuk", "fcuker", "fcuking", "feck", "fecker", "fook", "fooker", "fuck", "fuck", "fucka", "fucker", "fuckers", "fuckhead", "fuckin", "fucking", "fuckingshitmotherfucker", "fuckwhit", "fuckwit", "fuk", "fuker", "fukker", "fukkin", "fukwhit", "fukwit", "fux", "fux0r", "gaylord", "goatse", "heshe", "hoare", "hoer", "hore", "jackoff", "jism", "kawk", "knob", "knobead", "knobed", "knobhead", "knobjocky", "knobjokey", "l3i+ch", "l3itch", "m0f0", "m0fo", "m45terbate", "ma5terb8", "ma5terbate", "master-bate", "masterb8", "masterbat*", "masterbat3", "masterbation", "masterbations", "masturbate", "mo-fo", "mof0", "mofo", "motherfucker", "motherfuckka", "mutha", "muthafecker", "muthafuckker", "muther", "mutherfucker", "n1gga", "n1gger", "nazi", "nigg3r", "nigg4h", "nigga", "niggah", "niggas", "niggaz", "nigger", "nob", "nob jokey", "nobhead", "nobjocky", "nobjokey", "numbnuts", "nutsack", "p0rn", "pawn", "penis", "penisfucker", "phuck", "pigfucker", "pimpis", "piss", "pissflaps", "porn", "prick", "pron", "pusse", "pussi", "pussy", "rimjaw", "rimming", "s.o.b.", "schlong", "scroat", "scrote", "scrotum", "sh!+", "sh!t", "sh1t", "shag", "shagger", "shaggin", "shagging", "shemale", "shi+", "shit", "shit", "shitdick", "shite", "shited", "shitey", "shitfuck", "shithead", "shitter", "slut", "smut", "snatch", "spac", "t1tt1e5", "t1tties", "teets", "teez", "testical", "testicle", "titfuck", "tits", "titt", "tittie5", "tittiefucker", "titties", "tittyfuck", "tittywank", "titwank", "tw4t", "twat", "twathead", "twatty", "twunt", "twunter", "v14gra", "v1gra", "viagra", "w00se", "wang", "wank", "wanker", "wanky", "whoar", "whore"]
			
			for ( var i=0, len=naughtyWords.length; i<len; ++i ){
				var searchResult = comment.search(naughtyWords[i]);
				if (searchResult == -1)
					{
					continue;
					}
					
				else 
					{
					$('textarea.blogleavecomment').after("<div class=\"friendly-warning\"><p>You kiss your mother with that mouth? Clean it up and try again...</p></div>");
					var warningDisplay = $("div.friendly-warning").css("display");
						if (warningDisplay == "none") {
							$("div.friendly-warning").slideDown("slow");
						}
						else {
							$("div.friendly-warning").slideUp("slow");
						}		
						return false;
					}
				}
		});


   //Remove LOGIN/REGISTER form from On-Air Contest posts
	if ( $("span.header span:contains('[ON-AIR]')").length > 0 ) {
		$("span.header span:contains('[ON-AIR]')").each(function() {
		$("div[ id *= 'UnivLoginVerify_pnlLogin' ], div.hdiv11, div[id*='MemberAuthenticated']").remove();
		});
	} else if ( $("span.header span:contains('[ONLINE*]')").length > 0 ) {
		$("span.header span:contains('[ONLINE*]')").each(function() {
		$("div[ id *= 'UnivLoginVerify_pnlLogin' ], div.hdiv11, div[id*='MemberAuthenticated']").remove();
		});
	}
	
	// Makes the AVPlayer on the Media page look nice
	$("div[ id *= 'AVPlayerFlash' ]").parents('td:eq(0)').after("<td id='look-listen-player'></td>");
     
	 //SUPERFISH MAIN MENU
	 $('ul.sf-menu').superfish({ autoArrows:  false,  dropShadows: false, delay: 1000 });

	// ALLOWS YOU TO SELECT ALL EXTERNAL LINKS WITH $('a:external')					
	$.expr[':'].external = function(obj){
    return !obj.href.match(/^mailto\:/) && (obj.hostname != location.hostname) && !obj.href.match(/^javascript\:/);
	};
	
	//FORCES ALL EXTERNAL LINKS TO OPEN IN NEW WINDOW
	$('a:external').attr("target","_blank");
	
	
	/*ShareThis  // AddThis
	****************************/
	var addME = '<br /><br /><a href"' + window.location + '" class="addthis" title="95.7 BEN FM - Share or Bookmark This Page"></a>';
	if ($('table.blog_entry').length > 0 ) {
	
		setTitle("blog");
		$('table.blog_entry td.mini').append(addME);
	}
	if ($('a.jumperlink[href*=TellAFriend]').length > 0 ) {
	
		setTitle("channel");
		$('a.jumperlink[href*=TellAFriend]').after(addME);
		$('a.jumperlink[href*=TellAFriend]').remove();
	}
	$.addthis('jzajac');
	
	
	/*Random Masthead Image
	****************************/
	
	//set total number of images
	var imgTotal = 4;
	
	//Generate Random Number
	var randomNumber = Math.round(Math.random()*(imgTotal-1));
    
	//Set up image array
	var image = new Array(imgTotal);
	image[0]="http://www.ilikebenfm.com/Pics/Global/masthead/masthead-ams.png";
	image[1]="http://www.ilikebenfm.com/Pics/Global/masthead/masthead-bcj.png";
	image[2]="http://www.ilikebenfm.com/Pics/Global/masthead/masthead-pcp.png";
	image[3]="http://www.ilikebenfm.com/Pics/Global/masthead/masthead-tph.png";
	
	//Replace Masthead
	$('img#ben-masthead').attr('src', image[randomNumber] );
	
	
	//Alternating Row colors for BEN'S Games
	$("table#bens-games tr:odd").css("background-color", "#fbbc66");
	
	//Listen Live || Pop-up Window
	$(".stream-popup, .onairnow a").popup({
		width: 650,
		height: 600,
		titlebar: true,
		status: true,
		resizeable: false,
		toolbar: false,
		scrollbars: false,
		menubar: false
	});
	
	//BEN'S Games
	$(".game-popup").popup({
		width: 650,
		height: 500,
		titlebar: true,
		status: true,
		resizeable: false,
		toolbar: false,
		scrollbars: false,
		menubar: false
	});
	
	/*Swap Out Podcast RSS link
	****************************/
	if ($("img[src$=rss_podcast_large.gif]").length > 0) {
		console.log("Large RSS");
		var rssLINKtest = $("img[src$=rss_podcast_large.gif]").parents('a:eq(0)').attr("href", "http://feeds.feedburner.com/BENFM-WOTW");
		console.log(rssLINKtest);
	}
	
	/*Generate RSS Menu
	****************************/
	$('input[src$=rss.gif], img[src$=rss.gif]').each(function(){
		// Selects RSS Images on Event Calendars					  
		if ($('img[src$=rss.gif]').length > 0) {
				//Grab Input ID
				var cssID = $(this).parents('a:eq(0)').attr("id");
				//Place RSS Image Icon in page
				$(this).parents('div:eq(0)').after("<div class=\"subscribe\"><a href=\"#\" id='" + cssID + "' class='rssIMG' >Subscribe</a></div>");
				}
		// Selects RSS Images everywhere else (Blogs, Channels)
		else {
				//Grab Input ID
				var cssID = $(this).attr("id");
				var rssInputID = "input#" + cssID;
				//Place RSS Image Icon in page
				$(this).parents('table:eq(0)').after("<div class=\"subscribe\"><a href=\"#\" id='" + cssID + "' class='rssIMG' >Subscribe</a></div>");
				}	
		//Remove RSS Input from page
		$(this).remove();
		//Detects What RSS Feed it is
		detectRSS(cssID);
	});
	
	// Binds new link to  drop-down action
	$("a.rssIMG").bind("click", function(){
			var optionDisplay = $("ul.ben-rss-links").css("display");
				if (optionDisplay == "none") {
					$("ul.ben-rss-links").slideDown("slow");
				}
				else {
					$("ul.ben-rss-links").slideUp("slow");
				}		
			return false;
	});
	
	//Check to see if the Fun Facts container exists, then grabs a random fact to populate
	if ($("div.label_img h4 img[src$=benformation-rc-header.jpg]").length > 0) {
		var factBox = $("div.label_img h4 img[src$=benformation-rc-header.jpg]").parents("div:eq(1)").find("tr.trdef td:eq(0)");
		getRandomFact(factBox);	
	}
	
	/*if ($("h4:contains('Fun Facts')").length > 0) {
		getRandomFact("tr.trdef td:eq(0)");	
	}*/
	
	// GOOGLE ANALYTICS TRACKING FOR PHOTO GALLERIES AND AV PLAYERS
	$("div[ id *= 'flash_gallery' ] > *").bind("click", function() {
		trackThis(this);
		});
	
	$("div[ id *= 'AVPlayerFlash' ] > *").bind("click", function() {
		trackThis(this);
		});
	
	$("div[ id *= 'Images_' ] > *").bind("click", function() {
		trackThis(this);
		});
	
	$("div[ id *= 'Audio_' ] > *").one("click", function() {
		trackThis(this);
		});
	
	$("a[href=*='.mp3']").bind("click", function() {
			trackThis(this);									  
		});
	
	$('a:external').click(function(){
 		pageTracker._trackPageview('/outgoing/'+ $(this).attr('href'));
		});
	
	

});

//RSS EMAIL SUBSCRIPTION || Pop-up Window
	$(".rss-email-popup").popup({
		width: 675,
		height: 550,
		titlebar: true,
		status: true,
		resizeable: false,
		toolbar: false,
		scrollbars: false,
		menubar: false
	});

//Detects What RSS Feed it is
function detectRSS(cssID) {
	var fbPage;
	var fbEmail;
	
	switch (cssID) {
		//BEN's Blog - ilikebenfm.com/blogs/ben
		case 'ctl00_MainLead_GenericControl9_uc688f37ff3c63410cb19318e35f4cf93a_imgbtnRSS':
			fbURL = "BEN-FM/blogs/ben";
			fbName = "BEN's Blog";
			break;

		//Celebrity Interviews Blog - ilikebenfm.com/blogs/interviews
		case 'ctl00_MainLead_GenericControl9_uc889c24e29b7d43dd8f09e211669a23fb_imgbtnRSS':
			fbURL = "BEN-FM/blogs/celebrity-interviews";
			fbName = "Celebrity Interviews Blog";
			break;			
			
		//Woman of the Week Blog - ilikebenfm.com/blogs/woman-of-the-week
		case 'ctl00_MainLead_GenericControl9_uc4f8c27d3fe994b44a54ecef4edcfc2eb_imgbtnRSS':
			fbURL = "BEN-FM/blogs/woman-of-the-week";
			fbName = "Woman of the Week Blog";
			break;
			
		//All Philly Blog - ilikebenfm.com/blogs/all-philly
		case 'ctl00_MainLead_GenericControl9_uc40d92d64d95d44abb0d440daabda78a1_hlinkRSS':
			fbURL = "BEN-FM/blogs/all-philly";
			fbName = "All Philly Blog";
			break;
			
		//Music News - ilikebenfm.com/music/news/
		case 'ctl00_MainLead_GenericControl9_uc55aeb07117cd4e0ba4909a90b7adb16b_ImageRss':
			fbURL = "BEN-FM/channels/music-news";
			fbName = "Music News";
			break;
			
		//Concert Calendar - ilikebenfm.com/music/concerts/listings.aspx
		case 'ctl00_MainLead_GenericControl9_ucceb5a1d5663745d79e2e5b23cb37b9f6_imgRss':
			fbURL = "BEN-FM/calendar/concerts";
			fbName = "Concert Calendar";
			break;
	
		//Events Calendar - ilikebenfm.com/events/listings.aspx
		case 'ctl00_MainLead_GenericControl9_ucdd74c44c10b84cbf8d5f3c8b402cb3e6_imgRss':
			fbURL = "BEN-FM/calendar/events";
			fbName = "Events Calendar";
			break;	
			
		//Community Events - ilikebenfm.com/events/community/listings.aspx
		case 'ctl00_MainLead_GenericControl9_uc850de8935a9f4e7e91f49f3b7a7d5ac9_imgRss':
			fbURL = "BEN-FM/calendar/community-events";
			fbName = "Community Events";
			break;	

		default:
			fbURL = "BEN-FM/all";
			fbName = "ILikeBenFM.com"
			break;
	}
	fbPage = "http://feeds.feedburner.com/" + fbURL;
	fbEmail = "http://feedburner.google.com/fb/a/mailverify?uri=" + fbURL

	rssHTML(fbPage, fbEmail, fbName);
}

//Inserts RSS Menu into HTML
function rssHTML(feed_url, email_url, feed_name) {
	$("div.subscribe").after("<ul class='ben-rss-links rssHide'><li class='info'><h3>Subscribe to " + feed_name + "</h3></li> <li id='rss-option'><h4>Option 1: RSS</h4><p>Take our RSS [ <a href='http://www.ilikebenfm.com/about/RSS/' target='_blank'>?</a> ] feed and use it with one of your favorite Feed Reader or News Aggregator software.</p><a href='" + feed_url + "' target='_blank'>Subscribe via RSS</a></li><li id='email-option'><h4>Option 2: Email</h4><p>Not too familiar with any RSS reader or News Aggregators? No problem! We offer updates via email!</p><a href='" + email_url + "' class='rss-email-popup'>Subscribe via Email</a></li><li id='all-feeds-option' class='info'><a href='http://www.ilikebenfm.com/about/RSS/#feeds-list'>All ILikeBenFM.com feeds</a></li></ul>");
}

//Adds Blog Title to Page Document Title
function setTitle(entryType) {
/*	var pgTitle = document.title;
	var blogTitle;
	switch(entryType) {
		case "blog":
			blogTitle = $('table.blog_entry span.largeheader:eq(0)').text();
			break;
		case "channel":
			blogTitle = $('span.header:eq(0)').text();
			break;
		default:
			blogTitle = "";
			break;
	}
	pgTitle += ': ' + blogTitle;
	document.title = pgTitle;*/
}

//Grabs headlines from Fun Facts channel RSS at random and displays them with a link generate another random one.
function getRandomFact(element) {
var fact;
		$.ajax({
			type: "GET",
			url: "_Shared/Channels/Public/RSS/GetXMLDataForRSS.ashx?ChannelID=2721",
			dataType: "xml",
			success: function(xml) {		
					var count = $(xml).find('item').length;
					var randomnumber = Math.floor(Math.random()*count);
					$(xml).find("item").each(function(i){
							if (i == randomnumber) {
								fact = $(this).find("title").text();
							}		
					});
					$(element).html("<span class='fun-fact'>" + fact + "</span><span class='fun-fact-link'><a class='minilink' id='get-another-random-fact' href='#'>Get another fun fact!</a></span>");
					$("a#get-another-random-fact").bind("click", function() {		
						getRandomFact(element);
						pageTracker._trackPageview('/fun-fact/#' + randomnumber);
						return false;
						});
					}
				});
	}
	
function trackThis(object) {
	var embedID = $(object).attr("id");	
	var thisURL = document.location+"";
	var splitURL = thisURL.split("?");
	var noQueryStringURL = splitURL[0]; 
	pageTracker._trackPageview(noQueryStringURL + "#" + embedID);
}

function URLEncode (clearString) {  
  var output = '';  
  var x = 0;  
  clearString = clearString.toString();  
  var regex = /(^[a-zA-Z0-9_.]*)/;  
  while (x < clearString.length) {  
    var match = regex.exec(clearString.substr(x));  
    if (match != null && match.length > 1 && match[1] != '') {  
        output += match[1];  
      x += match[1].length;  
    } else {  
      if (clearString[x] == ' ')  
        output += '+';  
      else {  
        var charCode = clearString.charCodeAt(x);  
        var hexVal = charCode.toString(16);  
        output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();  
      }  
      x++;  
    }  
  }  
  return output;  
}  
