﻿// JScript File

function GenderChangeEvent(ddlTitle, rdlGender){
	var titleControl = ddlTitle;
	//document.getElementById(ddlTitle.name);
	var genderControl = rdlGender;
	//document.getElementById(rdlGender.name);
	
	var str_title = titleControl.value; 
	var str_gender = genderControl.value; 
	
	if(str_title == "Mrs" || str_title == "Ms" || str_title == "Miss")
	{
		genderControl.value = "F";
	}
	else
	{
		str_title == "Mr" ? genderControl.value = "M" : genderControl.value = "";
	}
}


function PaymentMethodChangeEvent(ddlPaymentMethod, divDebited){

	var paymentMethodControl = document.getElementById(ddlPaymentMethod);
	var debitedControl = document.getElementById(divDebited);
	
	var paymentMethod = paymentMethodControl.value; 
	
	if (paymentMethod == "Payroll Deduction")
	{
        debitedControl.style.visibility = "hidden"; 
        debitedControl.style.display = "none";         
	}
	else
	{
        debitedControl.style.visibility = "visible"; 
        debitedControl.style.display = "block"; 
	}
}

//*************************************************************
//Args:
//      daySelId - day combo ControlId
//      monthSelId - month combo ControlId
//      yearSelId - year combo ControlId
//**************************************************************
function CheckDateAndLoadPopup(daySelId, monthSelId, yearSelId)
{
	var selDay = document.getElementById(daySelId);
	var selMonth = document.getElementById(monthSelId);
	var selYear = document.getElementById(yearSelId);	

	var isValid = true;

	//check all controls are valid	
	isValid = isDateTimeControlValid(selDay);

	if (isValid)
	    isValid = isDateTimeControlValid(selMonth);

	if (isValid)	    
	    isValid = isDateTimeControlValid(selYear);	

	if (isValid)
	{	
		//Load popup..
		//var strPopupPage = '/Client/StaticPages/Popup.aspx?Message=If you select a date before February 13, 2007, your premium for the period ending on that date will be $100.45. After that date, your premium will be $100.45.<br>If you select a date on or after February 13, 2007, your premium will be $100.45.&Heading=Notification';
		var strPopupPage = '/Client/Popups/Popup.aspx?MessageType=RateChange&Heading=Notification';
    
	    window.open(strPopupPage,'NewRates','scrollbars=no,resize=no,width=550,height=200');	  
	        
	}
}

//returns boolean to determine if the drop down list control is valid or not.
function isDateTimeControlValid(dtcControlObj)
{
    if (dtcControlObj == null)
        return false;
    else
    {    
        if (dtcControlObj.value == "")
            return false;
    }
    
    return true;
}

//go to other join steps
function clickJoinStep(controlId)
{
    var ctrlObject; 
        
    ctrlObject = document.getElementById(controlId); 
    if (ctrlObject != null) 
    {   
       eval(ctrlObject.href);
    }
}

//check browser type - save join
function checkBrowser(controlId) 
{
    //check browser type
    var newURL='', verStr=navigator.appVersion, app=navigator.appName, version = parseFloat(verStr);
    var browser='';

    if (app.indexOf('Netscape') != -1) 
    {
    if (version >= 4.0) 
    {
        browser="ns"
    }
    } 
    else if (app.indexOf('Microsoft') != -1) 
    {
        if (version >= 4.0 || verStr.indexOf(4.0) != -1)
        {
            browser="ie"
        }
    } 
    else browser="ns"
  
    //Assign to the hidden 
    var ctrlObject; 
        
    ctrlObject = document.getElementById(controlId); 
    if (ctrlObject != null) 
    {   
       var browserHiddenField = eval(ctrlObject);
       browserHiddenField.value = browser;
    }  
}

function buttonmouseon(buttonId)
{
    
    if(buttonId != null)
    {
        buttonId.className = buttonId.className + "_hover";
    }
}

function buttonmouseout(buttonId)
{
    if(buttonId != null)
    {
        buttonId.className = buttonId.className.replace("_hover", "");
    }
}