function resizeFrame(f) {
	var size;
	if(f != null) {
		size = f.contentWindow.document.body.scrollHeight + 10;
		f.style.height = size + "px";
	}
}

// modal overlay (login/signup etc)
function revealModal(divID) {
	window.scrollTo(0,0);
	window.onscroll = function () { document.getElementById(divID).style.top = document.body.scrollTop; };
	document.getElementById(divID).style.display = "block";
	document.getElementById(divID).style.top = document.body.scrollTop;
}

function hideModal(divID){
	document.getElementById(divID).style.display = "none";
}
// custom function added to update login related page elements
// initially used by fb connect to avoid page refresh
function ajax_fixloginstate() {
  // get the new elements
  jQuery.getJSON(location.protocol+"//"+location.hostname+"/login_ajax/?action=gethtml", function(data) {
    // update signin/signup bttons
    jQuery("#user_bar").html(data.user_bar); 
    // update the comment box if it exists
  });
}


// custom function added to update login related page elements
// initially used by fb connect to avoid page refresh
function ajax_fixloginstate(reload) {
  if(reload==null){reload=0;}
	if(reload==1){
		location.reload();
	} else {
		// get the new elements
	  jQuery.getJSON(location.protocol+"//"+location.hostname+"/login_ajax/?action=gethtml&anticache="+Math.random()+"&uri="+location.href, function(data) {
	    // update signin/signup bttons
	    jQuery("#user_bar").html(data.user_bar); 
	    // update the comment box if it exists
	    if(data.comments_block!=''){
			jQuery("#comments_block").html(data.comments_block);
                }
		});
	}
}

var reload_on_logout = false;

function ajax_logout(fblogout,reload) {
	if(fblogout==null){fblogout=0;}
	 if(reload==null){reload=1;}
  // get the new elements
	reload_on_logout = reload;
	if(fblogout==1) {
		FBConnect.logout(); // this will fire ajax_fixloginstate(reload_on_logout)
	} else {
		jQuery.getJSON(location.protocol+"//"+location.hostname+"/login_ajax/?action=logout", function(data) {
			ajax_fixloginstate(reload); // update login related elements
		});
	}
}
