//-----------------------------------------------------------------------------
//	name:		CheckReferEmail		
//	purpose:	Validate Email Format
//
//	author:		MC					date: 3-12-02 
//-----------------------------------------------------------------------------
function checkreferEmail() {
	var EmailInfo = ""
	var reDigit = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
	
if (document.Submit_refer_a_friend.email1.value != ""){	
	if (!reDigit.test(document.Submit_refer_a_friend.email1.value)){
	EmailInfo += "\n     -  Referral One ";
	}
}
if (document.Submit_refer_a_friend.email2.value != ""){	
	if (!reDigit.test(document.Submit_refer_a_friend.email2.value)){
	EmailInfo += "\n     -  Referral Two ";
	}
}
if (document.Submit_refer_a_friend.email3.value != ""){	
	if (!reDigit.test(document.Submit_refer_a_friend.email3.value)){
	EmailInfo += "\n     -  Referral Three ";
	}
}
if (document.Submit_refer_a_friend.email4.value != ""){	
	if (!reDigit.test(document.Submit_refer_a_friend.email4.value)){
	EmailInfo += "\n     -  Referral Four ";
	}
}
if (document.Submit_refer_a_friend.email5.value != ""){	
	if (!reDigit.test(document.Submit_refer_a_friend.email5.value)){
	EmailInfo += "\n     -  Referral Five ";
	}
}
if (EmailInfo != "") {
EmailInfo ="_____________________________\n" +
"\n" +
"When Submitting Referrals, Please\n" +
"Provide Valid Email Addresses for:\n" +
EmailInfo + "\n_____________________________" +
"\nPlease re-enter and submit again!";
alert(EmailInfo);
return false;
}
else return true;
}
//-----------------------------------------------------------------------------
//	name:		ValidNumCount	
//	purpose:	validation of Numeric Data - Count
//
//	author:	MC						date: 3.15.02
//-----------------------------------------------------------------------------
function validnumcount(field, count) {
	if (field.length!=count ) {
	alert("Please enter a" +count+" digit number.");
	field.focus();
	field.select();
	}
}
//-----------------------------------------------------------------------------
//	name:		ValidNum	
//	purpose:	validation of Numeric Data
//
//	author:	MC						date: 3.15.02
//-----------------------------------------------------------------------------

function validnum(field, count) {
var valid = "0123456789"
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";
}
if (ok == "no") {
alert("Invalid entry!  Only numbers are accepted!");
field.focus();
field.select();
    }
if (field.length!=count ) {
alert("Please enter a " +count+" digit number.");
	field.focus();
	field.select();
	}
}
//-----------------------------------------------------------------------------
//	name:		checkFields	
//	purpose:	validation of Profile Data
//
//	author:	MC						date: 3.15.02
//-----------------------------------------------------------------------------

