var xmlDoc,alerted
function mkObj() {
xmlDoc = undefined;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
  try {
  xmlDoc=new ActiveXObject("Msxml2.XMLHTTP")
 } catch (e) {
  try {
    xmlDoc=new ActiveXObject("Microsoft.XMLHTTP")
  } catch (E) {
   alert("You must have Microsofts XML parsers available")
  }
 }
@else
 alert("You must have JScript version 5 or above.")
 xmlDoc=false
 alerted=true
@end @*/
if (!xmlDoc && !alerted) {
 try {
  xmlDoc = new XMLHttpRequest();
 } catch (e) {
  alert("You need a browser which supports an XMLHttpRequest Object.\nMozilla build 0.9.5 has this Object and IE5 and above, others may do...")
 }
}
}

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;}
}

document.onkeypress = stopRKey; 

function preLoadimg() {

if (document.images) {

      //preload_image_object = new Image();

      image_url = new Array();
      image_url[0] = "https://viperadmin.enta.net/img/bgdiv_dark.gif";
      image_url[1] = "https://viperadmin.enta.net/img/ajax-loader3.gif";


       var i = 0;
       for(i=0; i<image_url.length; i++) { 
	 eval("preload_image_object"+i+" = new Image();");
	 eval("preload_image_object"+i+".src = image_url["+i+"];");
         //preload_image_object.src = image_url[i];
	}
}
}

function getKeyCode(e)
{
if (window.event)
    return window.event.keyCode;
else if (e)
    return e.which;
else
    return null;
}

function keyRestrict(e, validchars) {
var key='', keychar='';
     key = getKeyCode(e);

if (key == null) return true;
        keychar = String.fromCharCode(key);
        keychar = keychar.toLowerCase();
        validchars = validchars.toLowerCase();
if (validchars.indexOf(keychar) != -1)
  return true;
if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27 )
  return true;
return false;
}
/*
function showLoading(msg, showbg, append) {

scrolls = getPageScroll();
boxsizes = getPageSize();

	if(append==''||append==undefined) {
		append = 'load';
	}


        el = document.getElementById(append);

	if(msg==''||msg==undefined) {
		msg='Please Wait...';
	}

boxPos = scrolls[1] + (boxsizes[3] / 2) - 50;

                if(el.innerHTML != '' && document.getElementById('LoadingMsg').innerHTML == '<b>Validating Form...</b>') {

                        document.getElementById('LoadingMsg').innerHTML = "<b>"+msg+"</b>";
                }

                if(el.innerHTML == '') {
                el.innerHTML = "<div class='loader' id='divloader' style='top: "+boxPos+"'><center><span><p><table border='0' cellpadding='6' width='95%' height='100%'><tr><td id='LoadingMsg' style='color: #FFF;' valign='bottom' align='center'><b>"+msg+"</b></td></tr><tr><td align='center' height='50px' valign='top'><img src='img/ajax-loader3.gif'></td></tr></table></p></span></div>";
                }

creatediv(showbg, append);
}
*/
function creatediv(show, append) {

if(show==true) {

document.getElementById('thebody').style.overflow = "hidden";

   var newdiv = document.createElement('div');
   newdiv.setAttribute('id', 'cover');

       newdiv.style.position = 'absolute';
       newdiv.style.top = '0px';
       newdiv.style.left = '0px';
       newdiv.style.width = '100%';
       newdiv.style.height = '100%';
       newdiv.style.filter = 'alpha(opacity=50)';
       newdiv.style.MozOpacity = '.5';



   newdiv.style.background = "#000";
   newdiv.style.border = "0px solid #000";

   //document.body.appendChild(newdiv);
   document.getElementById(append).appendChild(newdiv);

}


}

