
var emailerror1="Please input your email address";
var emailerror2="Bad Syntax of Email address";

function newalert(errorstring) {
   alert(errorstring);
};

function Validator(theForm)
{ if (theForm.email.value =="")
  { theForm.email.focus();
    newalert(emailerror1);
    return (false); }
	
  var checkOK = "@";
  var checkStr = theForm.email.value;
  var allValid = false;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
      {
 allValid = true;
 break;
      }
  }
 if (!allValid)
  {
    theForm.email.focus();
    newalert(emailerror2);
    return (false);
  }
  var checkOK = ".";
  var checkStr = theForm.email.value;
  var allValid = false;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
      {
 allValid = true;
 break;
      }
  }
 if (!allValid)
  {
    theForm.email.focus();
    newalert(emailerror2);
    return (false);
  }
  var checkOK = "@???????????????????????º???0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_.";
  var checkStr = theForm.email.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
 break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    theForm.email.focus();
    newalert(emailerror2);
    return (false);
  }
  return (true);
};

function Mp3Fix(className){
	var testClass = new RegExp("(^|\\\\s)" + className + "(\\\\s|$)");
	var testClass2 = new RegExp("(^|\\\\s)" + ' '+className + "(\\\\s|$)");
	var tag =  "*";
	var elm = document;
	var elements = (elm.all)? elm.all : elm.getElementsByTagName(tag);
	var current;
	var songTitle;
	var length = elements.length;
	for(var i=0; i<length; i++){
		current = elements[i];
		if(testClass.test(current.className) || testClass2.test(current.className)){
			sname=current.href;
			songTitle=current.title;
			current.href="javascript:jukebox({title:'"+songTitle+"',filename:'" + sname +"'})";
		}
	}
}

var pendingTrack;

function jukebox(mp3_obj)
{
	var id= "mp3player";
	var loc = BASEURL+"player.html";
	var attr = "toolbar=0,titlebar=0, resizable=no, scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=419,height=554,left=1000,top=0";
	
	newWin=window.open('', id,attr);
	newLoc = newWin.location.href.split('/');
	newLoc = BASEURL+newLoc[newLoc.length-1];
	
	if(newLoc!=loc){
		newWin=window.open(loc, id,attr  );
		pendingTrack=mp3_obj;
		newWin.focus();
	} else {
		newWin.addTrack(mp3_obj);
		newWin.focus();
	}
}

