function loadXML(){
	var xhttp;
	try{
		xhttp = new XMLHttpRequest();
		//alert(myXML);
	} catch (e){
		try{
			xhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				xhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				alert("Please download the newest version of your browser!");
				return false;
			}
		}
	}

		  
		  
		xhttp.open("GET","xml/backgrounds.xml",false);
		xhttp.send("");
		xmlDoc=xhttp.responseXML;
}

var myInterval = 5;
var runInterval = setInterval("alphaDown()", myInterval);
var alphaNum = 10;


function resizeDoc(){
		if(navigator.appName == 'Microsoft Internet Explorer'){
			return;
		}
	
		if(window.innerWidth>window.innerHeight){
	document.getElementById('fsimage').style.height = (window.innerWidth*0.75) + "px";
	document.getElementById('fsimage').style.width = window.innerWidth + "px";
	} 
	
	if((window.innerWidth/window.innerHeight)<1.3){
		document.getElementById('fsimage').style.height = window.innerHeight + "px";
		document.getElementById('fsimage').style.width = (window.innerHeight*1.33) + "px";
	
	}
		
	
}

function alphaDown(){
	alphaNum --;
	document.getElementById('fade').style.opacity = (alphaNum/10);
	if(alphaNum <=0){
		document.getElementById('fade').style.opacity = 0;
		clearInterval(runInterval);
	}
}

function newBkg(){
	if(navigator.appCodeName == 'Microsoft Internet Explorer'){
		document.getElementById('fsimage').src="";
		document.body.style.backgroundColor = "#6f1d05";
		return;
	}
	
	
	
	var randImg = Math.round(Math.random()*7);
	document.getElementById('fsimage').src = "img/btt_main" + (randImg+1) +".jpg";

}

function alertme(){
	alert(window.innerWidth/window.innerHeight);
}

function init(){
	resizeDoc();
	loadXML();
	newBkg();
}


