function newsletterSignup(){
	window.open('', 'newsletterwin', 'width=500,height=300,scrollbars,resizable');
}

function playit()
		{
		    if (navigator.appName == "Netscape")
				{
				if (document.wmpPlayer.GetReadyState() > 3)
  				document.wmpPlayer.Play();
				}
			else
				{
				if (document.wmpPlayer.ReadyState > 3)
					document.wmpPlayer.Play();
				}
		}

	function pauseit()
		{
		    if (navigator.appName == "Netscape")
				{
					if (document.wmpPlayer.GetPlayState() == 2)
          document.wmpPlayer.Pause();
				}
			else
				{
					if (document.wmpPlayer.PlayState == 2)
						document.wmpPlayer.Pause();
				}
		}
	function stopit()
		{
		    if (navigator.appName == "Netscape")
				{
					if (document.wmpPlayer.GetPlayState() == 2)
          document.wmpPlayer.Stop();
				}
			else
				{
					if (document.wmpPlayer.PlayState == 2)
						document.wmpPlayer.Stop();
				}
		}


function openWindow(sel, restore){
    if (sel.selectedIndex > 0) {
        if ((sel.options[sel.selectedIndex].value).indexOf("http://") != -1) {
            window.open(sel.options[sel.selectedIndex].value);
        }
        else {
            window.location = sel.options[sel.selectedIndex].value;
        }
    
        if (restore) {
            sel.selectedIndex = 0;
        }
    }
}

function toggle (targetId) {
	if (document.getElementById) {
		var target = document.getElementById( targetId );
			if (target.style.display == "none") {
				target.style.display = "";
			} else {
				target.style.display = "none";
			}
	}
}


// Removes all characters which appear in string bag from string s.
function stripCharsInBag (s, bag)

{   var i;
    var returnString = "";

    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }

    return returnString;
}

// Removes all whitespace characters from s.
function stripWhitespace (s)
{
   if (isEmpty(s))
	return s;
   return stripCharsInBag (s, " ");
}


// Check whether string is empty.
function isEmpty(s)
{   

    return ((s == null) || (s.length == 0))
}


function isNumericNN (s,necessary)
{   var i;

    s =	stripWhitespace(s);
    if (isEmpty(s)&&(!necessary))
        return true;
    if (isEmpty(s)&&(necessary))
        return false;

    for (i = 0; i < s.length; i++)
    {
        var c = s.charAt(i);
        if (! isDigit(c) )
	        return false;
    }
    return true;
}

// Returns true if character c is a digit
function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}

// isYear returns true if string s is a valid year.  Must be 4 digits
function isYearNN (s,necessary)
{
   s =	stripWhitespace(s);
   if (isEmpty(s)&&(!necessary))
	return true;
    if (!isNumericNN(s,true))
	return false;
    if (parseInt(s)<1900)
	return false;
    return (s.length == 4);
}

// isMonth returns true if string s is a valid
// month number between 1 and 12.
function isMonth (s)
{
   if (isEmpty(s))
	return false;
    var c= s.charAt(0);
    if (c == "0")
	s = s.substring(1,s.length);
    var num = parseInt(s);
    return isIntegerInRange (num, 1, 12);
}

// isDay returns true if string s is a valid
// day number between 1 and 31.
function isDay (s)
{

   if (isEmpty(s))
	return false;
    var c= s.charAt(0);
    if (c == "0")
	s = s.substring(1,s.length);
    var num = parseInt(s);
    return isIntegerInRange (num, 1, 31);
}

// isIntegerInRange returns true if string s is an integer
// within the range of integer arguments a and b, inclusive.
function isIntegerInRange (s, a, b)
{   if (isEmpty(s))
	return false;
    if (!isInteger(s, false)) return false;
    var num = parseInt (s);
    return ((num >= a) && (num <= b));
}

function isInteger (s)
{
   var i;
    for (i = 0; i < s.length; i++)
    {
        var c = s.charAt(i);
        if (!isDigit(c)) return false;
    }
    return true;
}

var daysInMonth = new Array(5);
daysInMonth[1] = 31;
daysInMonth[2] = 29;   // must programmatically check this
daysInMonth[3] = 31;
daysInMonth[4] = 30;
daysInMonth[5] = 31;
daysInMonth[6] = 30;
daysInMonth[7] = 31;
daysInMonth[8] = 31;
daysInMonth[9] = 30;
daysInMonth[10] = 31;
daysInMonth[11] = 30;
daysInMonth[12] = 31;

// isDate returns true if string arguments form a valid date.
function isDateValid (s,necessary)
{


   s =	stripWhitespace(s);

   if (isEmpty(s)&&(!necessary))
	return true;
   if (isEmpty(s)&&(necessary))
	return false;

    var slash = "/";
    var counter = 0;
    var c;

    for (i = 0; i < s.length; i++)
    {
        c = s.charAt(i);
        if (slash.indexOf(c) >-1)
		counter++;
    }

    if (counter !=2)
	return false;

    var firstocc = -1;
    var secondocc = -1;
    for (i = 0; i < s.length; i++)
    {
        c = s.charAt(i);
        if (slash.indexOf(c) >-1){
	    if (firstocc<0)
	    	firstocc = i;
	    else
		secondocc = i;
	}
    }

    month = s.substring(0,firstocc);
    day  = s.substring(firstocc+1,secondocc);
    year = s.substring(secondocc+1,s.length);

    var c= month.charAt(0);
    if (c == "0")
	month = month.substring(1,month.length);

    c= day.charAt(0);
    if (c == "0")
	day = day.substring(1,day.length);

   // catch invalid years (not  4-digit) and invalid months and days.
   if (! (isYearNN(year,true) && isMonth(month) && isDay(day))) return false;

    // catch invalid days, except for February
    if (day > daysInMonth[month]) return false;

    return true;
}

