//====================================================================================================
//    File Name        :    login.js
//    # File Version: v 1.0
//    # Created By: Maulik Chandarana
//    # Created On: 14 July 2008
//    # Last Modified By:
//    # Last modified On:
//  # Purpose : This is file carries validation and other related function for Login page.
//----------------------------------------------------------------------------------------------------
//====================================================================================================
//    Function Name    :    Click_Login()
//    Created By: Maulik Chandarana
//    Created On: 14 July 2008
//    Last Modified By: Harsh Aghicha
//    Last modified On: 29 Jan 2009
//  Purpose : Set action variables and Submit Page for login
//  Parameters: frm : Form Object
//----------------------------------------------------------------------------------------------------
function Click_Login(frm)
{ 	
	with(frm)
    {
        if(!IsEmpty(txtEmail, 'Please enter the email address'))
        {
            return false;
        }
        if(!IsEmail(txtEmail, 'Please enter the valid email address'))
        {
            return false;
        }
		
		if(txtPassword.value=="")
		{
			 alert("Please enter the password.");
			 return false;
		}       
        hdMode.value = "login"; 
		        
        var hdUserType;
        
		for (var i=0; i<frm.rdAffiliateType.length; i++)  {
			if (frm.rdAffiliateType[i].checked){			
				hdUserType.value = frm.rdAffiliateType[i].value;			
			}
		}
		
		if(hdUserType.value==''){
			alert("Please choose your user type");
			return false;
		}
    }        
}

//====================================================================================================
//    Function Name    :    loginClient()
//    Created By: Harsh Aghicha
//    Created On: 29 Jan 2009
//    Last Modified By: 
//    Last modified On: 
//    Purpose : Auto-fill values for email and password if cookie for the same are set
//			    Remember Me Option - Client user
//    Parameters: userTypeCookie : usertype cookie
//				  emailCookie : email cookie stored
//				  passwordCookie : password cookie stored
//----------------------------------------------------------------------------------------------------
function loginClient(userTypeCookie,emailCookie,passwordCookie)
{	
	if(userTypeCookie=='Client'){
		document.getElementById('txtEmail').value=emailCookie;
		document.getElementById('txtPassword').value=passwordCookie;
	}
}

//====================================================================================================
//    Function Name    :    loginPublisher()
//    Created By: Harsh Aghicha
//    Created On: 29 Jan 2009
//    Last Modified By: 
//    Last modified On: 
//    Purpose : Auto-fill values for email and password if cookie for the same are set
//			    Remember Me Option - Publisher user
//    Parameters: userTypeCookie : usertype cookie
//				  emailCookie : email cookie stored
//				  passwordCookie : password cookie stored
//----------------------------------------------------------------------------------------------------
function loginPublisher(userTypeCookie,emailCookie,passwordCookie)
{	
	if(userTypeCookie=='Publisher'){	 	
		document.getElementById('txtEmail').value=emailCookie;
		document.getElementById('txtPassword').value=passwordCookie;
	}
}