function checkFields() {
missinginfo = "";
var invalid = " "; // Invalid character is a space
var Numvalid = "0123456789"; //Valid Numeric Character
var temp;
var ok = "yes";
var tempaddress;
if (document.Sweeps_profile_entry.first_name.value.indexOf(invalid) > -1) {
missinginfo += "\n     -  First Name";
}
if (document.Sweeps_profile_entry.first_name.value == "") {
missinginfo += "\n     -  First Name";
}
if (document.Sweeps_profile_entry.last_name.value.indexOf(invalid) > -1) {
missinginfo += "\n     -  Last Name";
}
if (document.Sweeps_profile_entry.last_name.value == "") {
missinginfo += "\n     -  Last Name";
}
tempaddress = document.Sweeps_profile_entry.address.value.substring(0,2);
if (tempaddress.indexOf(invalid) > -1) {
missinginfo += "\n     -  sp Address "+ tempaddress ;
}
if (document.Sweeps_profile_entry.address.value == "") {
missinginfo += "\n     -  Address";
}
if (document.Sweeps_profile_entry.city.value.indexOf(invalid) > -1) {
missinginfo += "\n     -  City";
}
if (document.Sweeps_profile_entry.city.value == "") {
missinginfo += "\n     -  City";
}
if (document.Sweeps_profile_entry.state.value == "") {
missinginfo += "\n     -  State";
}
if (document.Sweeps_profile_entry.currentzip.value.indexOf(invalid) > -1) {
missinginfo += "\n     -  Current Zip/Postal Code";
}
if (document.Sweeps_profile_entry.currentzip.value == "") {
missinginfo += "\n     -  Current Zip/Postal Code";
}
if (document.Sweeps_profile_entry.daytime_area.value.indexOf(invalid) > -1) {
missinginfo += "\n     -  Daytime Phone - Area Code";
}
if (document.Sweeps_profile_entry.daytime_area.value == "") {
missinginfo += "\n     -  Daytime Phone - Area Code";
}
var ok = "yes";
for (var i=0; i<document.Sweeps_profile_entry.daytime_area.value.length; i++) {
temp = "" + document.Sweeps_profile_entry.daytime_area.value.substring(i, i+1);
if (Numvalid.indexOf(temp) == "-1")ok = "no";
}
if (ok == "no") {
missinginfo += "\n     -  Valid Daytime Phone - Area Code";
}
if (document.Sweeps_profile_entry.daytime_area.value.length!=3) {
missinginfo += "\n     -  Valid Daytime Phone - Area Code";
}
if (document.Sweeps_profile_entry.daytime_xchange.value.indexOf(invalid) > -1) {
missinginfo += "\n     -  Daytime Phone - Exchange";
}
if (document.Sweeps_profile_entry.daytime_xchange.value == "") {
missinginfo += "\n     -  Daytime Phone - Exchange";
}
var ok = "yes";
for (var i=0; i<document.Sweeps_profile_entry.daytime_xchange.value.length; i++) {
temp = "" + document.Sweeps_profile_entry.daytime_xchange.value.substring(i, i+1);
if (Numvalid.indexOf(temp) == "-1")ok = "no";
}
if (ok == "no") {
missinginfo += "\n     -  Valid Daytime Phone - Exchange";
}
if (document.Sweeps_profile_entry.daytime_xchange.value.length!=3) {
missinginfo += "\n     -  Valid Daytime Phone - Exchange";
}
if (document.Sweeps_profile_entry.daytime_num.value.indexOf(invalid) > -1) {
missinginfo += "\n     -  Daytime Phone - Number";
}
if (document.Sweeps_profile_entry.daytime_num.value == "") {
missinginfo += "\n     -  Daytime Phone - Number";
}
var ok = "yes";
for (var i=0; i<document.Sweeps_profile_entry.daytime_num.value.length; i++) {
temp = "" + document.Sweeps_profile_entry.daytime_num.value.substring(i, i+1);
if (Numvalid.indexOf(temp) == "-1")ok = "no";
}
if (ok == "no") {
missinginfo += "\n     -  Valid Daytime Phone - Number";
}
if (document.Sweeps_profile_entry.daytime_num.value.length!=4) {
missinginfo += "\n     -  Valid Daytime Phone - Number";
}
if (document.Sweeps_profile_entry.bday_month.value.indexOf(invalid) > -1) {
missinginfo += "\n     -  Birthday - Month";
}
if (document.Sweeps_profile_entry.bday_month.value == "") {
missinginfo += "\n     -  Birthday - Month";
}
var ok = "yes";
for (var i=0; i<document.Sweeps_profile_entry.bday_month.value.length; i++) {
temp = "" + document.Sweeps_profile_entry.bday_month.value.substring(i, i+1);
if (Numvalid.indexOf(temp) == "-1")ok = "no";
}
if (ok == "no") {
missinginfo += "\n     -  Valid Birthday - Month";
}
if (document.Sweeps_profile_entry.bday_month.value.length!=2) {
missinginfo += "\n     -  Valid Birthday - Month";
}
if (document.Sweeps_profile_entry.bday_day.value.indexOf(invalid) > -1) {
missinginfo += "\n     -  Birthday - Day";
}
if (document.Sweeps_profile_entry.bday_day.value == "") {
missinginfo += "\n     -  Birthday - Day";
}
var ok = "yes";
for (var i=0; i<document.Sweeps_profile_entry.bday_day.value.length; i++) {
temp = "" + document.Sweeps_profile_entry.bday_day.value.substring(i, i+1);
if (Numvalid.indexOf(temp) == "-1")ok = "no";
}
if (ok == "no") {
missinginfo += "\n     -  Valid Birthday - Day";
}
if (document.Sweeps_profile_entry.bday_day.value.length!=2) {
missinginfo += "\n     -  Valid Birthday - Day";
}
if (document.Sweeps_profile_entry.bday_year.value.indexOf(invalid) > -1) {
missinginfo += "\n     -  Birthday - Year";
}
if (document.Sweeps_profile_entry.bday_year.value == "") {
missinginfo += "\n     -  Birthday - Year";
}
var ok = "yes";
for (var i=0; i<document.Sweeps_profile_entry.bday_year.value.length; i++) {
temp = "" + document.Sweeps_profile_entry.bday_year.value.substring(i, i+1);
if (Numvalid.indexOf(temp) == "-1")ok = "no";
}
if (ok == "no") {
missinginfo += "\n     -  Valid Birthday - Year";
}
if (document.Sweeps_profile_entry.bday_year.value.length!=4) {
missinginfo += "\n     -  Valid Birthday - Year";
}
if (document.Sweeps_profile_entry.zip.value.indexOf(invalid) > -1) {
missinginfo += "\n     -  Target ZIP/Postal Code";
}
if (document.Sweeps_profile_entry.zip.value == "") {
missinginfo += "\n     -  Target ZIP/Postal Code";
}

var checkstr = "0123456789";
var DateField = (document.Sweeps_profile_entry.bday_month.value) + (document.Sweeps_profile_entry.bday_day.value) + (document.Sweeps_profile_entry.bday_year.value);
var Datevalue = "";
var DateTemp = "";
var seperator = ".";
var day;
var month;
var year;
var leap = 0;
var err = 0;
var i;
   err = 0;
   DateValue = DateField;
   /* Delete all chars except 0..9 */
   for (i = 0; i < DateValue.length; i++) {
	  if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {
	     DateTemp = DateTemp + DateValue.substr(i,1);
	  }
   }
   DateValue = DateTemp;
   /* Always change date to 8 digits - string*/
   /* if year is entered as 2-digit / always assume 20xx */
   if (DateValue.length == 6) {
      DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2); }
   if (DateValue.length != 8) {
      err = 19;}
   /* year is wrong if year = 0000 */
   year = DateValue.substr(4,4);
   if (year == 0) {
      err = 20;
   }
   /* Validation of month*/
   month = DateValue.substr(2,2);
   if ((month < 1) || (month > 12)) {
      err = 21;
   }
   /* Validation of day*/
   day = DateValue.substr(0,2);
   if (day < 1) {
     err = 22;
   }
   /* Validation leap-year / february / day */
   if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
      leap = 1;
   }
   if ((month == 2) && (leap == 1) && (day > 29)) {
      err = 23;
   }
   if ((month == 2) && (leap != 1) && (day > 28)) {
      err = 24;
   }
   /* Validation of other months */
   if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
      err = 25;
   }
   if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
      err = 26;
   }
   /* if 00 ist entered, no error, deleting the entry */
   if ((day == 0) && (month == 0) && (year == 00)) {
      err = 0; day = ""; month = ""; year = ""; seperator = "";
   }
   /* if no error, write the completed date to Input-Field (e.g. 13.12.2001) */
   if (err == 0) {
      DateField.value = day + seperator + month + seperator + year;
   }
   /* Error-message if err != 0 */
   else {
missinginfo += "\n     -  Valid Birth Date";
    
   }