function validateRegistration(frm) {  	

	ErrorMsg = "";
	
	rtnvalue = isEmpty(stripWhitespace(frm.firstName.value));
	
	if (rtnvalue){
		ErrorMsg = ErrorMsg + "* First Name is a required field\n";
	}
	
	rtnvalue = isEmpty(stripWhitespace(frm.lastName.value));
	if (rtnvalue){
		ErrorMsg = ErrorMsg + "* Last Name is a required field\n";
	}
	
	rtnvalue = isEmpty(stripWhitespace(frm.screenName.value));
	if (rtnvalue || frm.screenName.value.length<5){
			ErrorMsg = ErrorMsg + "* The login name you requested is not valid.  Your login name must be between five and thirty two characters\n";
	}
	
	rtnvalue = isEmpty(stripWhitespace(frm.password.value));
	if (rtnvalue || frm.password.value.length<7){
			ErrorMsg = ErrorMsg + "* The password you provided is invalid. Your password must be at least seven characters\n";
	}
	
	rtnvalue = isEmpty(stripWhitespace(frm.confirmpassword.value));
	if (rtnvalue || (frm.password.value!=frm.confirmpassword.value)){
			ErrorMsg = ErrorMsg + "* Confirm password is invalid or does not match your password\n";
	}
	
	rtnvalue = isEmpty(stripWhitespace(frm.email.value));
		if (rtnvalue){
			ErrorMsg = ErrorMsg + "* The email address provided is invalid\n";
	}
	// use element index since the dateBirth name of the input generated by ATG has forward slashes
    rtnvalue = isEmpty(stripWhitespace(frm.dateOfBirth.value));
    if (rtnvalue){
        ErrorMsg = ErrorMsg + "* Please enter a valid date of birth.  Date format must be mm/dd/yyyy\n";
    }
    if(!rtnvalue) {
        rtnvalue = isDateValid(frm.dateOfBirth.value, true) ;
         if (!rtnvalue){
            ErrorMsg = ErrorMsg + "* Please enter a valid date of birth.  Date format must be mm/dd/yyyy\n";
        }
    }


	if (ErrorMsg.length>0){
		try{
			alert(ErrorMsg);
			return false;
		}
		catch (e){}
	}
	return true;
}// validate

function validatePasswdUpdate(frm) {
	ErrorMsg = "";

	rtnvalue = isEmpty(stripWhitespace(frm.oldpassword.value));
	if (rtnvalue || frm.oldpassword.value.length<1){
			ErrorMsg = ErrorMsg + "* You must supply your old password\n";
	}

	rtnvalue = isEmpty(stripWhitespace(frm.password.value));
	if (rtnvalue || frm.password.value.length<7){
			ErrorMsg = ErrorMsg + "* The password you provided is invalid. Your password must be at least seven characters\n";
	}

	rtnvalue = isEmpty(stripWhitespace(frm.confirmpassword.value));
	if (rtnvalue || (frm.password.value!=frm.confirmpassword.value)){
			ErrorMsg = ErrorMsg + "* Confirm password is invalid or does not match your password\n";
	}

	if (ErrorMsg.length>0){
		try{
			alert(ErrorMsg);
			return false;
		}
		catch (e){}
	}
	return true;

}

function validateRegUpdate(frm) {  	

	ErrorMsg = "";
	
	rtnvalue = isEmpty(stripWhitespace(frm.firstName.value));
	
	if (rtnvalue){
		ErrorMsg = ErrorMsg + "* First Name is a required field\n";
	}
	
	rtnvalue = isEmpty(stripWhitespace(frm.lastName.value));
	if (rtnvalue){
		ErrorMsg = ErrorMsg + "* Last Name is a required field\n";
	}

	// use element index since the dateBirth name of the input generated by ATG has forward slashes
	if(frm.elements.length>0) {
	    index=0;
        while(index<frm.elements.length) {
            if(frm.elements[index].name=="/wmg/olm/visitor/services/registration/handler/VisitorProfileHandler.value.dateOfBirth") {
                rtnvalue = isEmpty(stripWhitespace(frm.elements[index].value));
                if (rtnvalue){
                    ErrorMsg = ErrorMsg + "* Please enter a valid date of birth.  Date format must be mm/dd/yyyy\n";
                }
                if(!rtnvalue) {
                    rtnvalue = isDateValid(frm.elements[index].value, true) ;
                     if (!rtnvalue){
                        ErrorMsg = ErrorMsg + "* Please enter a valid date of birth.  Date format must be mm/dd/yyyy\n";
                    }
                }
                break;
            }
            index++;
        }
	}
		

	if (ErrorMsg.length>0){
		try{
			alert(ErrorMsg);
			return false;
		}
		catch (e){}
	}
	return true;
}// validate


       function popWin( url, name, width, height, scroller ) {
       var outStr = 'height=' + height + ',width=' + width;
       if (scroller != 'true') {
       outStr = outStr +
       ',menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes';
       }
       else {
       outStr = outStr +
       ',menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no';
       }
       window.open(url, name, outStr);
       }

       function popWin2( url, name, width, height, scroller ) {
       var outStr = 'height=' + height + ',width=' + width;
        if (scroller != 'true') {
       outStr = outStr +
       ',menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no';
       }
       else {
       outStr = outStr +
       ',menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no';
       }
       window.open(url, name, outStr);
       }