var iPad = navigator.userAgent.match(/iPad/i) != null;
var iPhone = navigator.userAgent.match(/iPhone/i) != null;
var ie6;
var ie7;
var ie = /*@cc_on!@*/false;

function create_ajax(){
	if (window.XMLHttpRequest){
		xmlhttp=new XMLHttpRequest();
	}
	else{
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	return xmlhttp;
}

function run_ajax(ajax_var,type,url,vars){
	ajax_var.open(type,url+"?"+vars,true);
	ajax_var.send();
}

function newwindow_links(){
	var e = new Array();
	var i;
	e = document.getElementsByTagName("a");
	for(i=0;i<e.length;i++){
		if(e[i].className.indexOf("newwindow") > -1){
			e[i].target="_blank";
		}
	}
}

function browser_fixes(){
	//FIX NO LEFT PADDING ON A TAGS BELOW IMAGE LIST
	if (ie7){
		var as = document.getElementsByTagName("a");
		for (i=0;i<as.length;i++){
			if (as[i].className.indexOf("ie7") > -1){
				var parent = as[i].parentNode;
				var newspan = document.createElement('span');
  				newspan.innerHTML = "&nbsp;";
				parent.insertBefore(newspan, as[i]);
			}
		}
	}

	//FIX HR BORDER
	if (ie6 || ie7){
		var hrs = document.getElementsByTagName("hr");
		for (i=0;i<hrs.length;i++){
			if (hrs[i].className.indexOf("line") == -1){
				var parent = hrs[i].parentNode;
				var newdiv = document.createElement('div');
				var divClassName = 'hr';
	  			newdiv.className = divClassName;
				parent.insertBefore(newdiv, hrs[i]);
				parent.removeChild(hrs[i]);
			}
		}
	}
	
	// STYLE FORM ELEMENTS
	if (ie6){
		e=document.getElementsByTagName("input");
		for(i=0;i<e.length;i++){
			if (e[i].type == "text" || e[i].type == "password"){
				e[i].className += " ie6_text";
			}
		}
		
		e=document.getElementsByTagName("textarea");
		for(i=0;i<e.length;i++){
			e[i].className += " ie6_text";
		}
		
		e=document.getElementsByTagName("select");
		for(i=0;i<e.length;i++){
			e[i].className += " ie6_text";
		}
		
		e=document.getElementsByTagName("td");
		for(i=0;i<e.length;i++){
			if (e[i].className == "inputs"){
				var children = e[i].childNodes;
				for (j=0;j<children.length;j++){
					if (children[j].tagName == "SELECT" || children[j].tagName == "TEXTAREA" || children[j].type == "text" || children[j].type == "password" || children[j].type == "file"){
						children[j].className += " ie6_form_element";
					}
				}
			}
		}
	}
	
	// REPLACE TOP AND BOTTOM IMAGES ON OVERLAY
	if (ie6){
		e=document.getElementsByTagName("div");
		for(i=0;i<e.length;i++){
			if (e[i].className == "content"){
				var children = e[i].childNodes;
				for (j=0;j<children.length;j++){
					if (children[j].className == "top"){
						children[j].src = "/_images/overlay/overlay_top_ie6.gif";
					}
					if (children[j].className == "bottom"){
						children[j].src = "/_images/overlay/overlay_bottom_ie6.gif";
					}
				}
			}
		}
	}
	
	// SET NO BACKGROUND TO PAGINATION LINKS
	if (ie6){
		e=document.getElementsByTagName("div");
		for(i=0;i<e.length;i++){
			if (e[i].className.indexOf("divPagination") > -1){
				var children = e[i].childNodes;
				for (j=0;j<children.length;j++){
					if (children[j].tagName == "A"){
						children[j].style.backgroundImage = "none";
					}
				}
			}
		}
	}
	
	if (ie6 || ie7){
		e=document.getElementsByTagName("div");
		for(i=0;i<e.length;i++){
			if (e[i].className.indexOf("divPagination") > -1){
				var blankSpan = document.createElement("span");
				e[i].insertBefore(blankSpan,e[i].childNodes[0]);
			}
		}
	}
}








function homebox_change(button){
	
	var theButtons = new Array();
	var theButtonsText = new Array();
	
	theButtons[1] = document.getElementById("aHomebox1");
	theButtons[2] = document.getElementById("aHomebox2");
	theButtons[3] = document.getElementById("aHomebox3");

	theButtonsText[1] = "Recycle Zones";
	theButtonsText[2] = "Recycling at events";
	theButtonsText[3] = "Recycling on the high street";
	
	theButtons[button].className = "top on";
	theButtons[button].innerHTML = theButtonsText[button];
		
	for (i=1;i<=3;i++){
		if (i != button){
			theButtons[i].className = "top off";
			theButtons[i].innerHTML = '<span class="red">&gt;</span> ' + theButtonsText[i];
		}
	}
	
	for (i=1;i<=3;i++){
		for (j=1;j<=10;j++){
			var theDiv = document.getElementById("divHomebox_"+i+"_"+j);
			var thePagination = document.getElementById("divHomeboxPagination_"+i);
			var theLink = document.getElementById("aHomebox_"+i+"_"+j);
			if (theDiv){
				theDiv.style.display = "none";
			}
			if (thePagination){
				thePagination.style.display = "none";
			}
			if (theLink){
				theLink.className = "";
			}
		}
	}
	
	var theContent = document.getElementById("divHomebox_"+button+"_1");
	var thePagination = document.getElementById("divHomeboxPagination_"+button);
	var theLink = document.getElementById("aHomebox_"+button+"_1");
	var spnPrevious = document.getElementById("spnHomeboxPrevious_"+button);
	var spnNext = document.getElementById("spnHomeboxNext_"+button);
	
	theContent.style.display = "block";
	if (thePagination){
		thePagination.style.display = "block";
		theLink.className = "on";
		spnPrevious.innerHTML = '<span id="spnHomeboxPrevious_'+button+'"><a href="#na" class="off">&lt;</a></span> ';
		spnNext.innerHTML = '<span id="spnHomeboxNext_'+button+'"><a href="#next" onclick="homebox_change_page('+button+',2);">&gt;</a></span> ';
	}
	
}

function clear_text(element,text){
	if (element.value == text){
		element.value = "";
	}
}

function clear_textarea(element,text){
	if (element.innerHTML == text){
		element.innerHTML = "";
	}
}

var global_nav = 0;

function highlight_nav(id1,id2){

	global_nav = id1;

	var subNav = document.getElementById("ulSubnav"+id1);
	var mainLink = document.getElementById("liNav"+id1);
	var subLink = document.getElementById("aSubnav"+id1+"_"+id2);

	if (subNav){
		show_subnav(id1);
	}

	mainLink.className = "on";
	if (id2){
		subLink.className = "on";
	}
	
}

function show_subnav(id1){
	
	var theHeader = document.getElementById("divHeader");
	var mainNav = document.getElementById("ulNavbar");
	var subNav = document.getElementById("ulSubnav"+id1);
	
	theHeader.style.height = "222px";
	mainNav.style.bottom = "42px";
	subNav.style.display = "block";
	
}

function change_zone_view(button){
	
	var theLeft = document.getElementById("aZoneViewMap");
	var theRight = document.getElementById("aZoneViewList");
	var theDiv = document.getElementById("divFindZone");
	var theMap = document.getElementById("divMap");
	var theList = document.getElementById("divList");
	var theKey = document.getElementById("divMapkey");
	
	if (button == "map"){
		theLeft.className = "top on";
		theRight.className = "top";
		theDiv.style.height = "460px";
		theMap.style.display = "block";
		theList.style.display = "none";
		theKey.style.display = "block";
	}
	else{
		theLeft.className = "top";
		theRight.className = "top on";
		theDiv.style.height = "1050px";
		theMap.style.display = "none";
		theList.style.display = "block";
		theKey.style.display = "none";
	}
	
}

function show_more(){
	
	var theDiv = document.getElementById("divZoneProfile");
	var theMoreDiv = document.getElementById("divMore");
	var theLink = document.getElementById("aMore");
	
	if (theMoreDiv.style.display == "" || theMoreDiv.style.display == "none"){
		theMoreDiv.style.display = "block";
		theDiv.style.display = "none";
		theLink.innerHTML = "<span class=\"red\">&gt;</span> Show less";
	}
	else{
		theDiv.style.display = "block";
		theMoreDiv.style.display = "none";
		theLink.innerHTML = "<span class=\"red\">&gt;</span> Show more";
	}
	
}

function show_tooltip(picnum,text){
	
	var theTooltip = document.getElementById("divTooltip");
	var startLeft = -11;
	var startTop = -15;
	var moveLeft = 54;
	var moveTop = 65;
	
	timesbyLeft = (picnum - 1) - (Math.floor((picnum - 1) / 4) * 4);
	timesbyTop = Math.floor((picnum - 1) / 4);
	
	theTooltip.style.left = startLeft + (moveLeft * timesbyLeft) + "px";
	theTooltip.style.top = startTop + (moveTop * timesbyTop) + "px";
	
	theTooltip.innerHTML = text;
	theTooltip.style.display = "block";
	
}

function hide_tooltip(){
	
	var theTooltip = document.getElementById("divTooltip");
	
	theTooltip.style.display = "none";
	
}

function show_faq(id1){
	
	var theFAQ = document.getElementById("ddFAQ"+id1);
	var theImg = document.getElementById("imgFAQ"+id1);
	
	var imgExpand = "/_images/faq/expand.jpg";
	var imgCollapse = "/_images/faq/collapse.jpg";

	if (theFAQ.style.display == "" || theFAQ.style.display == "none"){
		theFAQ.style.display = "block";
		theImg.src = imgCollapse;
	}
	else{
		theFAQ.style.display = "none";
		theImg.src = imgExpand;
	}
	
}

function show_overlay(popup,form_id){
	
	var theOverlay = document.getElementById("divDarkOverlay");
	var theHeading = document.getElementById("popup_heading");
	var theContent = document.getElementById("popup_content");
	
	ajax = create_ajax();
	
	ajax.onreadystatechange=function(){
		if (ajax.readyState==4 && ajax.status==200){
			response = ajax.responseText;
			i = response.indexOf('</h2>'); 
			splits = [response.slice(0,i+5), response.slice(i+5)]; 
			theHeading.innerHTML = splits[0];
			theContent.innerHTML = splits[1];
			browser_fixes();
			if (popup == "preview_content"){
				preview_content(form_id);
			}
		}
	}
	
	run_ajax(ajax,"GET","/_ajax/popup_content.php","popup="+popup);

	if (ie6 || iPad || iPhone){
		document.location = "#top";
	}

	theOverlay.style.display = "block";
	
}

function hide_overlay(){
	
	var theOverlay = document.getElementById("divDarkOverlay");
	var theHeading = document.getElementById("popup_heading");
	var theContent = document.getElementById("popup_content");
	
	theOverlay.style.display = "none";
	
	theHeading.innerHTML = "";
	theContent.innerHTML = "<p>Loading...</p>";
	
}

function follow_link(element){
	for(i = 0;element.childNodes[i]; i++ ){
	    if(element.childNodes[i].tagName == 'A'){ 
			window.location = element.childNodes[i].href; 
		}
	}
}

function postCodeValidated(strOrganisation, strProperty, strStreet, strLocality, strTown, strCounty, strPostcode,gridEast,gridNorth, address_fields, latitude, longitude)
{

	switch (address_fields){
		case "zones":
			document.getElementById("fmAddress1").value="";
			document.getElementById("fmAddress2").value="";
			document.getElementById("fmAddress3").value="";
			document.getElementById("fmTown").value="";
			document.getElementById("fmCounty").value="";
			document.getElementById("fmLatitude").value="";
			document.getElementById("fmLongitude").value="";
			break;
	}
				
	try
	{
		var sCompany='';
		var sLine1='';
		var sLine2='';
		var sLine3='';
		var sTown='';
		var sCounty=''; 
		var sPostCode='';
		var sgridEast=''; 
		var sgridNorth='';
		var sLatitude = '';
		var sLongitude = '';
	
		if (strOrganisation!='') sCompany=strOrganisation;

		if (strProperty!='') sLine1=strProperty;
//		if (strStreet!='') sLine2=strStreet;
//		if (strLocality!='') sLine3=strLocality;

		if (strStreet!='')
		{
			if (sLine1!='')
sLine2=strStreet;
			else
sLine1=strStreet;
		}

		if (strLocality!='')
		{
			if (sLine2!='')
sLine3=strLocality;
			else
sLine2=strLocality;
		}	
		sTown=strTown;
		sCounty=strCounty;
		sPostCode=strPostcode;
		sgridEast = gridEast;
		sgridNorth = gridNorth;
		sLatitude=latitude;
		sLongitude=longitude;
	
	switch (address_fields){
		case "zones":
			document.getElementById("fmAddress1").value=sLine1;
			document.getElementById("fmAddress2").value=sLine2;
			document.getElementById("fmAddress3").value=sLine3;
			document.getElementById("fmTown").value=sTown;
			document.getElementById("fmCounty").value=sCounty;
			document.getElementById("fmLatitude").value=sLatitude;
			document.getElementById("fmLongitude").value=sLongitude;
			break;
	}
	
	}
	catch(Exception)
	{
	alert(Exception.description);
	}
}

function validatePostCode(address_fields)
{
	try{postCodeValidationWindow.close();} catch(Exception) {}

	var postcode_field="";
	
	switch (address_fields){
		case "zones":
			postcode_field = "fmPostcode";
		break;
	}

	if (document.getElementById(postcode_field).value != ""){
		postCodeValidationWindow=window.open("/_includes/postcodecheck.asp?address_fields="+ address_fields +"&searchpostcode=" + document.getElementById(postcode_field).value,"PostCodeValidation","fullscreen=no,height=50,width=800,directories=no,location=no,menubar=no,resizable=yes,scrollbars=no,titlebar=no,toolbar=no");
	}
	else{
		alert("Please enter a postcode");
	}
}

function show_promo_img(id,pb_id,img_id,type1){
	
	var theImg = document.getElementById("imgPromo_"+pb_id);
	var theLink = document.getElementById("aPromoImg_"+pb_id+"_"+img_id);
	
	theImg.src = "/_assets/"+type1+"/promos/"+id+"_"+pb_id+"_"+img_id+".jpg";
	theLink.className = "on";
	
	for (i=1;i<10;i++){
		if (i != img_id){
			var theA = document.getElementById("aPromoImg_"+pb_id+"_"+i);
			if (theA){
				theA.className = "";
			}
		}
	}
	
}


/*

function show_next_zone_media(id1,z_id){
	
	var theImg = document.getElementById("imgZoneMedia");
	var theDiv = document.getElementById("divZoneMediaPagination");
	var theTitle = document.getElementById("divMediaTitle");
	
	theImg.src = "/_assets/zones/topmedia/"+z_id+"_"+zone_media[id1]+".jpg";
	theDiv.innerHTML = '';
	theTitle.innerHTML = zone_media_titles[id1];
	
	//alert (zone_media[id1]);

	if (id1 != 0){
		theDiv.innerHTML += '<a href="#previous" onclick="show_next_zone_media('+ (id1 - 1) +','+z_id+');">&lt;</a>&nbsp;';
	}
	else{
		theDiv.innerHTML += '<a href="#next" class="off">&lt;</a>&nbsp;';
	}
	
	if (zone_media.length-1 > id1){
		theDiv.innerHTML += '<a href="#previous" onclick="show_next_zone_media('+ (id1 + 1) +','+z_id+');">&gt;</a>';
	}
	else{
		theDiv.innerHTML += '<a href="#next" class="off">&gt;</a>';
	}
	
}

*/



function insertAtCursor(myField, myValue) {
	if (document.selection){
		myField.focus();
		sel = document.selection.createRange();
		sel.text = myValue;
	}
	else if (myField.selectionStart || myField.selectionStart == '0'){
		var startPos = myField.selectionStart;
		var endPos = myField.selectionEnd;
		myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length);
	}
	else{
		myField.value += myValue;
	}
	
	myField.focus();
	
	//alert (myField);
}