function maskPage(id) {

   var newdiv = document.createElement('div');
   newdiv.setAttribute('id', 'coverit');

       newdiv.style.position = 'absolute';
       newdiv.style.top = '105px';
       newdiv.style.left = '0px';
       newdiv.style.width = '100%';
       newdiv.style.height = '100%';

   newdiv.style.background = "#FFF";
   newdiv.style.border = "0px solid #000";

   document.getElementById(id).appendChild(newdiv);

}
function selectedForm(input) {
if(input!='' && input!='check') {

        color = input.style.background;
        if(color=='' || color=='rgb(102, 102, 102) none repeat scroll 0% 0%' || color=='rgb(255, 255, 255) none repeat scroll 0% 0%' || color=='#fff' || color=='#666') {
        input.style.background='#9DC0D1';
        } else { 
                if(input.value=='') {
                input.style.background='#FFF';
                } else {
                input.style.background='#666';
                }
	}
} else {
        input.style.background='#FFF';
}
}
function selectedInput(input, saved, colors) {
if(input!='' && input!='check') {
	
	color = input.style.background;
	if(color=='' || color=='rgb(102, 102, 102) none repeat scroll 0% 0%' || color=='rgb(255, 255, 255) none repeat scroll 0% 0%' || color=='#fff' || color=='#666') {
	if(saved==1) { 
	input.style.background='#666';
	input.style.color='#FFF';
	} else {
	//input.style.background='#9DC0D1';
	input.style.background=colors;
	}
	} else {
		if(input.value=='') {
		input.style.background='#FFF';
		}  else {
		input.style.background='#666';
		input.style.color='#FFF';

//	alert(input.style.background);
		}
	}
} else {
	var user = document.getElementById('username');
	var pass = document.getElementById('password');
	var submit = document.getElementById('submit');

	if(input!='check') {
	user.style.background='#FFF';
	pass.style.background='#FFF';
	//submit.disabled=true;
	} else {
	
	if(user.value!='' && pass.value!='') {
	//submit.disabled=false;
	if(saved==1) {
	selectedInput(user, 1);
	selectedInput(pass, 1);
	document.login.submit.focus();
	}
	} else {
	//submit.disabled=true;
	}

	}
}
}

var marked_row = new Array

function setPointer(item, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor, count)
{
    var theRow = document.getElementById(item);
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }
    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[theRowNum].getAttribute) != 'undefined') {
        currentColor = theCells[theRowNum].getAttribute('bgcolor');
        domDetect    = true;
    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[theRowNum].getAttribute) != 'undefined') {
        currentColor = theCells[theRowNum].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[theRowNum].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 3.3 ... Opera changes colors set via HTML to rgb(r,g,b) format so fix it
    if (currentColor.indexOf("rgb") >= 0)
    {
        var rgbStr = currentColor.slice(currentColor.indexOf('(') + 1,
                                     currentColor.indexOf(')'));
        var rgbValues = rgbStr.split(",");
        currentColor = "#";
        var hexChars = "0123456789ABCDEF";
        for (var i = 0; i < 3; i++)
        {
            var v = rgbValues[i].valueOf();
            currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16);
        }
    }

    // 4. Defines the new color
    // 4.1 Current color is the default one

