﻿function ClearTextField(element, initialValue) 
{
    var myElement = document.getElementById(element);

    if (myElement.value == initialValue) 
    {
        myElement.value = "";
    }
}

function ClearLabel(element) 
{
    var myElement = document.getElementById(element);
    myElement.style.display = "none";
}

/// <summary>
/// Finds the element that has specified part of a string name of a certain type
/// e.g. "Arrow"
/// </summary>
function GetElement(element, partialName, type) 
{
    if (element.tagName == type) if (element.id.indexOf(partialName) != -1) return element;
    if (element.childNodes.length < 1) return null;
    var elementArray = element.childNodes;
    var nodeCount = element.childNodes.length;

    for (var i = 0; i < nodeCount; i++) {
        childElement = GetElement(elementArray[i], partialName, type);
        if (childElement != null) return childElement;
    }
    return null;
}

function PopFullScreenWindow(url, name) 
{
    if (Page_ClientValidate()) 
    {
        var params;
        params = 'width=' + screen.width;
        params += ', height=' + screen.height;
        params += ', top=0, left=0'
        params += ', fullscreen=yes';
        params += ', menubar=yes, location=yes, scrollbars=yes,toolbar=yes,resizable=yes';

        newwin = window.open(url, name, params);

        if (newwin != null) 
        {
            if (window.focus) 
            {
                newwin.focus();
            }
        }
    }

    return false;
}

//function checkpopupblocker() 
//{
//    var popupBlockChecker = document.getElementById('hiddenPopupBlockerCheck');

//    if (popupBlockChecker.value=='') 
//    {
//        var sOption = "toolbar=no,location=no,directories=no,menubar=no,";
//        sOption += "scrollbars=no,width=1,height=1,left=0,top=0";
//        var i = window.open("popupblockertest.htm", "", sOption);

//        if (!i)
//            alert("Please disable your Popup Blocker before running a quote.");
//        else {
//            i.close();
//            popupBlockChecker.value='checked';
//        }
//    }
//}

////window.onload = detectPopupBlocker;
//function detectPopupBlocker() 
//{
//    var myTest = window.open("about:blank", "", "directories=no,height=100,width=100,menubar=no,resizable=no,scrollbars=no,status=no,titlebar=no,top=0,location=no");
//    if (!myTest) 
//    {
//        alert("Please disable your Popup Blocker before running a quote.");
//    } else 
//    {
//        myTest.close();
//    }
//}

function PopUpQuoteResultsWindow() 
{
    var myNewPage = document.getElementById("popQuoteResults");
    if(myNewPage!=null) myNewPage.click();
}

