﻿/*!
* jQuery xmlDOM Plugin v1.0
* http://outwestmedia.com/jquery-plugins/xmldom/
*
* Released: 2009-04-06
* Version: 1.0
*
* Copyright (c) 2009 Jonathan Sharp, Out West Media LLC.
* Dual licensed under the MIT and GPL licenses.
* http://docs.jquery.com/License
*/
(function ($) {
    // IE DOMParser wrapper
    if (window['DOMParser'] == undefined && window.ActiveXObject) {
        DOMParser = function () { };
        DOMParser.prototype.parseFromString = function (xmlString) {
            var doc = new ActiveXObject('Microsoft.XMLDOM');
            doc.async = 'false';
            doc.loadXML(xmlString);
            return doc;
        };
    }

    $.xmlDOM = function (xml, onErrorFn) {
        try {
            var xmlDoc = (new DOMParser()).parseFromString(xml, 'text/xml');
            if ($.isXMLDoc(xmlDoc)) {
                var err = $('parsererror', xmlDoc);
                if (err.length == 1) {
                    throw ('Error: ' + $(xmlDoc).text());
                }
            } else {
                throw ('Unable to parse XML');
            }
        } catch (e) {
            var msg = (e.name == undefined ? e : e.name + ': ' + e.message);
            if ($.isFunction(onErrorFn)) {
                onErrorFn(msg);
            } else {
                $(document).trigger('xmlParseError', [msg]);
            }
            return $([]);
        }
        return $(xmlDoc);
    };
})(jQuery);

var BrowserDetect = {
    init: function () {
        this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
        this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "An unknown version";
        this.OS = this.searchString(this.dataOS) || "an unknown OS";
    },
    searchString: function (data) {
        for (var i = 0; i < data.length; i++) {
            var dataString = data[i].string;
            var dataProp = data[i].prop;
            this.versionSearchString = data[i].versionSearch || data[i].identity;
            if (dataString) {
                if (dataString.indexOf(data[i].subString) != -1)
                    return data[i].identity;
            }
            else if (dataProp)
                return data[i].identity;
        }
    },
    searchVersion: function (dataString) {
        var index = dataString.indexOf(this.versionSearchString);
        if (index == -1) return;
        return parseFloat(dataString.substring(index + this.versionSearchString.length + 1));
    },
    dataBrowser: [
		{
		    string: navigator.userAgent,
		    subString: "Chrome",
		    identity: "Chrome"
		},
		{
		    string: navigator.vendor,
		    subString: "Apple",
		    identity: "Safari",
		    versionSearch: "Version"
		},
		{
		    prop: window.opera,
		    identity: "Opera"
		},
		{
		    string: navigator.userAgent,
		    subString: "Firefox",
		    identity: "Firefox"
		},
		{		// for newer Netscapes (6+)
		    string: navigator.userAgent,
		    subString: "Netscape",
		    identity: "Netscape"
		},
		{
		    string: navigator.userAgent,
		    subString: "MSIE",
		    identity: "Explorer",
		    versionSearch: "MSIE"
		},
		{
		    string: navigator.userAgent,
		    subString: "Gecko",
		    identity: "Mozilla",
		    versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
		    string: navigator.userAgent,
		    subString: "Mozilla",
		    identity: "Netscape",
		    versionSearch: "Mozilla"
		}
	],
    dataOS: [
		{
		    string: navigator.platform,
		    subString: "Win",
		    identity: "Windows"
		},
		{
		    string: navigator.platform,
		    subString: "Mac",
		    identity: "Mac"
		},
		{
		    string: navigator.userAgent,
		    subString: "iPhone",
		    identity: "iPhone/iPod"
		},
		{
		    string: navigator.platform,
		    subString: "Linux",
		    identity: "Linux"
		}
	]

};
BrowserDetect.init();