// I ADDED THIS, SEEMS TO WORK...
if (theAction == 'out') { marked_row = ''; }

    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {

        if (theAction == 'out') {
            newColor              = theDefaultColor;

        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = false;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        var toNum = theRowNum + count;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = theRowNum; c < toNum; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = theRowNum; c < toNum; c++) {

                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function
}
function chgMtchTxt(selected) {

	document.getElementById('filter').value = '';

	if(selected=='map') {

		document.getElementById('user_txt').innerHTML = '&nbsp;Match Mapped To Domain';

	} else {

		document.getElementById('user_txt').innerHTML = '&nbsp;Match Username';
	}


}
function clientSideInclude(id, url) {
  var req = false;
  // For Safari, Firefox, and other non-MS browsers
  if (window.XMLHttpRequest) {
    try {
      req = new XMLHttpRequest();
    } catch (e) {
      req = false;
    }
  } else if (window.ActiveXObject) {
    // For Internet Explorer on Windows
    try {
      req = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        req = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {
        req = false;
      }
    }
  }
 var element = document.getElementById(id);
 if (!element) {
  alert("Bad id " + id +
   "passed to clientSideInclude." +
   "You need a div or span element " +
   "with this id in your page.");
  return;
 }
  if (req) {
    // Synchronous request, wait till we have it all
    req.open('GET', url, false);
    req.send(null);
    element.innerHTML = req.responseText;
  } else {
    element.innerHTML =
   "Sorry, your browser does not support " +
      "XMLHTTPRequest objects. This page requires " +
      "Internet Explorer 5 or better for Windows, " +
      "or Firefox for any system, or Safari. Other " +
      "compatible browsers may also exist.";
  }
}
function intValidate(elements, page, loader, msg, bg, con, conDesc) {

	showLoading('Validating Form...');

	setTimeout("validate('"+elements+"','"+page+"',"+loader+",'"+msg+"',"+bg+",'"+con+"','"+conDesc+"')", 700);
	
}
function validate(elements, page, loader, msg, bg, con, conDesc) {

error = 0;
mesg = "";

if(elements==undefined || elements=='' || elements=='undefined') {

var El = new Array("domainName", "subs", "maindomain", "websiteRedirect", "domainusername", "domainpasswd", "masterMailbox", "firstname", "lastname", "address", "postcode", "phoneno", "mysqlName", "mysqlUser", "mysqlPass", "mysqlHost", "smtphost", "noMailbox", "landed", "landed1", "landed2", "landed3", "landed4", "landed5", "landed6", "landed7", "landed8", "landed9", "landed10", "landed11", "landed12", "landed13", "landed14", "landed15", "landed16", "landed17", "landed18", "landed19", "landed20");

} else {

	var El = new Array();
	El = elements.split(',');

}

        for(i=0;i<=El.length;i++) {

                if(document.getElementById(El[i]+"_blob")) {

                        theBlob = document.getElementById(El[i]+"_blob").style.color;

		if(document.getElementById(El[i]) != null) {


		    if(document.getElementById(El[i]).disabled == false) {

                        if(theBlob!='#0d0' && theBlob!='#00dd00' && theBlob!='rgb(0, 221, 0)' && theBlob!='#ccc' && theBlob!='#cccccc' && theBlob!='rgb(204, 204, 204)') {

                                error++;
                                if(document.getElementById(El[i]+"_desc")) {

					if(document.getElementById(El[i].replace(/[^[a-z]+/, "")+"_desc")) {
                                        var itemDesc = document.getElementById(El[i].replace(/[^[a-z]+/, "")+"_desc").innerHTML;
					} else {
                                        var itemDesc = document.getElementById(El[i]+"_desc").innerHTML;
					}
                                        var errorMsg = document.getElementById(El[i]+"_msg").innerHTML;


                                                itemDesc = itemDesc.stripTags();
                                                itemDesc = itemDesc.trim();

                                                if(errorMsg=="") {

                                                        errorMsg = itemDesc+" cannot be empty";

                                                } else {

                                                        errorMsg = errorMsg.stripTags();
                                                        errorMsg = errorMsg.trim();

                                                }

                                        mesg += "<b>" + error+": "+itemDesc+"</b> - "+errorMsg+"<br>\n";

                                }

                        }

                    }
                }

                }
        }
if(error>0) {

        if(error==1) {
                var info = "is <b>"+error+"</b> error";
        } else {
                var info = "are <b>"+error+"</b> errors";
        }

	document.getElementById("load").innerHTML = '';

	$.unblockUI();

        alert_jive("<div style='font-weight: bold; color: #D00; font-size: 12pt; text-align: center; padding-bottom: 15px;'>Validation Error</div> There "+info+" on this page:<br /><br />\n\n"+mesg+"<br />\nYou must resolve these issues before you can continue");

} else {

	if(page==undefined || page=='undefined') {

        	domainSubmit();

	}  else {

		if(con != '' && con != undefined && con != 'undefined' && con != 'false') {

			var ok = confirm(conDesc);

		}

		if(ok == true || con == '' || con == undefined || con == 'undefined' || con == 'false') {

        		basicSubmit(page, loader, msg, bg);

		} else {

			document.getElementById("load").innerHTML = '';

			$.unblockUI();
		}

	}

}

}

function basicSubmit(formName, loader, msg, bg) {

	if(loader==true || loader=='true') {

		showLoading(msg, bg, false);
		//alert('');
	}

	eval('document.'+formName+'.submit();');

}

function basicCheck(value, name) {

 if(value!='') { 

	document.getElementById(name+'_blob').style.color = '#0D0'; 

 } else { 

	document.getElementById(name+'_blob').style.color = '#D00'; 
 }

}

function swapChecks(option) {

        var opt = document.getElementById(option);

        if(opt.checked==true) { opt.checked = false; }

}

String.prototype.stripTags = function () {
   return this.replace(/<([^>]+)>/g,'');
}
String.prototype.trim = function() {
   return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
   return this.replace(/^\s+/g,"");
}
String.prototype.rtrim = function() {
   return this.replace(/\s+$/g,"");
}

function phongEgg() {

                currentElement = document.createElement("div");
                currentElement.setAttribute("id", "egg");
                currentElement.setAttribute("style", "text-align: center;");

                        document.getElementById('thebody').appendChild(currentElement);

                currentElement = document.createElement("div");
                currentElement.setAttribute("id", "eggbg");
                currentElement.setAttribute("style", "text-align: center;");

                        document.getElementById('thebody').appendChild(currentElement);


document.getElementById('egg').innerHTML = "<div class='eggs' id='eggloader'><center><span><p><table border='0' width='85%' height='100%'><tr><td align='right'><div><a href='#' onClick='closeEgg();'><img src='img/popup_box_close.gif' border='0'></a></div> <iframe src='eggs/phong.htm' frameborder='0' style='width: 450px; height: 355px'></iframe></td></tr></table></p></span></div>";

	creatediv(true, 'eggbg');

}

function snakeEgg() {

                currentElement = document.createElement("div");
                currentElement.setAttribute("id", "egg");
                currentElement.setAttribute("style", "text-align: center;");

                        document.getElementById('thebody').appendChild(currentElement);

                currentElement = document.createElement("div");
                currentElement.setAttribute("id", "eggbg");
                currentElement.setAttribute("style", "text-align: center;");

                        document.getElementById('thebody').appendChild(currentElement);


document.getElementById('egg').innerHTML = "<div class='eggs' id='eggloader'><center><span><p><table border='0' width='85%' height='100%'><tr><td align='right'><div><a href='#' onClick='closeEgg();'><img src='img/popup_box_close.gif' border='0'></a></div> <iframe src='eggs/snake.htm' frameborder='0' style='width: 420px; height: 480px;' scrolling='no'></iframe></td></tr></table></p></span></div>";

        creatediv(true, 'eggbg');

}

function closeEgg() {

document.getElementById('thebody').removeChild(document.getElementById('egg'));
document.getElementById('thebody').removeChild(document.getElementById('eggbg'));

}

var $keystrokes = "";
var $eastereggcode = "38 38 40 40 37 39 37 39 66 65";
var $seastereggcode = "38 38 40 40 37 39 37 39 65 66";
function log_keystrokes($event){
//ie only
$keycode = $event.keyCode;
$keystrokes = $keystrokes + $keycode + " ";
$match = $keystrokes.indexOf($eastereggcode);
$smatch = $keystrokes.indexOf($seastereggcode);
if($match > -1){
phongEgg();
$keystrokes = "";
}
if($smatch > -1){
snakeEgg();
$keystrokes = "";
}
}
function showPasswd(checkbox, Form, el) {

        if(checkbox==true) {

                changeInputType(eval('document.'+Form+'.'+el),'text',eval('document.'+Form+'.'+el+'.value'),false,true);
        } else {

                changeInputType(eval('document.'+Form+'.'+el),'password',eval('document.'+Form+'.'+el+'.value'),false,true);
        }
}
function changeInputType(oldElm, iType, iValue, blankValue, noFocus) {

  if(!oldElm || !oldElm.parentNode || (iType.length<4) || !document.getElementById || !document.createElement) return;

  var newElm = document.createElement('input');
  newElm.type = iType;

  if(oldElm.name) newElm.name = oldElm.name;
  if(oldElm.style.fontSize) newElm.style.fontSize = oldElm.style.fontSize;
  if(oldElm.id) newElm.id = oldElm.id;
  if(oldElm.onblur) newElm.onblur = oldElm.onblur;
  if(oldElm.className) newElm.className = oldElm.className;
  if(oldElm.size) newElm.size = oldElm.size;
  if(oldElm.tabIndex) newElm.tabIndex = oldElm.tabIndex;
  if(oldElm.accessKey) newElm.accessKey = oldElm.accessKey;

  oldElm.parentNode.replaceChild(newElm,oldElm);
  if(!blankValue) newElm.value = iValue;
  if(!noFocus || typeof(noFocus)=='undefined') {
    window.tempElm = newElm;
    setTimeout("tempElm.hasFocus=true;tempElm.focus();",1);
  }
  return newElm;
}

function getPageScroll(){

        var xScroll, yScroll;

        if (self.pageYOffset) {
                yScroll = self.pageYOffset;
                xScroll = self.pageXOffset;
        } else if (document.documentElement && document.documentElement.scrollTop){      // Explorer 6 Strict
                yScroll = document.documentElement.scrollTop;
                xScroll = document.documentElement.scrollLeft;
        } else if (document.body) {// all other Explorers
                yScroll = document.body.scrollTop;
                xScroll = document.body.scrollLeft;
        }

        arrayPageScroll = new Array(xScroll,yScroll)
        return arrayPageScroll;
}

function getPageSize(){

        var xScroll, yScroll;

        if (window.innerHeight && window.scrollMaxY) {
                xScroll = window.innerWidth + window.scrollMaxX;
                yScroll = window.innerHeight + window.scrollMaxY;
        } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
                xScroll = document.body.scrollWidth;
                yScroll = document.body.scrollHeight;
        } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
                xScroll = document.body.offsetWidth;
                yScroll = document.body.offsetHeight;
        }

        var windowWidth, windowHeight;

//      console.log(self.innerWidth);
//      console.log(document.documentElement.clientWidth);

        if (self.innerHeight) { // all except Explorer
                if(document.documentElement.clientWidth){
                        windowWidth = document.documentElement.clientWidth;
                } else {
                        windowWidth = self.innerWidth;
                }
                windowHeight = self.innerHeight;
        } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
                windowWidth = document.documentElement.clientWidth;
                windowHeight = document.documentElement.clientHeight;
        } else if (document.body) { // other Explorers
                windowWidth = document.body.clientWidth;
                windowHeight = document.body.clientHeight;
        }

        // for small pages with total height less then height of the viewport
        if(yScroll < windowHeight){
                pageHeight = windowHeight;
        } else {
                pageHeight = yScroll;
        }

//      console.log("xScroll " + xScroll)
//      console.log("windowWidth " + windowWidth)

        // for small pages with total width less then width of the viewport
        if(xScroll < windowWidth){
                pageWidth = xScroll;
        } else {
                pageWidth = windowWidth;
        }
//      console.log("pageWidth " + pageWidth)

        arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
        return arrayPageSize;
}
function webTools(action, thename, thevalue) {
    if (action == "blur") {
        if (thevalue != "") {
            checkInput(thename, thevalue);
            disableRedirect(false, true);
        } else {
            document.getElementById("websiteRedirect_msg").innerHTML = "";
        }
    }
    if (action == "key") {
        document.getElementById("websiteRedirect_blob").style.color = "#D00;";
        if (thevalue == "") {
            document.getElementById("websiteRedirect_blob").style.color = "#CCC;";
            disableRedirect(true, true);
        } else {
            disableRedirect(false, true);
        }
    }
}
function disableRedirect(checked, fromtext) {
    if (checked == true) {
        if (fromtext != true) {
            document.getElementById("websiteRedirect").disabled = true;
            document.getElementById("websiteRedirect_desc").style.color = "#CCC";
        }
        document.getElementById("websiteRedirect").value = "";
        document.getElementById("websiteRedirect_msg").innerHTML = "";
        document.getElementById("websiteRedirect_blob").style.color = "#CCC";
        document.getElementById("php5_desc").style.color = "#444";
        document.getElementById("php5_data").style.color = "#444";
        document.getElementById("php5").disabled = false;
        document.getElementById("php4").disabled = false;
        document.getElementById("redirect").value = "N";
    } else {
        document.getElementById("websiteRedirect").disabled = false;
        document.getElementById("websiteRedirect_desc").style.color = "#444";
        if (fromtext == true) {
            document.getElementById("php5_desc").style.color = "#CCC";
            document.getElementById("php5_data").style.color = "#CCC";
            document.getElementById("php5").disabled = true;
            document.getElementById("php4").disabled = true;
            document.getElementById("websiteRedirect_blob").style.color = "#D00";
        } else {
            document.getElementById("websiteRedirect_blob").style.color = "#CCC";
        }
        document.getElementById("redirect").value = "Y";
    }
}
function fix_autofill()
{

if(document.addEventListener)
{
  window.addEventListener('load', function()
  {

  var nodes = document.getElementsByTagName('input');

    for(var i = 0; i < nodes.length; i++)
    {
    var node = nodes[i];

        if(node.getAttribute('type') == 'password')
        {
            var depth = 2;
            for(x = 1; x <= depth; x++)
            {
                if(nodes[i - x].getAttribute('type') == 'text')
                {

                    if(document.getElementById('loaded_'+nodes[i - x].getAttribute('id')))
                    {
                        document.getElementById(nodes[i - x].getAttribute('id')).value = document.getElementById('loaded_'+nodes[i - x].getAttribute('id')).value;
                    }
                }
            }

            if(document.getElementById(node.getAttribute('id')))
            {
                if(document.getElementById('loaded_'+node.getAttribute('id')))
                {
                    document.getElementById(node.getAttribute('id')).value = document.getElementById('loaded_'+node.getAttribute('id')).value;
                }
                else
                {
                    document.getElementById(node.getAttribute('id')).value = '';
                }
            }
        }
    }
  } , false);
}

}
