// JavaScript source file
// Revision date: 10/07/08
// Contains all JScript functions used on headendband.com web pages

function submitDownloadForm()
{
    var str=document.theForm.email.value;
    var at="@";
    var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
    var emess="Please enter a valid e-mail address.";
    
    if(document.theForm.Name.value.length < 1)
        {
		alert("Please enter your name (your first name is sufficient).");
		document.theForm.Name.focus();
		return false;
		}

	if (str.indexOf(at)==-1)
        {
		alert(emess);
        document.theForm.email.focus();
		return false;
		}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
        {
		alert(emess);
        document.theForm.email.focus();
		return false;
		}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
        {
		alert(emess);
        document.theForm.email.focus();
		return false;
		}
    
    if (str.indexOf(at,(lat+1))!=-1)
        {
		alert(emess);
        document.theForm.email.focus();
		return false;
		}
    
    if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
        {
		alert(emess);
        document.theForm.email.focus();
		return false;
		}
    
    if (str.indexOf(dot,(lat+2))==-1)
        {
		alert(emess);
        document.theForm.email.focus();
		return false;
		}
		
	if (str.indexOf(" ")!=-1)
        {
		alert(emess);
        document.theForm.email.focus();
		return false;
		}
    
    document.theForm.submit();
}


function submitCommentForm()
{
    var str=document.contactForm.email.value;
    var at="@";
    var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
    var emess="Please enter a valid e-mail address to join our mailing list.";
    
    if(document.contactForm.Comments.value.length < 1)
        {
		alert("Please enter a message for the band in the text box.");
		document.theForm.Comments.focus();
		return false;
		}
    if(document.contactForm.list.checked)
    {
	if (str.indexOf(at)==-1)
        {
		alert(emess);
        document.theForm.email.focus();
		return false;
		}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
        {
		alert(emess);
        document.theForm.email.focus();
		return false;
		}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
        {
		alert(emess);
        document.theForm.email.focus();
		return false;
		}
    
    if (str.indexOf(at,(lat+1))!=-1)
        {
		alert(emess);
        document.theForm.email.focus();
		return false;
		}
    
    if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
        {
		alert(emess);
        document.theForm.email.focus();
		return false;
		}
    
    if (str.indexOf(dot,(lat+2))==-1)
        {
		alert(emess);
        document.theForm.email.focus();
		return false;
		}
		
	if (str.indexOf(" ")!=-1)
        {
		alert(emess);
        document.theForm.email.focus();
		return false;
		}
    }
    
    document.contactForm.submit();
}

function openPlayer(mylink, windowname)
{
if (! window.focus) { return true; }
var href;

if (typeof(mylink) == 'string') { href=mylink; }
else { href=mylink.href; }

window.open(href,windowname,'width=570,height=175,scrollbars=no,resizable=no,toolbar=no,location=no');

return false;
}


function showTrackInfo(x,y)
{
    var album, total, elem, a, i;

    if(x == 1) { album='sens'; total=9; }

    for(i = 1; i <= total; i++)
    {
        elem = album + i + '';
        a = document.getElementById(elem);
        a.className = 'hidden';
    }

    elem = album + y + '';
    a = document.getElementById(elem);
    a.className = 'shown';
}


sfHover = function()
{
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++)
        {
		sfEls[i].onmouseover=function() { this.className+=" sfhover"; }
		sfEls[i].onmouseout=function() { this.className=this.className.replace(new RegExp(" sfhover\\b"), ""); }
        }
}

if(window.attachEvent)
    {
    if (window.XMLHttpRequest)
        { // IE7, mozilla, safari, opera 9
        }
    else
        { // IE6, older browsers
        window.attachEvent("onload", sfHover);
        }
    }
    
