/*
MMR Javascript File
AUTHOR: Jason Zajac & TJ Nicolaides
VERSION: 1.1
****************************/

$(document).ready(function() {
						   
/* AUDIO PLAYER TOOLTIPS */
$(function () {
  $('div[id*="Audio"]').each(function () {
	$(this).addClass("blog-audio-player");
	$(this).parent('div').addClass("blog-audio-container");
	$(this).after("<div class='blog-audio-tooltip'><p>To listen, <b>click the play button</b> here.</p><p>(<a href='mailto:webmaster@wmmr.com?subject=WMMR Web Comment - Difficulty Listening To Podcast Audio'>Having trouble? Click here!</a>)</p></div>");
	
    // options
    var distance = 30;
    var time = 250;
    var hideDelay = 500;
	
	if ($(this).height() > 50) {
		var init_bottom = 25;
	} else {var init_bottom = 10; }
	
    var hideDelayTimer = null;

    // tracker
    var beingShown = false;
    var shown = false;
    
    var trigger = $(this);
    var popup = $(trigger).siblings('.blog-audio-tooltip').css('opacity', 0);
	var popupWidth = $(trigger).width();
	
	// animate when the page loads
	setTimeout(function() {      
		beingShown = true;
		popup.css({
			  bottom: init_bottom, display: 'block' // brings the popup back in to view
			  })        
			.animate({opacity:1}).animate({left:'-=5px'}).animate({left:'+=5px'}).animate({left:'-=5px'}).animate({left:'+=5px'}).animate({left:'-=5px'}).animate({left:'+=2px'}, function () {
		  // reset the timer if we get fired again - avoids double animations
		  if (hideDelayTimer) clearTimeout(hideDelayTimer);
				  beingShown = false;
				  shown = true;
		  // store the timer so that it can be cleared in the mouseover if required
		  hideDelayTimer = setTimeout(function () {
			hideDelayTimer = null;
			popup.animate({
			  bottom: '-=' + distance + 'px',
			  opacity: 0
			}, time, 'swing', function () {
			  // once the animate is complete, set the tracker variables
			  shown = false;
			  // hide the popup entirely after the effect (opacity alone doesn't do the job)
			  popup.css('display', 'none');
			});
		  }, 4000);
		});
	}, 4000);

    // set the mouseover and mouseout on both element
    $([trigger.get(0), popup.get(0)]).mouseover(function () {
      // stops the hide event if we move from the trigger to the popup element
      if (hideDelayTimer) clearTimeout(hideDelayTimer);

      // don't trigger the animation again if we're being shown, or already visible
      if (beingShown || shown) {
        return;
      } else {
        beingShown = true;
        // reset position of popup box
        popup.css({
          bottom: init_bottom + 30,
          //left: -10,
          display: 'block' // brings the popup back in to view
        })
        // (we're using chaining on the popup) now animate it's opacity and position
        .animate({
          bottom: '-=' + distance + 'px',
          opacity: 1
        }, time, 'swing', function() {
          // once the animation is complete, set the tracker variables
          beingShown = false;
          shown = true;
        });
      }
    }).mouseout(function () {
      // reset the timer if we get fired again - avoids double animations
      if (hideDelayTimer) clearTimeout(hideDelayTimer);
      
      // store the timer so that it can be cleared in the mouseover if required
      hideDelayTimer = setTimeout(function () {
        hideDelayTimer = null;
        popup.animate({
          bottom: '-=' + distance + 'px',
          opacity: 0
        }, time, 'swing', function () {
          // once the animate is complete, set the tracker variables
          shown = false;
          // hide the popup entirely after the effect (opacity alone doesn't do the job)
          popup.css('display', 'none');
        });
      }, hideDelay);
    });
  });
});

/** Philly's Hottest Voting	**/
	$("div.votingOptions div.otherSubmission input, div.votingOptions div.otherSubmission label").remove();
	$("span.errorHeader").html("There was an error during submission. Please select one contestant.");
	$("input[id*=chkSongID]").live("click", function() {
			$("input[id*=chkSongID]").attr("checked", false);		
			$(this).attr("checked", true);
	});
					  						
// 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");

//Remove LOGIN/REGISTER form from On-Air Contest posts
if ( $("span.header span:contains('[ON-AIR]')").length > 0 ) {
	$("span.header").parents('div:eq(0)').next("div").remove();
} else if ( $("span.header span:contains('[ONLINE*]')").length > 0 ) {
	$("div[ id *= 'UnivLoginVerify_pnlLogin' ]").remove();
}
	
//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();
	});
}

	/** Facebook "Like" Button // ShareThis  // AddThis **/	
	var addME = '<div class="addthis-widget"><a class="addthis" title="Bookmark and Share WMMR.com"></a></div>';
	var page_name = returnDocument();

	if(page_name == "home.aspx" || page_name == null || page_name =="index.aspx" || page_name == "") {
			var pathName = returnPath();
			
		$('table.blogs_home_link').each(function(){
			var entryLink = $(this).find("a:last").attr("href");
			var fbLike = '<div class="facebook-like"><fb:like href="' + entryLink + '" layout="standard" show-faces="true" width="600" action="like" colorscheme="light"></fb:like></div>';
			$(this).after("<div class='share-widgets'>" + fbLike + "</div>");

		});
		
		$('a.jumperlink').each(function(){
			var entryLink = pathName + $(this).attr("href");
			var fbLike = '<div class="facebook-like"><fb:like href="' + entryLink + '" layout="standard" show-faces="true" width="600" action="like" colorscheme="light"></fb:like></div>';
			$(this).after("<div class='share-widgets'>" + fbLike + "</div>");
			
		});
		
		FB.XFBML.parse();

	}
	else if (page_name == "blogentry.aspx") {
		var fbLike = '<div class="facebook-like"><fb:like href="' + window.location.href + '" layout="standard" show-faces="true" width="600" action="like" colorscheme="light"></fb:like></div>';

		$('table.blog_entry td.mini').append("<div class='share-widgets'>" + fbLike +  addME + "</div>");
			$.addthis('jzajac');
		FB.XFBML.parse();
	}
	else if (page_name == "story.aspx") {
		var fbLike = '<div class="facebook-like"><fb:like href="' + window.location.href + '" layout="standard" show-faces="true" width="600" action="like" colorscheme="light"></fb:like></div>';	
		$('a.jumperlink[href*=TellAFriend]').after("<div class='share-widgets'>"+ addME + fbLike + "</div>");
				$.addthis('jzajac');
		$('a.jumperlink[href*=TellAFriend]').remove();	
		FB.XFBML.parse();
	}
	
							   	//PLACE ADS
