// JavaScript Document


function setOpacity(what, amount) {
obj = document.getElementById(what);
obj.style.MozOpacity = amount;
obj.style.opacity = amount/10;
obj.style.filter = 'alpha(opacity=' + amount*10 + ')';
};

function fade(what,inout,next){
obj = document.getElementById(what); //Get the Element

if(inout=="out") {


 var alpha = 10; //Set the initial amountue of alpha to 10 (Opaque)
 function f(){ //Internal function

  alpha--; //Decrement the alpha amountue
  setOpacity(what, alpha); //Set the opacity of our element to the specified alpha

  if(alpha > -1){ //If alpha is still bigger than -1 then..
   setTimeout(f, 100); //..then call the function again after 100 milliseconds

  }else{ //otherwise..
   obj.style.display = 'none'; //..otherwise now that we cant see the element anyways, hide it
   if(next) fade(next,"in");

  }
}
setTimeout(f, 100); //This is where we call the f() function for the first time

} else {

setOpacity(what, 0);
	
 obj.style.display = 'block'; //Un-hide the object before its animation
 var alpha = 0; //Set the initial amountue of alpha to 0 (invisible)

 function a(){ //Internal function
  alpha++; //Increment alpha

  setOpacity(what, alpha); //Set the opacity of our element to the specified alpha
  if(alpha < 11)setTimeout(a, 200);
  if(alpha>9) { if(next) fade(next,"out"); };

/*Till alpha is 10, keep calling the
a() function after 100 milliseconds */
}
setTimeout(a, 100); //This is where we call the a() function for the first time

} 

};

function setSidebar(value)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+360);
document.cookie="ftqblogbar"+ "=" +escape(value)+";expires="+exdate.toGMTString();


}

function findSidebar() {
	var name = "ftqblogbar";
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	
	
	var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) &&
( name != document.cookie.substring( 0, name.length ) ) )
{
return "none";
}
if ( start == -1 ) return "none";
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );

}



function createSidebar() {
	
		
	
	
	
	var sitebarDOM = "secondarycontent";
	var blogbarDOM = "blogcontent";
	var sitebar = document.getElementById(sitebarDOM);
	var blogbar = document.getElementById(blogbarDOM);
	
	var status = findSidebar();
	if(status=="none") {
		sitebar.style.display = "block";
		blogbar.style.display = "none";
		document.getElementById("sitebarnav").style.display = "none";
		fade(sitebarDOM,"out",blogbarDOM);
		setSidebar("blog");
		document.getElementById("sitebarnav").style.display = "block";
	}
	else if(status=="site") {
		sitebar.style.display = "block";

	} else {
		blogbar.style.display = "block";

	};
	
	
	
};

function createBlogbar() {
	var sitebarDOM = "secondarycontent";
var blogbarDOM = "blogcontent";
var sitebar = document.getElementById(sitebarDOM);
var blogbar = document.getElementById(blogbarDOM);
	setSidebar("blog");
	fade(sitebarDOM,"out",blogbarDOM);

}

function createSite2bar() {
	var sitebarDOM = "secondarycontent";
var blogbarDOM = "blogcontent";
var sitebar = document.getElementById(sitebarDOM);
var blogbar = document.getElementById(blogbarDOM);
	setSidebar("site");
	fade(blogbarDOM,"out",sitebarDOM);

}



	