// JavaScript Document

//*************************************************************************//
//***************************Ajax Functions********************************//
//*************************************************************************//
/******************************Update Archive********************************/
function getUpdateList(year, month){
	xmlhttp=GetXmlHttpObject();
		if (xmlhttp==null)
  		{
  			alert ("Browser does not support HTTP Request");
  			return;
  		}
		var url="archive.php";
		url=url+"?selected_year="+year+"&selected_month="+month;
		url=url+"&sid="+Math.random();
		xmlhttp.onreadystatechange=archive;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
}

function archive()
{
	var loading = "<div align='center'><img src='http://www.alexanderdelargebootlegs.com/img/lyteimages/loading.gif' /><h2>Loading Updates...</h2></div>";
	if(xmlhttp.readyState < 4)
	{
		document.getElementById("update_list").innerHTML = loading;
	}
	else if (xmlhttp.readyState==4)
	{
		document.getElementById("update_list").innerHTML=xmlhttp.responseText;
		initLytebox();
	}
}
/******************************Menu Samples********************************/
function getSamples(page){
	xmlhttp=GetXmlHttpObject();
		if (xmlhttp==null)
  		{
  			alert ("Browser does not support HTTP Request");
  			return;
  		}
		var url="menus.inc.php";
		url=url+"?page="+page;
		url=url+"&sid="+Math.random();
		xmlhttp.onreadystatechange=samples;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
}

function samples()
{
	var loading = "<div align='center'><img src='http://www.alexanderdelargebootlegs.com/img/lyteimages/loading.gif' /><h2>Loading Samples...</h2></div>";
	if(xmlhttp.readyState < 4)
	{
		document.getElementById("menu_list").innerHTML = loading;
	}
	else if (xmlhttp.readyState==4)
	{
		document.getElementById("menu_list").innerHTML=xmlhttp.responseText;
		initLytebox();
	}
}



/***************************Band list search*********************************/

function getBandList(mediaid){
	xmlhttp=GetXmlHttpObject();
		if (xmlhttp==null)
  		{
  			alert ("Browser does not support HTTP Request");
  			return;
  		}
		var url="getbandlist.php";
		url=url+"?media="+mediaid;
		url=url+"&sid="+Math.random();
		xmlhttp.onreadystatechange=bands;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
}

function bands()
{
	var loading = "<select><option value=''>Loading list of bands/artists...</option></select>";
	if(xmlhttp.readyState < 4)
	{
		document.getElementById("band_select").innerHTML = loading;
	}
	else if (xmlhttp.readyState==4)
	{
		document.getElementById("band_select").innerHTML=xmlhttp.responseText;
	}
}

/**************************************************************************/
/****************************Bootleg list**********************************/

function getBootlegs(bandid)
{
	xmlhttp=GetXmlHttpObject();
		if (xmlhttp==null)
  		{
  			alert ("Browser does not support HTTP Request");
  			return;
  		}
		var url="getbootleglist.php";
		var x=document.getElementById("media_select").selectedIndex;
  		var mediaid=document.getElementById("media_select").options[x].value;
		url=url+"?media="+mediaid;
		url=url+"&band="+bandid;
		url=url+"&sid="+Math.random();
		xmlhttp.onreadystatechange=bootlegs;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
}

function bootlegs()
{
	var loading = "<div align='center'><img src='http://www.alexanderdelargebootlegs.com/img/lyteimages/loading.gif' /><h2>Loading Bootleg List...</h2></div>";
	var t;
	if(xmlhttp.readyState < 4)
	{
		document.getElementById("band_list").innerHTML = loading;
	}
	else if (xmlhttp.readyState==4)
	{
		
		document.getElementById("band_list").innerHTML=xmlhttp.responseText;
		initLytebox();
		getRandom();
		
		//t=setTimeout("refreshpage()", 20000);
	}
}
/*************************************************************************************/
/**********************************Random Screens*************************************/
function getRandom()
{
	xmlhttp=GetXmlHttpObject();
		if (xmlhttp==null)
  		{
  			alert ("Browser does not support HTTP Request");
  			return;
  		}
		var url="randombootleg.php";
		var y=document.getElementById("bands").selectedIndex;
		var bandid=document.getElementById("bands").options[y].value;
		url=url+"?band="+bandid;
		url=url+"&sid="+Math.random();
		xmlhttp.onreadystatechange=randomBoot;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
}

