﻿// JScript File

var strPrefix = "ctl00_ContentPlaceHolder1_";

function setFilter(val)
{
    var hidFilteredBy = document.getElementById(strPrefix+"hidFilteredBy")
    if(null != hidFilteredBy)
        hidFilteredBy.value = val;
        
    return true;
}


function  validateRegistrationSubmit()
{    
    var arrControlValidation = new Array(
            new Array(strPrefix + 'txtFirstName',"textbox","First Name","string",1),            
            new Array(strPrefix + 'txtLastName',"textbox","Last Name","string",1),
            new Array(strPrefix + 'txtOffTitle',"textbox","Official Title","string",1),
            new Array(strPrefix + 'txtDept',"textbox","Department","string",1),
            new Array(strPrefix + 'ddlInstitution',"dropdown","Institution","Int",1,3,-1),
            new Array(strPrefix + 'txtOffAdd',"textbox","Office Address","string",1),
            new Array(strPrefix + 'txtCity',"textbox","City","string",1),
            new Array(strPrefix + 'txtState',"textbox","State","string",1),
            new Array(strPrefix + 'txtZip',"textbox","Zip","string",1),
            new Array(strPrefix + 'txtOffPhone',"textbox","Office Phone","string",1),
            new Array(strPrefix + 'txtEmail',"textbox","Email","string",1),
            new Array(strPrefix + 'txtPhotoUpload',"fileupload","Photo","jpg-bmp-gif-png"),
            new Array(strPrefix + 'txtUserName',"textbox","User Name","string",1),
            new Array(strPrefix + 'txtPassword',"textbox","Password","string",1)
                        
          );
          var isValid =  genericValidator(arrControlValidation);
          
          if(isValid)
          {
                var ddlERCTitle = document.getElementById(strPrefix+"ddlERCTitle");	
                var txtERCTitleOther = document.getElementById(strPrefix+"txtERCTitleOther");
                var ercTitle = Trim(txtERCTitleOther.value);
                
                if((ddlERCTitle.value == '') && (ercTitle == ''))
                {
                    alert('ERC Title is a required field. It can\'t be blank.');
                    ddlERCTitle.focus();            	    
                    isValid= false;
                }
                
                var file = document.getElementById(strPrefix+"txtPhotoUpload");
                if(null != file && file.value.length > 0)
                {
                    if(!validateFilePath(file.value))
                    {
                        alert('File name should not include special characters.');
                        file.focus();   
                        return false; 
                    }
                }    
          }
          
          return isValid;

}

function validateFilterCriteria()
{
    var arrControlValidation = new Array(
            new Array(strPrefix + 'txtStartDate',"textbox","Start Date","date",1),
            new Array(strPrefix + 'txtEndDate',"textbox","End Date","date",1),            
            new Array(strPrefix + 'txtLastName',"textbox","Last Name","string",1),
            new Array(strPrefix + 'txtUserName',"textbox","User Name","string",1)
          );
         
          var status = genericValidator(arrControlValidation);
          
          if(status == true)
          {
                var ddlStatus = document.getElementById(strPrefix+"ddlStatus")	
                if(ddlStatus.value == 'Select')
                {
                    alert('Please select status.');
                    ddlStatus.focus();            	    
                    return false;
                }
	       }
	    return true;
}   

function ConfirmDelete()
{
	if(!confirm('Selected group(s) will be deleted. Do you want to continue?'))
	{	    
	    return false;
	}  
	return true;
}

function ConfirmUserDelete()
{
	if(!confirm('Selected user(s) will be deleted. Do you want to continue?'))
	{	    
	    return false;
	}  
	return true;
}



