﻿// JScript File

//debugger;
var strPrefix = "ctl00_ContentPlaceHolder1_";

function CollabInstitutionPage()
{
        var cboInstituteAff = document.getElementById(strPrefix+"cboInstituteAff");	
        var crtltxtOtherInstitution = document.getElementById(strPrefix+"OtherInstitution");        
        
        if(cboInstituteAff.value == '')
        {
            alert('Name of institution is a required field. It can\'t be blank.');                       	    
            cboInstituteAff.focus();
            return false;
        }        
        else if(cboInstituteAff.options[cboInstituteAff.selectedIndex].text == 'Other' && Trim(crtltxtOtherInstitution.value).length == 0)
        {
            alert('Please enter value for Other institution.');
            crtltxtOtherInstitution.value = Trim(crtltxtOtherInstitution.value);
            crtltxtOtherInstitution.focus();
            return false;
        }
         
                
   var arrControlValidation = new Array(                        
            new Array(strPrefix + 'OtherPesonnel',"textbox","Name of Personnel","string",1),
            new Array(strPrefix + 'OtherEmail',"textbox","Email Address","string",1),
            new Array(strPrefix + 'cboType_invol',"dropdown","Type of Involvement","Int",1,0,-1)
            );
            
            return genericValidator(arrControlValidation); 
}

function ValidateConfAtteneded()
{      
                
   var arrControlValidation = new Array(                        
            new Array(strPrefix + 'cboType',"dropdown","Type","Int",1,0,-1),
            new Array(strPrefix + 'ConferenceDate',"textbox","Date","date",1),
            new Array(strPrefix + 'Conference',"textbox","Name of Conference","string",1),
            new Array(strPrefix + 'Location',"textbox","Location","string",1),
            new Array(strPrefix + 'cboPurpose',"dropdown","Purpose","Int",1,0,-1),
            new Array(strPrefix + 'txtProjectImage',"fileupload","Project Image","jpg-bmp-gif-png")
            );
            
            return genericValidator(arrControlValidation); 
}

function ValidateCourse()
{      
   var arrControlValidation = new Array(                        
            new Array(strPrefix + 'ddlProgramType',"dropdown","Program Type","Int",1,0,-1),
            new Array(strPrefix + 'ddlDiscipline',"dropdown","Discipline","Int",1,0,-1),
            new Array(strPrefix + 'Course_Name',"textbox","Program Name","string",1),
            new Array(strPrefix + 'ddlProgStatus',"dropdown","Program Status","Int",1,0,-1),
            new Array(strPrefix + 'Course_Num',"textbox","Course #","int",1),
            new Array(strPrefix + 'Num_StudentsUnd',"textbox","Total # of undergraduate students enrolled","int",0),
            new Array(strPrefix + 'Num_StudentsMaster',"textbox","Total # of masters students enrolled","int",0),
            new Array(strPrefix + 'Num_StudentsDoc',"textbox","Total # of doctoral students enrolled","int",0),
            new Array(strPrefix + 'NumPracEnrolled',"textbox","Total # of practitioner students enrolled","int",0),            
            new Array(strPrefix + 'Date_First_Offered',"textbox","Date first offered","date",1),
            new Array(strPrefix + 'cboSemester',"dropdown","Semester","Int",1,0,-1)
            );
            return genericValidator(arrControlValidation); 
}

function ValidateDemographic()
{    
                
   var arrControlValidation = new Array(                        
            new Array(strPrefix + 'txtBirthCountry',"textbox","Country Of Birth","string",1),          
            new Array(strPrefix + 'Race',"dropdown","Race","Int",1,0,-1)
            );
            
    var isValid = genericValidator(arrControlValidation); 
    
    if(isValid)
    {
        var Citizen_Status = document.getElementById(strPrefix+"Citizen_Status");	
        var Country = document.getElementById(strPrefix+"Country");        
        
        if((Citizen_Status.value == '') && (Country.value == ''))
        {
            alert('Citizen Status is a required field. It can\'t be blank.');                       	    
            isValid = false;
        }
    }
    
    return isValid;
}

function ValidateERC()
{      
                
   var arrControlValidation = new Array(                        
            new Array(strPrefix + 'cboHow_many_a',"dropdown","How many inventions","Int",1,0,-1),
            new Array(strPrefix + 'cboHow_many_b',"dropdown","How many patent applications","Int",1,0,-1),
            new Array(strPrefix + 'SpinOffCoEmply',"textbox","What is the estimated number of employees at spin-off companies","int",0),            
            new Array(strPrefix + 'cboHowManyG',"dropdown","How many technology standard","Int",1,0,-1)            
            );
            
           return genericValidator(arrControlValidation); 
                   
}

function AddAnotherButtonClick()
{
    var hidIsAddAnotherClick = document.getElementById(strPrefix+"hidIsAddAnotherClick");
    hidIsAddAnotherClick.value = "Y";
    return true;
}

function ValidateTextBookInfo()
{  
   var arrControlValidation = new Array(                        
            new Array(strPrefix + 'txtTextBookName',"textbox","TextBook Name","string",1),
            new Array(strPrefix + 'txtTextBookDate',"textbox","TextBook Date","date",1)
            );
            
           return genericValidator(arrControlValidation); 
}