function switch_news_thumbnail(id1){
	
	var theImg = document.getElementById("imgNewsThumbnail");
	
	theImg.src = "/_assets/news/images/thumbs/"+id1+".jpg";
	
}

function show_news_list(old_id,new_id){
	
	var theOldUl = document.getElementById("ulNewsList_"+old_id);
	var theNewUl = document.getElementById("ulNewsList_"+new_id);
	var theDiv = document.getElementById("divNewsPagination");
	
	theOldUl.style.display = "none";
	theNewUl.style.display = "block";
	
	var prevUl = document.getElementById("ulNewsList_"+(new_id - 1));
	var nextUl = document.getElementById("ulNewsList_"+(new_id + 1));
	
	if (prevUl){
		theDiv.innerHTML = '<a href="#previous" onclick="show_news_list('+new_id+','+(new_id - 1)+');">&lt;</a> ';
	}
	else{
		theDiv.innerHTML = '<a href="#previous" class="off">&lt;</a> ';
	}
	
	if (nextUl){
		theDiv.innerHTML += '<a href="#next" onclick="show_news_list('+new_id+','+(new_id + 1)+');">&gt;</a>';
	}
	else{
		theDiv.innerHTML += '<a href="#next" class="off">&gt;</a>';
	}
	
}

function whathappens_change_stage(stage,type){

	var homeDiv = document.getElementById("divStageHome");
	var newDiv = document.getElementById("divStage"+stage);
	var newStageLink = document.getElementById("a"+type+stage);
	var newPageLink = document.getElementById("aPage"+stage);
	
	//var thePagination = document.getElementById("divWhathappensPagination");
	var spnPrevious = document.getElementById("spnPrevious");
	var spnNext = document.getElementById("spnNext");
	
	if (homeDiv){
		homeDiv.style.display = "none";
	}

	for (i=1;i<=5;i++){
		var theDiv = document.getElementById("divStage"+i);
		var theStageLink = document.getElementById("a"+type+i);
		var thePageLink = document.getElementById("aPage"+i);
		if (theDiv){
			theDiv.style.display = "none";
		}
		if (theStageLink){
			theStageLink.className = "";
		}
		if (thePageLink){
			thePageLink.className = "";
		}
	}
	
	var prevDiv = document.getElementById("divStage"+(stage - 1));
	var nextDiv = document.getElementById("divStage"+(stage + 1));
	
	if (prevDiv){
		spnPrevious.innerHTML = '<a onclick="whathappens_change_stage('+(stage - 1)+',\''+type+'\')" href="#stage'+(stage - 1)+'">&lt;</a>';
	}
	else{
		spnPrevious.innerHTML = '<a href="#na" class="off">&lt;</a>';
	}
	
	if (nextDiv){
		spnNext.innerHTML = '<a onclick="whathappens_change_stage('+(stage + 1)+',\''+type+'\')" href="#stage'+(stage + 1)+'">&gt;</a>';
	}
	else{
		spnNext.innerHTML = '<a href="#na" class="off">&gt;</a>';
	}

	newDiv.style.display = "block";
	newStageLink.className = "on";
	newPageLink.className = "on";
	
}