function randomBoot()
{
	var loading = "<div align='center'><img src='http://www.alexanderdelargebootlegs.com/img/lyteimages/loading.gif' /><h2><font color='#666666'>Loading Bootleg...</font></h2></div>";
	var t;
	if(xmlhttp.readyState < 4)
	{
		document.getElementById("random").innerHTML = loading;
	}
	else if (xmlhttp.readyState==4)
	{
		
		document.getElementById("random").innerHTML=xmlhttp.responseText;
		initLytebox();
		//t=setTimeout("refreshpage()", 20000);
	}
}

/*****************************************************************************************/
/******************************Traders List***********************************************/
function getTrader(country)
{
	xmlhttp=GetXmlHttpObject();
		if (xmlhttp==null)
  		{
  			alert ("Browser does not support HTTP Request");
  			return;
  		}
		var url="getTraderlist.php";
		var x = document.getElementById("trader_type").selectedIndex;
		if(x != 'undefined'){
			var trader = document.getElementById("trader_type").options[x].value;		
			url=url+"?trader="+trader+"&country="+country;
			url=url+"&sid="+Math.random();
		}
		
		xmlhttp.onreadystatechange=list;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
}

function list()
{
	var loading = "<div align='center'><img src='http://www.alexanderdelargebootlegs.com/img/lyteimages/loading.gif' /><h2>Loading Trader List...</h2></div>";
	if(xmlhttp.readyState < 4)
	{
		document.getElementById("trader_list").innerHTML = loading;
	}
	else if (xmlhttp.readyState==4)
	{
		
		document.getElementById("trader_list").innerHTML=xmlhttp.responseText;

		
		}
}

/*************************************************************************************************/
/************************************Select Traders by country************************************/

function getCountryList(trader){
	xmlhttp=GetXmlHttpObject();
		if (xmlhttp==null)
  		{
  			alert ("Browser does not support HTTP Request");
  			return;
  		}
		var url="getcountry.php";
		url=url+"?trader="+trader;
		url=url+"&sid="+Math.random();
		xmlhttp.onreadystatechange=countries;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
}

function countries()
{
	var loading = "<select><option value=''>Loading list of countries...</option></select>";
	if(xmlhttp.readyState < 4)
	{
		document.getElementById("country").innerHTML = loading;
	}
	else if (xmlhttp.readyState==4)
	{
		document.getElementById("country").innerHTML=xmlhttp.responseText;
	}
}


/*
function refreshpage(){
	var x=document.getElementById("media_select").selectedIndex;
  	var mediaid=document.getElementById("media_select").options[x].value;
	var y=document.getElementById("bands").selectedIndex;
  	var bandid=document.getElementById("bands").options[y].value;
	var url = "getbootleglist.php?media="+mediaid+"&band="+bandid+"&sid="+Math.random();;
	xmlhttp.onreadystatechange=function other(){
				if(xmlhttp.readyState < 4)
				{
				document.getElementById("alert").innerHTML = "Loading...";
				}
				if (xmlhttp.readyState==4)
				{
					document.getElementById("alert").innerHTML = "Ready";
					document.getElementById("band_list").innerHTML=xmlhttp.responseText;
					var t=setTimeout("refreshpage()", 20000);
				};
	}
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
}
*/
/*************************************************************************/

/***************************XMLHTML Object*********************************/