$("div#bottom-banner").html("<iframe id='a50223c2' name='a50223c2' src='http://banners.andomedia.com/openx_gm/www/delivery/afr.php?n=a50223c2&amp;zoneid=329&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=a9c5e759&amp;cb=INSERT_RANDOM_NUMBER_HERE' target='_blank'><img src='http://banners.andomedia.com/openx_gm/www/delivery/avw.php?zoneid=329&amp;cb=INSERT_RANDOM_NUMBER_HERE&amp;n=a9c5e759' border='0' alt='' /></a></iframe><script type='text/javascript' src='http://banners.andomedia.com/openx_gm/www/delivery/ag.php'></script>");
$("div#ll_ad").html("<iframe id='ac9a0f7f' name='ac9a0f7f' src='http://banners.andomedia.com/openx_gm/www/delivery/afr.php?n=ac9a0f7f&amp;zoneid=331&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=a8721a67&amp;cb=INSERT_RANDOM_NUMBER_HERE' target='_blank'><img src='http://banners.andomedia.com/openx_gm/www/delivery/avw.php?zoneid=331&amp;cb=INSERT_RANDOM_NUMBER_HERE&amp;n=a8721a67' border='0' alt='' /></a></iframe><script type='text/javascript' src='http://banners.andomedia.com/openx_gm/www/delivery/ag.php'></script>");
		
	/** WMMR.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(){$(this).val("");});
	$("input#es-input").blur(function(){ emailValue = $(this).val(); $(this).val(emailValue);});
	$("input#subscribe-button").click(function(){
		formEmail = "http://www.feedburner.com/fb/a/mailverify?uri=WMMR/all&email=" + $("input#es-input").val();
		window.open(formEmail , "", "scrollbars=yes,width=550,height=520");								   
    });
	
	/** Random Masthead Image **/
	var mh = ["masthead-v1-foo-fighters.png", "masthead-v1-green-day.png", "masthead-v1-pearl-jam.png", "masthead-v2-nirvana.png", "masthead-v2-metallica.png", "masthead-v2-u2.png", "masthead-v2-guns-n-roses.png"];
	var mhpath = "http://www.wmmr.com/Pics/Global/masthead/";
	var randomNumber = 0;
	$('img#mmr-masthead').attr('src', mhpath + mh[Math.round(Math.random()*(mh.length-1))] );

	/**POP-UP WINDOWS **/
	/*AV PLAYER*/ $(".av-popup").popup({width: 675, height: 320});
	/*Listen Live HD1*/ $(".stream-popup-lc").popup({width: 680,height: 511});
	/*Listen Live HD2*/ $(".stream-popup-lc-hd2").popup({width: 680,height: 380});
	/*Webcam*/ $(".webcam-popup").popup({width: 980,height: 620,resizeable: true,scrollbars: true	});
	/** RSS **/ $(".rss-email-popup").popup({width: 675,height: 550});
	
	$('ul.sf-menu').superfish({autoArrows:false,dropShadows:false,delay:1000});
		
	/** Generate RSS Menu **/
	$('input[src$=rss.gif], img[src$=rss.gif]').each(function(){
		html = "<div class=\"subscribe\"><a href=\"#\" class='rssIMG' >Subscribe</a></div>";
		if ($('img[src$=rss.gif]').length > 0) {
				var cssID = $(this).parents('a:eq(0)').attr("id");
				$(this).parents('div:eq(0)').after(html);
			}
		else {
			var cssID = $(this).attr("id");
			var rssInputID = "input#" + cssID;
			$(this).parents('table:eq(0)').after(html);
		}	
		$(this).remove();
		detectRSS(cssID);
	});
	
	// Binds new link to  drop-down action
	$("a.rssIMG").bind("click", function(){
		if ($("ul.mmr-rss-links").css("display") == "none") {$("ul.mmr-rss-links").slideDown("slow");}
		else {$("ul.mmr-rss-links").slideUp("slow");}		
		return false;
	});