function homebox_change_page(parent,page){

	var newDiv = document.getElementById("divHomebox_"+parent+"_"+page);
	var newLink = document.getElementById("aHomebox_"+parent+"_"+page);
	
	for (i=1;i<=3;i++){
		for (j=1;j<=10;j++){
			var theDiv = document.getElementById("divHomebox_"+i+"_"+j);
			var theLink = document.getElementById("aHomebox_"+i+"_"+j);
			if (theDiv){
				theDiv.style.display = "none";
			}
			if (theLink){
				theLink.className = "";
			}
		}
	}
	
	var spnPrevious = document.getElementById("spnHomeboxPrevious_"+parent);
	var spnNext = document.getElementById("spnHomeboxNext_"+parent);
	var prevDiv = document.getElementById("divHomebox_"+parent+"_"+(page - 1));
	var nextDiv = document.getElementById("divHomebox_"+parent+"_"+(page + 1));
	
	if (prevDiv){
		spnPrevious.innerHTML = '<span id="spnHomeboxPrevious_'+parent+'"><a href="#previous" onclick="homebox_change_page('+parent+','+(page - 1)+');">&lt;</a></span> ';	
	}
	else{
		spnPrevious.innerHTML = '<span id="spnHomeboxPrevious_'+parent+'"><a href="#na" class="off">&lt;</a></span> ';	
	}
	
	if (nextDiv){
		spnNext.innerHTML = '<span id="spnHomeboxNext_'+parent+'"><a href="#next" onclick="homebox_change_page('+parent+','+(page + 1)+');">&gt;</a></span> ';	
	}
	else{
		spnNext.innerHTML = '<span id="spnHomeboxNext_'+parent+'"><a href="#na" class="off">&gt;</a></span> ';	
	}

	newDiv.style.display = "block";
	newLink.className = "on";
	
}

