//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,}))$/
var tld = '';

$(document).ready(function() {
   $('p#member-login-link a').click(function(){
      if ($('#login').is(':hidden')) {
         $('#login').slideDown('medium');	 
         $('p#member-login-link a').addClass('down');
      } else {
         $('#login').slideUp('medium');
         $('p#member-login-link a').removeClass('down');
      }
   });  
});


// Form validation for Brothers Only global login
function CkBOLogin(){
  if(document.frmLogin.fbo_email.value.length <= 0){
  alert('Please enter your user id.');
  document.frmLogin.fbo_email.focus();
  return false;
  }
  if(document.frmLogin.fbo_pwd.value.length <= 0){
  alert('Please enter your password.');
  document.frmLogin.fbo_pwd.focus();
  return false;
  }   
 }
 
function CkForgotLogin(){
  if(document.frmForgotLogin.fbo_email.value.length <= 0){
  alert('Please enter your user ID.');
  document.frmForgotLogin.fbo_email.focus();
  return false;
  }   
 }
 
function CkPayDues(){
  /*if(!document.frmPayDues.wp[0].checked && !document.frmPayDues.wp[1].checked){
  alert('Please select a payee.');
  return false;
  }*/
  if(document.frmPayDues.dollars.value.length <= 0){
  alert('Please enter an amount you wish to pay.');
  document.frmPayDues.dollars.focus();
  return false;
  }
  if(document.frmPayDues.dollars.value.length > 0){
   var sText = document.frmPayDues.dollars.value
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;
   for (i=0; i<sText.length  && IsNumber == true; i++){
     Char = sText.charAt(i);
	 if (ValidChars.indexOf(Char) == -1){ 
	   alert('Please enter only numbers in the dollars/cents fields');
       document.frmPayDues.dollars.select();
	   return false;
	  }
	 }
  }  
}

function ConfirmMsg(argMsgNumb){
  switch (argMsgNumb){
  case 1: 
	var TheMessage = 'You are about to be directed to PayPal\'s website to make a credit card payment.    \nAlexandria\-Fairfax Alumni uses PayPal to process its online payments safely and securely.\nYou don\'t have to create a PayPal account to make a payment.';
    break;
  case 2: 
	var TheMessage = 'Are you sure you want to delete your profile photo?';
    break;
  }
   var msg = confirm(TheMessage)
   if (msg==true) {  //if user pressed OK
   return true;  // location.href already in place
   } 
   else {  //if user pressed Cancel
   return false;  // blank action
   }
}
 // -----------------------------------------------
//  Add to favorites
// -----------------------------------------------
function AddToFavorites() {
  var title = document.title;
  var url = document.URL;
  if( document.all ) {
    window.external.AddFavorite( url, title);
  } else if (window.sidebar) { 
    window.sidebar.addPanel(title, url,""); 
  } else if( window.opera && window.print ) {
  return true;
  }
}

function InstantiateEmailPage(){
	str = 'mailto:?subject=A Link From New Orleans Alumni Chapter of Kappa Alpha Psi&body=' + escape(document.URL);
	document.location.href=str;
}

function ChangeFontSize(argSize){
	var ContainerDiv = document.getElementById("fontcontrol");
	var sClassName = 'font' + argSize;
	ContainerDiv.className = sClassName;
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

// Jump menu mods that open new browser window for external files/pages
function MM_jumpMenuNewWindow(targ,selObj,restore){ //v3.0
  var s = selObj.options[selObj.selectedIndex].value;
  window.open(s);
  if (restore) selObj.selectedIndex=0;
}

function CkChangePassword(){
  if(document.frmChangePassword.cp.value.length <= 0){
  alert('Please enter your CURRENT password.');
  document.frmChangePassword.cp.focus();
  return false;
  }
  if(document.frmChangePassword.np.value.length <= 0){
  alert('Please enter a NEW password.');
  document.frmChangePassword.np.focus();
  return false;
  }
  if(document.frmChangePassword.np.value != document.frmChangePassword.vnp.value){
  alert('Please make sure you verify the NEW password.');
  document.frmChangePassword.np.value = '';
  document.frmChangePassword.vnp.value = '';
  document.frmChangePassword.np.focus();
  return false;
  }
}

// Form validation for Brothers Only profile
function checkProfile(){
  if(document.frm1.fn.value.length <= 0){
  alert('Please enter your first name.');
  document.frm1.fn.focus();
  return false;
  }
  if(document.frm1.ln.value.length <= 0){
  alert('Please enter your last name.');
  document.frm1.ln.focus();
  return false;
  }
  if(document.frm1.chapter.value.length <= 0){
  alert('Please enter your chapter of initiation.');
  document.frm1.chapter.focus();
  return false;
  }
  if(document.frm1.dm1.value == 0){
  alert('Please select your date of initiation (e.g. SPR 1977).');
  document.frm1.dm1.focus();
  return false;
  }
  if(document.frm1.dm2.value == 0){
  alert('Please select your date of initiation (e.g. SPR 1977).');
  document.frm1.dm2.focus();
  return false;
  }
  if (re.test(document.frm1.email.value)){
  return true;
  }
  alert("There\'s a problem with the email address you entered.  Please re-check it and try again.")
  document.frm1.email.focus();
  return false;   
 }

// Form validation for Brothers Only global login
function CheckJoinList(){
  if(document.frmJoinList.email.value.length <= 0){
  alert('Please enter your email address.');
  document.frmJoinList.email.focus();
  return false;
  }
  if (re.test(document.frmJoinList.email.value)){
  return true;
  }
  alert("Please enter a valid email address and try again.")
  document.frmJoinList.email.focus();
  return false;   
 }
 
function openPhotoGallery(argGalleryID){
	var galwindow;
	galwindow = window.open('photo-gallery.asp?id='+ argGalleryID,'thegallery','height=700,width=800,resizable=no,scrollbars=no,toolbar=no,status=no');
	if (window.focus){
		galwindow.focus();
	}
  }