
//no time to refactor

var podnavcontent = null
var podcontent = null
var treebackgroundlist = null
var domswap = null
var podnavcontentswap = null

function pageSetUp() {

	podnavcontent = document.getElementById("podnavcontent")
	podcontent = document.getElementById("instructions")
	treebackgroundlist = {"parent":document.getElementById("instructions").parentNode,"0":document.getElementById("instructions"), "1":document.getElementById("hostbio"), "2":document.getElementById("whatispodcast"), "3":document.getElementById("subscribe") }
	
	CreateControl (
							'flashDiv0',
							'objFlash0',
							'/media/vehicles/current/buick/enclave/podcast/enclave_promo_player.swf?filePath=/media/vehicles/current/buick/enclave/podcast/',
							'100',
							'30',
							'transparent',
							'reg',
							'',
							'',

							''
						)

}



function podnavRollover(obj, mapto, state) {
	var objimage = obj.firstChild
	var imagelist = {"0":"nav_text_off.jpg","1":"nav_text_01.jpg", "2":"nav_text_02.jpg", "3":"nav_text_03.jpg", "4":"nav_text_04.jpg", "5":"nav_text_05.jpg", "6":"nav_text_06.jpg"}
	var navoverlist = {"1":"nav_01_rollover.jpg", "2":"nav_02_rollover.jpg", "3":"nav_03_rollover.jpg", "4":"nav_04_rollover.jpg", "5":"nav_05_rollover.jpg", "6":"nav_06_rollover.jpg" }
	var navonlist = {"1":"nav_01_on.jpg", "2":"nav_02_on.jpg", "3":"nav_03_on.jpg", "4":"nav_04_on.jpg", "5":"nav_05_on.jpg", "6":"nav_06_on.jpg" }
	var imageout = ""
	var basepath = "/images/vehicles/2007/buick/enclave/podcast/"


	if (state == 1) { //switch to rollover state
		imageout = "<img src=\""+basepath+imagelist[mapto]+"\" />"
		objimage.src = basepath+navoverlist[mapto]
		if ( podnavcontentswap == null ) { podnavcontentswap = podnavcontent.innerHTML }
		podnavcontent.innerHTML = imageout
	} else { //revert to normal state
		imageout = "<img src=\""+basepath+imagelist[0]+"\" />"
		objimage.src = basepath+navonlist[mapto]
		//alert(podnavcontentswap)
		podnavcontent.innerHTML = podnavcontentswap
		CreateControl (
							'flashDiv0',
							'objFlash0',
							'/media/vehicles/current/buick/enclave/podcast/enclave_promo_player.swf?filePath=/media/vehicles/current/buick/enclave/podcast/',
							'100',
							'30',
							'transparent',
							'reg',
							'',
							'',

							''
						)
	}
	


}

function simpleSwap(obj, mapto) {
	var objimage = obj.firstChild
	var carpfest = {"0":"img_subscribebtn_rss_on.gif", "1":"img_subscribebtn_rss_off.gif", "2":"img_subscribebtn_itunes_on.gif", "3":"img_subscribebtn_itunes_off.gif"}
	var basepath = "/images/vehicles/2007/buick/enclave/podcast/"

	objimage.src = basepath+carpfest[mapto]


}


function podcastInfoOver(obj, mapto, state) {

	var objimage = obj.firstChild
	var navoverlist = { "1":"subnav_host_on.gif", "2":"subnav_podcast_on.gif", "3":"subnav_subscribe_on.gif"  }
	var navofflist = { "1":"subnav_host_off.gif", "2":"subnav_podcast_off.gif", "3":"subnav_subscribe_off.gif"  }


	var imageout = null
	var basepath = "/images/vehicles/2007/buick/enclave/podcast/"

	if (state == 1) { //switch to rollover state
		objimage.src = basepath+navoverlist[mapto]
	} else { //revert to normal state

		if (domswap != null) {

			if (treebackgroundlist["parent"].firstChild.id !=  treebackgroundlist[mapto].id) {//note the mapto for the treebackgroundlist comparison. this works becasue the content list ids for both the rollovers and the content nodes are in sync
				objimage.src = basepath+navofflist[mapto]
			}
		} else {
			objimage.src = basepath+navofflist[mapto]
		}
	}


}

function clearAllRollOvers(ignore) {
	var podhowtonav	= document.getElementById("podhowtonav")
	var imglist = podhowtonav.getElementsByTagName("img")
	
	var navofflist = new Array("subnav_host_off.gif","subnav_podcast_off.gif","subnav_subscribe_off.gif")
	var basepath = "/images/vehicles/2007/buick/enclave/podcast/"

	for (var i=0; i<=2; i++) {
		if (i != (ignore-1)) {
			imglist[i].src = basepath+navofflist[i]
		}
	}
}

function podcastInfoChange(mapto) {
	if (domswap == null) {
		var tmp = treebackgroundlist["parent"].replaceChild(treebackgroundlist[mapto], treebackgroundlist[0])

	} else {
		var tmp = treebackgroundlist["parent"].replaceChild(treebackgroundlist[mapto], treebackgroundlist[domswap])
	}
	clearAllRollOvers(mapto)
	domswap = mapto
}

function flashOnOff(id,state,obj) {
	
	flashPlayerDisplay(obj.parentNode.parentNode.childNodes)

	var player = document.getElementById("player"+id)
	if (state == 1) {
		player.style.display = "block"
	} else  {
		player.style.display = "none"
	}

}

function flashPlayerDisplay(objlist) {

	var basepath = "/images/vehicles/2007/buick/enclave/podcast/"
	var reg = /http:\/\/(?:\w+)(\.\w+)*/

	if (objlist[0].firstChild.firstChild.src.replace(reg,"") == basepath+"img_listen_text_on.gif") {
		objlist[0].firstChild.firstChild.src = basepath+"img_listen_text_faded.gif"
		objlist[2].firstChild.firstChild.src = basepath+"img_hide_text_off.gif"
	} else if ( objlist[2].firstChild.firstChild.src.replace(reg,"") == basepath+"img_hide_text_on.gif") {
		objlist[2].firstChild.firstChild.src = basepath+"spacer.gif"
		objlist[0].firstChild.firstChild.src = basepath+"img_listen_text_off.gif"
	}


}

function flashOver(obj, mapto, state) {
	var objimage = obj.firstChild
	var navoverlist = { "1":"img_listen_text_on.gif", "2":"img_download_text_on.gif", "3":"img_hide_text_on.gif"  }
	var navofflist = { "1":"img_listen_text_off.gif", "2":"img_download_text_off.gif", "3":"img_hide_text_off.gif"  }
	var reg = /http:\/\/(?:\w+)(\.\w+)*/
	var basepath = "/images/vehicles/2007/buick/enclave/podcast/"
	
//	alert(objimage.src.replace(reg,""))
 	if (objimage.src.replace(reg,"") != basepath+"spacer.gif" && objimage.src.replace(reg,"") != basepath+"img_listen_text_faded.gif") {
		if (state == 1) {
			objimage.src = basepath+navoverlist[mapto]
		} else {
			objimage.src = basepath+navofflist[mapto]
		}
	}
}


