﻿var sslist = '', ssrunning = false, xmlObj, xmlPObj, xmlRObj, IE = false;
var xmlhttp2, xmlhttp3, xmlhttp4, xmlhttp5, xmlhttp6, xmlhttp7;
var xmlDoc, xmlPDoc, newsDoc, xmlCtr, xmlRDoc;
var menutable = '', submenutable = '', newsclicked = false, homemenu = '', sitemap = '';
var cart = new Array();
cart.items = [];
var arr = new Array(50), arrmax = 0;
var arr2 = new Array(50), arrmax2 = 0;
var mytimer, myWidth = 0, myHeight = 0;
var treehtml, lvl = 0, freight = 0;
var attop = false, loggedin = false, username = '', useremail;
var colorbg = "#dfeffd";
var colorbor = "#E05F26";
var colorf = "#052d6c";
var colorover = "#FF3C7B";
var colorout = "#999999";
var coname = "Wilderness Treatment", coemail = "herosjourney@bigpond.com";
// to stop pictures being downloaded
document.oncontextmenu = new Function("{ alert('Graphics remain the property of " + coname + "');return false; }");
window.onscroll = mysc;
document.onkeypress = stopRKey;
var toppic = '';
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
// ####################
function loadXML() {
    try {
        if (window.ActiveXObject) IE = true;        
    }
    catch (err) { };
    //mytimer = setTimeout(getFile2, 1);
    //getFile5('./dbs/Counter.xml');
    //getFile6('SSList.txt');
    //mytimer = setTimeout("getFile6('SSList.txt')", 1);
    mytimer = setTimeout('getFile7("./dbs/myregister.xml")', 1);
    //getFile7('./dbs/myregister.xml');
    //addbreadcrumb("Page", 0, "Home");
    getPageSize();
    //this is for scrolling logo
    resetsubmenu();
    var elem = document.getElementById('content').innerHTML;
    var lo = elem.toLowerCase();
    pos = lo.indexOf('ticker');
    if (pos > 0) newswindow();
    //wtafblog
    if (document.getElementById('wtafblog')) showblog();
};
// ####################
function stopRKey(evt) {
    var evt = (evt) ? evt : ((event) ? event : null);
    var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
    if ((evt.keyCode == 13) && (node.type == "text")) { return false; }
};
// ####################
function getPageSize() {
    myHeight = pageHeight();
    myWidth = pageWidth();
};
// ####################
function getFile7(pURL) {
    pURL = './dbs/MyRegister.xml';
    if (window.XMLHttpRequest) { // code for Mozilla, Safari, etc 
        xmlhttp7 = new XMLHttpRequest();
        xmlhttp7.onreadystatechange = postFileReady7;
        xmlhttp7.open("GET", pURL, true);
        xmlhttp7.send(null);
    } else if (window.ActiveXObject) { //IE 
        xmlhttp7 = new ActiveXObject('Microsoft.XMLHTTP');
        if (xmlhttp7) {
            xmlhttp7.onreadystatechange = postFileReady7;
            xmlhttp7.open('GET', pURL, true);
            xmlhttp7.send();
        }
    }
};
// ####################
// function to handle asynchronous call
function postFileReady7() {
    if (xmlhttp7.readyState == 4) {
        if (xmlhttp7.status == 200) {
            xmlRDoc = xmlhttp7.responseXML;
            useremail = getCookie('eordercmse');
            if (useremail) { loggedin = true; username = getCookie('eordercmsu'); welcomeit(useremail); }
            return;
        }
    }
};
// ####################
function sendemail() {
    var strTo = coname;
    var strFrom = "sales@nbsites.com";
    var strSubject = "Enquiry via web site";
    var strTextBody, noerrors = true;
    document.getElementById('conmsg').innerHTML = "";
    if (document.getElementById('con1').value.length > 0) strTextBody = "Name: " + document.getElementById("con1").value + "|";
    if (document.getElementById('con1').value.length == 0) { document.getElementById('conmsg').innerHTML = 'Please enter your name'; noerrors = false; }
    if (document.getElementById('con2').value.length > 0) strTextBody = strTextBody + "Company: " + document.getElementById("con2").value + "|";
    if (document.getElementById('con3').value.length > 0) strTextBody = strTextBody + "Phone: " + document.getElementById("con3").value + "|";
    if (document.getElementById('con4').value.length > 0) strTextBody = strTextBody + "Email: " + document.getElementById("con4").value + "|";
    if (document.getElementById('con4').value.length == 0) { document.getElementById('conmsg').innerHTML = 'Please enter an email address'; noerrors = false; }
    //if(document.getElementById('con4').value.indexOf('@')==0) { document.getElementById('conmsg').innerHTML='Please enter a valid email address'; noerrors=false;}
    var str = document.getElementById('con4').value;
    var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
    if (!filter.test(str)) {
        document.getElementById('conmsg').innerHTML = 'Please enter a valid email address';
        noerrors = false;
    }
    if (document.getElementById('con5').value.length > 0) strTextBody = strTextBody + "Comments: " + document.getElementById("con5").value + "|";
    //alert(noerrors);
    if (noerrors) document.getElementById('conmsg').innerHTML = 'Please wait ... <img src="sysimages/waiting.gif">';
    //if (noerrors) new Ajax.Updater('conmsg','sendit.aspx?Body=' + strTextBody + '&Subject=' + strSubject + '&From=' + document.getElementById('con4').value,{method:'get'});
    if (noerrors) sendemailasp('sendit.asp', '?Body=' + strTextBody + '&Subject=' + strSubject + '&From=' + document.getElementById('con4').value);
};
// ####################
function sendemailasp(pURL, param) {
    var xmlhttp;
    if (window.XMLHttpRequest) {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();
    }
    else {
        // code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4) {
            document.getElementById('conmsg').innerHTML = xmlhttp.responseText;
        }
    };
    //xmlhttp.open("GET", "sendit.aspx" + param, true);
    xmlhttp.open("GET", "sendit.asp" + param, true);
    xmlhttp.send(null);
};
// ####################
function modaloverlay() {
    el = document.getElementById("modaloverlay");
    getPageSize();
    if (document.getElementById('myoverlay')) {
        document.getElementById('modalcontents').innerHTML = document.getElementById('myoverlay').innerHTML;
        document.getElementById('modalcontents').innerHTML += "<br/><br/>Click here to [<a href='#' onclick='modaloverlay()'>close</a>]";
    }
    //el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
    if (el.style.visibility == "visible") {
        el.style.visibility = 'hidden';
    } else {
        el.style.visibility = 'visible';
        try {
            el.style.width = pageWidth();
            el.style.height = pageHeight();
        } catch (Error) {
            el.style.width = myWidth;
            el.style.height = myHeight;
        };
        //new Effect.Appear(el, { duration: 0.2, from: 0.0, to: 0.9 });
        //unfortunately this drags the background also and looks messy - can't seem to reset it
        //new Draggable(el, {onStart:resetback(), revert: false });
    }
};
// ####################
function resetback() {
    document.getElementById('modaloverlay').height = '100%';
    document.getElementById('modaloverlay').width = '100%';
};
// ####################
function pageWidth() { return window.innerWidth != null ? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null; };
function pageHeight() { return window.innerHeight != null ? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null ? document.body.clientHeight : null; };
function posLeft() {
    return typeof window.pageXOffset != 'undefined' ? window.pageXOffset : document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;
};
function posTop() { return typeof window.pageYOffset != 'undefined' ? window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0; };
function posRight() { return posLeft() + pageWidth(); };
function posBottom() { return posTop() + pageHeight(); };
// ####################
function registerit() {
    var el = document.getElementById('modaloverlay');
    var sr;
    if (el.style.visibility == "visible") {
        //check values entered
        var strTextBody, noerrors = true;
        document.getElementById('rconmsg').innerHTML = "";
        if (document.getElementById('Firstname').value.length > 0) strTextBody = "Firstname=" + document.getElementById("Firstname").value + "|";
        if (document.getElementById('Firstname').value.length == 0) { document.getElementById('rconmsg').innerHTML = 'Please enter your Firstname'; noerrors = false; }
        if (document.getElementById('Surname').value.length > 0) strTextBody += "Surname=" + document.getElementById("Surname").value + "|";
        if (document.getElementById('Surname').value.length == 0) { document.getElementById('rconmsg').innerHTML = 'Please enter your Surname'; noerrors = false; }
        strTextBody += "Coname=" + document.getElementById("Coname").value + "|";
        strTextBody += "Phone=" + document.getElementById("Phone").value + "|";
        strTextBody += "Mobile=" + document.getElementById("Mobile").value + "|";
        if (document.getElementById('Email').value.length > 0) strTextBody += "Email=" + document.getElementById("Email").value + "|";
        if (document.getElementById('Email').value.length == 0) { document.getElementById('rconmsg').innerHTML = 'Please enter an email address'; noerrors = false; }
        if (document.getElementById('Pword').value.length > 0) strTextBody += "Pword=" + document.getElementById("Pword").value + "|";
        if (document.getElementById('Pword').value.length == 0) { document.getElementById('rconmsg').innerHTML = 'Please enter a valid Password'; noerrors = false; }
        if (document.getElementById('Hint').value.length > 0) strTextBody += "Hint=" + document.getElementById("Hint").value + "|";
        if (document.getElementById('Hint').value.length == 0) { document.getElementById('rconmsg').innerHTML = 'Please enter a password hint'; noerrors = false; }
        if (document.getElementById('Addr1').value.length > 0) strTextBody += "Addr1=" + document.getElementById("Addr1").value + "|";
        if (document.getElementById('Addr1').value.length == 0) { document.getElementById('rconmsg').innerHTML = 'Please enter Address Line 1'; noerrors = false; }
        if (document.getElementById('Addr2').value.length > 0) strTextBody += "Addr2=" + document.getElementById("Addr2").value + "|";
        if (document.getElementById('Addr2').value.length == 0) { document.getElementById('rconmsg').innerHTML = 'Please enter Address Line 2'; noerrors = false; }
        strTextBody += "DAddr1=" + document.getElementById("DAddr1").value + "|";
        strTextBody += "DAddr2=" + document.getElementById("DAddr2").value + "|";
        var etype = 'HTML';
        if (document.getElementById('EHTML2').checked) etype = 'Text';
        strTextBody += 'Category=Register|EHTML=' + etype + '|';
        if (document.getElementById('Agree').checked == false) { document.getElementById('rconmsg').innerHTML = 'Please agree to the terms and conditions'; noerrors = false; }
        var str = document.getElementById('Email').value;
        var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
        if (!filter.test(str)) {
            document.getElementById('rconmsg').innerHTML = 'Please enter a valid email address';
            noerrors = false;
        }
        if (noerrors) {
            xmlRObj = xmlRDoc.documentElement;
            var regxml = selNode(xmlRObj, "//Applicant[Email='" + str + "']", true);
            var regval;
            if (regxml) {
                if (IE) regval = regxml.getElementsByTagName('Email').item(0).text;
                if (!IE) regval = regxml.getElementsByTagName('Email')[0].childNodes[0].nodeValue;
                if (regval.length > 0) { document.getElementById('rconmsg').innerHTML = 'That email address already exists - try another email address or use <a href=# onclick="logincust()">Login</a> instead'; noerrors = false; return; }
            }
        }
        if (noerrors) window.open('registerit.aspx?Body=' + strTextBody);
        if (noerrors) welcomeit(str);
        //if (noerrors) alert(strTextBody);
    } else {
        getPageSize();
        el.style.width = myWidth;
        el.style.height = myHeight;
        var mc;
        mc = '<table style="font-size:7pt">';
        mc += '<tr><th style="font-size:12pt" colspan=2 align=left>Register with ' + coname + '</th></tr>';
        mc += '<tr><td>Firstname:*</td><td><input id=Firstname style="width:200px" /></td></tr>';
        mc += '<tr><td>Surname:*</td><td><input id=Surname style="width:200px" /></td></tr>';
        mc += '<tr><td>Company Name:</td><td><input id=Coname style="width:200px" /></td></tr>';
        mc += '<tr><td>Phone:</td><td><input id=Phone style="width:200px" /></td></tr>';
        mc += '<tr><td>Mobile:</td><td><input id=Mobile style="width:200px" /></td></tr>';
        mc += '<tr><td>Email:*</td><td><input id=Email style="width:200px" /></td></tr>';
        mc += '<tr><td>Password (more than 5 characters):*</td><td><input id=Pword style="width:200px" /></td></tr>';
        mc += '<tr><td>Password Hint:*</td><td><input id=Hint style="width:400px" /></td></tr>';
        mc += '<tr><td>Address Line 1:*</td><td><input id=Addr1 style="width:400px" /></td></tr>';
        mc += '<tr><td>Address Line 2:*</td><td><input id=Addr2 style="width:400px" /></td></tr>';
        mc += '<tr><td>Delivery Address 1: <input type=button class=button style="font-size:7pt" value="Copy" onclick="document.getElementById(&quot;DAddr1&quot;).value=document.getElementById(&quot;Addr1&quot;).value;document.getElementById(&quot;DAddr2&quot;).value=document.getElementById(&quot;Addr2&quot;).value" /></td><td><input id=DAddr1 style="width:400px" /></td></tr>';
        mc += '<tr><td>Delivery Address 2:</td><td><input id=DAddr2 style="width:400px" /></td></tr>';
        mc += '<tr><td>Email Format:</td><td><input id=EHTML1 name=ehtml type=radio checked=true" onclick="document.getElementById(&quot;EHTML2&quot;).checked=false" />HTML or&nbsp;&nbsp;<input id=EHTML2 name=ehtml type=radio onclick="document.getElementById(&quot;EHTML1&quot;).checked=false" />Text ?</td></tr>';
        mc += '<tr><td colspan=2><input id=Agree type=checkbox >I agree with and accept the terms and conditions as per the<a href=# onclick="document.getElementById(&quot;modaloverlay&quot;).style.visibility=&quot;hidden&quot; ;window.open(&quot;Privacy Policy.html&quot;,&quot;_self&quot;)"> privacy policy</a> and the <a href=# onclick="document.getElementById(&quot;modaloverlay&quot;).style.visibility=&quot;hidden&quot; ;window.open(&quot;Anti Spam Policy.html&quot;,&quot;_self&quot;)">Anti Spam Policy</a></td></tr>';
        mc += '<tr><td colspan=2><label id=rconmsg style="color:red" /></td><td></td></tr>';
        mc += '<tr><td><input type="button" class="button" value="Continue with Registration" onclick="registerit()" /></td><td align=right><input type="button" class="button" value="Close" onclick="document.getElementById(&quot;modaloverlay&quot;).style.visibility=&quot;hidden&quot;" /></td></tr>';
        mc += '</table>';
        var mcel = document.getElementById('modalcontents');
        var mshadow = document.getElementById('modalshadow');
        mcel.innerHTML = mc;
        var pw = pageWidth();
        var ph = pageHeight();
        mcel.style.width = '600px';
        mcel.style.height = '480px';
        mcel.style.top = '50px';
        mcel.style.left = ((pw - 600) / 2) + 'px';
        mshadow.style.width = '600px';
        mshadow.style.height = '480px';
        mshadow.style.top = '60px';
        mshadow.style.left = ((pw - 580) / 2) + 'px';
        el.style.visibility = 'visible';
        //new Effect.Appear(el, { duration: 0.2, from: 0.0, to: 0.9 });
        window.scrollTo(0, 0);
        //unfortunately this drags the background also and looks messy - can't seems to reset it
        //new Draggable(el, {onStart:resetback(), revert: false });
    }
};
// ####################
function logincust() {
    if (loggedin) logout();
    var el = document.getElementById('modaloverlay');
    getFile7("./dbs/myregister.xml");
    var sr;
    if (el.style.visibility == "visible") {
        //check values entered
        var strTextBody, noerrors = true;
        document.getElementById('rconmsg').innerHTML = "";
        if (document.getElementById('Email').value.length > 0) strTextBody = "Email=" + document.getElementById("Email").value + "|";
        if (document.getElementById('Email').value.length == 0) { document.getElementById('rconmsg').innerHTML = 'Please enter an email address'; noerrors = false; }
        if (document.getElementById('Pword').value.length > 5) strTextBody = strTextBody + "Pword=" + document.getElementById("Pword").value + "|";
        if (document.getElementById('Pword').value.length == 0) { document.getElementById('rconmsg').innerHTML = 'Please enter a valid Password'; noerrors = false; }
        var str = document.getElementById('Email').value;
        var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
        if (!filter.test(str)) {
            document.getElementById('rconmsg').innerHTML = 'Please enter a valid email address';
            noerrors = false;
            return;
        }
        xmlRObj = xmlRDoc.documentElement;
        if (noerrors) {
            var regxml = selNode(xmlRObj, "//Applicant[Email='" + str + "']", true);
            if (!regxml) { noerrors = false; document.getElementById('rconmsg').innerHTML = 'Please enter a valid email address'; }
        }
        if (noerrors) {
            var emval, pval, uname;
            if (IE) {
                emval = regxml.getElementsByTagName('Email').item(0).text;
                pval = regxml.getElementsByTagName('Pword').item(0).text;
                uname = regxml.getElementsByTagName('Firstname').item(0).text;
            }
            if (!IE) {
                emval = regxml.getElementsByTagName('Email')[0].childNodes[0].nodeValue;
                pval = regxml.getElementsByTagName('Pword')[0].childNodes[0].nodeValue;
                uname = regxml.getElementsByTagName('Firstname')[0].childNodes[0].nodeValue;
            }
            if (emval.length == 0 || (emval.length > 0 && emval != document.getElementById('Email').value)) { document.getElementById('rconmsg').innerHTML = 'That email address/login doesn\'t exist - try again'; noerrors = false; }
            if (pval.length == 0 || (pval.length > 0 && pval != document.getElementById('Pword').value)) { document.getElementById('rconmsg').innerHTML = 'That password is incorrect - try again or use <a href=# onclick="loginhint(document.getElementById(&quot;Email&quot;).value)">Password Hint</a> instead'; noerrors = false; }
        }
        if (noerrors) { username = uname; welcomeit(emval); }
        //if (noerrors == true) window.open('registerit.aspx?Body=' + strTextBody );
    } else {
        getPageSize();
        el.style.width = myWidth;
        el.style.height = myHeight;
        var mc;
        mc = '<table style="font-size:7pt">';
        mc += '<tr><th style="font-size:12pt" colspan=2 align=left>Login with ' + coname + '</th></tr>';
        mc += '<tr><td>Email:*</td><td><input id=Email style="width:200px" /></td></tr>';
        mc += '<tr><td>Password:*</td><td><input id=Pword type="password" style="width:200px" /></td></tr>';
        mc += '<tr><td colspan=2><label id=rconmsg style="color:red" /></td><td></td></tr>';
        var hcmd = 'loginhint(document.getElementById(&quot;Email&quot;).value)';
        mc += '<tr><td><input type="button" class="button" value="Close" onclick="document.getElementById(&quot;modaloverlay&quot;).style.visibility=&quot;hidden&quot;" /> <input type="button" class="button" value="Password Hint" onclick="loginhint(document.getElementById(&quot;Email&quot;).value)" /> <input type="button" class="button" onclick="logout();" value="Logout" /></td><td align=right><input type="button" class="button" value="Login" onclick="logincust()" /></td></tr>';
        mc += '</table>';
        var mcel = document.getElementById('modalcontents');
        var mshadow = document.getElementById('modalshadow');
        mcel.innerHTML = mc;
        var pw = pageWidth();
        var ph = pageHeight();
        mcel.style.width = '600px';
        mcel.style.height = '150px';
        mcel.style.top = '50px';
        mcel.style.left = ((pw - 600) / 2) + 'px';
        mshadow.style.width = '600px';
        mshadow.style.height = '150px';
        mshadow.style.top = '60px';
        mshadow.style.left = ((pw - 580) / 2) + 'px';
        el.style.visibility = 'visible';
        //new Effect.Appear(el, { duration: 0.2, from: 0.0, to: 0.9 });
        window.scrollTo(0, 0);
        //unfortunately this drags the background also and looks messy - can't seems to reset it
        //new Draggable(el, {onStart:resetback(), revert: false });
    }
};
// ####################
function loginhint(emval) {
    if (emval.length == 0) { document.getElementById('rconmsg').innerHTML = 'Please enter an email address'; logincust(); return; }
    document.getElementById('rconmsg').innerHTML = '';
    var str = document.getElementById('Email').value;
    var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
    if (!filter.test(str)) {
        document.getElementById('rconmsg').innerHTML = 'Please enter a valid email address';
        return;
    }
    xmlRObj = xmlRDoc.documentElement;
    var hint = '';
    var regxml = selNode(xmlRObj, "//Applicant[Email='" + emval + "']", true);
    if (!regxml) { document.getElementById('rconmsg').innerHTML = 'Please enter a valid email address'; logincust(); return; }
    if (IE) hint = 'Hint: ' + regxml.getElementsByTagName('Hint').item(0).text;
    if (!IE) hint = 'Hint: ' + regxml.getElementsByTagName('Hint')[0].childNodes[0].nodeValue;
    document.getElementById('rconmsg').innerHTML = hint;
};
// ####################
function welcomeit(emailval) {
    xmlRObj = xmlRDoc.documentElement;
    if (emailval.length > 0) {
        var regxml = selNode(xmlRObj, "//Applicant[Email='" + emailval + "']", true);
        if (regxml) {
            if (IE) {
                try {
                    document.getElementById('BName').value = regxml.getElementsByTagName('Firstname').item(0).text + ' ' + regxml.getElementsByTagName('Surname').item(0).text;
                    document.getElementById('BAddress1').value = regxml.getElementsByTagName('Addr1').item(0).text;
                    document.getElementById('BAddress2').value = regxml.getElementsByTagName('Addr2').item(0).text;
                    document.getElementById('BEmail').value = emailval;
                    document.getElementById('BPhone').value = regxml.getElementsByTagName('Phone').item(0).text;
                    document.getElementById('DAddress1').value = regxml.getElementsByTagName('DAddr1').item(0).text;
                    document.getElementById('DAddress2').value = regxml.getElementsByTagName('DAddr2').item(0).text;
                }
                catch (Error) { };
                username = regxml.getElementsByTagName('Firstname').item(0).text;
            }
            if (!IE) {
                try {
                    document.getElementById('BName').value = regxml.getElementsByTagName('Firstname')[0].childNodes[0].nodeValue + ' ' + regxml.getElementsByTagName('Surname')[0].childNodes[0].nodeValue;
                    document.getElementById('BAddress1').value = regxml.getElementsByTagName('Addr1')[0].childNodes[0].nodeValue;
                    document.getElementById('BAddress2').value = regxml.getElementsByTagName('Addr2')[0].childNodes[0].nodeValue;
                    document.getElementById('BEmail').value = emailval;
                    document.getElementById('BPhone').value = regxml.getElementsByTagName('Phone')[0].childNodes[0].nodeValue;
                    document.getElementById('DAddress1').value = regxml.getElementsByTagName('DAddr1')[0].childNodes[0].nodeValue;
                    document.getElementById('DAddress2').value = regxml.getElementsByTagName('DAddr2')[0].childNodes[0].nodeValue;
                }
                catch (Error) { };
                username = regxml.getElementsByTagName('Firstname')[0].childNodes[0].nodeValue;
            }
            document.getElementById('username').innerHTML = 'Welcome back ' + username + '&nbsp;&nbsp;';
            loggedin = true;
            document.getElementById('modaloverlay').style.visibility = 'hidden';
            //create cookie - 30 days till expiry
            //var date = new Date();
            //date.setTime(date.getTime() + (30 * 24 * 60 * 60 * 1000));
            //var expires = "; expires=" + date.toGMTString();
            //document.cookie = "eordercms=" + username + expires + "; path=/";
            setCookie('eordercmsu', username, 365);
            setCookie('eordercmse', emailval, 365);
        }
    }
};
// ####################
function logout() {
    document.getElementById('username').innerHTML = '';
    username = '';
    loggedin = false;
    removeCookie('eordercmsu');
    removeCookie('eordercmse');
    document.getElementById('modaloverlay').style.visibility = 'hidden';
};
// ####################
function setCookie(c_name, value, expiredays) {
    var exdate = new Date(); exdate.setDate(exdate.getDate() + expiredays);
    document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString());
};
// ####################
function getCookie(c_name) {
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(c_name + "=");
        if (c_start != -1) {
            c_start = c_start + c_name.length + 1;
            c_end = document.cookie.indexOf(";", c_start);
            if (c_end == -1) c_end = document.cookie.length;
            return unescape(document.cookie.substring(c_start, c_end));
        }
    }
    return "";
};
// ####################
function removeCookie(c_name) {
    setCookie(c_name, "", -1);
};
// ####################
var phe;
function pichover(pic) {
    var coors = findPos(pic);
    //alert('left=' + coors[0] + ' top=' + coors[1]);
    //var oc = pic.parentNode.href;
    var oc = pic.alt;
    //document.getElementById('pichover').innerHTML = '<img src="' + pic.src + '" width="300px" border=1px onclick="window.open(&quot;' + oc + '&quot;,&quot;_blank&quot;);" />';
    document.getElementById('pichover').innerHTML = '<img src="' + pic.src + '" width="200px" onclick="pichoverend();showprod(&quot;' + oc + '&quot;);" />';
    document.getElementById('pichover').style.left = coors[0] + 'px';
    document.getElementById('pichover').style.top = coors[1] + 'px';
    document.getElementById('pichover').style.display = 'block';
    //phe=window.setTimeout('pichoverend()', slideShowSpeed);
};
// ####################
function pichoverend() {
    document.getElementById('pichover').style.display = 'none';
    //window.clearTimeout(phe);
};
// ####################
function emailfriend(entnu) {
    //add email to friend
    //document.getElementById('content').innerHTML += '<br/><a href="mailto:enter-email-address?Subject=Check out this web page&Body=Thought you might be interested in this - http://www.micropulse.com.au/?' + entnu + '" />Email to a friend</a>';
    var el = document.getElementById('modaloverlay');
    getPageSize();
    if (el.style.visibility == "visible") {
        var femail = document.getElementById('friendemail').value;
        var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
        if (!filter.test(femail)) {
            document.getElementById('emailmsg').innerHTML = 'Please enter a valid email address';
            return;
        } else {
            document.getElementById('emailmsg').innerHTML = '';
            var regExp = /\s+/g;
            entnu = trim(entnu).replace(/\s/g, "%20");
            //window.location = "mailto:" + femail + "?subject=I thought you might be interested in this ...&body=Click on the link to go to this web site - http://decms.micropulse.com.au" + encodeURIComponent(entnu);
            window.location = "mailto:" + femail + "?subject=I thought you might be interested in this ...&body=Click on the link to go to this web site - http://www.wildernesstreatment.com.au";
        }
        el.style.visibility = 'hidden';
    } else {
        el.style.width = myWidth;
        el.style.height = myHeight;
        var mc;
        mc = "<label>Enter your friend's email address: </label><input type='text' style='width:300px;font-family:Arial' id='friendemail'></input>";
        mc += '<br/><label id=emailmsg style="color:red; font-size:7pt;"></label>';
        //mc += "<br/><br/>Click here to [<a href='#' onclick='emailfriend(&quot;" + entnu + "&quot;)'>continue</a>] or [<a href='#' onclick='document.getElementById(&quot;modaloverlay&quot;).style.visibility=&quot;hidden&quot; '>exit</a>]";
        mc += "<br/><br/><input type='button' class='button' onclick='emailfriend(&quot;" + entnu + "&quot;)' value='Continue' /> &nbsp;&nbsp;<input type='button' class='button' onclick='document.getElementById(&quot;modaloverlay&quot;).style.visibility=&quot;hidden&quot;' value='Close' />";
        var mcel = document.getElementById('modalcontents');
        var mshadow = document.getElementById('modalshadow');
        mcel.innerHTML = mc;
        var pw = pageWidth();
        var ph = pageHeight();
        mcel.style.width = '600px';
        mcel.style.height = '100px';
        mcel.style.top = '50px';
        mcel.style.left = ((pw - 600) / 2) + 'px';
        mshadow.style.width = '600px';
        mshadow.style.height = '100px';
        mshadow.style.top = '60px';
        mshadow.style.left = ((pw - 580) / 2) + 'px';
        el.style.visibility = 'visible';
        //new Effect.Appear(el, { duration: 0.2, from: 0.0, to: 0.9 });
        window.scrollTo(0, 0);
        //unfortunately this drags the background also and looks messy - can't seems to reset it
        //new Draggable(el, {onStart:resetback(), revert: false });
    }
};
// ####################
function mysc() {
    if (document.getElementById('modaloverlay').style.visibility == 'visible') {
        document.getElementById('modaloverlay').style.top = document.body.scrollTop;
        window.scrollTo(0, 0); return;
    }
};
// ####################
function selNode(xmlDoc2, elementPath, single) {
    if (window.ActiveXObject) {
        if (single == true) { return xmlDoc2.selectSingleNode(elementPath); }
        if (single != true) { return xmlDoc2.selectNodes(elementPath); }
    }
    else {
        var xpe = new XPathEvaluator();
        var nsResolver = xpe.createNSResolver(xmlDoc2.ownerDocument == null ? xmlDoc2.documentElement : xmlDoc2.ownerDocument.documentElement);
        var results;
        //results=xpe.evaluate(elementPath,xmlDoc2,nsResolver,XPathResult.FIRST_ORDERED_NODE_TYPE, null);
        if (single == true) results = xpe.evaluate(elementPath, xmlDoc2, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
        if (single != true) results = xpe.evaluate(elementPath, xmlDoc2, nsResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
        if (single == true) { return results.singleNodeValue; }
        if (single != true) { return results.selectNodes; }
    }
};
// ####################
function trim(stringToTrim) {
    return stringToTrim.replace(/^\s+|\s+$/g, "");
};
// ####################
function ltrim(stringToTrim) {
    return stringToTrim.replace(/^\s+/, "");
};
// ####################
function rtrim(stringToTrim) {
    return stringToTrim.replace(/\s+$/, "");
};
// ####################
function lightbox(wot, caption) {
    var newImg = new Image();
    newImg.src = wot.src;
    var maxw = 600, maxh = 550;
    var sty = '';
    var ustyle = 'w';
    var factor = 1;
    if (newImg.width > 1000) { factor = newImg.width / maxw; newImg.width = newImg.width / factor; newImg.height = newImg.height / factor; }
    if (newImg.height > newImg.width) ustyle = 'h';
    if (ustyle == 'w') factor = newImg.width / maxw;
    if (ustyle == 'h') factor = newImg.height / maxh;
    getPageSize();
    if (factor > 1) { newImg.width = newImg.width / factor; newImg.height = newImg.height / factor; }
    if (factor < 1) {
        if (ustyle == 'w') factor = maxw / newImg.width;
        if (ustyle == 'h') factor = maxh / newImg.height;
        newImg.width = newImg.width * factor;
        newImg.height = newImg.height * factor;
    }
    var el = document.getElementById('modaloverlay');
    el.style.width = myWidth + 'px';
    el.style.height = myHeight + 'px';
    var mc;
    mc = '<table style="font-size:9pt;font-weight:bold;"><tr><td><img src=' + newImg.src + ' height="' + newImg.height + 'px" width="' + newImg.width + 'px" /></td><td align=right valign=top><input type="button" class="button" value="Close" onclick="document.getElementById(&quot;modaloverlay&quot;).style.visibility=&quot;hidden&quot;" /></td></tr><tr><td colspan=2>' + caption + '</td></tr></table>';
    document.getElementById('modalcontents').innerHTML = mc;
    document.getElementById('modalcontents').style.width = myWidth - 50 + 'px';
    document.getElementById('modalcontents').style.height = myHeight - 50 + 'px';
    el.style.visibility = 'visible';
    //new Effect.Appear(el, { duration: 0.2, from: 0.0, to: 0.9 });
    window.scrollTo(0, 0);
};
// ####################
function showsubmenu(mparent, el) {
    mparent = mparent.replace(' ', '_');
    try {
        var mchild = document.getElementById(mparent);
        if (mchild.innerHTML.length > 0) {
            var coors = findPos(el);
            mchild.style.position = 'absolute';
            mchild.style.left = coors[0] + 'px';
            mchild.style.top = coors[1] + 30 + 'px';
            mchild.style.width = "200px";
        }
        mchild.style.display = 'block';
        //Effect.SlideDown(mparent, { duration: .5 });
        //mootools
        //var mp2 = '#' + mparent;
        //$(mp2).slideDown('slow');
    }
    catch (Error) { }
};
// ####################
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
	    curleft = obj.offsetLeft;
	    curtop = obj.offsetTop;
		while (obj = obj.offsetParent) {
		    curleft += obj.offsetLeft;
		    curtop += obj.offsetTop;
		}
	}
	return [curleft,curtop];
};
// ####################
function hidesubmenu() {
    //document.getElementById('submenu').style.display = 'none';
    resetsubmenu();
};
// ####################
function resetsubmenu() {
    var e = document.getElementById('submenu');
    e.style.height = '10px';
var es = e.getElementsByTagName('SPAN'); 
i = 0; 
while (i != es.length) { es[i].style.display = 'none'; i++; } 
};
// ####################
// ####################
function newswindow() {
    //just as easy to open the news feed in a popup window!
    //var xml = loadXMLDoc("rss.xml");
    var fname = 'rss.xml';
    if (window.XMLHttpRequest) { // code for Mozilla, Safari, etc 
        xmlhttp3 = new XMLHttpRequest();
        xmlhttp3.onreadystatechange = news2;
        xmlhttp3.open("GET", fname, true);
        xmlhttp3.send(null);
    } else if (window.ActiveXObject) { //IE 
        xmlhttp3 = new ActiveXObject('Microsoft.XMLHTTP');
        if (xmlhttp3) {
            xmlhttp3.onreadystatechange = news2;
            xmlhttp3.open('GET', fname, true);
            xmlhttp3.send();
        }
    }
};
// ####################
// function to handle asynchronous call
function news2() {
    if (xmlhttp3.readyState == 4) {
        if (xmlhttp3.status == 200) {
            newsDoc = xmlhttp3.responseXML;
            //shownews();
            myticker();
        }
    }
};
// ####################
var ttxt = new Array();
ttxt[0] = "<a href='http://www.nbsites.com/myblog'>micropulse blog</a>";
ttxt[1] = "<a href='index.html?News'>RSS and news feeds ... </a>";
ttxt[2] = "<a href='rss.xml'>RSS feed</a>";
var tk = new Array();
var tkctr = -1;
var tktimer = false;
var tickerSpeed = 50;
// ####################
function myticker() {
    if (tktimer) return;
    //document.getElementById('ticker').innerHTML = ttxt[rndId];
    var rssxml = newsDoc.documentElement;
    var items = rssxml.getElementsByTagName('Title');
    var links = rssxml.getElementsByTagName('Link');
    var descs = rssxml.getElementsByTagName('Description');
    //document.getElementById('ticker').innerHTML += "<div><strong style='font-size:16pt; font-style:italic; width:100%; color:#FF3C7B'>micropulse news</strong><br/><br/></div>";
    //start at 1 instead of 0 to skip 1st title
    for (var x = 0; x < items.length; x++) {
        var item = items[x].firstChild.nodeValue;
        var lnk;
        try {
            lnk = links[x].firstChild.nodeValue;
        } catch (Error) { }
        if (lnk == null) lnk = '#';
        tk[x] = "<div style='font-size:8pt'><a href='" + lnk + "'>" + item + "</a> - " + descs[x].firstChild.nodeValue.substring(0, 180 - (item.length * 2)) + " ... <br/><br/><a href='" + lnk + "'>Read more »</a><br/><br/></div>";
        //document.getElementById('ticker').innerHTML += "<div><a href='" + links[x].firstChild.nodeValue + "' target='_blank'>Headline: " + item + "</a> - " + descs[x].firstChild.nodeValue.substring(0, 30 - item.length) + " ...<br/><br/></div>";
    };
    var rndId = Math.floor(Math.random() * tk.length);
    document.getElementById('ticker').style.display = 'none';
    //document.getElementById('ticker').innerHTML = tk[1];
    //new Effect.Appear('ticker');
    window.setTimeout('runTicker()', tickerSpeed);
};
function runTicker() {
    tktimer = true;
    rndId = Math.floor(Math.random() * tk.length);
    tkctr += 1;
    if (tkctr < 1 || tkctr >= tk.length) tkctr = 0;
    //alert(tkctr + ' ' + tk[tkctr]);
    try {
        //document.images.SlideShow.src = arrBanner[rndId];
        //Effect.Fade('ticker');
        document.getElementById('ticker').innerHTML = tk[tkctr];
        //new Effect.Appear('ticker', { duration: 4.0, from: 0.0, to:1.0 });
        document.getElementById('ticker').style.display = 'block';
    }
    catch (Error) {
        return;
    };
    if (tickerSpeed < 9000) {
        tickerSpeed = 9000;
        setInterval(runTicker, tickerSpeed);
    }
    //Effect.Appear('ticker', { duration: slideShowSpeed });
    //return;

    if (document.all) {
        //only works for document.images!!!
        //document.getElementById('ticker').style.filter = "blendTrans(duration=5)";
        //document.getElementById('ticker').style.filter = "blendTrans(duration=crossFadeDuration)";
        //document.getElementById('ticker').filters.blendTrans.Apply();
    }
    if (document.all) {
        //document.getElementById('ticker').filters.blendTrans.Play();
    }
    //Effect.Appear('ticker', { duration: 2000 });
};
// ####################
function showblog() {
    var dom = document.getElementById('wtafblog');
    dom.innerHTML = '<iframe src="http://wtaf.wordpress.com/" style="border:solid 1px #ccc" width="650px" height="500px">Your browser cannot handle frames.  <a href="http://wtaf.wordpress.com/">Please click here to view our blog ... </a></iframe>';
};