function parseXml(xmlDoc) {
	var HTMLDisp = '';
	var submittedPass = document.FPP.SendPass.value;
	var x = xmlDoc.getElementsByTagName('PasswordSub');
	
	if( xmlDoc.documentElement && xmlDoc.documentElement.tagName && xmlDoc.documentElement.tagName.toUpperCase() == 'HTML' ) {
		setTimeout('alert(\'Your browser has currupted the XML.\\nScript aborted.\');',50); return; 
	}
	
	if(checkAdminLogin(xmlDoc) == 'adminLogin'){
		var loggedInPage = pageFile();
		if(siteUrl().indexOf('orbisdesign.net') == -1){
			alert('Administration only available on development server');
		}else{
			if(loggedInPage.indexOf('aspx') != -1){
				loggedInPage = loggedInPage.substring(0,loggedInPage.indexOf("x"));
			}
			document.getElementById('submitForm').style.visibility = 'hidden';
			document.getElementById('adminLoginMessage').innerHTML = 'Password accepted <p /> Loading Admin...<img src=\"/images/loading_3.gif\" />';
			document.FPP.BZSessionEle_FUPassword.value = document.FPP.SendPass.value
			document.FPP.action = loggedInPage;
			document.FPP.submit();
		}	
	}else{	
		for (i=0;i<x.length;i++)
		{
			for (j=0;j<x[i].childNodes.length;j++)
			{
				if (x[i].childNodes[j].nodeType != 1) continue;
				passWordSub = x[i].childNodes[j].firstChild.nodeValue;
				if(passWordSub == submittedPass){
					document.getElementById('submitForm').innerHTML = 'Password accepted <p /> Loading files...<img src=\"/images/loading_3.gif\" />';
					setTimeout('showContent()',2000);
				}else{
					alert('Wrong password');
				}
			}
		}
	}	
}
function checkAdminLogin(xmlDoc){
	var submittedPass = document.FPP.SendPass.value;
	var y = xmlDoc.getElementsByTagName('Password');
	for (i=0;i<y.length;i++)
	{
		for (j=0;j<y[i].childNodes.length;j++)
		{
			if (y[i].childNodes[j].nodeType != 1) continue;
			passWordSub = y[i].childNodes[j].firstChild.nodeValue;
			if(passWordSub == submittedPass){
				return "adminLogin";
			}else{
				return "adminLoginFail";
			}
		}
	}	
}
function showContent(){
		document.getElementById('submitForm').style.display = 'none';
		document.getElementById('files').style.display = 'block';
		if(document.getElementById('leftcontent')){
			document.getElementById('leftcontent').style.display = 'none';
		}
}
function siteUrl(){
	var sSite = window.location;
	var tempHold = document.forms['searchform'].vars1.value;
	
	document.forms['searchform'].vars1.value = sSite;
	sSite = document.forms['searchform'].vars1.value;
	document.forms['searchform'].vars1.value = tempHold;
	sSite = sSite.substring(sSite.indexOf("/")+2);
	sSite = sSite.substring(0,sSite.indexOf("/"));
	return sSite;
}
function pageFile(){
	var sPage = window.location;
	var tempHold = document.forms['searchform'].vars1.value;
	
	document.forms['searchform'].vars1.value = sPage;
	sPage = document.forms['searchform'].vars1.value;
	document.forms['searchform'].vars1.value = tempHold;
	sPage = sPage.substring(sPage.indexOf("/")+2);
	sPage = sPage.substring(sPage.indexOf("/")+1);
	return sPage;
}

