//  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 !="/echotools/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="'+l+'" target="_blank">'+itunesHtml+'</a>');
		}else{
			document.write('<a href="'+l+'" target="_blank">'+html+'</a>');
		}
			
			if(after)document.write(after);
	}
}
		
function vipTickets(val){
	
	var icon;
	if(val == 'active') icon = '<a href="?content=tickets_policy">GET TICKETS &raquo;</a>';
	if(val == 'inactive') icon = '';
	if(val == 'closed') icon = 'Vip Tix Closed';
}

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 toggle(obj, t) {
	var el = document.getElementById(obj);
	if ( el.style.display != 'none'|| t== 'hide') {
		el.style.display = 'none';
	}
	else {
		el.style.display = 'block';
	}
	if(t == 'show')el.style.display = 'block';
}

function stripeOver(id) 
{
	//need to define CSS classes .alt and .over
	var target = document.getElementById(id);
	if(!target)return;// ijf element with passed id not found - forget it
	var striping = false;
    var objects = target.getElementsByTagName("div");//create an array of these tags within the target
	for (i=0; i < objects.length; i++) {
		var obj = objects[i];// refernce to the current objec in the loop
		if(obj.className == 'tour') //only affect objs with this classname
		{
			
			if (striping) {//toggle for applying stripe class
				//console.log(striping);
				obj.className += ' alt';
			}
			obj.onmouseover = function() 
			{
				this.classState = this.className;//local reference to the original class name
				this.className += " over";
			}
			
			obj.onmouseout = function() 
			{
				this.className = this.classState ;
			}
			striping = !striping;
		}
       
    }
}

function hover(id) 
{
	//need to define CSS classes .alt and .over
	var target = document.getElementById(id);
	if(!target)return;// ijf element with passed id not found - forget it
	var striping = false;
    var objects = target.getElementsByTagName("div");//create an array of these tags within the target
	for (i=0; i < objects.length; i++) {
		var obj = objects[i];// refernce to the current objec in the loop
		if(obj.className == 'hover_row') //only affect objs with this classname
		{
			
			obj.onmouseover = function() 
			{
				this.classState = this.className;//local reference to the original class name
				this.className += " over";
			}
			
			obj.onmouseout = function() 
			{
				this.className = this.classState ;
			}
			striping = !striping;
		}
       
    }
}

function stripeOver(id) 
{
	var target = document.getElementById(id);
	if(!target)return;// if element with passed id not found - forget it
	var striping = false;
    var objects = target.getElementsByTagName("div");//create an array of these tags within the target
	for (i=0; i < objects.length; i++) {
		var obj = objects[i];// refernce to the current objec in the loop
		if(obj.className == 'event_one') //only affect objs with this classname
		{
			
			if (striping) {//toggle for applying stripe class
				obj.className += ' alt';
			}
			obj.onmouseover = function() 
			{
				this.classState = this.className;//local reference to the original class name
				this.className += " over";
			}
			
			obj.onmouseout = function() 
			{
				this.className = this.classState ;
			}
			striping = !striping;
		}
       
    }
}
