//  pass the url  and  optionally a width, height, and window name
function spawnWindow(url,name,w,h){
	if(w == undefined) w = 320;
	if(h == undefined) h = 240;
	if(name == undefined) name = "popWindow";
	var newWindow = window.open(url,name,"toolbar=0,scrollbars=1,resizable=1,width="+w+",height="+h+"\"");
 } 
 function ifExists(val, htmlOut, other){
	if (typeof other=='undefined') other = "";
	
	if (val.length && val != "false" && val !="/images/spacer.gif"){
	document.write (htmlOut);
	}else{
		if(other.length)
		{
			document.write (other);
		}
	}
}

var albumItunes = '<img src="/images/badgeitunes.gif" alt="iTunes" title="get album from iTunes" border="0" />';
function createLink(str, html, itunesHtml,after)
{
	if(!itunesHtml)itunesHtml = '<img src="/images/itunes.gif" alt="iTunes" title="get from iTunes" border="0" />';
	//alert(itunesHtml);
	var l;
	if (str.length)
	{
		if (!str.match("http://"))
		{
			l = 'http://'+str;
		}else{
			l = str;
		}
		
		if(str.match('phobos.apple.com')){
			document.write('<a href="'+str+'" target="_blank">'+itunesHtml+'</a>');
		}else{
			document.write('<a href="'+str+'" target="_blank">'+html+'</a>');
		}
			
			if(after)document.write(after);
	}
}
function makeMailTo(name, domain, linkText)
{

	if(!name || !domain)return false;
	if (!linkText) linkText = name+'@'+domain;
	document.write('<a href="mailto:'+name+'@'+domain+'">'+linkText+'</a>');
}

function fancyTable(id){
	overClass = 'over';
	var table = document.getElementById(id);
	if(!table)return;
    var rows = table.getElementsByTagName("tr");
    for (var i=0; i < rows.length; i++) {
		var r = rows[i];
		if(i % 2 != 0) // striping
		{
			rows[i].bgColor = "#383d3c";
		}
		r.onmouseover = function() { this.className=overClass };
		r.onmouseout = function() { this.className='' };
	}
}
