// AlbertaScene.ca Javascript functions


// POPUP AND CENTER WINDOWS
<!--
function flvFPW1(){//v1.44
// Copyright 2002-2004, Marja Ribbers-de Vroed, FlevOOware (www.flevooware.nl/dreamweaver/)
var v1=arguments,v2=v1[2].split(","),v3=(v1.length>3)?v1[3]:false,v4=(v1.length>4)?parseInt(v1[4]):0,v5=(v1.length>5)?parseInt(v1[5]):0,v6,v7=0,v8,v9,v10,v11,v12,v13,v14,v15,v16;v11=new Array("width,left,"+v4,"height,top,"+v5);for (i=0;i<v11.length;i++){v12=v11[i].split(",");l_iTarget=parseInt(v12[2]);if (l_iTarget>1||v1[2].indexOf("%")>-1){v13=eval("screen."+v12[0]);for (v6=0;v6<v2.length;v6++){v10=v2[v6].split("=");if (v10[0]==v12[0]){v14=parseInt(v10[1]);if (v10[1].indexOf("%")>-1){v14=(v14/100)*v13;v2[v6]=v12[0]+"="+v14;}}if (v10[0]==v12[1]){v16=parseInt(v10[1]);v15=v6;}}if (l_iTarget==2){v7=(v13-v14)/2;v15=v2.length;}else if (l_iTarget==3){v7=v13-v14-v16;}v2[v15]=v12[1]+"="+v7;}}v8=v2.join(",");v9=window.open(v1[0],v1[1],v8);if (v3){v9.focus();}document.MM_returnValue=false;return v9;}
//-->


// show/hide tab content and icons

function hideLevel(_levelId,_iconId) {
	var thisLevel = document.getElementById(_levelId );
	var thisIcon = document.getElementById(_iconId );
	thisLevel.className = "hideThis";
	thisIcon.className = "tabClosed";
	}
function showLevel(_levelId,_iconId){
	var thisLevel = document.getElementById(_levelId);
	var thisIcon = document.getElementById(_iconId);
	if(thisLevel.className != "showThis"){
		thisLevel.className = "showThis";
		thisIcon.className = "tabOpened";
		}
	else {
		hideLevel(_levelId, _iconId);
		}
	}


// General purpose filter menu, used in admin
function selectView() {
	if (document.fmSelectView.mnuViews[document.fmSelectView.mnuViews.selectedIndex]) {
		top.location.href=document.fmSelectView.mnuViews[document.fmSelectView.mnuViews.selectedIndex].value;
	}
}

// General purpose trigger for "Add" buttons, used in tour admin
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}


// CLEAR SEARCH FIELD
function clearFieldDefault(el) {
	if (el.defaultValue==el.value) el.value = ""
}	


// LANGUAGE TOGGLE

function toggleLanguage() {
	var strOrigPath = top.location.href
	//document.write(strOrigPath)
	// this is an english page so toggle to french
	if (strOrigPath.match("/en/")) {
		strNewPath = strOrigPath.replace("/en/","/fr/")
		//top.location.href = strNewPath
	}
	else {
	// assume this is a french page so toggle to english
	strNewPath = strOrigPath.replace("/fr/","/en/")
	//top.location.href = strNewPath
	}
	//document.write(strNewPath)
	top.location.href = strNewPath
}



// OCTOBER 2004

// automatically create photo captions and credits from img TITLE and CAPTION attributes
// works in Windows IE5.01, IE5.5 IE6, NN6, NN7, Firefox
// works in Mac IE 5, Safari
// also requires CSS to style captions

// will only be applied to images in the ID=contentColumn
//<div class="photoRight"><img src="/scripts/photo.jpg" width="161" height="160" title="caption text" alt="photo credit" /></div>


function extractImageTitles() {
	
	images = document.getElementById('contentColumn').getElementsByTagName('img');
	for (var i = 0; i < images.length; i++) {
	
	// only add a caption to an image if a title was provided for the image
	var checkTitle = images[i].getAttribute('title');
	if ((checkTitle) && (checkTitle != '')) {
		
		// get the photo width to apply it to the caption/credits
		var width = images[i].getAttribute('width');

		// photo credit		
		var credit = images[i].getAttribute('alt');
		if ((credit) && (credit != '')) {
			var newdiv = document.createElement('div');
			newdiv.className = 'credit';
			newdiv.style.width = width+"px";
 			newdiv.appendChild(document.createTextNode(credit));
			images[i].parentNode.appendChild(newdiv);
			images[i].removeAttribute('credit');
			}		

		// photo caption
		var title = images[i].getAttribute('title');
		if ((title) && (title != '')) {
			if (title.match('http://', 'i')) {
				newlink = document.createElement('a');
				newlink.setAttribute('href', title);
				newlink.setAttribute('title', ('Go to ' + title));
				newlink.appendChild(document.createTextNode('Image source'));
				var newdiv = document.createElement('div');
				newdiv.className = 'caption';
				newdiv.style.width = width+"px";
				newdiv.appendChild(newlink);
				images[i].parentNode.appendChild(newdiv);
				images[i].removeAttribute('title');
				}
			else {
				var newdiv = document.createElement('div');
				newdiv.className = 'caption';
				newdiv.style.width = width+"px";
				//title = title.replace("<em>","")  // suppress em tags
				//title = title.replace("</em>","")  // suppress em tags
				newdiv.appendChild(document.createTextNode(title));
				images[i].parentNode.appendChild(newdiv);
				images[i].removeAttribute('title');
				}
			}
		}
	}
}	
window.onload = extractImageTitles;
	

