function createREQ() {
	if (window.XMLHttpRequest) {
		var request = new XMLHttpRequest()    // IE7, Mozilla
		}
	else {
	if (window.ActiveXObject) {
		var request = new ActiveXObject("Microsoft.XMLHTTP");   // IE5 & IE6
		}
	}
	return request;
	}

// ===============================================================================================================================

function loadContent(whichdiv,file) {
	document.getElementById(whichdiv).innerHTML="Loading.....";
	var myreq = createREQ();
	randomNum=parseInt(Math.random()*99999999);
	var url = file + "?" + randomNum;
	myreq.onreadystatechange = function() {
		if ((myreq.readyState == 4) && (myreq.status == 200)) {
		  	var textinpage = myreq.responseText;
			document.getElementById(whichdiv).innerHTML=textinpage;
			}
		}
	myreq.open("GET",url,true);
	myreq.send(null);
}

// ===============================================================================================================================

function loadVideo(vidFile) {
	var soCC = new SWFObject("/flash/mediaplayer.swf?height=260&width=320&file=/videos/cmoncmon.flv&image=/videos/images/prevCmonCmon.jpg&amp;backcolor=0xc0c0c0&lightcolor=0x990000&amp;logo=/videos/images/topRight.png&showstop=true&autostart=true", "cmoncmon", "320", "260", "8", "#000000");	
	var soNL = new SWFObject("/flash/mediaplayer.swf?height=260&width=320&file=/videos/nineLives.flv&image=/videos/images/prevNineLives.jpg&amp;backcolor=0xc0c0c0&lightcolor=0x990000&amp;logo=/videos/images/topRight.png&showstop=true&autostart=true", "ninelives", "320", "260", "8", "#000000");
	var soRO = new SWFObject("/flash/mediaplayer.swf?height=260&width=320&file=/videos/rockOn.flv&image=/videos/images/prevRockOn.jpg&amp;backcolor=0xc0c0c0&lightcolor=0x990000&amp;logo=/videos/images/topRight.png&showstop=true&autostart=true", "rockon", "320", "260", "8", "#000000");
	var soNMW = new SWFObject("/flash/mediaplayer.swf?height=260&width=320&file=/videos/noMatterWhat.flv&image=/videos/images/prevNoMatterWhat.jpg&amp;backcolor=0xc0c0c0&lightcolor=0x990000&amp;logo=/videos/images/topRight.png&showstop=true&autostart=true", "nomatterwhat", "320", "260", "8", "#000000");
	var soEHone = new SWFObject("/flash/mediaplayer.swf?height=260&width=320&file=/videos/trailerEhCheckThisOut.flv&image=/videos/images/prevCheckThisOut.jpg&amp;backcolor=0xc0c0c0&lightcolor=0x990000&amp;logo=/videos/images/topRight.png&showstop=true&autostart=true", "ehcheckthisout", "320", "260", "8", "#000000");
	var soEHtwo = new SWFObject("/flash/mediaplayer.swf?height=260&width=320&file=/videos/trailerEhCheckThisOut2.flv&image=/videos/images/prevCheckThisOut2.jpg&amp;backcolor=0xc0c0c0&lightcolor=0x990000&amp;logo=/videos/images/topRight.png&showstop=true&autostart=true", "ehcheckthisout2", "320", "260", "8", "#000000");


	if (vidFile == "ninelives") {
		soNL.write("videoFrame");		
		}
	else if (vidFile == "cmoncmon") {
		soCC.write("videoFrame");		
		}
	else if (vidFile == "rockon") {
		soRO.write("videoFrame");		
		}
	else if (vidFile == "nomatterwhat") {
		soNMW.write("videoFrame");		
		}
	else if (vidFile == "ehcheckthisout1") {
		soEHone.write("videoFrame");		
		}
	else if (vidFile == "ehcheckthisout2") {
		soEHtwo.write("videoFrame");		
		}		

	}
// ===============================================================================================================================


function setSize() {

	var pageSize = this.getPageSize();
	var vpWidth = pageSize[2];
	var vpHeight = pageSize[3];

	// alert(vpWidth + " - " + vpHeight + " - " + contentHeight);

	// topnav = 30 
	// h2 = 250 (height and top margin) + 20 bottom margin = 270
	// footer = 30 + 1 top border = 31
	// TOTAL: 30 + 270 + 31 = 331
	
	// 331 is the minimum content on the page
	
	// If the viewport is larger than 331, then HEIGHTSET should be sized to make sure
	// the footer is at the bottom of the page; the size of the HEIGHTSET is viewport - 333.
	// We then add another pixel to make sure there's always a scrollbar.
	
	var contentHeight = vpHeight - 331 + 1;   

	 if (vpHeight > 331 ) {
	 	document.getElementById("heightSet").style.height = contentHeight + "px";
	 	}
	 	
	}
		
