window.addEvent('domready', function(){
	if ($('browse-by-letter')) {
		$('browse-by-letter').set({
			'events': {
				'change': function(){
					var letter = $(this).get('value');
					
					if (letter) {
						$('listing-section').getElements('.listing-item').addClass('hide');
						$('listing-section').getElements('#artist-list-bottom').removeClass('hide');
						$('listing-section').getElements('.first-' + letter).removeClass('hide');
					} else {
						$('listing-section').getElements('.listing-item').addClass('hide');
						$('listing-section').getElements('.is_featured').removeClass('hide');
						$('listing-section').getElements('#artist-list-bottom').addClass('hide');
					}
					
					return false;
				}
			}
		});
	}

	if ($('listen-button')) {
		$('listen-button').set({
			'events': {
				'click': function(){
					window.open('/listen.php','listen','width=450,height=260,menubar=0,resizable=0,scrollbars=0,status=0');
					return false;
				}
			}
		});
	}
	
	
	if ($('listen-button-footer')) {
		$('listen-button-footer').set({
			'events': {
				'click': function(){
					window.open('/listen.php','listen','width=450,height=260,menubar=0,resizable=0,scrollbars=0,status=0');
					return false;
				}
			}
		});
	}
});


/*
	parseUri 1.2.1
	(c) 2007 Steven Levithan <stevenlevithan.com>
	MIT License
*/

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;
};

Request.HTML.implement({
    processHTML: function(text){
        var match = text.match(/<body[^>]*>([\s\S]*?)<\/body>/i);
        text = (match) ? match[1] : text;
       
        var container = new Element('div');
       
        return $try(function(){
            var root = '<root>' + text + '</root>', doc;
            if (Browser.Engine.trident){
                doc = new ActiveXObject('Microsoft.XMLDOM');
                doc.async = false;
                doc.loadXML(root);
            } else {
                doc = new DOMParser().parseFromString(root, 'text/html');
            }
            root = doc.getElementsByTagName('root')[0];
            for (var i = 0, k = root.childNodes.length; i < k; i++){
                var child = Element.clone(root.childNodes[i], true, true);
                if (child) container.grab(child);
            }
            return container;
        }) || container.set('html', text);
    }  
});

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*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
	}
};