//<!--

//
// slideshow functions
//
function openSlide(sDN)
{
	var sScript = "slideshow.aspx"
	
	window.open(sScript+"?DN="+sDN,"_blank","menubar=0,toolbar=0,location=0,directories=0,status=0,scrollbars=0,resizable=0,width=620px,height=420px,center=1")
	//window.open(sScript+"?DN="+sDN,"_blank")
} 

///<summary>
///Validates the email field
///</summary>
function EmailValidate(Email)
{
	var re=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/;
	return re.test(Email);
}

///<summary>
///Validates the profile page fields.
///</summary>
function ValidateProfile()
{
    var oForm = document.forms['aspnetForm'];
    if (!oForm) 
    {
        oForm = document.aspnetForm;
    }
	
    var RetVal = true;
    if( oForm.FirstName.value.length < 1)
    {
        alert("Please enter your first name");
        RetVal = false;        
    }
    else if(oForm.LastName.value.length < 1)
    {
		alert("Please enter your last name");
        RetVal = false;
    }
    else if(oForm.Street.value.length < 1)
    {
		alert("Please enter your student society");
        RetVal = false;
    }
    else if( oForm.Email.value.length < 1)
    {
        alert("Please enter your email address");
        RetVal = false;        
    }
    else if( !EmailValidate(oForm.Email.value))
    {
		alert("The email address you have entered is invalid. Please enter your valid email address");
        RetVal = false;
    }
    else if(oForm.Degree.value == '')
    {
        alert("Please enter in your degree/level obtained.");
        //AttemptFocus(oForm.Degree);
        RetVal = false;
    }
    else if(oForm.Discipline.value == '')
    {
        alert("Please enter in your discipline.");
        RetVal = false;
    }
    else if(oForm.AttachmentUpload.value == '')
    {
        alert("Please upload your resume.");
        RetVal = false;
    }
    
    return RetVal;
}//ValidateProfile

///<summary>
///Validates the update user profile page fields.
///</summary>
function ValidateEditProfile()
{
    var oForm = document.forms['aspnetForm'];
    if (!oForm) 
    {
        oForm = document.aspnetForm;
    }
	
    var RetVal = true;
    if( oForm.FirstName.value.length < 1)
    {
        alert("Please enter your first name");
        RetVal = false;        
    }
    else if(oForm.LastName.value.length < 1)
    {
		alert("Please enter your last name");
        RetVal = false;
    }
    else if(oForm.Street.value.length < 1)
    {
		alert("Please enter your student society");
        RetVal = false;
    }
    else if( oForm.Email.value.length < 1)
    {
        alert("Please enter your email address");
        RetVal = false;        
    }
    else if( !EmailValidate(oForm.Email.value))
    {
		alert("The email address you have entered is invalid. Please enter your valid email address");
        RetVal = false;
    }
	else if (oForm.NewPassword.value != '' && oForm.ConfirmPassword.value != '' && oForm.NewPassword.value != oForm.ConfirmPassword.value)
	{
		alert(" Your password and confirmed password must match");
		RetVal = false;
	}
    
    return RetVal;
}//ValidateEditProfile

///<summary>
/// Validate the ProfileSignUp Register form
///</summary>
function ValidateRegister()
{
	var sErrorMsg = '';
	RetVal = true;
	
	var oForm = document.forms.Register;
    if (!oForm) 
    {
        oForm = document.forms.Register;
    }

    
    
    if( oForm.FirstName.value.length < 1)
    {
        alert("Please enter your first name");
        RetVal = false;        
    }
    else if(oForm.LastName.value.length < 1)
    {
		alert("Please enter your last name");
        RetVal = false;
    }
    else if(oForm.Street.value.length < 1)
    {
		alert("Please enter your student society");
        RetVal = false;
    }
    else if( oForm.Email.value.length < 1)
    {
        alert("Please enter your email address");
        RetVal = false;        
    }
    else if( !EmailValidate(oForm.Email.value))
    {
		alert("The email address you have entered is invalid. Please enter your valid email address");
        RetVal = false;
    }
    else if (oForm.NewPassword.value == '')
	{
		alert("Please enter your password");
		RetVal = false;
	}
	else if (oForm.ConfirmPassword.value == '')
	{
		alert("Please enter your confirmed password");
		RetVal = false;
	}
	else if (oForm.NewPassword.value != '' && oForm.ConfirmPassword.value != '' && oForm.NewPassword.value != oForm.ConfirmPassword.value)
	{
		alert("Your password and confirmed password must match");
		RetVal = false;
	}
    else
	{
		// set display name and username
		oForm.DisplayName.value = oForm.FirstName.value + " " + oForm.LastName.value;		
	}
	return RetVal;
}//ValidateRegister

///<summary>
/// KeyHandler for EnterKey
///</summary>
function EnterLogon() 
{
	e = window.event;
	if ( e.keyCode == 13 )
	{
		ValidateLogon();
	}
}//end of KeyHandler

///<summary>
/// Validate the Logon form
///</summary>
function ValidateLogon()
{
	var sErrorMsg = '';
	RetVal = true;
	
	if (Logon.Username.value == "")
	{
		sErrorMsg += "  Username.";
	}
	if (Logon.Password.value == "")
	{
		sErrorMsg += "  Password.";
	}
	if (sErrorMsg != '')
	{
		sErrorMsg = "We're sorry, the entry of the following fields are required: " + sErrorMsg + ". " + 
					" Please review your entry, complete these fields and click Submit.";
		
		alert(sErrorMsg);
		RetVal = false;
	}
	return RetVal;
}//ValidateLogon

///<summary>
/// Validate the ChangePassword form
///</summary>
function ValidateChangePassword()
{
	var sErrorMsg = '';
	RetVal = true;
	
	if (document.forms.ChangePassword.NewPassword.value == "")
	{
		sErrorMsg += "  New Password.";
	}
	if (document.forms.ChangePassword.NewPasswordConfirm.value == "")
	{
		sErrorMsg += "  Confirm Password.";
	}
	if (document.forms.ChangePassword.NewPassword.value != '' && document.forms.ChangePassword.NewPasswordConfirm.value != '' && document.forms.ChangePassword.NewPassword.value != document.forms.ChangePassword.NewPasswordConfirm.value)
	{
		sErrorMsg += ((sErrorMsg == "") ? "" : ", ") + " your password and confirmed password must match";
	}
	if (sErrorMsg != '')
	{
		sErrorMsg = "We're sorry, the entry of the following fields are required: " + sErrorMsg + ". " + 
					" Please review your entry, complete these fields and click Submit.";
		
		alert(sErrorMsg);
		RetVal = false;
	}
	return RetVal;
}//ValidateChangePassword

//-->