function ShowHide(toShow, toHide)
{
    /*
        used with a button 'onclick' event.
        toShow - array with the IDs of the elements to be shown
        toHide - array with the IDs of the elements to be hidden

    */
    for (i = 0; i < toShow.length; i++) {
        Display($("[id$='" + toShow[i] + "']")[0]);
    }
    for (i = 0; i < toHide.length; i++)
    {
        UnDisplay($("[id$='" + toHide[i] + "']")[0]);
    }
}

function SetFocus(ctrlId)
{
    var ctrl = $("[id$='" + ctrlId + "']")[0];
    if (ctrl != null)
    {
        ctrl.focus();
    }
}

function Display(displayControl) {
    if (displayControl != null) {
        displayControl.style.display = '';
    }
}

function UnDisplay(displayControl) {
    if (displayControl != null) {
        displayControl.style.display = 'none';
    }
}

/*******************************************************************************************************/
//redirects to an aspx page called pageName
//adds a policyid to the querystring based on the value of control, controlName
//used on the left icons user control
/*******************************************************************************************************/
function Redirect(pageName,controlName)
{
    var policyId = $("[id$='_" + controlName + "']")[0];
    document.location.href(pageName + '.aspx?PolicyId='+ policyId.value);
}

/***********************************************************************************************************/
//opens email page modally
//used on EmailPopUp and LinkPopUp functions
/***********************************************************************************************************/
function EmailModalPopup(emailInfo)
{
    return window.showModalDialog('EmailModal.aspx',emailInfo,'dialogWidth:700px;dialogHeight:650px;status:no;scroll:no;help:no;');

}

function EmailPopUp(pageName, param2)
{
    var emailInfo = new Array();

    if(pageName == 'UWEmail')
    {
        emailInfo[0] = 'AgentUWList';				//where email came from
        emailInfo[1] = param2;
        return window.showModalDialog('EmailModal.aspx', emailInfo, 'dialogWidth:527px;dialogHeight:405px;status:no;scroll:no;help:no;');
    }
}

function HelpPopUp(helpId) {
    var url = 'Help.aspx?HelpId=' + helpId ;
    newwin = window.open(url,'Help','toolbar=no,location=no,menubar=no,top=30,left=90,width=400,height=450px,scrollbars=no,resizable=no');
}

function ContactUsPopUp() {
    window.open('ContactUs.aspx','ContactUs','toolbar=no,location=no,menubar=no,width=516,height=500,scrollbars=no,resizable=no');
}

function LeadDetailPopUp(leadId, leadType) {
    url = 'LeadDetails.aspx?leadId=' + leadId + '&leadType=' + leadType;
    window.open(url, 'LeadDetail', 'toolbar=no,location=no,menubar=no,width=400,height=400,scrollbars=no,resizable=yes');
}

function ChangeFrameSource(ctrlId, url)
{
    if ($("[id$='_" + ctrlId + "']")[0] != null)
    {
        $("[id$='_" + ctrlId + "']")[0].src = url;
    }
}

//******************************************************************************************

function popwindow(URL, windowName, properties) {
    popupWin = window.open(URL, windowName, properties);
    window.top.name = 'opener';
}


function swap(id, img) {
    document.images[id].src = img;
}

/**************************************************/
function swap1(ctrl, img) {
    ctrl.src = img;
}