function show_next_homemedia(id1){
	
	var newDiv = document.getElementById("divMediaEmbed_"+id1);

	var theTitle = document.getElementById("h2MediaTitle");
	var theSubheading = document.getElementById("h3MediaSubheading");
	var theText = document.getElementById("pMediaText");
	var theLink = document.getElementById("aMediaLink");
	
	var spnPrevious = document.getElementById("spnPrevious");
	var spnNext = document.getElementById("spnNext");
	
	for (i=1;i<=homemedia_titles.length-1;i++){
		var theDiv = document.getElementById("divMediaEmbed_"+i);
		theDiv.style.display = "none";
	}
	
	newDiv.style.display = "block";
	
	theTitle.innerHTML = homemedia_titles[id1];
	theSubheading.innerHTML = homemedia_subheadings[id1];
	theText.innerHTML = homemedia_text[id1];
	theLink.innerHTML = homemedia_linktext[id1];
	theLink.href = homemedia_linkhrefs[id1];
	
	var prevDiv = document.getElementById("divMediaEmbed_"+(id1-1));
	var nextDiv = document.getElementById("divMediaEmbed_"+(id1+1));
	
	if (prevDiv){
		spnPrevious.innerHTML = '<a href="#previous" onclick="show_next_homemedia('+(id1 - 1)+')">&lt;</a> ';
	}
	else{
		if (spnPrevious){spnPrevious.innerHTML = '<a href="#na" class="off">&lt;</a> ';}
	}
	
	if (nextDiv){
		spnNext.innerHTML = '<a href="#next" onclick="show_next_homemedia('+(id1 + 1)+')">&gt;</a> ';
	}
	else{
		if (spnNext){spnNext.innerHTML = '<a href="#na" class="off">&gt;</a> ';}
	}
	
}

