var iFrameLoadCount = 0;

function iFrameOnloadHandler() {
	
	var iframe = document.getElementById("pl-app");
	if (iFrameLoadCount == 1) {
		iframe.width = "100%";
		iframe.height = "100%";
		iframe.style.width = "100%";
		iframe.style.height = "100%";
		iframe.style.visibility = "visible";
		location.hash = "app";
		document.body.style.overflow = "hidden";
		document.getElementById('password').value = "";
	} else if (iFrameLoadCount == 0) {
		location.hash = "login";
	}
	iFrameLoadCount++;
	
}

var lasthash = "";

var curHash = "";

function pollHash() {
	
	var newHash = window.location.hash.replace(/^#/,"");
	
	curHash = newHash;
	
	if (newHash == "login") {
		
		var iframe = document.getElementById("pl-app");
		iframe.width = "0%";
		iframe.height = "0%";
		iframe.style.width = "0%";
		iframe.style.height = "0%";
		iframe.style.visibility = "hidden";
		iFrameLoadCount = 1;
		document.body.style.overflow = "auto";
		
    }
}

window.onload = function() {
	var docURL = String(document.location).split("#");
	document.getElementById('parentURL').value = docURL[0];
	setInterval("pollHash()",200);
}
