/**
 * For homepage
 */

var currenthash = "";
var currentflow = null;
function winshow(id) {
	$('#fdw'+id).fadeIn();
	currentflow = id;
	updateHash('#flow'+id);
}

function winhide(id) {
	$('#fdw'+id).fadeOut();
	currentflow = null;
	location.hash = "";
}

jQuery(document).ready(function() {
	$.post("/web/index/flowlayers", {},
			function(data) {
				if (data.indexOf("NoResultException") == -1) {
					$('#flowlayers').html(data);
				} else {
					$('#flowlayers').html("error.");
				}
				
			});
	startHashListener();
});

function updateHash(hash) {
	location.hash = hash;
	currenthash = hash;
}

function startHashListener() {
	hashListener = setInterval(checkHashChange, 200);
}

function checkHashChange() {
	if (currenthash != "" && location.hash != currenthash) {
		winhide(currentflow);
		currenthash = "";
	}
}
