// Bay Area Producers Conference
// Common scripts

/* clearField()
* clears passed field value if the default value exists
*/
function clearField(thisField,newColor)
{
	var defaultValue = "Type your email address";
	var trimmed = thisField.value.replace(/^\s+|\s+$/g, '') ;
	
	if(trimmed == defaultValue)
	{
		thisField.value = "";
	}

	thisField.style.color = newColor;
		
	return true;
}

function checkEmail(str)
{
		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		
        if(str.length > 64)
			return emailError();
		
		if (str.indexOf(at)==-1)
		   return emailError();

		if ( str.indexOf(at)== -1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
		   return emailError();

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr + 1)
		    return emailError();

		if (str.indexOf(at,(lat+1))!=-1)
		    return emailError();

		if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
		    return emailError();

		if (str.indexOf(dot,(lat+2))==-1)
		    return emailError();
		
		if (str.indexOf(" ")!=-1)
            return emailError();

        return true;	
}

function emailError()
{

   alert("The email address you entered appears to be invalid.\r\nPlease re-enter your email address again.");
    
   document.forms[0].from.focus();
   document.forms[0].from.select();

   return false;

}
 
function getSponsors(){

	var html  = "<map name='imap_sponsors' id='imap_sponsors'><area shape='rect' coords='1,1,140,97' href='http://openlabs.com' target='_blank' alt='Open Labs' />";
  		html += "<area shape='rect' coords='258,0,386,95' href='http://tydeupmedia.info' target='_blank' alt='Tyde Up Media' />";
		html += "<area shape='rect' coords='386,1,496,95' href='http://ascap.com' alt='ASCAP' />";
		html += "<area shape='rect' coords='496,1,634,94' href='http://iStandardProducers.com' alt='iStandard Producers' />";
		html += "<area shape='rect' coords='633,0,742,94' href='http://17hertz.com' target='_blank' />";
		html += "</map>";
		html += "<img src='Images/sponsors.jpg' alt='Sponsors' usemap='#imap_sponsors' />";
		
	document.write(html);
	document.close();
}