// ===============================================================================================================================

getPageSize = function() {
	var xScroll, yScroll, windowWidth, windowHeight;
	if (window.innerHeight && window.scrollMaxY) {
		xScroll = this.document.scrollWidth;
		yScroll = (this.isFrame ? parent.innerHeight : self.innerHeight) + (this.isFrame ? parent.scrollMaxY : self.scrollMaxY);
		}
	else if (this.document.body.scrollHeight > this.document.body.offsetHeight){
		xScroll = this.document.body.scrollWidth;
		yScroll = this.document.body.scrollHeight;
		}
	else {
		xScroll = this.document.getElementsByTagName("html").item(0).offsetWidth;
		yScroll = this.document.getElementsByTagName("html").item(0).offsetHeight;
		xScroll = (xScroll < this.document.body.offsetWidth) ? this.document.body.offsetWidth : xScroll;
		yScroll = (yScroll < this.document.body.offsetHeight) ? this.document.body.offsetHeight : yScroll;
		}

	if (self.innerHeight) {
		windowWidth = (this.isFrame) ? parent.innerWidth : self.innerWidth;
		windowHeight = (this.isFrame) ? parent.innerHeight : self.innerHeight;
		}
	else if (document.documentElement && document.documentElement.clientHeight) {
		windowWidth = this.document.documentElement.clientWidth;
		windowHeight = this.document.documentElement.clientHeight;
		}
	else if (document.body) {
		windowWidth = this.document.getElementsByTagName("html").item(0).clientWidth;
		windowHeight = this.document.getElementsByTagName("html").item(0).clientHeight;
		windowWidth = (windowWidth == 0) ? this.document.body.clientWidth : windowWidth;
		windowHeight = (windowHeight == 0) ? this.document.body.clientHeight : windowHeight;
		}

	var pageHeight = (yScroll < windowHeight) ? windowHeight : yScroll;
	var pageWidth = (xScroll < windowWidth) ? windowWidth : xScroll;
	return new Array(pageWidth, pageHeight, windowWidth, windowHeight);
	}


// ===============================================================================================================================

function externalLinks() {
	if (!document.getElementsByTagName) return;
 	var anchors = document.getElementsByTagName("a");
 	for (var i=0; i<anchors.length; i++) {
 		var anchor = anchors[i];
   		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
     		anchor.target = "_blank";
 		}
	}
	
	
// ===============================================================================================================================	
	
function lyrics(song) {
	var pageSize = this.getPageSize();
	var vpWidth = pageSize[2];
	var leftPos = (vpWidth/2)-200;
	popupWin = window.open('lyrics.asp?song='+song, 'Lyrics', 'left=' + leftPos + ',top=10,width=400,height=550,menubar=no,scrollbars=yes,resizable=no,toolbar=no,location=no,directories=no,status=yes');
	}

// ===============================================================================================================================	

function showPop(url,w,h) {
	var pageSize = this.getPageSize();
	var vpWidth = pageSize[2];
	var vpHeight = pageSize[3];
	var leftPos = (vpWidth/2)-(w/2);
	var topPos = (vpHeight/2)-(h/2);
	popupWin = window.open(url,'dlcompop','left=' + leftPos + ',top=' + topPos + ',width=' + w + ',height=' + h + ',menubar=no,scrollbars=no,resizable=no,toolbar=no,location=no,directories=no,status=yes');
	}

// ===============================================================================================================================	

function showAmount(item1,item2,item3) {
	var amtTotal = (299*item1) + (149*item2) + (12*item3);
	var itemTotal = (1*item1) + (1*item2) + (1*item3);
	if (itemTotal == 0) {
		alert("Please select at least one item to add to your cart.");
		}
	else if (itemTotal == 1) {
		alert("Your cart contains " + itemTotal + " item.");
		document.getElementById("yourTotalAmount").style.display = "block";
		document.getElementById("totalAmount").style.display = "block";
		document.getElementById("totalAmount").innerHTML = "$" + amtTotal + ".00";		
		document.getElementById("afterAdd").style.display = "block";
		}
	else {
		alert("Your cart contains " + itemTotal + " items.");
		document.getElementById("yourTotalAmount").style.display = "block";
		document.getElementById("totalAmount").style.display = "block";
		document.getElementById("totalAmount").innerHTML = "$" + amtTotal + ".00";		
		document.getElementById("afterAdd").style.display = "block";
		}			
	}
	
	
	



// ===============================================================================================================================	

