//Regexp for testing email addy validity
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
// Write out current date from user's system
function writeCurrDate(){
	var days=new Array(7);
	days[0]="Sunday";
	days[1]="Monday";
	days[2]="Tuesday";
	days[3]="Wednesday";
	days[4]="Thursday";
	days[5]="Friday";
	days[6]="Saturday";
	var months=new Array(12);
	months[1]="January";
	months[2]="February";
	months[3]="March";
	months[4]="April";
	months[5]="May";
	months[6]="June";
	months[7]="July";
	months[8]="August";
	months[9]="September";
	months[10]="October";
	months[11]="November";
	months[12]="December";
	var time=new Date();
	var lmonth=months[time.getMonth() + 1];
var lday=days[time.getDay()];
	var date=time.getDate();
	var year=time.getYear();
	if (navigator.appName == "Microsoft Internet Explorer" && (parseInt(navigator.appVersion) >2))
	{year= ", " + year;
 document.write(lday + ", ");
	 document.write(lmonth);
	 document.write(" " + date + year);}
	if (navigator.appName == "Microsoft Internet Explorer" && (parseInt(navigator.appVersion) ==2))
	{year= ", " + (1900 + year);
 document.write(lday + ", ");
	 document.write(lmonth);
	 document.write(" " + date + year);}
	if (navigator.appName == "Netscape" && (parseInt(navigator.appVersion) >3))
	{year= ", " + (1900 + year);
 document.write(lday + ", ");
	 document.write(lmonth);
	 document.write(" " + date + year);}
	if (navigator.appName == "Netscape" && (parseInt(navigator.appVersion) ==3))
	{year= ", "  + year;
 document.write(lday + ", ");
	 document.write(lmonth);
	 document.write(" " + date + year);}
}

//Grab system year for copyright designation in global footer
function writeCopyright(){
  var d=new Date()
  document.write(d.getFullYear())
}

// Form validation for main login module (homepage)
function CkITKLOGIN(){
  if(document.frmITKLOGIN.itkemail.value.length <= 0){
  alert('Please enter your email address.');
  document.frmITKLOGIN.itkemail.focus();
  return false;
  }
  if(document.frmITKLOGIN.itkpwd.value.length <= 0){
  alert('Please enter your password.');
  document.frmITKLOGIN.itkpwd.focus();
  return false;
  }
  if (re.test(document.frmITKLOGIN.itkemail.value)){
  return true;
  }
  alert("There\'s a problem with the email address you entered.  Please re-check it and try again.")
  document.frmITKLOGIN.itkemail.focus();
  return false;   
 }
 
// Form validation for ITK event search
function CkEventSearch(){
  if(document.frmEventSearch.mo.value == 0){
  alert('Please select a month to search events.');
  document.frmEventSearch.mo.focus();
  return false;
  }
  if(document.frmEventSearch.yr.value == 0){
  alert('Please select a year to search events.');
  document.frmEventSearch.yr.focus();
  return false;
  }  
 }
 
var urlAddress = "http://www.alwaysintheknow.com/";
var pageName = "A Gem Am I\'s \"In The Know\"";
function addToFavorites(){
if (window.external){
  window.external.AddFavorite(urlAddress,pageName) 
}
else {
  alert("Sorry! Your browser doesn't support this function."); 
  }
}
// --> 
 
// Jump menu JS
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

//Open window to view support activites

function _openSupport(args1,args2,args3){
  var url = "support.asp?id=" + args1 + "&sd=" + args2 + "&td=" + args3
  window.open(url,"","width=560,height=560,scrollbars=yes,resize=no");
}

//Open window to view photo gallery
function _openPhotoGallery(args1){
  var url = "photo_gallery_viewer.asp?gid=" + args1
  window.open(url,"","width=540,height=570,scrollbars=yes,resize=no");
}

//validate send/to boxes

function CkSendTo(){
  if (re.test(document.frmSendPage.email.value)){
  return true;
  }
  alert("There\'s a problem with the email address you entered.  Please re-check it and try again.")
  document.frmSendPage.email.focus();
  return false; 
}

//Status message function
function showMsg(args){
  window.status=args;
  document.stat = true;
}

// ITK member signup validation

function CkFrmMbrSignup(){
  if(document.frmMbrSignup.fn.value.length <= 0){
  alert('Please enter your first name.');
  document.frmMbrSignup.fn.focus();
  return false;
  }
  if(document.frmMbrSignup.ln.value.length <= 0){
  alert('Please enter your last name.');
  document.frmMbrSignup.ln.focus();
  return false;
  }
  if(document.frmMbrSignup.zip.value.length <= 4){
  alert('Please enter your zip code.');
  document.frmMbrSignup.zip.focus();
  return false;
  }  
  if(document.frmMbrSignup.age.value == 0){
  alert('Please select your age group.');
  document.frmMbrSignup.age.focus();
  return false;
  }
  if(document.frmMbrSignup.gender.value == 0){
  alert('Please select your gender.');
  document.frmMbrSignup.gender.focus();
  return false;
  }
  if(document.frmMbrSignup.gender.howhear == 0){
  alert('Please indicate how you learned of \"In The Know\".');
  document.frmMbrSignup.howhear.focus();
  return false;
  }        
  if (re.test(document.frmMbrSignup.email.value)){
  return true;
  }
  alert("There\'s a problem with the email address you entered.  Please re-check it and try again.")
  document.frmMbrSignup.email.focus();
  return false;    
}

//Account validation form

function CkITKValidate(){
  if(document.frmITKValidate.pwd1.value.length <= 4){
  alert('Please enter a desired account password.');
  document.frmITKValidate.pwd1.focus();
  return false;
  }    
  if(document.frmITKValidate.pwd1.value !=  document.frmITKValidate.pwd2.value){
  alert('Your password doesn\'t confirm. Please make sure you carefully enter your password.');
  document.frmITKValidate.pwd1.focus();
  return false;
  }
}

//Validate ITK member event submission

function checkPostEvent(){
  if(document.frmPostEvent.title.value.length <= 0){
  alert('Please enter the name of the event.');
  document.frmPostEvent.title.focus();
  return false;
  }
  if(document.frmPostEvent.loc.value.length <= 0){
  alert('Please enter the location of the event (e.g. Chicago, IL).');
  document.frmPostEvent.loc.focus();
  return false;
  }
  if(document.frmPostEvent.edate1.value.length <= 0){
  alert('Please select a event start date.');
  document.frmPostEvent.edate1.focus();
  return false;
  }  
  if(document.frmPostEvent.ehour.value.length <= 0 || document.frmPostEvent.emin.value.length <= 0 || document.frmPostEvent.etod.value.length <= 0){
  alert('Please enter a starting time for this event.');
  document.frmPostEvent.ehour.focus();
  return false;
  }
}

// Validate ITK Report email sign-up only
function CkFrmITKRSignup(){
  if (re.test(document.frmITKRSignup.email.value)){
  return true;
  }
  alert("There\'s a problem with the email address you entered.  Please re-check it and try again.")
  document.frmITKRSignup.email.focus();
  return false; 
}