if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.Sweeps_profile_entry.email.value)){
}
else {
missinginfo += "\n     -  Valid Email Address";
}

if (missinginfo != "") {
missinginfo ="_____________________________\n" +
"You failed to correctly fill in your:\n" +
missinginfo + "\n_____________________________" +
"\nPlease re-enter and submit again!";
alert(missinginfo);
return false;
}
else return true;
}

//-----------------------------------------------------------------------------
//	name:		InactivateItem	
//	purpose:	
//
//	author:							date: 
//-----------------------------------------------------------------------------
function InactivateItem(url) {
	var blnInactivate = false
	
	blnInactivate = confirm('Cancel this subscription?');
	if (blnInactivate){
		return true;
		//document.location = url;
		}
	else{
		return false;
		}
}
//-----------------------------------------------------------------------------
//	name:		InactivateItem2	
//	purpose:	post form on confirm, without a form
//					replaces the function above, which
//					does not seem to work with all browsers
//
//	author:		sdh					date:	4/26/01
//-----------------------------------------------------------------------------
function InactivateItem2() {
		
	if (confirm('Cancel this subscription?')){
		return true;
		}
	else{
		return false;
		}
}
//-----------------------------------------------------------------------------
//	name:		ComingSoon		
//	purpose:	
//
//	author:							date: 
//-----------------------------------------------------------------------------
function ComingSoon() {
	alert('This feature is coming soon.');
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-----------------------------------------------------------------------------
//	name:		CheckEmail		
//	purpose:	Validate Email Format
//
//	author:		MC					date: 3-12-02 
//-----------------------------------------------------------------------------
//  Last Changed: 2-28-03 TQ
//-----------------------------------------------------------------------------
function checkEmail(myForm) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(myForm.email.value)){
return (true)
}
alert("Invalid E-mail Address! Please re-enter.")
return (false)
}
//-----------------------------------------------------------------------------
//	name:		PopUp Window		
//	purpose:	Pop Up new Window
//
//	author:		TQ					date: 
//-----------------------------------------------------------------------------
var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+'';
win = window.open(mypage,myname,settings);
}




