iphone = false;
try {
 iphone = navigator.userAgent.match(/iPhone/);
} finally { 
}

function tracklistButton(id) {
}
function coverartButton(kw) {
	window.open('images/'+kw+'_L.jpg', kw+'|coverart', 'scrollbars=no,width=700,height=700');
}
function playButton(kw) {
	if (jQuery.browser.msie) {
		window.location = 'mixes/'+kw+'.html';
	} else if (iphone) { 
		window.location = 'mixes/'+kw+'.mp3';
	} else {
		window.open('mixes/'+kw+'.html', kw+'|player', 'scrollbars=no,width=350,height=453');
	}
}
function downloadButton(kw) {
	window.location = 'mixes/'+kw+'.zip';
}
function trackButton(type, data) {
	if (type == 'link') {
		var loc = data;
	} else if (type == 'beatport') {
		if (iphone) { 
			alert("Sorry, Beatport's Flash UI does not work on the iPhone.");
		} else {
			var loc = "https://www.beatport.com/en-US/html/content/release/detail/"+data;
		}
	} else if (type == 'discogs') {
		var loc = "http://www.discogs.com/release/"+data;
	}
	if (loc != undefined) {
		window.open(loc, '_blank');
	}
}

$(document).ready( function() {
	if (jQuery.browser.msie) {

	$(".reveal").each( function() {
		$(this).find(".tracklist").css("display", "none");
		$(this).find(".trli").toggle( function() {
			$(this).parent().parent().parent().find(".tracklist").css("display", "block");
		}, function() {
			$(this).parent().parent().parent().find(".tracklist").css("display", "none");
		});	
	});
		
  } else {
														
	$(".reveal").each( function() {
		var _tracklistHeight = parseInt($(this).find(".mix").css("height"));
		$(this).find(".tracklist").css("display", "none");
		var _hoverHeight = parseInt($(this).find(".mix").css("height"));
		$(this).find(".mix").css("height", 25);
		$(this).find(".mix").css("overflow", "hidden");
		$(this).find(".thumb").css("height", 22);
		$(this).hover( function() {
			var _mode = $(this).find(".tracklist").css("display");
			if (_mode == "none") {
				$(this).find(".mix").css("height", _hoverHeight);
			} else {
				$(this).find(".mix").animate({ height: _tracklistHeight }, 180, "easeOutQuint");
			};
			$(this).find(".thumb").css("height", 45);
		}, function() {
			var _indicator = $(this).find(".num").hasClass("open");
			if (_indicator != true) {
				var _mode = $(this).find(".tracklist").css("display");
				if (_mode == "none") {
					$(this).find(".mix").css("height", 25);
					$(this).find(".thumb").css("height", 22);
				} else {
					$(this).find(".mix").animate({ height: 25 }, 180, "easeOutQuint");
					$(this).find(".thumb").animate({ height: 22 }, 180, "easeOutQuint");
				}
			};
		});
		$(this).find(".trli").toggle( function() {
			$(this).parent().parent().parent().animate({ height: _tracklistHeight }, 180, "easeOutQuint");
			$(this).parent().parent().parent().find(".tracklist").css("display", "block");
		}, function() {
			$(this).parent().parent().parent().animate({ height: _hoverHeight }, 180, "easeOutQuint");
			$(this).parent().parent().parent().find(".tracklist").css("display", "none");
		});
	});
	
	$(".r1").toggle( function() {
		$(this).find(".num").addClass("open");
	}, function() {
		$(this).find(".num").removeClass("open");
	});
	
	}
});

function loadTracklist(filename) {
	var _path = "text/tl-"+filename+".xml";
	var xmlDoc;
	if (window.XMLHttpRequest) {
		xmlDoc=new window.XMLHttpRequest();
		xmlDoc.open("GET",_path,false);
		xmlDoc.send("");
		xmlDoc=xmlDoc.responseXML;
	} else if (ActiveXObject("Microsoft.XMLDOM")) { // IE 5 and IE 6
		xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async=false;
		xmlDoc.load(_path);
	}
	document.write("<table class=\"tracklist\" cellspacing=0 cellpadding=0>");
	document.write("<tr><th class=\"first\">No.</th><th>Artist</th><th>Track</th><th>Label</th></tr>");
	var x = xmlDoc.getElementsByTagName("item");
	for (i=0;i<x.length;i++) { 
		var _ti = x[i].getAttribute("vTi");
		var _ar = x[i].getAttribute("vAr");
		var _la = x[i].getAttribute("vLa");
		if (x[i].getAttribute("vBp") != null) {
			var _li = "beatport";
			var _co = x[i].getAttribute("vBp");
		} else if (x[i].getAttribute("vCo") != null) {
			var _li = "discogs";
			var _co = x[i].getAttribute("vCo");
		} else {
			var _li = "link";
			var _co = x[i].getAttribute("vLi");
		}
		document.write("<tr onclick=\"javascript:trackButton('"+_li+"',"+_co+");\"><td class=\"first\">1</td><td>"+_ar+"</td><td>"+_ti+"</td><td>"+_la+"</td></tr>");
	}
	document.write("</table>");
}