function ArticleView(url) {
    link = window.open(url, "Article", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=600,height=500,left=40,top=50");
}
//below function is used when displaying links and resources in a dropdown
//this will hide/show the anchor element next to the dropdown based on the selection
function setAnchorElement(ctrl, id) {
    var selIndex = ctrl.selectedIndex;
    var selValue = ctrl[selIndex].value.split("[#####]");
    if (selValue[0] != "#") {
        document.getElementById(id).style.display = "";
        document.getElementById(id).href = selValue[0];
        document.getElementById(id).target = selValue[1];
    }
    else {
        document.getElementById(id).style.display = "none";
    }

}
//below function is used when displaying links and resources in a dropdown
//this will hide/show the anchor element next to the dropdown based on the selection
function RedirectLinkResource(ctrl) {
    var selIndex = ctrl.selectedIndex;
    var selValue = ctrl[selIndex].value.split("[#####]");
    if (selValue[0] != "#") {
        if (selValue[1] == "_self") {
            window.navigate(selValue[0]);
        }
        else {
            window.open(selValue[0], "LinkResource");
        }
    }


}
//below function is used for displaying news in a popup window
function openpopup(Path) {
    if (window.showModalDialog) {
        window.showModalDialog(Path, "newclient", "dialogWidth:750px;dialogHeight:475px");
    }
    else {
        window.open(Path, "newwin", "top=100,left=100,width=750,height=475,resizable=yes,scrollbars=yes").focus();
    }
}
//below function is used for displaying dynamic result
function Symm_UpdateExpressionResult(behaviorId, expressionId, formatType, formId, pageId, slNo, controlType, control, fileNameWithPath) {
    var behavior = $find(behaviorId);
    var xml = CreateXMLData(pageId, controlType, control, "Value");
    xml += CreateXMLData(pageId, controlType, control, "Text");
    xml = '<Form Id="' + formId + '"><Page Id="' + pageId + '"><Control Id="' + slNo + '">' + xml + '</Control></Page></Form>';
    if (behavior) {
        behavior.populate(xml + "<ExpressionId>" + expressionId + "</ExpressionId><FormatType>" + formatType + "</FormatType><FormFilePath>" + fileNameWithPath + "</FormFilePath><TargetControlId>" + behaviorId + "</TargetControlId>");
    }

}
function CreateXMLData(PageId, ControlType, Control, ValueOrText) {
    var ValueXML;
    switch (ControlType) {
        case "LBL":
        case "MTXT":
        case "TXT":
            {
                if (ValueOrText == "Text")
                    ValueXML = "<ControlText><Row1><Column1><Value0>" + Control.value + "</Value0></Column1></Row1></ControlText>";
                else
                    ValueXML = "<ControlValue><Row1><Column1><Value0>" + Control.value + "</Value0></Column1></Row1></ControlValue>";

                break;
            }
        case "DP":
            {
                if (ValueOrText == "Text")
                    ValueXML = "<ControlText><Row1><Column1><Value0>" + Control.value + "</Value0></Column1></Row1></ControlText>";
                else
                    ValueXML = "<ControlValue><Row1><Column1><Value0>" + Control.value + "</Value0></Column1></Row1></ControlValue>";

                break;
            }
        case "CSEL":
        case "RBL":
            {
                if (ValueOrText == "Text") {
                    var text = "";
                    var labels = document.getElementsByTagName("label"), i;
                    for (i = 0; i < labels.length; i++) {
                        if (labels[i].htmlFor == Control.id) {
                            text = labels[i].innerHTML;
                        }
                    }
                    ValueXML = "<ControlText><Row1><Column1><Value1>" + text + "</Value1></Column1></Row1></ControlText>";
                }
                else
                    ValueXML = "<ControlValue><Row1><Column1>" + Control.value + "</Column1></Row1></ControlValue>";
                break;
            }
        case "CBL":
            {
                if (ValueOrText == "Text") {
                    var id = Control.id.substring(0, Control.id.lastIndexOf('_'));
                    var selTexts = ''; var counter = 1;
                    $('[for*=' + id + ']').each(function () {
                        selTexts += "<Column" + counter + "><Value1>" + $(this).text() + "</Value1></Column" + counter + ">";
                        counter++;
                    });

                    ValueXML = "<ControlText><Row1>" + selTexts + "</Row1></ControlText>";
                }
                else {
                    var name = Control.name.substring(0, Control.name.lastIndexOf('$'));
                    var selValues = ''; var counter = 1;
                    $('[name*=' + name + ']').each(function () {
                        if ($(this).is(':checked')) {
                            selValues += "<Column" + counter + "><Value0>true</Value0>" + $(this).val() + "</Column" + counter + ">";
                        }
                        else {
                            selValues += "<Column" + counter + "><Value0>false</Value0>" + $(this).val() + "</Column" + counter + ">";
                        }
                        counter++;
                    });
                    ValueXML = "<ControlValue><Row1>" + selValues + "</Row1></ControlValue>";
                }
                break;
            }
            //        case "SMTX":
            //        {
            //            if (ValueOrText == "Text")
            //            {
            //                var text = "";
            //                var labels=document.getElementsByTagName("label"),i;
            //                for( i=0; i<labels.length;i++ )
            //                {
            //                    if(labels[i].htmlFor==Control.id)
            //                    {
            //                        text = labels[i].innerHTML;
            //                    }
            //                }            
            //                ValueXML = "<ControlText><Column1><Value1>" + text + "</Value1></Column1></ControlText>";
            //            }
            //            else
            //                ValueXML = "<ControlValue><Column1>" + Control.value + "</Column1></ControlValue>";
            //            break;
            //        }        
        case "CDD":
        case "DDL":
            {
                if (ValueOrText == "Text") {
                    ValueXML = "<ControlText><Row1><Column1><Value1>" + Control.options[Control.selectedIndex].text + "</Value1></Column1></Row1></ControlText>";
                }
                else
                    ValueXML = "<ControlValue><Row1><Column1>" + Control.value + "</Column1></Row1></ControlValue>";
                break;
            }
        case "CB":
            {
                var arrCheckValue = Control.value.split("~");
                var selValues = "";
                var selTexts = "";
                if (Control.checked) {
                    selValues = "true";
                    selTexts = arrCheckValue[0];
                }
                else {
                    selValues = "false";
                    selTexts = arrCheckValue[1];
                }
                if (ValueOrText == "Text")
                    ValueXML = "<ControlText><Row1><Column1><Value1>" + selTexts + "</Value1></Column1></Row1></ControlText>";
                else
                    ValueXML = "<ControlValue><Row1><Column1><Value1>" + selValues + "</Value1></Column1></Row1></ControlValue>";

                break;
            }
    }
    return ValueXML;
}

function rnd() {
    today = new Date();
    jran = today.getTime();

    ia = 9301;
    ic = 49297;
    im = 233280;
    jran = (jran * ia + ic) % im;
    return jran / (im * 1.0);
}

function openHelp(name) {

    if (window.showModalDialog) {
        var myRand = Math.ceil(rnd() * 50000);
        var returnValue = window.showModalDialog(name + "&rand=" + myRand, "newclient", "scroll:no;resizable:no;status:no;dialogWidth:990px;dialogHeight:660px");
        if (returnValue != null && returnValue != '') {
        }
    }
    else {
        window.open(name, "newwin", "top=100,left=100,width=990,height=660,resizable=no,scrollbars=no").focus();
    }
}
function openExtrasPopup(name) {
    if (window.showModalDialog) {
        var myRand = Math.ceil(rnd() * 50000);
        var returnValue = window.showModalDialog(name + "&rand=" + myRand, "newclient", "scroll:yes;resizable:yes;status:no;dialogWidth:750px;dialogHeight:550px");
        if (returnValue != null && returnValue != '') {
        }
    }
    else {
        window.open(name, "newwin", "top=100,left=100,width=900,height=550,resizable=yes,scrollbars=yes").focus();
    }
}
function openContactViewPopup(name) {
    if (window.showModalDialog) {
        var myRand = Math.ceil(rnd() * 50000);
        var returnValue = window.showModalDialog(name + "&rand=" + myRand, "newclient", "scroll:no;resizable:yes;status:no;dialogWidth:400px;dialogHeight:165px");
        if (returnValue != null && returnValue != '') {
        }
    }
    else {
        window.open(name, "newwin", "top=100,left=100,width=400,height=165,resizable=yes,scrollbars=yes").focus();
    }
}
function openNewsViewPopup(name) {
    if (window.showModalDialog) {
        var myRand = Math.ceil(rnd() * 50000);
        var returnValue = window.showModalDialog(name + "&rand=" + myRand, "newclient", "scroll:yes;resizable:yes;status:no;dialogWidth:750px;dialogHeight:475px");
        if (returnValue != null && returnValue != '') {
        }
    }
    else {
        window.open(name, "newwin", "top=100,left=100,width=750,height=475,resizable=yes,scrollbars=yes").focus();
    }
}
function openFormflowHistoryPopup(name) {
    if (window.showModalDialog) {
        var myRand = Math.ceil(rnd() * 50000);
        var returnValue = window.showModalDialog(name + "&rand=" + myRand, "newclient", "scroll:no;resizable:yes;status:no;dialogWidth:750px;dialogHeight:475px");
        if (returnValue != null && returnValue != '') {
        }
    }
    else {
        window.open(name, "newwin", "top=100,left=100,width=750,height=475,resizable=yes,scrollbars=yes").focus();
    }
}
function checkDecimals(id, evt) {
    var txtControl = (evt.srcElement) ? document.getElementById(evt.srcElement.id).value : document.getElementById(evt.target.id).value;
    var txtLength = txtControl.length;
    var fieldvalues = new Array(txtLength);
    var charCode = (evt.which) ? evt.which : event.keyCode

    if (txtControl.length > 0) {
        for (i = 0; i < txtLength; i++) {
            fieldvalues[i] = txtControl.slice(i, i + 1);
        }
        if (charCode == 0x2E) {
            for (i = 0; i < txtLength; i++) {
                if (fieldvalues[i] == '.') {
                    charCode = 0;
                }
            }
        }
    }
    pass = (((charCode >= 0x30) && (charCode <= 0x39)) || ((charCode == 0x2E)) || ((charCode == 8)));
    if (pass == false) {
        charCode = 0;
    }
    return pass;
}

/* Date validation dd/MM/yyyy starts here*/
// Declaring valid date character, minimum year and maximum year
var dtCh = "/";
var minYear = 1900;
var maxYear = 2100;

function isInteger(s) {
    var i;
    for (i = 0; i < s.length; i++) {
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag) {
    var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++) {
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary(year) {
    // February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ((!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28);
}
function DaysArray(n) {
    for (var i = 1; i <= n; i++) {
        this[i] = 31
        if (i == 4 || i == 6 || i == 9 || i == 11) { this[i] = 30 }
        if (i == 2) { this[i] = 29 }
    }
    return this
}

function checkDate(ctrl, format) {
    dtStr = ctrl.value;
    if (dtStr == "")
        return true;
    var daysInMonth = DaysArray(12)
    var pos1 = dtStr.indexOf(dtCh)
    var pos2 = dtStr.indexOf(dtCh, pos1 + 1)
    var strDay;
    var strMonth;
    var strYear;
    if (format == "dd/MM/yyyy") {
        strDay = dtStr.substring(0, pos1)
        strMonth = dtStr.substring(pos1 + 1, pos2)
    }
    else if (format == "MM/dd/yyyy") {
        strMonth = dtStr.substring(0, pos1)
        strDay = dtStr.substring(pos1 + 1, pos2)
    }
    strYear = dtStr.substring(pos2 + 1)
    strYr = strYear
    if (strDay.charAt(0) == "0" && strDay.length > 1) strDay = strDay.substring(1)
    if (strMonth.charAt(0) == "0" && strMonth.length > 1) strMonth = strMonth.substring(1)
    for (var i = 1; i <= 3; i++) {
        if (strYr.charAt(0) == "0" && strYr.length > 1) strYr = strYr.substring(1)
    }
    month = parseInt(strMonth)
    day = parseInt(strDay)
    year = parseInt(strYr)
    if (pos1 == -1 || pos2 == -1) {
        alert("The date format should be : " + format);
        ctrl.value = "";
        ctrl.focus();
        return false
    }
    if (strMonth.length < 1 || month < 1 || month > 12) {
        alert("Please enter a valid month")
        ctrl.value = "";
        ctrl.focus();
        return false
    }
    if (strDay.length < 1 || day < 1 || day > 31 || (month == 2 && day > daysInFebruary(year)) || day > daysInMonth[month]) {
        alert("Please enter a valid day")
        ctrl.value = "";
        ctrl.focus();
        return false
    }
    if (strYear.length != 4 || year == 0 || year < minYear || year > maxYear) {
        alert("Please enter a valid 4 digit year between " + minYear + " and " + maxYear)
        ctrl.value = "";
        ctrl.focus();
        return false
    }
    if (dtStr.indexOf(dtCh, pos2 + 1) != -1 || isInteger(stripCharsInBag(dtStr, dtCh)) == false) {
        alert("Please enter a valid date")
        ctrl.value = "";
        ctrl.focus();
        return false
    }
    return true
}
/* Date validation dd/MM/yyyy starts here*/

var fontSize = 1;
function ZoomIn() {
    fontSize += 0.1;
    document.body.style.fontSize = fontSize + "em";
}
function ZoomOut() {
    fontSize -= 0.1;
    document.body.style.fontSize = fontSize + "em";
}


/* Horizontal Menu with image starts here*/
function MM_swapImgRestore() { //v3.0
    var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}

function MM_preloadImages() { //v3.0
    var d = document; if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i, j = d.MM_p.length, a = MM_preloadImages.arguments; for (i = 0; i < a.length; i++)
            if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; } 
    }
}

function MM_findObj(n, d) { //v4.01
    var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
    var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
        if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
}
/* Horizontal Menu with image ends here*/


/* To avoid double clicks on Wizard button */
var pbControl = null;
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_beginRequest(BeginRequestHandler);
prm.add_endRequest(EndRequestHandler);
function BeginRequestHandler(sender, args) {
    pbControl = args.get_postBackElement();  //the control causing the postback
    if (pbControl != null) {
        pbControl.disabled = true;
    }
//    if (prm.get_isInAsyncPostBack()) {
//        args.set_cancel(true);
//    }
}
function EndRequestHandler(sender, args) {
    if (pbControl != null) {
        pbControl.disabled = false;
    }
    pbControl = null;
}
/* End of - To avoid double clicks on Wizard button */


//this function is used for removing session variables in the admin side
//in the master page we use one hidden field for storing the required data instead of storing in session
function SubmitForm(path) {
    document.forms[0].method = 'post';
    document.forms[0].action = path;
    document.forms[0].submit();
}

function getAlternative(divid, alternateDivId) {
    document.getElementById("tbl" + divid + "_" + alternateDivId).style.display = "";
    document.getElementById("tbl" + alternateDivId + "_" + divid).style.display = "none";
}

function formDurationElapsed(hiddenFieldId, redirectPath, timeOutMessage) {
    var arrTimer = document.getElementById(hiddenFieldId).value.split(",");
    if (arrTimer[1] == 'false') {
        alert(timeOutMessage);
        document.getElementById(hiddenFieldId).value = "0,true";
        __doPostBack('', 'TimedForm');
        //SubmitForm(redirectPath);
    }
}
function SubmitFrameForm(path, Id, encryptId) {
    document.getElementById("ctl00_ContentPlaceHolder1_hdnGlassSession").value = "";
    if (document.getElementById("ctl00_ContentPlaceHolder1_hdnGlassSession") != null)
        document.getElementById("ctl00_ContentPlaceHolder1_hdnGlassSession").value = "<FrameModelId>" + Id + "</FrameModelId>";
    document.aspnetForm.method = 'post';
    document.aspnetForm.action = path + "?os=" + encryptId;
    document.aspnetForm.submit();
}
function SubmitSunglassForm(path, Id, encryptId) {
    document.getElementById("ctl00_ContentPlaceHolder1_hdnSunGlassSession").value = "";
    if (document.getElementById("ctl00_ContentPlaceHolder1_hdnSunGlassSession") != null)
        document.getElementById("ctl00_ContentPlaceHolder1_hdnSunGlassSession").value = "<FrameModelId>" + Id + "</FrameModelId>";
    document.aspnetForm.action = path + "?os=" + encryptId;
    document.aspnetForm.submit();
}
function SubmitAccessoriesForm(path, Id, encryptId) {
    document.getElementById("ctl00_ContentPlaceHolder1_hdnAccessoriesSession").value = "";
    if (document.getElementById("ctl00_ContentPlaceHolder1_hdnAccessoriesSession") != null)
        document.getElementById("ctl00_ContentPlaceHolder1_hdnAccessoriesSession").value = "<AccessoriesId>" + Id + "</AccessoriesId>";
    document.aspnetForm.method = 'post';
    document.aspnetForm.action = path + "?os=" + encryptId;
    document.aspnetForm.submit();
}
function SubmitContactLensForm(path, Id, encryptId) {
    document.getElementById("ctl00_ContentPlaceHolder1_hdnContactLensSession").value = "";
    if (document.getElementById("ctl00_ContentPlaceHolder1_hdnContactLensSession") != null)
        document.getElementById("ctl00_ContentPlaceHolder1_hdnContactLensSession").value = "<ContactLensId>" + Id + "</ContactLensId>";
    document.aspnetForm.method = 'post';
    document.aspnetForm.action = path + "?os=" + encryptId;
    document.aspnetForm.submit();
}
function SetSearchValue(obj, selectId) {

    i = 0
    if (document.getElementById("ctl00_ContentPlaceHolder1_hdnGlassSearch").value == '')
        document.getElementById("ctl00_ContentPlaceHolder1_hdnGlassSearch").value = "";

    if (obj.id.indexOf("chk") > -1) {
        value = document.getElementById("ctl00_ContentPlaceHolder1_hdnGlassSearch").value;
        var chk = obj.getElementsByTagName('input');
        for (var ichk = 0; ichk < chk.length; ichk++) {
            if (chk[ichk].type == "checkbox") {
                id = chk[ichk].id.split("_")
                if (id.length > 0) {
                    index = id[id.length - 1]
                    Chk = id[id.length - 3]
                }
                if (chk[ichk].checked) {
                    if (value.indexOf("<Id>" + Chk + index + "</Id>") == -1) {
                        document.getElementById("ctl00_ContentPlaceHolder1_hdnGlassSearch").value = document.getElementById("ctl00_ContentPlaceHolder1_hdnGlassSearch").value + "<Id>" + Chk + index + "</Id>";
                    }
                }
                else {
                    if (value.indexOf("<Id>" + Chk + index + "</Id>") != -1) {
                        nodeToReplace = "<Id>" + Chk + index + "</Id>";
                        value = value.replace(nodeToReplace, "");
                        document.getElementById("ctl00_ContentPlaceHolder1_hdnGlassSearch").value = value;
                    }
                }
            }
        }
    }
    if (obj.id.indexOf("rdBrand") > -1) {
        tempValue = document.getElementById("ctl00_ContentPlaceHolder1_hdnGlassSearch").value;
        var rd = obj.getElementsByTagName('input');
        for (var ird = 0; ird < rd.length; ird++) {
            id = rd[ird].id.split("_")
            if (id.length > 0) {
                index = id[id.length - 1]
                rdid = id[id.length - 3]
            }
            if (rd[ird].type == "radio") {
                if (rd[ird].checked) {
                    if (tempValue.indexOf("<Id>" + rdid) != -1) {
                        nodeToReplace = tempValue.substring(tempValue.indexOf("<Id>" + rdid), tempValue.indexOf("</Id>"));
                        var newNode = "<Id>" + rdid + index;
                        tempValue = tempValue.replace(nodeToReplace, newNode);
                        document.getElementById("ctl00_ContentPlaceHolder1_hdnGlassSearch").value = tempValue;

                    }
                    else {
                        document.getElementById("ctl00_ContentPlaceHolder1_hdnGlassSearch").value = document.getElementById("ctl00_ContentPlaceHolder1_hdnGlassSearch").value + "<Id>" + rdid + index + "</Id>";

                    }
                }
            }
        }
    }
    if (obj.id.indexOf("btnGeneralGlassSearch") > -1) {
        document.getElementById("ctl00_ContentPlaceHolder1_hdnGlassSearch").value = 1;
    }
    if (obj.id.indexOf("btnGeneralAccessoriesSearch") > -1) {
        document.getElementById("ctl00_ContentPlaceHolder1_hdnGlassSearch").value = 1;
    }
    if (obj.id.indexOf("btnGeneralContactLensSearch") > -1) {
        document.getElementById("ctl00_ContentPlaceHolder1_hdnGlassSearch").value = 1;
    }
    if (obj.id.indexOf("btnGeneralGlassReset") > -1) {
        document.getElementById("ctl00_ContentPlaceHolder1_hdnGlassSearch").value = 0;
    }
    if (obj.id.indexOf("lnk") > -1) {
        if (selectId != "") {
            value = document.getElementById("ctl00_ContentPlaceHolder1_hdnGlassSearch").value;
            var chk = document.getElementById("ctl00_ContentPlaceHolder1_" + selectId).getElementsByTagName('input');
            for (var ichk = 0; ichk < chk.length; ichk++) {
                id = chk[ichk].id.split("_")
                if (id.length > 0) {
                    index = id[id.length - 1]
                    Chk = id[id.length - 3]
                }
                if (value.indexOf("<Id>" + Chk + index + "</Id>") != -1) {
                    nodeToReplace = "<Id>" + Chk + index + "</Id>";
                    value = value.replace(nodeToReplace, "");
                    document.getElementById("ctl00_ContentPlaceHolder1_hdnGlassSearch").value = value;
                }
            }
        }
    }

    //prompt("please copy the code",document.getElementById("ctl00_ContentPlaceHolder1_hdnGlassSearch").value);
    //alert(defpath)
}

function setId(Id, node) {

    var nodeToReplace = "";
    if (document.getElementById("hdnId") != null) {
        if (Id != 0) {
            var value = document.getElementById("hdnId").value;
            if (node != "File") {
                if (value.indexOf("<FileId>") != -1) {
                    nodeToReplace = value.substring(value.indexOf("<FileId>"), value.indexOf("</FileId>") + 9);
                    value = value.replace(nodeToReplace, "");
                    document.getElementById("hdnId").value = value;
                }
            }
            if (value.indexOf("<" + node + "Id>") == -1)
                document.getElementById("hdnId").value = document.getElementById("hdnId").value + "<" + node + "Id>" + Id + "</" + node + "Id>";
            else {
                nodeToReplace = value.substring(value.indexOf("<" + node + "Id>"), value.indexOf("</" + node + "Id>"));
                var newNode = "<" + node + "Id>" + Id;
                value = value.replace(nodeToReplace, newNode);
                document.getElementById("hdnId").value = value;

            }
        }


    }
}

function showHideSectionCondition(control, pageId, controlType, slNo, formId, responseFile, siteRoot) {
    
    var summaryXML = "";
    $('[summarycontrol]').each(function () {
        summaryXML += "<Summary>" + $(this).attr('summarycontrol') + "</Summary>";
        $("#siteUpdateProgress").show();
//        // create new span
//        var newDiv = $('<span class="busy_postback">&nbsp;&nbsp;&nbsp;&nbsp;</span>');
//        if (($(this).get(0).tagName.toLowerCase() == "input" && $(this).attr("type").toLowerCase() == "hidden") || $(this).attr('id').indexOf('_DR_') > 0)
//            newDiv = null;
//        else
//            $(this).after(newDiv);

    });   //$('[summarycontrol]').each(function () {
    $('[customattrib]').each(function () {
        $("#siteUpdateProgress").show();
//        // create new span
//        var newDiv = $('<span class="busy_postback">&nbsp;&nbsp;&nbsp;&nbsp;</span>');
//        $(this).after(newDiv);
    });
    summaryXML = "<Root>" + summaryXML + "</Root>";

    var valueXML = CreateXMLData(pageId, controlType, control, "Value");
    valueXML = valueXML.substring(valueXML.indexOf('<ControlValue>') + '<ControlValue>'.length, valueXML.indexOf('</ControlValue>'));
    var textXML = CreateXMLData(pageId, controlType, control, "Text");
    textXML = textXML.substring(textXML.indexOf('<ControlText>') + '<ControlText>'.length, textXML.indexOf('</ControlText>'));
    $.ajax({
        url: siteRoot + "/SymmWebService.asmx/DoPostBack",
        global: false,
        type: "POST",
        data: "controlValue=" + valueXML + "&controlText=" + textXML
        + "&pageId=" + pageId + "&slNo=" + slNo + "&formId=" + formId + "&responseFile=" + responseFile + "&summaryXML=" + summaryXML,
        dataType: "html",
        async: false,
        failure: function () {
            $("#siteUpdateProgress").hide();
            //            //remove the busy span created
            //            $('.busy_postback').each(function () {
            //                $(this).remove();
            //            });
        },
        success: function (xmlData) {
            $("#siteUpdateProgress").hide();
            //            //remove the busy span created
            //            $('.busy_postback').each(function () {
            //                $(this).remove();
            //            });
            xmlData = xmlData.replace(/\&lt;/g, '<').replace(/\&gt;/g, '>');
            xmlData = xmlData.substring(xmlData.indexOf('<Root>'), xmlData.indexOf('</string>'));
            var $dom = $.xmlDOM(xmlData);
            $dom.find("Expression").each(function () {
                var id = $(this).attr("Id");
                var result = $(this).text();
                //show/hide rows,div,tables
                $('[customattrib]').each(function () {
                    var attrib = $(this).attr('customattrib');
                    attrib = attrib.substring(attrib.indexOf('}') + 1, attrib.indexOf('{/'));
                    if (attrib == id) {
                        if (result.toLowerCase() == "true")
                            $(this).fadeIn(500);
                        else
                            $(this).fadeOut();
                    }
                }); //$('[customattrib]').each(function () {
            }); //$dom.find("Expression").each(function () {
            //set summary values
            $dom.find("Summary").each(function () {
                var id = $(this).attr("Id");
                var result = $(this).text();
                //set summary value for controls
                $('[summarycontrol]').each(function () {
                    var attrib = $(this).attr('summarycontrol');
                    if (attrib == id) {
                        if ($(this).get(0).tagName.toLowerCase() == "select") {
                            $("select option").each(function () {
                                if ($(this).text() == result)
                                    $(this).attr("selected", "selected");
                            });
                        }
                        else {
                                this.innerHTML = result;
                        }
                    }
                }); //$('[summarycontrol]').each(function () {
            }); //$dom.find("Summary").each(function () {

        } //success: function (xmlData) {
    });                  //$.ajax({
}

var myReq = new XMLHttpRequest();

function refreshCaptcha(siteRoot, controlId) {
    if (window.XMLHttpRequest) {
        var url = siteRoot + "/SymmWebService.asmx/RefreshCaptcha";
        /* Calling web service */
        myReq = new XMLHttpRequest();
        myReq.onreadystatechange = setCaptchaImage;
        myReq.open("POST", url, false);
        myReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        myReq.send("contextKey=" + controlId);
    }
}

function setCaptchaImage() {
    if (myReq.readyState == 4) // Completed operation
    {
        var doc;

        if (navigator.appName != "Microsoft Internet Explorer") {
            // Mozilla, Firefox, and related browsers
            doc = document.implementation.createDocument("", "", null);
            parser = new DOMParser();
            doc = parser.parseFromString(myReq.responseText, "text/xml");
        }
        else {
            // Internet Explorer.
            doc = new ActiveXObject("Microsoft.XMLDOM");
            doc.async = "false";
            doc.loadXML(myReq.responseText);                //  Parse text into it
        }

        var docelt = doc.firstChild;
        while (docelt != null) {
            if (docelt.nodeType == 1)                       //Node.ELEMENT_NODE
                break;
            docelt = docelt.nextSibling;
        }

        var responseInfo = docelt.childNodes[0].nodeValue.split(",");

        document.getElementById(responseInfo[0] + "_IFR").src = responseInfo[1];
        document.getElementById(responseInfo[0] + "_CPCH").value = responseInfo[2];
    }
}

//ADDED NEW POSTCODE CONTROL
/* POSTCODE Script Starts */
function getPostcodePopulateAddress(controlId) {    //ADDED NEW POSTCODE CONTROL
    var addressCtrld = controlId;
    if (document.getElementById(addressCtrld + "_DDLADDRESS") != null) {
        if (document.getElementById(addressCtrld + "_DDLADDRESS").selectedIndex != null) {
            var ddl = document.getElementById(addressCtrld + "_DDLADDRESS");
            var address = ddl[ddl.selectedIndex].value.split(",");

            if (document.getElementById(addressCtrld + "_TRDRPDOWN") != null) {
                document.getElementById(addressCtrld + "_TRDRPDOWN").style.display = "none";

                if (document.getElementById(addressCtrld + "_TRFIND") != null) {
                    document.getElementById(addressCtrld + "_TRFIND").style.display = "";
                }
                if (document.getElementById(addressCtrld + "_TBLPSTCTRL") != null) {
                    document.getElementById(addressCtrld + "_TBLPSTCTRL").style.display = "";

                    if (document.getElementById(addressCtrld + "_HDNVSBL") != null)
                        document.getElementById(addressCtrld + "_HDNVSBL").value = addressCtrld + "_TBLPSTCTRL";
                    
                    if (document.getElementById(addressCtrld + "_TXTCOMPANY") != null) {
                        document.getElementById(addressCtrld + "_TXTCOMPANY").value = address[0];
                    }
                   
                    if (document.getElementById(addressCtrld + "_TXTBUILDINGNAME") != null) {
                        document.getElementById(addressCtrld + "_TXTBUILDINGNAME").value = address[1];
                    }
                   
                    if (document.getElementById(addressCtrld + "_TXTADDRESS1") != null) {
                        document.getElementById(addressCtrld + "_TXTADDRESS1").value = address[2];
                    }
                    
                    if (document.getElementById(addressCtrld + "_TXTADDRESS2") != null) {
                        document.getElementById(addressCtrld + "_TXTADDRESS2").value = address[3];
                    }
                    
                    if (document.getElementById(addressCtrld + "_TXTADDRESS3") != null) {
                        document.getElementById(addressCtrld + "_TXTADDRESS3").value = address[4];
                    }
                    
                    if (document.getElementById(addressCtrld + "_TXTADDRESS4") != null) {
                        document.getElementById(addressCtrld + "_TXTADDRESS4").value = address[5];
                    }
                   
                    if (document.getElementById(addressCtrld + "_TXTADDRESS5") != null) {
                        document.getElementById(addressCtrld + "_TXTADDRESS5").value = address[6];
                    }
                   
                    if (document.getElementById(addressCtrld + "_TXTPOSTCODE") != null) {
                        document.getElementById(addressCtrld + "_TXTPOSTCODE").value = address[7];
                    }
                   
                    if (document.getElementById(addressCtrld + "_TXTCOUNTRY") != null) {
                        document.getElementById(addressCtrld + "_TXTCOUNTRY").value = address[8];
                    }
                    if (document.getElementById(addressCtrld + "_TXTSTREET") != null) {
                        document.getElementById(addressCtrld + "_TXTSTREET").value = address[0];
                    }
                    if (document.getElementById(addressCtrld + "_TXTPLACE") != null) {
                        document.getElementById(addressCtrld + "_TXTPLACE").value = address[1];
                    }
                }
            }
        }
    }
}

function getPostcodeSelectedText(controlId) {   //ADDED NEW POSTCODE CONTROL
    var addressCtrld = controlId;
    if (document.getElementById(addressCtrld + "_DDLADDRESS") != null) {
        if (document.getElementById(addressCtrld + "_DDLADDRESS").selectedIndex != null) {
            var ddl = document.getElementById(addressCtrld + "_DDLADDRESS");
            if (document.getElementById(addressCtrld + "_HDNONCHANGE") != null) {
                document.getElementById(addressCtrld + "_HDNONCHANGE").value = ddl[ddl.selectedIndex].value;

                alert(ddl[ddl.selectedIndex].value);
            }
        } 
    }
    
}
function getPostcodeFind(controlId) {   //ADDED NEW POSTCODE CONTROL
    var addressCtrld = controlId;
    if (document.getElementById(addressCtrld + "_HDNONCHANGE") != null)
        document.getElementById(addressCtrld + "_HDNONCHANGE").value = "";

    if (document.getElementById(addressCtrld + "_DDLADDRESS") != null) {
        if (document.getElementById(addressCtrld + "_DDLADDRESS").selectedIndex != null) {
            var ddl = document.getElementById(addressCtrld + "_DDLADDRESS");
            ddl.removeAttribute("class");
            ddl.setAttribute("class", "Symm_postcode-dropdown");
        }
    }
    if (document.getElementById(addressCtrld) != null) {
        var txt = document.getElementById(addressCtrld);
        txt.removeAttribute("class");
        txt.setAttribute("class", "Symm_postcode-textbox");
    }
    if (document.getElementById(addressCtrld + "_TRPOSTCODE") != null)
        document.getElementById(addressCtrld + "_TRPOSTCODE").style.display = "";
    if (document.getElementById(addressCtrld + "_TRDRPDOWN") != null) {
        document.getElementById(addressCtrld + "_TRDRPDOWN").style.display = "none";
    }
    if (document.getElementById(addressCtrld + "_HDNVSBL") != null)
        document.getElementById(addressCtrld + "_HDNVSBL").value = addressCtrld + "_TRPOSTCODE";
    if (document.getElementById(addressCtrld + "_TBLPSTCTRL") != null) {
        document.getElementById(addressCtrld + "_TBLPSTCTRL").style.display = "none";


        if (document.getElementById(addressCtrld + "_TXTCOMPANY") != null) {
            document.getElementById(addressCtrld + "_TXTCOMPANY").value = "";
        }
        if (document.getElementById(addressCtrld + "_TXTBUILDINGNAME") != null) {
            document.getElementById(addressCtrld + "_TXTBUILDINGNAME").value = "";
        }
        if (document.getElementById(addressCtrld + "_TXTPOSTCODE") != null) {
            document.getElementById(addressCtrld + "_TXTPOSTCODE").value = "";
        }
        if (document.getElementById(addressCtrld + "_TXTCOUNTRY") != null) {
            document.getElementById(addressCtrld + "_TXTCOUNTRY").value = "";
        }
        if (document.getElementById(addressCtrld + "_TXTADDRESS1") != null) {
            document.getElementById(addressCtrld + "_TXTADDRESS1").value = "";
        }
        if (document.getElementById(addressCtrld + "_TXTADDRESS2") != null) {
            document.getElementById(addressCtrld + "_TXTADDRESS2").value = "";
        }
        if (document.getElementById(addressCtrld + "_TXTADDRESS3") != null) {
            document.getElementById(addressCtrld + "_TXTADDRESS3").value = "";
        }
        if (document.getElementById(addressCtrld + "_TXTADDRESS4") != null) {
            document.getElementById(addressCtrld + "_TXTADDRESS4").value = "";
        }
        if (document.getElementById(addressCtrld + "_TXTADDRESS5") != null) {
            document.getElementById(addressCtrld + "_TXTADDRESS5").value = "";
        }
        if (document.getElementById(addressCtrld + "_TXTSTREET") != null) {
            document.getElementById(addressCtrld + "_TXTSTREET").value = "";
        }
        if (document.getElementById(addressCtrld + "_TXTPLACE") != null) {
            document.getElementById(addressCtrld + "_TXTPLACE").value = "";
        }
        if (document.getElementById(addressCtrld + "_TRFIND") != null)
            document.getElementById(addressCtrld + "_TRFIND").style.display = "none";
    }
}
function getPostcodeDropdownValuesBegin(controlId, postCodeKey, postCodeUserName, search) {  //ADDED NEW POSTCODE CONTROL
    var addressCtrld = controlId;
    document.getElementById("POSTCODECTRLID").value = addressCtrld;

    var Key = postCodeKey; // "MW72-WY65-TD33-UK94";
    var UserName = postCodeUserName; //"CMPNY14000";
    var SearchTerm = document.getElementById(controlId).value;
    var PreferredLanguage = "English";
    var Filter = "";
    if (document.getElementById(addressCtrld + "_TXTSTREET") != null) {
        var script = document.createElement("script"),
        head = document.getElementsByTagName("head")[0],
        url = "http://services.postcodeanywhere.co.uk/PostcodeAnywhere/Interactive/FindByPostcode/v1.00/json.ws?";

        // Build the query string
        url += "&Key=" + encodeURIComponent(postCodeKey);
        url += "&Postcode=" + encodeURIComponent(SearchTerm);
        url += "&UserName=" + encodeURIComponent(postCodeUserName);
        url += "&CallbackFunction=getPostcodeDropdownValuesEnd";
    }
    else {
        var script = document.createElement("script"),
        head = document.getElementsByTagName("head")[0],
        url = "http://services.postcodeanywhere.co.uk/PostcodeAnywhere/Interactive/RetrieveByParts/v1.00/json.ws?";

        // Build the query string
        url += "&Key=" + encodeURIComponent(postCodeKey);
        url += "&" + search + "=" + encodeURIComponent(SearchTerm);
        url += "&UserName=" + encodeURIComponent(postCodeUserName);
        url += "&CallbackFunction=getPostcodeDropdownValuesEnd";
    }

    script.src = url;

    // Make the request
    script.onload = script.onreadystatechange = function () {
        if (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") {
            script.onload = script.onreadystatechange = null;
            if (head && script.parentNode)
                head.removeChild(script);
        }
    }
    head.insertBefore(script, head.firstChild);
}

function getPostcodeDropdownValuesEnd(response) {   //ADDED NEW POSTCODE CONTROL

    var addressCtrld=document.getElementById("POSTCODECTRLID").value;
    // Test for an error
    if (response.length == 1 && typeof (response[0].Error) != "undefined") {
        // Show the error message
        alert(response[0].Description);
    }
    else {
        // Check if there were any items found
        if (response.length == 0)
            alert("Sorry, there were no results");
        else {
            var ddl = document.getElementById(addressCtrld + "_DDLADDRESS");
            
            for (i = 0; i <= ddl.options.length; i++) {
                ddl.remove(0);
            }
            if (document.getElementById(addressCtrld + "_TXTSTREET") != null) {
                for (var i = 0; i < response.length; i++) {
                    var opt = document.createElement("option");
                    ddl.options.add(opt);
                    var text = '';
                    if (text == '') {
                        if (response[i].StreetAddress != '') {
                            text = response[i].StreetAddress;
                        }
                    }
                    else {
                        if (response[i].StreetAddress != '') {
                            text = text + ',' + response[i].StreetAddress;
                        }
                    }
                    if (text == '') {
                        if (response[i].Place != '') {
                            text = response[i].Place;
                        }
                    }
                    else {
                        if (response[i].Place != '') {
                            text = text + ',' + response[i].Place;
                        }
                    }
                    opt.text = text;
                    opt.value = response[i].StreetAddress + ',' + response[i].Place;
                }
            }
            else {
                for (var i = 0; i < response.length; i++) {
                    var opt = document.createElement("option");
                    ddl.options.add(opt);
                    var text = '';
                    if (text == '') {
                        if (response[i].Company != '') {
                            text = response[i].Company;
                        }
                    }
                    else {
                        if (response[i].Company != '') {
                            text = text + ',' + response[i].Company;
                        }
                    }
                    if (text == '') {
                        if (response[i].BuildingName != '') {
                            text = response[i].BuildingName;
                        }
                    }
                    else {
                        if (response[i].BuildingName != '') {
                            text = text + ',' + response[i].BuildingName;
                        }
                    }
                    if (text == '') {
                        if (response[i].Line1 != '') {
                            text = response[i].Line1;
                        }
                    }
                    else {
                        if (response[i].Line1 != '') {
                            text = text + ',' + response[i].Line1;
                        }
                    }
                    if (text == '') {
                        if (response[i].Line2 != '') {
                            text = response[i].Line2;
                        }
                    }
                    else {
                        if (response[i].Line2 != '') {
                            text = text + ',' + response[i].Line2;
                        }
                    }
                    if (text == '') {
                        if (response[i].Line3 != '') {
                            text = response[i].Line3;
                        }
                    }
                    else {
                        if (response[i].Line3 != '') {
                            text = text + ',' + response[i].Line3;
                        }
                    }
                    if (text == '') {
                        if (response[i].Line4 != '') {
                            text = response[i].Line4;
                        }
                    }
                    else {
                        if (response[i].Line4 != '') {
                            text = text + ',' + response[i].Line4;
                        }
                    }
                    if (text == '') {
                        if (response[i].Line5 != '') {
                            text = response[i].Line5;
                        }
                    }
                    else {
                        if (response[i].Line5 != '') {
                            text = text + ',' + response[i].Line5;
                        }
                    }
                    if (text == '') {
                        if (response[i].Postcode != '') {
                            text = response[i].Postcode;
                        }
                    }
                    else {
                        if (response[i].Postcode != '') {
                            text = text + ',' + response[i].Postcode;
                        }
                    }
                    if (text == '') {
                        if (response[i].CountryName != '') {
                            text = response[i].CountryName;
                        }
                    }
                    else {
                        if (response[i].CountryName != '') {
                            text = text + ',' + response[i].CountryName;
                        }
                    }
                    opt.text = text;
                    opt.value = response[i].Company + ',' + response[i].BuildingName + ',' + response[i].Line1 + ',' + response[i].Line2 + ',' + response[i].Line3 + ',' + response[i].Line4 + ',' + response[i].Line5 + ',' + response[i].Postcode + ',' + response[i].CountryName + ',';
                }
            }

            //Sort DDL...
            $("#" + addressCtrld + "_DDLADDRESS").html($("#" + addressCtrld + "_DDLADDRESS" + " option").sort(function (a, b) {
                return a.text == b.text ? 0 : a.text < b.text ? -1 : 1
            }))

            ddl.style.display = "";
            if (document.getElementById(addressCtrld + "_HDNONCHANGE") != null) {
                if (document.getElementById(addressCtrld + "_HDNONCHANGE").value != "") {
                    ddl.value = document.getElementById(addressCtrld + "_HDNONCHANGE").value;
                }
            }
            if (document.getElementById(addressCtrld + "_HDNVSBL") != null)
                document.getElementById(addressCtrld + "_HDNVSBL").value = addressCtrld + "_TRDRPDOWN";
            if (document.getElementById(addressCtrld + "_TRDRPDOWN") != null)
                document.getElementById(addressCtrld + "_TRDRPDOWN").style.display = "";
            if (document.getElementById(addressCtrld + "_TRPOSTCODE") != null)
                document.getElementById(addressCtrld + "_TRPOSTCODE").style.display = "none";
            if (document.getElementById(addressCtrld + "_TRFIND") != null)
                document.getElementById(addressCtrld + "_TRFIND").style.display = "";

//            var retString = response[0].Company + "<br>" + response[0].Line1 + "<br>" + response[0].Line2 + "<br>" + response[0].Line3 + "<br>" + response[0].PostTown + "<br>" + response[0].County + "<br>" + response[0].Postcode;
        }
    }
}
/* POSTCODE Script Ends */


/* Report Template Starts*/
function setXML() {
    document.getElementById("lbReportError").style.display = "none";
    document.getElementById("lblFrom").removeAttribute("class");
    document.getElementById("lblFrom").setAttribute("class", "Symm_ErrorPopup_Label_Std");
    var xml = "";
    var elements = document.getElementById("tblFilter")
    var trElement = elements.getElementsByTagName("tr")
    for (var i = 0; i < trElement.length; i++) {
        var lbl = document.getElementById("lblFilter" + (i + 1))
        var txt = document.getElementById("txtFilter" + (i + 1))
        xml = xml + "<" + lbl.innerHTML + ">" + txt.value.replace("<", "&lt;").replace(">", "&gt;") + "</" + lbl.innerHTML + ">";

    }

    document.getElementById("hdnVariableXML").value = "<Root>" + xml + "</Root>";

}
function populateValues() {
    var xml = document.getElementById("hdnVariableXML").value;
    var xmlDoc;
    if (window.DOMParser) {
        parser = new DOMParser();
        xmlDoc = parser.parseFromString(xml, "text/xml");
    }
    else {// Internet Explorer
        xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
        xmlDoc.async = "false";
        xmlDoc.loadXML(xml);
    }
    var variables = xmlDoc.getElementsByTagName("Root")[0];
    var elements = document.getElementById("tblFilter")
    var trElement = elements.getElementsByTagName("tr")
    for (var i = 0; i < trElement.length; i++) {
        var lbl = document.getElementById("lblFilter" + (i + 1))
        var txt = document.getElementById("txtFilter" + (i + 1))
        if (variables.getElementsByTagName(lbl.innerHTML)[0].firstChild != null) {
            txt.value = variables.getElementsByTagName(lbl.innerHTML)[0].firstChild.nodeValue.replace("&lt;", "<").replace("&gt;", ">");
        }
    }
}
function validatetext(lblText, mode) {
    var elements = document.getElementById("tblFilter")
    var trElement = elements.getElementsByTagName("tr")
    for (var i = 0; i < trElement.length; i++) {
        var lbl = document.getElementById("lblFilter" + (i + 1))
        var txt = document.getElementById("txtFilter" + (i + 1))
        if (lbl.innerHTML == lblText) {
            if (mode == "1") {
                lbl.removeAttribute("class");
                lbl.setAttribute("class", "Symm_ErrorPopup_Label_Err");
            }
            else {
                lbl.removeAttribute("class");
                lbl.setAttribute("class", "Symm_ErrorPopup_Label_Std");
            }
        }


    }
}
/* Report Template Ends*/
