Cufon.replace('#nav a,.cufon,h1,h2,h3,h4',{hover:true});
Cufon.replace('.cuffon',{hover:true,fontFamily: 'ITC Avant Garde Gothic'});
function clickclear(thisfield, defaulttext) {
	if (thisfield.value == defaulttext) { thisfield.value = ""; }
}
function clickrecall(thisfield, defaulttext) {
	if (thisfield.value == "") { thisfield.value = defaulttext; }
}

function changePlaylist(releaseId){
	document.getElementById('playlist_iframe').src = 'http://baroque.criticalrhythm.com/views/promotion/mplayer.php?cid=1&r='+ releaseId+'&w=200&h=160';
	return false;
}

function Linkify(inputText) {
	//URLs starting with http://, https://, or ftp://
	var replacePattern1 = /(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim;
	var replacedText = inputText.replace(replacePattern1, '<a href="$1" target="_blank">$1</a>');

	//URLs starting with www. (without // before it, or it'd re-link the ones done above)
	var replacePattern2 = /(^|[^\/])(www\.[\S]+(\b|$))/gim;
	var replacedText = replacedText.replace(replacePattern2, '$1<a href="http://$2" target="_blank">$2</a>');

	//Change email addresses to mailto:: links
	var replacePattern3 = /(\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,6})/gim;
	var replacedText = replacedText.replace(replacePattern3, '<a href="mailto:$1">$1</a>');

	return replacedText
}

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
	
$(document).ready(function(){
	var username='baroquerecords'; // set user name
	var format='json'; // set format, you really don't have an option on this one

	// GET LATEST TWEET
	var url='http://api.twitter.com/1/statuses/user_timeline/'+username+'.'+format+'?callback=?'; // make the url
	$.getJSON(url,function(tweet){ // get the tweets
		var str = '<p>'+Linkify(tweet[0].text)+'</p>';
		$(".latest-tweet").html(str);
		Cufon.replace('.latest-tweet p',{hover:true,fontFamily: 'ITC Avant Garde Gothic'});
	});


	// GET LATEST YOUTUBE VIDEO
	var yurl = 'http://gdata.youtube.com/feeds/api/users/'+username+'/uploads?alt='+format+'&callback=?&max-results=1';
	$.getJSON(yurl,function(data){ // get the tweets
        $.each(data.feed.entry, function(i,item) {
            var url = item['media$group']['media$content'][0]['url'];
			var content =   '<object width="280" height="160">'+
						    '<param name="movie" value="'+url+'"></param>'+
							'<param name="allowFullScreen" value="true"></param>'+
							'<param name="allowscriptaccess" value="always"></param>'+
							'<embed src="'+url+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="280" height="160"></embed></object>';
	        $(".yvideo").html(content);
		});
		
	});
});	
