// JavaScript Document
function addLoadEvent(func){
		
		var oldonload = window.onload;
		if ( typeof window.onload != 'function') {
			window.onload = func;
		} else {
			window.onload = function() {
				oldonload();
				func();
			}
		}
	}
	
	function dancing() {
	
		
		var theImages = Array();
		theImages[0] = 'images/rotate/img_rotate_1.png'
		theImages[1] = 'images/rotate/img_rotate_2.png'
		theImages[2] = 'images/rotate/img_rotate_3.png'
		theImages[3] = 'images/rotate/img_rotate_4.png'
		theImages[4] = 'images/rotate/img_rotate_5.png'
		theImages[5] = 'images/rotate/img_rotate_6.png'
		theImages[6] = 'images/rotate/img_rotate_7.png'
		theImages[7] = 'images/rotate/img_rotate_8.png'
		theImages[8] = 'images/rotate/img_rotate_9.png'
		theImages[9] = 'images/rotate/img_rotate_10.png'
	
		
		var j = 0;
		var p = theImages.length;
		var preBuffer = new Array()
		for (i = 0; i < p; i++){
		
		   preBuffer[i] = new Image()
		   preBuffer[i].src = theImages[i]
		}
		var whichImage = Math.round(Math.random()*(p-1));
		
		if(!document.getElementById){
	
			return false;
		}
		
		
		if(!document.getElementById("dancing-photos")){
	
			return false;
		}
		
		var placeholder = document.getElementById("dancing-photos");
		placeholder.setAttribute("src", theImages[whichImage]);
	}
	
	function footertarget() {
		
		if(!document.getElementById){
				return false;
		}
		if(!document.getElementById("j-sponsors")){
				return false;
		}
		var sponsors = document.getElementById("j-sponsors");
		var links = sponsors.getElementsByTagName("a");
		for(var i=0; i <links.length; i++) {
			links[i].setAttribute("target","_blank");	
		}
	}
		function bandtarget() {
		
		if(!document.getElementById){
				return false;
		}
		if(!document.getElementById("content")){
				return false;
		}
		var bandwebsite = document.getElementById("content");
		var links = bandwebsite.getElementsByTagName("a");
		for(var i=0; i <links.length; i++) {
			if (links[i].className == "bandsite"){
				links[i].setAttribute("target","_blank");	
			}
		}
	}
	function bandtarget() {
		
		if(!document.getElementById){
				return false;
		}
		if(!document.getElementById("content")){
				return false;
		}
		var hotellinks = document.getElementById("content");
		var links = hotellinks.getElementsByTagName("a");
		for(var i=0; i <links.length; i++) {
			if (links[i].className == "h-add"){
				links[i].setAttribute("target","_blank");	
			}
		}
	}
	
	addLoadEvent(dancing);
	addLoadEvent(footertarget);
	addLoadEvent(bandtarget);