function GetXmlHttpObject()
{
	if (window.XMLHttpRequest)
  	{
  		// code for IE7+, Firefox, Chrome, Opera, Safari
  		return new XMLHttpRequest();
  	}
	if (window.ActiveXObject)
  	{
  		// code for IE6, IE5
  		return new ActiveXObject("Microsoft.XMLHTTP");
	}
return null;
}

/**************************************************************************/


//*************************************************************************//
//*************************************************************************//

/*****************************Onload selected*********************************/

function onLoadSelected(){
	x = document.getElementById("media_select").selectedIndex;
	y = document.getElementsByTagName("option");
	selection = y[x].defaultSelected;
	
		if(selection == false){
			getBandList(x);
		}
}

function onLoadSelectCountry(){
	x = document.getElementById("trader_type").selectedIndex;
	y = document.getElementsByTagName("option");
	selection = y[x].defaultSelected;
	
		if(selection == false){
			getCountryList(x);
		}
}

/**************************************************************************/

//-------------------E-mail Trade Status Contol--------------------------------------------------------
function wantlist(){
		var Mail = document.getElementById("EmailForm");
		var confirmar = confirm("I'm only trading for stuff in my want list, you should check it out first. \n Click Cancel to view my want list");
		if(confirmar == false){
			Mail.action = "wantlist.php";
		}
		if(confirmar == true){
			alert("I will NOT reply to your email if you don't have anything from my want list");
			Mail.action = "mailto:alexanderdelarge@alexanderdelargebootlegs.com?subject=Trade";			
		}
}	

/*************************************************************************/

/************************************Biography controls********************************************/

function megadethColor(){
	document.getElementById("Megadeth").src="http://www.alexanderdelargebootlegs.com/img/images/Megadeth2.jpg";
}
function megadethBlue(){
	document.getElementById("Megadeth").src="http://www.alexanderdelargebootlegs.com/img/images/Megadeth.jpg";
}
function judasColor(){
	document.getElementById("JudasPriest").src="http://www.alexanderdelargebootlegs.com/img/images/JudasPriest2.jpg";
}
function judasBlue(){
	document.getElementById("JudasPriest").src="http://www.alexanderdelargebootlegs.com/img/images/JudasPriest.jpg";
}
function heartColor(){
	document.getElementById("Heart").src="http://www.alexanderdelargebootlegs.com/img/images/Heart2.jpg";
}
function heartBlue(){
	document.getElementById("Heart").src="http://www.alexanderdelargebootlegs.com/img/images/Heart.jpg";
}
function vixenColor(){
	document.getElementById("Vixen").src="http://www.alexanderdelargebootlegs.com/img/images/Vixen2.jpg";
}
function vixenBlue(){
	document.getElementById("Vixen").src="http://www.alexanderdelargebootlegs.com/img/images/Vixen.jpg";
}
function bColor(){
	document.getElementById("B-52s").src="http://www.alexanderdelargebootlegs.com/img/images/B-52s2.jpg";
}
function bBlue(){
	document.getElementById("B-52s").src="http://www.alexanderdelargebootlegs.com/img/images/B-52s.jpg";
}
	
function bioSelector(bio){
	url = "http://www.alexanderdelargebootlegs.com/biography.php";
	window.location = url+"?band="+bio;
}

/****************************************Menu Introductions************************************************/

img1 = new Image();
img1.src = "http://www.alexanderdelargebootlegs.com/img/images/adl_2006_intro1.png";

img2 = new Image();
img2.src = "http://www.alexanderdelargebootlegs.com/img/images/adl_2007_intro1.png";

img3 = new Image();
img3.src = "http://www.alexanderdelargebootlegs.com/img/images/adl_2007_intro2.png";

img4 = new Image();
img4.src = "http://www.alexanderdelargebootlegs.com/img/images/adl_2008_intro.png";

img5 = new Image();
img5.src = "http://www.alexanderdelargebootlegs.com/img/images/adl_2009_intro1.png";

function imageChange(image){
	document.images["samples"].src=eval(image+".src");
}

