﻿function callPage(url)
{
    document.getElementById('aspnetForm').action = url;

    document.getElementById('aspnetForm').submit();

}

function getRole()
{
    var lbl = document .getElementById ("ctl00_ctl00_cphOuter_cphSecondary_hfOrganizationId");
    
    var txt = document.getElementById("ctl00_ctl00_cphOuter_cphSecondary_txt"+lbl.value);
    
   document.getElementById ("ctl00_ctl00_cphOuter_cphSecondary_hfRole").value = txt.value;
}

function ValidateSignInForm ( form , mode , errControl )
{
    if( !ValidateForm( form,mode) )
    {
        errControl.style.visibility = "hidden";
        return false;
    }
}

function ValidateSignUpForm(form,mode)
{
    
    //Check if personal info is missing
    var isPersonalInfoValid = ValidateForm(form,mode);
    
    //Check if radio button is checked
    var isRoleChecked = RoleChecked();
    
    var errormsg = document.getElementById("errMessageRole");
    
    //Hide the error message by default
    errormsg.style.display="none";
    
    
    if(isPersonalInfoValid == false && isRoleChecked == false)
    {
        errormsg.style.color='red';
        
        errormsg.style.fontSize ='11px';
        
        errormsg.style.fontFamily ='arial';
		        
        errormsg.style.display="block";	
        
        return false;	
	}
	else if(isPersonalInfoValid == true && isRoleChecked == false)
    {
        errormsg.style.color='red';
        
        errormsg.style.fontSize ='11px';
        
        errormsg.style.fontFamily ='arial';
		        
        errormsg.style.display="block";	
        
        return false;	
    }
    else if(isPersonalInfoValid == false && isRoleChecked == true)
    {
        return false;	
    }
	
	getRole();
	return true;
        
}

function RoleChecked()
{
    var organizationId = document .getElementById ("ctl00_ctl00_cphOuter_cphSecondary_hfOrganizationId");
    var role = document.getElementById ("ctl00_ctl00_cphOuter_cphSecondary_hfRole");
    
    if( organizationId.value != "")
        return true;
    else
        return false;
}
