﻿// JavaScript File
function openWin_WH(url,height,width) 
{
    win = window.open(url,'WH','status=no,width=' + width + ',height=' + height + ',toolbar=no,location=no,scrollbars=no,resizable=yes,status=no');
    win.focus();
}

function footerSearch()
{
    try
    {
        var txtBox = document.forms['FooterSearchbox'].elements['footerinput'];
        document.location.href='/MainSearchResults.aspx?k=' + txtBox.value;
        return false;
    }
    catch (e)
    {
        alert(e.message);
    }
    
}

function CheckAll()
{
var arrayofElements = document.getElementsByTagName("input");
for (var i = 0; i <= arrayofElements.length -1; i++)
{
    if (arrayofElements[i].type == 'checkbox')
    {
  
        arrayofElements[i].checked = true ;
    }
}
}

function UnCheckAll()
{
var arrayofElements = document.getElementsByTagName("input");
for (var i = 0; i <= arrayofElements.length -1; i++)
{
    if (arrayofElements[i].type == 'checkbox')
    {
       
        arrayofElements[i].checked = false ;
    }
}
}

function ShowMeCellGridID(strPropertyIDs)
{
    window.opener.parent.document.forms["frmShell"].SelectedProperties.value = strPropertyIDs;
    window.opener.ShowSelectedProperties(strPropertyIDs);
    window.close();

}

function ShowSelectedProperties(strPropertyIDs)
{
    if (strPropertyIDs.length > 0)
    {
        var arrPDFs = strPropertyIDs.split(",");
    }
    if (arrPDFs != null)
    {
        if (arrPDFs.length > 1)
        {
            document.getElementById("divPDFLinks").innerHTML = arrPDFs.length + " marketing documents will be included in your email.";
        }
        else
        {
            document.getElementById("divPDFLinks").innerHTML = arrPDFs.length + " marketing document will be included in your email.";
        }
        document.getElementById("divPDFLinks").innerHTML += '<br><a href="#" onclick="cleardivPDFLinks();">clear</a>';
    }
}
function cleardivPDFLinks()
{
   document.getElementById("divPDFLinks").innerHTML = '';
} 

function ShowMainImage(MainImageClientID, NewImageURL)
{
    /*
        1.  Get a copy of the object with the id =  MainImageClientID
        2.  If that's not null (!= null) then we're going to update it's src property with the NewImageURL
    */
    
    var BigImage = document.getElementById(MainImageClientID);
    if (BigImage != null)
    {
        BigImage.src = NewImageURL;
    }
}


function ResizeWindow(CID) 
{
    try
    {
    
        var i = document.getElementById(CID); 
        if (i.complete == false)
        {
            setTimeout("1500", window.resizeTo(i.width+20, i.height+40));
        }
        else
        {
            window.resizeTo(i.width+20, i.height+40);
        }
    }
    catch (e)
    {
        //alert(e.message);
    }
}

function Outputmsg(sAddress, sSubject)
{
    try
    {
        
        var emailAddress = sAddress;
        var subject = sSubject;
        var mailto_link = 'mailto:' + emailAddress 
        if (sSubject.toString().length > 0)
        {
            mailto_link += '?subject=' + sSubject;
        }
        var win = window.open(mailto_link,'emailWindow');
        win;
        if (win && win.open &&!win.closed) win.close();
    }
    catch (e)
    {
        alert(e.message);
    }
}

function redirecttoSearch()
{
    window.location='/SearchResults.aspx?Search=' + document.getElementById('HeadSearch').value
    return false;
}