function clearLeft(node) { // makes node to left z-index of 1 
	var leftnodename = "wrapper"+(node-1);
	var leftnode = document.getElementById(leftnodename);
	if(leftnode != null){
		leftnode.style.zIndex = 1;
	}
}

function setLeft(node) { // returns node to left to corret z-index
	var leftnodename = "wrapper"+(node-1);
	var leftnode = document.getElementById(leftnodename);
	if(leftnode != null){
		leftnode.style.zIndex = 38 - node;
	}
}

function clearTopRight(node) { // makes node above and above-right z-index 1
	var toprightnodename = "wrapper"+(node-6);
	var topnodename = "wrapper"+(node-7);
	var toprightnode = document.getElementById(toprightnodename);
	var topnode = document.getElementById(topnodename);
	if(toprightnode != null){
		toprightnode.style.zIndex = 1;
	}
	if(topnode != null){
		topnode.style.zIndex = 1;
	}
}

function setTopRight(node) { // returns node above and above-right to correct z-index
	var toprightnodename = "wrapper"+(node-6);
	var topnodename = "wrapper"+(node-7);
	var toprightnode = document.getElementById(toprightnodename);
	var topnode = document.getElementById(topnodename);
	if(toprightnode != null){
		toprightnode.style.zIndex = 43 - node;
	}
	if(topnode != null){
		topnode.style.zIndex = 44 - node;
	}
}

function clearTopLeft(node) { // makes node above and above-left z-index 1
	var topleftnodename = "wrapper"+(node-8);
	var topnodename = "wrapper"+(node-7);
	var topleftnode = document.getElementById(topleftnodename);
	var topnode = document.getElementById(topnodename);
	if(topleftnode != null){
		topleftnode.style.zIndex = 1;
	}
	if(topnode != null){
		topnode.style.zIndex = 1;
	}
}

function setTopLeft(node) { // returns node above and above-left to correct z-index
	var topleftnodename = "wrapper"+(node-8);
	var topnodename = "wrapper"+(node-7);
	var topleftnode = document.getElementById(topleftnodename);
	var topnode = document.getElementById(topnodename);
	if(topleftnode != null){
		topleftnode.style.zIndex = 45 - node;
	}
	if(topnode != null){
		topnode.style.zIndex = 44 - node;
	}
}

function myFilter(day) {
	if(! $('#'+day).hasClass("expanded")){    
		if( $('#'+day).hasClass("right") && $('#'+day).hasClass("bottom")){
			clearTopLeft(day);
			clearLeft(day);
	    	$('#' + day).animate({
	    		width: "133px",
	    		height: "118px",
				left: "-72px",
				top: "-64px"});
     	    $('#'+day).addClass("expanded");	 
     	    $('#'+'more_'+day).text(" <<less");	
		}
		else if( $('#'+day).hasClass("right")){
			clearLeft(day);
	    	$('#' + day).animate({
	    		width: "133px",
	    		height: "118px",
				left: "-72px"});
     	    $('#'+day).addClass("expanded");	 
     	    $('#'+'more_'+day).text(" <<less");	
		}
    	else if( $('#'+day).hasClass("bottom")){
			clearTopRight(day);
	    	$('#' + day).animate({
	    		width: "133px",
	    		height: "118px",
				top: "-64px"});
     	    $('#'+day).addClass("expanded");	 
     	    $('#'+'more_'+day).text(" <<less");	 
		}
		else {
	    	$('#' + day).animate({
	    		width: "133px",
	    		height: "118px"});
     	    $('#'+day).addClass("expanded");	 
     	    $('#'+'more_'+day).text(" <<less");	 
		}
	}
	else {
		if( $('#'+day).hasClass("right") && $('#'+day).hasClass("bottom")){
	    	$('#' + day).animate({
	    		width: "62px",
	    		height: "55px",
				left: "0px",
				top: "0px"});
     	    $('#'+day).removeClass("expanded");	 
     	    $('#'+'more_'+day).text(" more>>");	
			setTopLeft(day);
			setLeft(day);
		}
		else if( $('#'+day).hasClass("right")){
	    	$('#' + day).animate({
	    		width: "62px",
	    		height: "55px",
				left: "0px"});
     	    $('#'+day).removeClass("expanded");	 
     	    $('#'+'more_'+day).text(" more>>");	
			setLeft(day);
		}
    	else if( $('#'+day).hasClass("bottom")){
	    	$('#' + day).animate({
	    		width: "62px",
	    		height: "55px",
				top: "0px"});
     	    $('#'+day).removeClass("expanded");	 
     	    $('#'+'more_'+day).text(" more>>");	 
			setTopRight(day);
		}
		else {
	    	$('#' + day).animate({
	    		width: "62px",
	    		height: "55px"});
 	    	$('#'+day).removeClass("expanded");	    
     	    $('#'+'more_'+day).text(" more>>");
		}
	}
}