function ValidateCourseInfo()
{      
                
   var arrControlValidation = new Array(                        
            new Array(strPrefix + 'txtCourseName',"textbox","Course Name","string",1),
            new Array(strPrefix + 'txtCourseDate',"textbox","Course Date","date",1)
            );
            
           return genericValidator(arrControlValidation); 
}

function ValidateCDInfo()
{      
                
   var arrControlValidation = new Array(                        
            new Array(strPrefix + 'txtCDName',"textbox","Instructional CD’s Name","string",1),
            new Array(strPrefix + 'txtCDDate',"textbox","Instructional CD’s Date","date",1)
            );
            
           return genericValidator(arrControlValidation); 
}

function ValidateLicense()
{      
                
   var arrControlValidation = new Array(                        
            new Array(strPrefix + 'LicenseName',"textbox","License Title","string",1),
            new Array(strPrefix + 'LicenseNumber',"textbox","Number","int",1)           
            );
            
            return genericValidator(arrControlValidation); 
}

function ValidatePatent()
{      
                
   var arrControlValidation = new Array(                        
            new Array(strPrefix + 'PatentName',"textbox","Patent Title","string",1),
            new Array(strPrefix + 'PatentNumber',"textbox","Number","int",1)           
            );
            
            return genericValidator(arrControlValidation); 
}

function ValidateProfHonors()
{      
                
   var arrControlValidation = new Array(                        
            new Array(strPrefix + 'HonorsDate',"textbox","Month/Year Received","date",1),
            new Array(strPrefix + 'Honors',"textbox","Honors","string",1)
            );
            
}

function ValidateWWW()
{      
                
   var arrControlValidation = new Array(                        
            new Array(strPrefix + 'WWWCourse',"textbox","Course Name","string",1),
            new Array(strPrefix + 'Describe',"textbox","Course Description","string",1)
            );
            
            return genericValidator(arrControlValidation); 
}