function showAnswer(question) {
	if (question == "blank") {
		alert("Please select a question from the dropdown list.");
		document.getElementById("question").focus();
		}
	else if (question == "fanclub") {
		document.getElementById("contactAnswer").innerHTML = "<p>If you have any trouble with your Fan Club membership (including questions about your username, password, membership renewal, or signing up as a new member), please contact the Fan Club directly at <a href=\"http://fanclub.defleppard.com/contact\" rel=\"external\" target=\"_blank\">http://fanclub.defleppard.com/contact</a>. They are the ones in charge of membership administration and everything related and should be able to answer your question instantly.</p> ";
		document.getElementById("contactIntro").style.display = "block";
		document.getElementById("contactForm").style.display = "none";		
		}
	else if (question == "fcnewsletter") {
		document.getElementById("contactAnswer").innerHTML = "<p>If you are a member of the Fan Club but you do not receive a newsletter while your friends did, it is possible that spam-control software did not let the newsletter go through. Please check your \"SPAM\" or \"BULK\" folders to see if the newsletter wasn't accidentally filtered as unwanted email and put the newsletter on your \"safe\" list. <br> It is also possible you don't receive the newsletter due to your provider's aggressive server-level spam filter (a common problem with AOL and Comcast subscribers, among others). If that is the case, there is not much we can do about that and we suggest that you change the email address in your profile to one that will allow you to configure spam-control software yourself (such as <a href=\"http://www.hotmail.com\" rel=\"external\">HotMail</a> or <a href=\"http://mail.yahoo.com\" rel=\"external\">Yahoo!</a>).</p><p>If this does not fully answer your question, please <a href=\"javascript:showContactForm()\">click here</a> to send us a message.</p>";
		document.getElementById("contactIntro").style.display = "block";
		document.getElementById("contactForm").style.display = "none";		
		}
	else if (question == "fcsite") {
		document.getElementById("contactAnswer").innerHTML = "<p>If you have any trouble with the Fan Club site (including problems logging in, or signing up as a new member), please contact the Fan Club directly at <a href=\"http://fanclub.defleppard.com/contact\" rel=\"external\">http://fanclub.defleppard.com/contact</a>. They are the ones in charge of membership administration and everything related and should be able to answer your question instantly.</p> ";
		document.getElementById("contactIntro").style.display = "block";
		document.getElementById("contactForm").style.display = "none";		
		}
	else if (question == "tour") {
		document.getElementById("contactAnswer").innerHTML = "<p>All information about any upcoming Def Leppard shows that we are able to share can be found <a href=\"/tour/\">HERE</a>. PLEASE DO NOT ASK US IF WE KNOW ABOUT ANY OTHER TOURING PLANS. If we would be able to tell, it would be on this site. Save yourself some trouble and don't ask us if we know if or when the band will play in the Australia, Dallas, Spain, or anywhere else. We will not respond to those questions.</p><p>If this does not fully answer your question, please <a href=\"javascript:showContactForm()\">click here</a> to send us a message.</p>";
		document.getElementById("contactIntro").style.display = "block";
		document.getElementById("contactForm").style.display = "none";		
		}
	else if (question == "backstage") {
		document.getElementById("contactAnswer").innerHTML = "<p>We can NOT help you meet the band or provide you with backstage passes. Any and all requests for band meetings will be ignored. The best way to meet the band is to find the backstage area/parking lot at a show and wait for them to come out after the show. As long as you're polite and act patient (that means, don't be rude or pushy), there's a good chance the band will stop for a picture or autograph.</p><p>If this does not fully answer your question, please <a href=\"javascript:showContactForm()\">click here</a> to send us a message.</p>";
		document.getElementById("contactIntro").style.display = "block";
		document.getElementById("contactForm").style.display = "none";		
		}
	else if (question == "messageboard") {
		document.getElementById("contactAnswer").innerHTML = "<p>The Def Leppard message board at <a href=\"http://forum.defleppard.com\" rel=\"external\">http://forum.defleppard.com</a> has its own extensive FAQ/manual in which many common questions and problems are addressed, and is located <a href=\"/forum/faq.asp\" rel=\"external\">here</a>. Please read this page first before you contact us with login issues.</p><p>If this does not fully answer your question, please <a href=\"javascript:showContactForm()\">click here</a> to send us a message.</p>";
		document.getElementById("contactIntro").style.display = "block";
		document.getElementById("contactForm").style.display = "none";		
		}
	else if (question == "bookorder") {
		document.getElementById("contactAnswer").innerHTML = "<p>Please note that due to the overwhelming success of the book and calendar and the unexpected amount of orders, as well as the holiday season, delivery may take a little longer than usual. While normal delivery time would be around 1-2 weeks, during these times it may take the postal service 3, sometimes even 4 weeks or more.</p><p>At this time <strong>all ordered books and calendars have been sent out</strong>, and there is a very good possibility the merchandise is still on its way to you. If you have not received anything 6-8 weeks after ordering, please contact us and we will start an investigation. Until then, we are sorry but we can not give tracking numbers for each individual order.</p><p>Also please note: each item is sent seperately. If you ordered a calendar and a book at the same time, it is very possible that your calendar and your book will arrive weeks apart. This is a postal service issue and unfortunately we are unable to do anything about it.</p><p>If this does not fully answer your question, please <a href=\"javascript:showContactForm()\">click here</a> to send us a message.</p>";
		document.getElementById("contactIntro").style.display = "block";
		document.getElementById("contactForm").style.display = "none";		
		}		
	else if (question == "store") {
		document.getElementById("contactAnswer").innerHTML = "<p>The band's official store, located <a href=\"http://www.fanfire.com/cgi-bin/WebObjects/fanfire.woa/wa/artist?artistName=Def+Leppard&amp;categoryName=Featured+Items&amp;sourceCode=DELWEB\" rel=\"external\">here</a>, is fully operated by <strong>FanFire</strong>. For any questions/comments about your order or the items offered through the store, please contact FanFire directly at <a href=\"mailto:orderhelp@fanfire.com\">orderhelp@fanfire.com</a>, or call 1-800-767-7160 (US) / +1-916-350-2016 (international).</p><p>If this does not fully answer your question, please <a href=\"javascript:showContactForm()\">click here</a> to send us a message.</p>";
		document.getElementById("contactIntro").style.display = "block";
		document.getElementById("contactForm").style.display = "none";		
		}		
	else if (question == "sendband") {
		document.getElementById("contactAnswer").innerHTML = "<p>We're sorry, it is currently not possible to send any letters, requests for autographs or any other mail to the band. As soon as this option is available again, we will post it on our web site.</p>";
		document.getElementById("contactIntro").style.display = "none";
		document.getElementById("contactForm").style.display = "none";
		}
	else if (question == "sendlabel") {
		document.getElementById("contactAnswer").innerHTML = "<p>Concert promoters, press, booking agents and other business-related companies should get in touch with the band's press agent at <a href=\"mailto:presspublicity@defleppard.com\" rel=\"external\">presspublicity@defleppard.com</a>. There are currently no options for contacting the management through email.</p><p>If this does not fully answer your question, please <a href=\"javascript:showContactForm()\">click here</a> to send us a message.</p>";
		document.getElementById("contactIntro").style.display = "block";
		document.getElementById("contactForm").style.display = "none";
		}
	else {
		document.getElementById("contactAnswer").innerHTML = "<p>Please use the form below to contact the DefLeppard.com webmaster. NOTE: please do NOT use this form to send mail to the <strong>BAND</strong>, their <strong>MANAGEMENT</strong> or their <strong>LABEL</strong>. Any messages sent through this page will only reach the DefLeppard.com <strong>webmaster</strong> and <strong style=\"color:#c33;\">will NOT reach the band.</strong></p>";
		document.getElementById("contactIntro").style.display = "none";
		document.getElementById("contactForm").style.display = "block";
		}		
		
	}