// GOOGLE ANALYTICS TRACKING FOR PHOTO GALLERIES AND AV PLAYERS
	
	
if (pageTracker) {
	$("div[ id *= 'flash_gallery' ] > *").bind("click", function() {
		trackThis("Flash Gallery", this);	
	});
	
	$("div[ id *= 'AVPlayerFlash' ] > *").bind("click", function() {
		trackThis("AV Player", this);
	});
	
	$("div[ id *= 'Images_' ] > *").bind("click", function() {
		trackThis("Photo Gallery", this);
	});
	
	$("div[ id *= 'Audio_' ] > *").one("click", function() {
		trackThis("Audio Embed", this);	
	});
	
	$("a[href=*='.mp3']").bind("click", function() {
		pageTracker._trackEvent('MP3 Download', $(this).context.hostname, $(this).attr('href'));
	});
	
	$('a:external').bind("click", function() {
		 pageTracker._trackEvent('Outbound Traffic', $(this).context.hostname, $(this).attr('href'));
	});
	
}
	
	$("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;
				}
			}
		});
	


});

//Detects What RSS Feed it is
function detectRSS(cssID) {
	var fbPage;
	var fbEmail;
	var cssID = cssID.split("_");
		cssID = cssID[3];
	switch (cssID) {
		//Preston and Steve Blog - Main - wmmr.com/shows/preston-and-steve/
		case 'uce2b03c24aa9a4a35bd98e2e4af6a7741':
			fbURL = "WMMR/blogs/preston-and-steve/main";
			fbName = "Preston and Steve's Show Notes";
			break;
			
		//Preston and Steve Blog - Celebrity Interviews - wmmr.com/shows/preston-and-steve/celebrity-interviews/
		case 'uce929694f61dc4e74b65b34ac806cb109':
			fbURL = "WMMR/blogs/preston-and-steve/celebrity-interviews";
			fbName = "Preston and Steve's Celebrity Interviews";
			break;
			
		//Preston and Steve Blog - LOST - wmmr.com/shows/preston-and-steve/lost/
		case 'uc3078860dec9946a8a5f59218fab9cbbd':
			fbURL = "WMMR/blogs/preston-and-steve/lost";
			fbName = "Preston and Steve's LOST blog";
			break;
			
		//Preston and Steve Blog - Troops - wmmr.com/shows/preston-and-steve/troops/
		case 'uc9fb24a3475fb4a42bfb4f30efa7ad55c':
			fbURL = "WMMR/blogs/preston-and-steve/troops";
			fbName = "Preston and Steve's Troops blog";
			break;
			
		//Pierre Robert Blog - wmmr.com/shows/pierre-robert
		//case 'ucdd3a6e8cce4d47658256b492ca8cf7c2':
				case 'ucdd3a6e8cce4d47658256b492ca8cf7c2':

			fbURL = "WMMR/blogs/pierre-robert";
			fbName = "Pierre Robert's Blog";
			break;

		//Jaxon Blog - wmmr.com/shows/jaxon
		case 'uc6cc950c54d5c4864a561cada2090e4bc':
			fbURL = "WMMR/blogs/jaxon";
			fbName = "Jaxon's Blog";
			break;			
			
		//Matt Cord Blog - wmmr.com/shows/matt-cord
		case 'ucc3273b7aaec64b39a023699f7183ef11':
			fbURL = "WMMR/blogs/matt-cord";
			fbName = "Matt's Blog";
			break;
			
		//Jacky Bam Bam Blog - wmmr.com/shows/jacky-bam-bam
		case 'uc4bc9cb6988e141d3a05ef5d5fd57c212':
			fbURL = "WMMR/blogs/jacky-bam-bam";
			fbName = "Jacky Bam Bam's Blog";
			break;
	
		//Markus Blog - wmmr.com/shows/markus
		case 'ucb465b696d0764e07826f57c385ab2e55':
			fbURL = "WMMR/blogs/markus";
			fbName = "Markus's Blog";
			break;			
	
		//Weekend Blog - wmmr.com/shows/markus
		case 'ucaf64c3b0e88246d98c246827ff7a38f7':
			fbURL = "WMMR/blogs/weekends";
			fbName = "the Weekend Blog";
			break;		
			
		//Vinyl Guide Blog - wmmr.com/shows/pierre-robert/vinyl-guide
		case 'uc0f078463bb3441d9939c50fff53f72f2':
			fbURL = "WMMR/blogs/pierre-robert/vinyl-guide";
			fbName = "Pierre's Vinyl Guide";
			break;		
			
		//Afternoon 12 Pack Blog - wmmr.com/shows/jaxon/afternoon-12-pack
		case 'ucb597f85867274bd7b955d727233bc875':
			fbURL = "WMMR/blogs/jaxon/afternoon-12-pack";
			fbName = "Jaxon's Afternoon 12 Pack Tracker";
			break;		
			
		//Local Shots Blog - wmmr.com/music/local-shots
		case 'ucedaabb8529e34c08acb613a7f4fad871':
			fbURL = "WMMR/blogs/local-shots";
			fbName = "the Local Shots Blog";
			break;		
			
		//Music News Channel RSS - wmmr.com/music/news/home.aspx
		case 'uc739e73a462ed4a90a3ba5c6d98daaf2f':
			fbURL = "WMMR/channels/music-news";
			fbName = "Music News";
			break;
			
		//Music Videos Channel RSS - wmmr.com/music/videos/home.aspx
		case 'uc3530ae9f841a4b1e8873063af047bd7d':
			fbURL = "WMMR/channels/music-videos";
			fbName = "Music Videos";
			break;
			
		//Events Calendar - wmmr.com/events
		case 'uc55718164861f4b8ca9b59b93fbd06d18':
			fbURL = "WMMR/calendar/events";
			fbName = "the MMR Events Calendar";
			break;					
			
		//MMaRmy Events Calendar - wmmr.com/events/mmarmy
		case 'ucac7e70528d9b42949a95f4263878eddc':
			fbURL = "WMMR/calendar/mmarmy-events";
			fbName = "the MMaRmy Events Calendar";
			break;		
			
		//Community Events Calendar - wmmr.com/events/community
		case 'ucd635deada7944d5b8ccceef529b26583':
			fbURL = "WMMR/calendar/community-events";
			fbName = "the Community Events Calendar";
			break;		
			
		//Pierre's Weekend Calendar - wmmr.com/shows/pierre-robert/weekend-calendar
		case 'uc9b4e961b31e34816a0919cbd0e016993':
			fbURL = "WMMR/calendar/pierres-weekend-calendar";
			fbName = "Pierre's Weekend Calendar";
			break;		
			
		//Concert Calendar - wmmr.com/events
		case 'uc1af4f654f9684fceb07943d78c2321c5':
			fbURL = "WMMR/calendar/concerts";
			fbName = "the MMR Concert Calendar";
			break;		
			
		//Local Shots Concert Calendar - wmmr.com/events
		case 'ucb7f5ee300a0a42c39c457190d6224307':
			fbURL = "WMMR/calendar/local-shots-concerts";
			fbName = "the Local Shots Concert Calendar";
			break;			
			
		default:
			fbURL = "WMMR/all";
			fbName = "WMMR.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='mmr-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://beta.wmmr.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.wmmr.com/about/RSS/#feeds-list'>All WMMR.com feeds</a></li></ul>");
}

function trackThis(category, object) {
	var embedID = $(object).attr("id");	
	var url = document.location+"";
	url = url.split("?");
	url = url[0]; 
	pageTracker._trackEvent(category, url, embedID);
}

// parseUri 1.2.2
function parseUri (str) {
	var	o   = parseUri.options,
		m   = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
		uri = {},
		i   = 14;

	while (i--) uri[o.key[i]] = m[i] || "";

	uri[o.q.name] = {};
	uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
		if ($1) uri[o.q.name][$1] = $2;
	});

	return uri;
};

parseUri.options = {
	strictMode: false,
	key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
	q:   {
		name:   "queryKey",
		parser: /(?:^|&)([^&=]*)=?([^&]*)/g
	},
	parser: {
		strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
		loose:  /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
	}
};



function returnDocument() {
        var file_name = document.location.href;
        var end = (file_name.indexOf("?") == -1) ? file_name.length : file_name.indexOf("?");
        return file_name.substring(file_name.lastIndexOf("/")+1, end).toLowerCase();
    }
	
function returnPath() {
		var path_name = parseUri(document.location.href).directory;
		path_name = window.location.protocol + window.location.host + path_name;
		return path_name;
}