﻿function FSfncGetOuterHTML(element) {
    // outerHTML support for Firefox
    if (element.outerHTML) {return element.outerHTML}
    else {
        var parent = element.parentNode;
        var el = document.createElement(parent.tagName);
        el.appendChild(element);
        return el.innerHTML;
        }
    }

function toggleBlock(strElementId) {
    if ((document.getElementById) && (document.getElementById(strElementId))) {
        objElem=document.getElementById(strElementId);
        objElem.style.display=(objElem.style.display=="none" ? "block" : "none");
        }
    }

function checkTextLength(FieldRef,Maxlength,CountTextID) {
	if (FieldRef.value.length>Maxlength) {FieldRef.value=FieldRef.value.substring(0,Maxlength)}
	if ((document.getElementById) && (document.getElementById(CountTextID))) {document.getElementById(CountTextID).innerText="(" + FieldRef.value.length + " characters of " + Maxlength + ")"}
	}

function FSfncPopUp(NextPage, width, height, resizable, scrollbars, status, winName) {
    if (resizable == "") { resizable = "no" }
    if (scrollbars == "") { scrollbars = "no" }
    if (status == "") { status = "no" }
    if (winName == "") { winName = "FSpopUpWindow" }
    FSpopUp = window.open(NextPage, winName, 'toolbar=no,width=' + width + ',height=' + height + ',status=' + status + ',scrollbars=' + scrollbars + ',resizable=' + resizable + ',menubar=no,directories=no');
	}

function ConfigureCollapser(ConfigureID, AjaxStoreFunction) {
    var collPanel = $find(ConfigureID);
    if (collPanel) {
        collPanel._animation._fps = 25;
        collPanel._animation._duration = 0.50;
        collPanel.add_expanding(Expanding);
        collPanel.add_collapsed(CollapseComplete);
        collPanel.add_propertyChanged(AjaxStoreFunction);
        }
    }

function ConfigureAccordian(ConfigureID, AjaxStoreFunction) {
    var collPanel = $find(ConfigureID);
    if (collPanel) { collPanel.add_selectedIndexChanged(AjaxStoreFunction) }
    }

function Expanding(sender, arg) {
    sender._childDiv.style.display = "block";
    var obj = document.getElementById(sender._collapseControlID);
    if (obj.className.substring(obj.className.length - 7, obj.className.length) == "_closed") { obj.className = obj.className.substring(0, obj.className.length - 7) }
    }

function CollapseComplete(sender, arg) {
    sender._childDiv.style.display = "none";
    var obj = document.getElementById(sender._collapseControlID);
    if (obj.className.substring(obj.className.length - 7, obj.className.length) != "_closed") { obj.className += "_closed" }
    }

function CheckRegion(oSrc, args) {
    var strPrefix = oSrc.id.substring(0, oSrc.id.lastIndexOf("_") + 1);
    var objChkLoc = document.getElementById(strPrefix + "FilterRegionLoc");
    var objChkNat= document.getElementById(strPrefix + "FilterRegionNat");
    if (document.getElementById(strPrefix + "FilterRegionReg")) { var objRegChk = document.getElementById(strPrefix + "FilterRegionReg") } else { var objRegChk = objChkLoc }
    args.IsValid = (objChkLoc.checked || objChkNat.checked || objRegChk.checked);
    }