function showContactForm() {
	document.getElementById("contactForm").style.display = "block";	
	}
	
// ===============================================================================================================================	

function forumShowHide(q) {
	divAnswer = "forumfaq" + q + "a";
	document.getElementById(divAnswer).style.display = (document.getElementById(divAnswer).style.display == "block") ? "none" : "block";
	}

// ===============================================================================================================================	


function showCustomFees() {
	var pageSize = this.getPageSize();
	var vpWidth = pageSize[2];
	var leftPos = (vpWidth / 2) - 330;

 	document.getElementById("afterAdd").style.left = leftPos + "px";
 	document.getElementById("afterAdd").style.display = "block";
	}

function hideCustomFees() {
 	document.getElementById("afterAdd").style.display = "none";
	}

// ===============================================================================================================================	

function translateNote(lang) {
	if (lang == "it") { langLong = "Italian"; } 
	else if (lang == "fr") { langLong = "French"; } 
	else if (lang == "ja") { langLong = "Japanese"; } 
	else if (lang == "de") { langLong = "German"; } 
	else if (lang == "pt") { langLong = "Portugese"; } 
	else { langLong = "Spanish"; } 
	
	alert("This page will now be automatically translated to " + langLong + ".\n\nPlease note that the translation may not be 100% accurate and that the translation scripts may cause some functionality issues, such as broken layout or incorrect links.\n");
	}


// ===============================================================================================================================	


function callScripts() {
	externalLinks();
	setSize();
	}
	
	
window.onload = callScripts;