function ValidateFacPersonalInfo()
{         
   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 + 'ddlPersonalType',"dropdown","Personnel Type","Int",1,0,-1),
            new Array(strPrefix + 'ddlGender',"dropdown","Gender","Int",1,0,-1),
            new Array(strPrefix + 'ddlEthnicity',"dropdown","Ethnicity","Int",1,0,-1),
            new Array(strPrefix + 'ddlDisabled',"dropdown","Disabled","Int",1,0,-1),
            new Array(strPrefix + 'ddlCitizenship',"dropdown","Citizenship","Int",1,0,-1),            
            new Array(strPrefix + 'txtOffTitle',"textbox","Official Title","string",1),
            new Array(strPrefix + 'txtDept',"textbox","Department","string",1),
            new Array(strPrefix + 'cboInstituteAff',"dropdown","Institute","Int",1,0,-1),
            new Array(strPrefix + 'txtOffAdd',"textbox","Official 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 Address","string",1),
            new Array(strPrefix + 'txtPhotoUpload',"fileupload","Photo","jpg-bmp-png-gif")
            );
            
            var isValid =  genericValidator(arrControlValidation); 
            
            if(isValid)
            {
//                var ddlERCTitle = document.getElementById(strPrefix+"ddlERCTitle");	
//                var txtERCTitleOther = document.getElementById(strPrefix+"txtERCTitleOther");        
//                
//                if(ddlERCTitle.value == '')
//                {
//                    alert('ERC Title is a required field. It can\'t be blank.');                       	    
//                    isValid = false;
//                }
//                else if(ddlERCTitle.options[ddlERCTitle.selectedIndex].text == 'Other' && Trim(txtERCTitleOther.value).length == 0)
//                {
//                    alert('Please enter value for Other ERC Title.');
//                    txtERCTitleOther.value = Trim(txtERCTitleOther.value);
//                    txtERCTitleOther.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 validateOther(objSelectCtrl,otherCtrlId)
{
    //debugger;    
    var objOtherCtrl = document.getElementById(strPrefix+otherCtrlId);	
    if(objSelectCtrl.options[objSelectCtrl.selectedIndex].text == 'Other')
    {
        objOtherCtrl.disabled = false;            
        objOtherCtrl.style.backgroundColor = '';
    }
    else
    {
        objOtherCtrl.value = '';
        objOtherCtrl.defaultValue = '';
        objOtherCtrl.disabled = true;            
        objOtherCtrl.style.backgroundColor= 'Silver';
    }
    return false;
}

function ShowControls(param)
{
    alert(param);
    if(param == 1)
    {
        var InvOptionCtrl = document.getElementById(strPrefix+"rdoYN1_0");
        if(null != InvOptionCtrl && InvOptionCtrl.value == 'Y')
        {
//            var InvDivCtrl = document.getElementById(strPrefix+"divInv");
            var InvDivCtrl = document.getElementById("divInv");
            alert(InvDivCtrl.style.visibility);
            InvDivCtrl.style.visibility = "";
            
            alert(InvDivCtrl.style.visibility);
        }
        else if(null != InvOptionCtrl && InvOptionCtrl.value == 'N')
        {
            var InvDivCtrl = document.getElementById("divInv");
            alert(InvDivCtrl.style.visibility);
            
            InvDivCtrl.style.visibillity = "hidden";
            alert(InvDivCtrl.style.visibility);
        }
        
    }
    
    return false;
}

function HideDiv(param)
{
    var InvDivCtrl = document.getElementById("divInv");
    if(null != InvDivCtrl)
    {    
        InvDivCtrl.style.visibility = "hidden";
    }
}

function ValidateFacAssProj()
{      
                
   var arrControlValidation = new Array(                        
            new Array(strPrefix + 'ddlThrustNames',"dropdown","Thrust Names","Int",1,0,-1),
            new Array(strPrefix + 'txtProjectName',"textbox","Project Name","string",1),
            new Array(strPrefix + 'ddlProjectRole',"dropdown","Project Role","Int",1,0,-1),
            new Array(strPrefix + 'ddlSponsorType',"dropdown","Sponsor Type","Int",1,0,-1),

            new Array(strPrefix + 'txtSponsor',"textbox","Sponsor","string",1),
            new Array(strPrefix + 'txtAmount',"textbox","Amount","int",1)
            );
            
            return genericValidator(arrControlValidation); 
}

function ValidateFacCentreProj()
{      
                
   var arrControlValidation = new Array(                        
            new Array(strPrefix + 'ddlThrustNames',"dropdown","Thrust Names","Int",1,0,-1),
            new Array(strPrefix + 'ddlProjectNames',"dropdown","Project Name","Int",1,0,-1),
            new Array(strPrefix + 'ddlProjectRole',"dropdown","Project Role","Int",1,0,-1),
            new Array(strPrefix + 'txtEffort',"textbox","Effort","int",1)
            );
            
            return genericValidator(arrControlValidation); 
}



function ValidateInvDisclosed()
{      
                
   var arrControlValidation = new Array(                        
            new Array(strPrefix + 'txtInvDisclosedName',"textbox","Invention Name","string",1),
            new Array(strPrefix + 'txtInvDisclosedDate',"textbox","Invention Date","date",1)            
            );
            
            return genericValidator(arrControlValidation); 
}

function ValidateERCPatent()
{      
                
   var arrControlValidation = new Array(                        
            new Array(strPrefix + 'txtPatentName',"textbox","Patent Name","string",1),
            new Array(strPrefix + 'txtPatentDate',"textbox","Patent Date","date",1)            
            );
            
            return genericValidator(arrControlValidation); 
}


function ValidatePatentAwarded()
{      
                
   var arrControlValidation = new Array(                        
            new Array(strPrefix + 'txtPatentAwardedName',"textbox","Patent Awarded Name","string",1),
            new Array(strPrefix + 'txtPatentAwardedDate',"textbox","Patent Awarded Date","date",1)            
            );
            
            return genericValidator(arrControlValidation); 
}

function ValidateERCLicense()
{      
                
   var arrControlValidation = new Array(                        
            new Array(strPrefix + 'txtLicenseName',"textbox","License Name","string",1),
            new Array(strPrefix + 'txtLicenseDate',"textbox","License Date","date",1)            
            );
            
            return genericValidator(arrControlValidation); 
}

function ValidateSpinOff()
{      
                
   var arrControlValidation = new Array(                        
            new Array(strPrefix + 'txtSpinOffName',"textbox","Spin Off Name","string",1),
            new Array(strPrefix + 'txtSpinOffDate',"textbox","Spin Off Date","date",1)            
            );
            
            return genericValidator(arrControlValidation); 
}

function ValidateEstimated()
{      
                
   var arrControlValidation = new Array(                        
            new Array(strPrefix + 'txtEstimatedName',"textbox","Estimated Name","string",1),
            new Array(strPrefix + 'txtEstimatedDate',"textbox","Estimated Date","date",1)            
            );
            
            return genericValidator(arrControlValidation); 
}

function ValidateBldngCode()
{      
                
   var arrControlValidation = new Array(                        
            new Array(strPrefix + 'txtBuildingCodeName',"textbox","Building Code Name","string",1),
            new Array(strPrefix + 'txtBuildingCodeDate',"textbox","Building Code Date","date",1)            
            );
            
            return genericValidator(arrControlValidation); 
}

function ValidateTech()
{      
                
   var arrControlValidation = new Array(                        
            new Array(strPrefix + 'txtTechnologyName',"textbox","Technology Standard Name","string",1),
            new Array(strPrefix + 'txtTechnologyDate',"textbox","Technology Standard Date","date",1)            
            );
            
            return genericValidator(arrControlValidation); 
}

function ValidateSurgical()
{      
                
   var arrControlValidation = new Array(                        
            new Array(strPrefix + 'txtSurgicalName',"textbox","Surgical Name","string",1),
            new Array(strPrefix + 'txtSurgicalDate',"textbox","Surgical Date","date",1)            
            );
            
            return genericValidator(arrControlValidation); 
}