function show_homemedia(id1){
	
	var newDiv = document.getElementById("divMediaEmbed_"+id1);
	
	for (i=1;i<=10;i++){
		var theDiv = document.getElementById("divMediaEmbed_"+i);
		if (theDiv){
			theDiv.style.display = "none";
		}
	}
	
	newDiv.style.display = "block";
	
}

function show_next_zonemedia(id1){
	
	var newDiv = document.getElementById("divMediaEmbed_"+id1);

	var theTitle = document.getElementById("divMediaTitle");
	
	var spnPrevious = document.getElementById("spnPrevious");
	var spnNext = document.getElementById("spnNext");
	
	for (i=1;i<=zonemedia_titles.length-1;i++){
		var theDiv = document.getElementById("divMediaEmbed_"+i);
		theDiv.style.display = "none";
	}
	
	newDiv.style.display = "block";
	
	theTitle.innerHTML = zonemedia_titles[id1];
	
	var prevDiv = document.getElementById("divMediaEmbed_"+(id1-1));
	var nextDiv = document.getElementById("divMediaEmbed_"+(id1+1));
	
	if (prevDiv){
		spnPrevious.innerHTML = '<a href="#previous" onclick="show_next_zonemedia('+(id1 - 1)+')">&lt;</a> ';
	}
	else{
		if(spnPrevious){spnPrevious.innerHTML = '<a href="#na" class="off">&lt;</a> ';}
	}
	
	if (nextDiv){
		spnNext.innerHTML = '<a href="#next" onclick="show_next_zonemedia('+(id1 + 1)+')">&gt;</a> ';
	}
	else{
		if(spnNext){spnNext.innerHTML = '<a href="#na" class="off">&gt;</a> ';}
	}
	
}

