var pageQuote;
var allQuotes = new Array();
var copyHeight;
var headerHeight;
var gutter = 70;
var newQuote;

function addQuote(_quoteCopy){
	allQuotes.push(_quoteCopy);
	
}

$(document).ready(function(){

	 $("#random_quote").fadeIn(1000); 
	// centerIt();
	//setInterval()
	setTimeout(headerQuoteOut,8000);
	 return false;

   });

function centerIt(){
	copyHeight = document.getElementById("headerInner").offsetHeight;
	headerHeight = document.getElementById("header").offsetHeight;

}

function taglineIn(){
	document.getElementById("headerCopy").innerHTML = "<table><tr><td class='quote' valign='bottom'>Shurafa Consulting | Complete IT Solutions</td></tr></table>";
	document.getElementById("headerInner").style.marginLeft = "50px";
	
	 $("#headerInner").fadeIn(1000);
	centerIt();
	 setTimeout(taglineOut,5000);
	  getNewQuote();
}

function taglineOut(){
	 $("#headerInner").fadeOut(100, headerQuoteIn);
}

function headerQuoteIn(){
	document.getElementById("random_quote").innerHTML = newQuote;
	//document.getElementById("headerInner").style.marginLeft = "60px";
	
	 $("#random_quote").fadeIn(1000);
	// centerIt();
	 setTimeout(headerQuoteOut, 8000);
}

function headerQuoteOut(){
	$("#random_quote").fadeOut(100, getNewQuote);	
	//setTimeout(headerQuoteOut,8000);
	//headerQuoteIn()
}

function getNewQuote(){
	
	if (!window.XMLHttpRequest){
		XMLHttpRequest = function(){
			try{ return new ActiveXObject("Msxml2.XMLHTTP.6.0") }catch(e){}
			try{ return new ActiveXObject("Msxml2.XMLHTTP.3.0") }catch(e){}
			try{ return new ActiveXObject("Msxml2.XMLHTTP") }catch(e){}
			try{ return new ActiveXObject("Microsoft.XMLHTTP") }catch(e){}
			throw new Error("Could not find an XMLHttpRequest alternative.")
		}
	}
	var request = new XMLHttpRequest();
	request.onreadystatechange = function(){
    	if (request.readyState == 4 && request.status == 200){
			newQuote = request.responseText;
			headerQuoteIn();
    	}
	};
	request.open("GET", "http://www.shurafa.com/index.php?quote=0", true);
	request.send(null);
	
}
