$(document).ready(function() {
	
	$.each($('.mailer'),function() {
		Email.mailto(this,'ejt');
	});
	
	// ENABLE NEW TAB/WINDOW LINKS TO EXTERNAL SITES
	$("a[rel*='external']").click(function() {
		window.open($(this).attr('href'), 'external', '');
		return false;
	});
	
	$('#golh-golh').click(function() {
			clearSearch(this);
	});
	
    $('.song').each(function(){

        audio_file = $(this).attr('id');

        $(this).flash({
                swf: '/assets/swf/player.swf',
                flashvars:
                {
                    file:'/assets/mp3/' + audio_file + '.mp3'
                },
                allowscriptaccess:'always',
                wmode:'opaque',
                height:24,
				width:340
        });
    });
	
	/* /E N A B L E  M A I L I N G  L I S T
	$('#kinetic').click(function() {
		window.scrollTo(0,0);
		$('#text_email').focus();
		clearSearch('#text_email');
	});
	/*
	
	/* E N A B L E  S L I D E S H O W
	$('#masthead_bg_images').cycle({
    	speed:4000
	});
	*/
});

/*function downloadFile(fileName) {
	$.ajax({
		type: 'POST',
		url: proxyUrl,
		data: 'method=downloadProxy&fileName=' + fileName + '&ip=' + ip + '&referer=' + referer + '&url=' + url,
		success: function(r) {
			window.location = 'http://' + fileName;
		}
	});

}*/

function clearSearch(i) {
	if($(i).val() == 'Your email') {
		$(i).val('');
	}
}

var Media = {
	video: function(targ,url,w,h) {
		$(targ).flash({
			swf: url,
			width:w,
			height:h
		});
	},
	vimeo: function(targ,vid_id,w,h) {
		$(targ).flash({
			swf: 'http://vimeo.com/moogaloop.swf?clip_id=' + vid_id + '&amp;server=vimeo.com',
			width:w,
			height:h,
			allowfullscreen:'true',
			allowscriptaccess:'always'			
		});
	}
};

var Email = {
    mailto: function (link, name, domain) {
		if (!domain) {
            domain = "ejtmusic.com";
        }

        link.href = "mailto:" + name + "@" + domain;
        link.onMouseover = null;
    }
};