function clean_text(){
	var rem_tags = new Array("caption","marquee","script");
	for (i=1;i<=3;i++){
		var theDiv = document.getElementById("divUserContent"+i);
		if (theDiv){
			for (j=0;j<rem_tags.length;j++){
				var theTags = document.getElementById("divUserContent"+i).getElementsByTagName(rem_tags[j]);
				for (k=0;k<theTags.length;k++){
					theTags[k].parentNode.removeChild(theTags[k]);
				}
			}
			var theTags = document.getElementById("divUserContent"+i).getElementsByTagName("td");
			for (j=0;j<theTags.length;j++){
				theTags[j].innerHTML = theTags[j].innerHTML.replace(/<p>/gi,"");
			}
			var theTables = document.getElementById("divUserContent"+i).getElementsByTagName("table");
			for (j=0;j<theTables.length;j++){
				theTables[j].id = "tblUser"+j;
				var theRows = document.getElementById(theTables[j].id).getElementsByTagName("tr");
				for (k=0;k<theRows.length;k++){
					if (k%2 != 0){
						theRows[k].className = "alt";
					}
				}
			}
		}
	}
}

function change_setup_step(id1){
	
	var theImg = document.getElementById("imgSetupImage");
	var newStep = document.getElementById("aStep"+id1);
	
	var spnPrevious = document.getElementById("spnPrevious");
	var spnNext = document.getElementById("spnNext");
	
	var theTitle = document.getElementById("spnStepTitle");
	var theText = document.getElementById("pStepText");
	
	var thePlayButton = document.getElementById("divPlayButton");
	
	for (i=1;i<setup_ids.length;i++){
		var theStep = document.getElementById("aStep"+i);
		theStep.className = "";
	}

	theImg.src = "/_assets/setupsteps/"+setup_ids[id1]+".jpg?"+Math.random();
	if (newStep){
		newStep.className = "on";
	}
	theTitle.innerHTML = setup_titles[id1];
	theText.innerHTML = setup_text[id1];
	if (id1 != 0){
		thePlayButton.style.display = "none";
	}
	
	if (id1 > 1){
		spnPrevious.innerHTML = '<a href="#'+(id1 - 1)+'" onclick="stop_slideshow();change_setup_step('+(id1 - 1)+')">&lt;</a>';
	}
	else{
		spnPrevious.innerHTML = '<a href="#na" class="off">&lt;</a>';
	}
	
	if (id1 != (setup_ids.length - 1)){
		spnNext.innerHTML = '<a href="#'+(id1 + 1)+'" onclick="stop_slideshow();change_setup_step('+(id1 + 1)+')">&gt;</a>';
	}
	else{
		spnNext.innerHTML = '<a href="#na" class="off">&gt;</a>';
		stop_slideshow();
	}

	if (slideshow_running){
		t = setTimeout("change_setup_step("+(id1+1)+")",slide_time);
		setup_progress();
		tp = setTimeout("setup_progress()",slide_time / 2);
	}
	
}

