//  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 spawnVideo(url){
	var newWindow = window.open(url,'videoWindow','toolbar=0,scrollbars=1,resizable=1,width=1024,height=640');	
 } 
 function spawnPress(url){
	var newWindow = window.open('pop.php'+url+'&content=press','videoWindow','toolbar=0,scrollbars=1,resizable=1,width=1024,height=640');	
}
 function spawnPhoto(url){
	var newWindow = window.open('/pop.php'+url+'&content=photos','videoWindow','toolbar=0,scrollbars=1,resizable=1,width=1024,height=640');	
 }
 
 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 vipTickets(val){
	
	var icon;
	if(val == 'active') icon = '<a href="/page.php?content=tickets_policy" style="font-weight:bold;font-size:11px;">PRESALE TIX&raquo;</a>';
	if(val == 'inactive') icon = '';
	if(val == 'closed') icon = 'Closed';
	if(icon)document.write(icon);
	//if(console)console.log('icon = ' +icon);
}

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 popImage(img){
	windowHandle = window.open('','pop','scrollbars=yes,resizable=yes,width=420,height=420');
	var tmp = windowHandle.document;
	var html= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'+
				'<html xmlns="http://www.w3.org/1999/xhtml">'+
				'<head>'+
				'<title>image</title>'+
				'<scr'+'ipt language="javas'+'cript">'+ 
				'var picUrl = "'+img+'"; '+
				'var NS = (navigator.appName=="Netscape")?true:false; '+
				'function sizeWin() { '+
				'   iWidth = (NS)?window.innerWidth:document.body.clientWidth; \n'+
				'   iHeight = (NS)?window.innerHeight:document.body.clientHeight; \n'+
				'   iWidth = (document.images[0].width - iWidth)+30; '+
				'   iHeight = (document.images[0].height - iHeight) + 50; '+
				'   window.resizeBy(iWidth, iHeight); '+
				'   self.focus(); '+
				' }; \n'+
				'</scr'+'ipt>\n'+ 
				'</head><body  style="background:#000 url(images/window_bg.jpg);margin:0;padding:5;color:#fff;text-align:center;" onload="sizeWin();" onblur="window.close();">'+
				'<div><img src="'+img+'" border="0"></div>'+
				'<button onclick="self.close();" style="margin:4px;">close</button>'+
				'</body></html>';
	tmp.write(html);			
	tmp.close();

}

function setupThumbs(){
	window.name = "main";
	
	var pagelinks=document.getElementsByTagName("a")
	for (var i=0; i<pagelinks.length; i++){ 
	
		if (pagelinks[i].className == "thumb" ){
			
			pagelinks[i].onclick=function(){
				popImage(this);
				return false;
			}
		}
	}
}

function blogComments(n , l ){
	var numComments = parseInt(n);	
	//if(numComments >= 10){
		//document.write('<a href="'+l+'" ><span class="numComments">'+n+' comments</span></a>  | ');
	//}else{
		document.write('<a href="'+l+'" ><span class="numComments">Leave a comment</span></a>');
	//}
	
}

				
