// JavaScript Document

function popWin(url,h,w) {

	supportWindow = window.open(url,"_blank","height="+h+",width="+w+",resizable=no,scrollbars=no,toolbar=no,location=no,menubar=no,copyhistory=no");
	
	supportWindow.focus();
	
	return false;
	
}

function swapVis(id,ids) {
		if (document.getElementById(id).style.visibility == "hidden") {
			document.getElementById(id).style.visibility = 'visible';
			document.getElementById(id).style.display = 'inline';
			
			
			
			
		} else {
			document.getElementById(id).style.visibility = 'hidden';
			document.getElementById(id).style.display = 'none';
			
			
		}
		if (document.getElementById(ids).style.visibility == "visible") {
			document.getElementById(ids).style.visibility = 'hidden';
			document.getElementById(ids).style.display = 'none';
			
			
		} else {
			document.getElementById(ids).style.visibility = 'visible';
			document.getElementById(ids).style.display = 'inline';
			
			
		}
		return false;
}

function roll(org,to) {	
	if (document.images) {
		document[org].src = eval (to + ".src")
	}
}

function swapMap(img,map) {
	if (document.images) {
		document[img].useMap = "#" + map
	}
}

if (document.images) {
	
	yoLogo = new Image
	yoLogoO = new Image
	
	butL = new Image
	butLO = new Image
	
	butM = new Image
	butMO = new Image
	
	butN = new Image
	butNO = new Image
	
	butR = new Image
	butRO = new Image
	
	mp1f1 = new Image
	mp2f1 = new Image
	mp3f1 = new Image
	mp4f1 = new Image
	mp5f1 = new Image
	mp2f1O = new Image
	mp3f1O = new Image
	mp4f1O = new Image
	mp5f1O = new Image
	
	lB1 = new Image
	lB1O = new Image
	
	lB2 = new Image
	lB2O = new Image
	
	yoLogo.src = "images/wvs_logo_v6.jpg"
	yoLogoO.src = "images/wvs_logo_v6O.jpg"
	
	butL.src = "images/button1.jpg"
	butLO.src = "images/button1O.jpg"
	
	butM.src = "images/button2.jpg"
	butMO.src = "images/button2O.jpg"
	
	butN.src = "images/button3.jpg"
	butNO.src = "images/button3O.jpg"
	
	butR.src = "images/button4.jpg"
	butRO.src = "images/button4O.jpg"
	
	mp1f1.src = "images/frameMain.jpg"
	mp2f1.src = "images/frameCountries.jpg"
	mp2f1O.src = "images/frameCountriesO.jpg"
	mp3f1.src = "images/frameProject.jpg"
	mp3f1O.src = "images/frameProjectO.jpg"
	mp4f1.src = "images/frameVoices.jpg"
	mp4f1O.src = "images/frameVoicesO.jpg"
	mp5f1.src = "images/frameService.jpg"
	mp5f1O.src = "images/frameServiceO.jpg"
	
	
	lB1.src = "images/layout/linkB1.png"
	lB1O.src = "images/layout/linkB1O.png"
	
	lB2.src = "images/layout/linkB2.png"
	lB2O.src = "images/layout/linkB2O.png"
	
	
	
} else {
	
	butL = ""
	butLO = ""
	butM = ""
	butMO = ""
	butR = ""
	butRO = ""
	document.buttonLeft = ""
	document.buttonMid = ""
	document.buttonRight = ""
	
}

var thisImg = 1
var lastImg = 6
var lastTid = null

function rotate() {
	
	buttonArray = new Array("butLO","butMO","butNO","butRO")
	buttonArray2 = new Array("butL","butM","butN","butR")
	mapsArray = new Array("Map","Map2","Map3","Map4")
	
	thisImg++
	if (thisImg == lastImg) {
		thisImg = 1
	}
	if (thisImg != 1) {
		but = thisImg - 1
		arr = but - 1
		tbut = "but" + but
		document[tbut].src = eval (buttonArray[arr] + ".src")
		swapMap('mf',mapsArray[arr])
		
		if (thisImg > 2) {
			but--
			arr--
			rbut = "but" + but
			document[rbut].src = eval (buttonArray2[arr] + ".src")
		}
	}
	
	if (thisImg == 1) {
		document['but4'].src = eval(buttonArray2[3] + ".src")
		swapMap('mf','')
	}
	
	document['mf'].src = eval ("mp" + thisImg + "f1.src")
	
	if (thisImg == 1) {
		longdelay()
	} else {
	
		delay()
	}
}

function delay() {
	var id
	if (lastTid != null) {
		clearTimeout(lastTid)
	}
	id = setTimeout("rotate()", 3*5000)
	addlastTid(id)
	
}

function longdelay() {
	var id
	if (lastTid != null) {
		clearTimeout(lastTid)
	}
	id = setTimeout("rotate()", 10*5000)
	addlastTid(id)
}

function addlastTid(tid) {
	lastTid = tid
}
function clearlast(clearid) {
	clearTimeout(clearid)
}