var slideshow_running = 0;
var slide_time = 5000;
var progress = 0;

function setup_slideshow(){
	
	slideshow_running = 1;
	change_setup_step(1);
	//document.getElementById("divSlideProgressContainer").style.display = "block";
	document.getElementById("divSlideProgressContainer").style.display = "none";
	
}

function stop_slideshow(){

	if (slideshow_running){
		slideshow_running = 0;
		clearTimeout(t);
		document.getElementById("divSlideProgressContainer").style.display = "none";
	}
	
}

function setup_progress(){
	
	var theDiv = document.getElementById("divSlideProgress");
	
	increment = (315 / (setup_ids.length - 1)) / 2;
	progress += increment;
	theDiv.style.width = progress + "px";

}

function show_map_tab(id1,z_id){
	
	var newDiv = document.getElementById("content"+id1+"_"+z_id);
	var theBack = document.getElementById("divMapPopupContent_"+z_id);
	
	for (i=1;i<=3;i++){
		var theDiv = document.getElementById("content"+i+"_"+z_id);
		theDiv.style.display = "none";
	}
	
	newDiv.style.display = "block";
	theBack.style.backgroundImage = "url(/_images/findazone/content_back"+id1+".jpg)";
	
}

function set_black(element,nav){
	if (ie6 && nav != global_nav){
		for(i = 0;element.childNodes[i]; i++ ){
		    if(element.childNodes[i].tagName == 'A'){ 
				element.childNodes[i].style.color = "black";
			}
		}
	}
}

function set_white(element,nav){
	if (ie6 && nav != global_nav){
		for(i = 0;element.childNodes[i]; i++ ){
		    if(element.childNodes[i].tagName == 'A'){ 
				element.childNodes[i].style.color = "white";
			}
		}
	}
}
