// Ergonet JavaScript Documenty updated March 2010
// All rights reserved Ergonet 2008-2011

function blowup(div) {
	// imageCirculation blow up
	var obj=document.getElementById(div);
	var w=450; // the 'maximised height
	if (obj != null) {
		if (obj.offsetWidth !=w) {
			obj.style.width=w+'px';
		} else {
			var newWidth = "220px";
			obj.style.width=newWidth;
		}
	}
}


var animatePageActiveA5=true;
var resizeDivActiveA5=true;
function setMetaName(name,content) {
	var metaTags = document.getElementsByTagName("meta");
	for (var i=0; i<metaTags.length; i++) {
		if (metaTags[i].getAttribute('NAME') == name) {
			metaTags[i].content = content;
		}
	}
}
function setMetaProperty(property,content) {
	var metaTags = document.getElementsByTagName("meta");
	for (var i=0; i<metaTags.length; i++) {
		if (metaTags[i].getAttribute('PROPERTY') == property) {
			metaTags[i].content = content;
		}
	}
}
function animateA5Page() {};
var dataSourceA5='';
function getParam(arg) {
	var q = location.hash;
	if (q.indexOf(arg) >= 0) {
		var pntr = q.indexOf(arg) + arg.length + 1;
		if (q.indexOf("&", pntr) >= 0) {
			return q.substring(pntr, q.indexOf("&", pntr));
		} else {
			return q.substring(pntr, q.length);
		}
	} else {
		return null;
	}
}
var hiddenRowArray=new Array();
function clsOpChildren(row) {
	var menu=document.getElementById("menu02list");
	if (menu != null) {
		var allow=false;
		var mode=0;
		for (var i=0; i<menu.childNodes.length; i++) {
			//trace(menu.childNodes[i].firstChild.firstChild.innerHTML); // gives us menu labels
			//trace(menu.childNodes[i].className); // gives the menu class name
			if (menu.childNodes[i].className=="smr") {mode=0;}
			if (mode==1) {
				menu.childNodes[i].style.display="none";
			}
			if (mode==2) {
				menu.childNodes[i].style.display="block";
			}
			if (menu.childNodes[i].className=="opsmrc") {
				mode=1;
				menu.childNodes[i].className="smrc";
			} else if (menu.childNodes[i].className=="smrc") {
				mode=2;
				menu.childNodes[i].className="opsmrc";
			}

		}
	} else { trace('menu not found'); }
}
function codaSliderControl() {
	var val = getParam("codatab");
	var str = '';
	if (parseInt(val)) { str="{crossLinking: false, firstPanelToLoad: "+parseInt(val)+"}"; }
	eval("$().ready(function() { $('#coda-slider-1').codaSlider("+str+"); });");
}  
function openEstallImage(uri) {
	var obj = document.getElementById('eStallImageBlowup');
	if (obj != null) {
		pageBodyScrollSet();
		obj.style.display="block";
		obj.innerHTML = getEstallImgArray(uri);
		obj.style.height="100%";
		obj.style.width="100%";
		document.body.style.overflow="hidden";
		
	}
}
var eStallImgSoloArray=new Array();
// at the same time as we call the following we must populate: eStallImgSoloArray using delayedOutput
function getEstallImgArray(uri) {
	var str = "<a href='javascript:closeEstallImage()'><img src='"+uri+"' /></a>";
	var transport = '';
	var traceStr = '';
	var classStr='';
	
	var i=0;
	if (eStallImgSoloArray.length >1) {
		for (i=0; i<eStallImgSoloArray.length; i++) {
			currentUri = eStallImgSoloArray[i];
			classStr='openEstallImageAnchor';
			if (currentUri == uri) {
				classStr='openEstallImageAnchorCurrent';
			}
			transport += "<a href=\"javascript:openEstallImage('"+currentUri+"')\" class=\""+classStr+"\">Image "+(i+1)+"</a> | ";
	
		}
	}
//	trace(traceStr);
	str = str + "<div id='eStallGalleryTransport'>" + transport + "<a href=\"javascript:closeEstallImage()\">Close</a></div>";
	return str;
}
function closeEstallImage() {
	var obj = document.getElementById('eStallImageBlowup');
	if (obj != null) {
		obj.style.display="none";
		obj.innerHTML = "";
		obj.style.height="0%";
		obj.style.width="0%";
		document.body.style.overflow="auto";
	}
}
var conducta=true;
function submitTopic() {
	postFormData('topicEditor');
}
function editTopicShow() {
	obj1 = document.getElementById('topicEditor');
	if (obj1!=null) {
		if (obj1.style) { 
			obj1=obj1.style;
			if(obj1.display=='none') {
				obj1.display = 'block';
			/*	if (useTinyMce) {
					tinyMCE.init({ mode : "textareas", theme : "simple" });
				} */
			} else {
				obj1.display = 'none';
			}
		}
	}
}
function tickerMouseOut() {
	tickerSpeed('default'); 
	suspendNewsTickerAnimation=false;	
	newsTickerAnimate();
}
function tickerSpeed(rate) {
	switch(rate) {
	case "default": newsTickerRate=15; break;
	case "slow": newsTickerRate=50; break;
	case "stop": suspendNewsTickerAnimation=true; window.clearTimeout(newsTickerTimeout); break;
	}
}
function newsTickerButtonOver(obj) {if(obj) obj.src='/conf/graphics/newsTickerButtonOver.gif';}
function newsTickerButtonOut(obj) {if(obj) obj.src='/conf/graphics/newsTickerButton.gif';};
function newsTickerSubmit() {
	var obj = document.getElementById('newsTickerInput');
	var obj1 = document.getElementById('pid');
	if (obj != null && obj1 != null) {
		var newsTicker=obj.value;
		obj.value='';
		var pid = obj1.value;
		var path = "/conf/conducta/app/newsTicker.php";
		if (newsTicker && pid) {
			var params="newsTickerInput="+newsTicker+"&pid="+pid;
			newsTickerXHR(path,params);
		} else {
			populate('newsTickerDisplayOnNewsUnitPage','Please Post something!');
		}
		
	}
	return false;
}
function newsTickerXHR(path,params) {
	loading('1','Loading');
	div='evaluate';
	pathForTheRecord = path;
	xmlhttpNewsTicker = false;
	createXMLHttpNewsTickerObject();
	xmlhttpNewsTicker.open("POST",path,true);
	xmlhttpNewsTicker.onreadystatechange = setNewsTickerInnerHtml;
	xmlhttpNewsTicker.initialise;
	xmlhttpNewsTicker.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
	xmlhttpNewsTicker.send(params);
}
function runNewsTicker() {
	var newsTicker = document.getElementById('newsTicker');
	if (newsTicker != null && newsTickerActive) {
		newsTicker.innerHTML="<div id='newsTickerSleeve' style='left:0px'>" + "Ticker initialising" + "</div>";
		newsTickerTimeout = window.setTimeout('newsTickerGet()',10000);
	}
}
var newsTickerTimeout=null;
var newsTickerGetStringTimeoutInterval=30000;
var newsTickerAnimateTimeout=null;
var maxLetters=400;
var newsTickerString='';
var newsTickerStringCurrent='';
var currentSleeveLeft=0;
//var newsUnitPagePid=1;
var newsTickerRate=10;
var suspendNewsTickerAnimation=false;

function newsTickerGet() {
	//window.clearTimeout(newsTickerGetStringTimeoutInterval);
	var path = newsTickerPath;
	var params = "func=getString";
	if (newsUnitPagePid) {
		params += "&newsUnitPagePid="+newsUnitPagePid;
	}
	newsTickerXHR(path,params);
	newsTickerTimeout = window.setTimeout('newsTickerGet()',newsTickerGetStringTimeoutInterval);
}
function newsTickerDisplay(str) {
	if (newsTickerString != str && str!='') {
		newsTickerString = str;
		newsTickerStringCurrent = "<div id='newsTickerSleeve' style='left:0px'>" + newsTickerString + "</div>";
		var newsTickerBox = document.getElementById('newsTicker');
		if (newsTickerBox != null) {
			newsTickerBox.innerHTML = newsTickerStringCurrent;
		}
		currentSleeveLeft = 500;
		newsTickerAnimate();
	}
}
function stopNewsTickerAnimation() {
	var newsTicker = document.getElementById('newsTicker');
	if (newsTicker != null) {
		window.clearTimeout(newsTickerAnimateTimeout);
		var newsTickerSleeve = document.getElementById('newsTickerSleeve');
		if (newsTickerSleeve != null) {
			newsTickerSleeve.style.left='0px';
			currentSleeveLeft=0;
			suspendNewsTickerAnimation=true;
		}
	}
}
function newsTickerAnimate() {
	var newsTicker = document.getElementById('newsTicker');
	if (newsTicker != null) {
		window.clearTimeout(newsTickerAnimateTimeout);
		/*
		var ltr = newsTickerStringCurrent.substr(0,1);
		newsTickerStringCurrent = newsTickerStringCurrent.substr(1)+ltr;
		newsTicker.innerHTML = newsTickerStringCurrent;
		*/
		var newsTickerSleeve = document.getElementById('newsTickerSleeve');
		if (newsTickerSleeve != null) {
			if (!suspendNewsTickerAnimation) {
				var width=newsTickerSleeve.offsetWidth;
				//if (width<1000) { width=1000; }
				currentSleeveLeft--;
				if ( currentSleeveLeft < ((width)*-1)) { currentSleeveLeft=400; }
				newsTickerSleeve.style.left=currentSleeveLeft+'px';
			} 
			newsTickerAnimateTimeout = window.setTimeout('newsTickerAnimate()',newsTickerRate);
		}
	}
}

//******* Shout
function shoutButtonOver(obj) {if(obj) obj.src='/conf/graphics/shoutButtonOver.gif';}
function shoutButtonOut(obj) {if(obj) obj.src='/conf/graphics/shoutButton.gif';};
function shoutSubmit() {
	var obj = document.getElementById('shoutBoxInput');
	var obj1 = document.getElementById('pid');
	if (obj != null && obj1 != null) {
		var shout=obj.value;
		obj.value='';
		var pid = obj1.value;
		var path = "/conf/conducta/app/shoutBox.php";
		if (shout && pid) {
			var params="shoutBoxInput="+shout+"&pid="+pid;
			shoutXHR(path,params);
		} else {
			populate('shoutBoxDisplayOnShowPage','Please Shout something!');
		}
		return false;
	}
	return false;
}
function shoutXHR(path,params) {
	loading('1','Loading');
	div='evaluate';
	pathForTheRecord = path;
	xmlhttp = false;
	createXMLHttpObject();
	xmlhttp.open("POST",path,true);
	xmlhttp.onreadystatechange = setAnyInnerHtml;
	xmlhttp.initialise;
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
	xmlhttp.send(params);
}
function runShout() {
	var shoutBox = document.getElementById('shoutBox');
	if (shoutBox) {
		shoutBox.innerHTML="<div id='shoutSleeve' style='left:0px'>" + "Shout Box initialising" + "</div>";
		shoutTimeout = window.setTimeout('shoutGet()',1000);
	}
}
var shoutTimeout=null;
var shoutGetStringTimeoutInterval=30000;
var shoutAnimateTimeout=null;
var maxLetters=400;
var shoutString='';
var shoutStringCurrent='';
var currentSleeveLeft=0;
var showPagePid=0;
function shoutGet() {
	//window.clearTimeout(shoutGetStringTimeoutInterval);
	var path = "/conf/conducta/app/shoutBox.php";
	var params = "func=getString";
	if (showPagePid) {
		params += "&showPagePid="+showPagePid;
	}
	shoutXHR(path,params);
	shoutTimeout = window.setTimeout('shoutGet()',shoutGetStringTimeoutInterval);
}
function shoutDisplay(str) {
	if (shoutString != str && str!='') {
		shoutString = str;
		shoutStringCurrent = "<div id='shoutSleeve' style='left:0px'>" + shoutString + "</div>";
		var shoutBox = document.getElementById('shoutBox');
		if (shoutBox) {
			shoutBox.innerHTML = shoutStringCurrent;
		}
		currentSleeveLeft = 500;
		shoutAnimate();
	}
}
function shoutAnimate() {
	var shoutBox = document.getElementById('shoutBox');
	if (shoutBox) {
		window.clearTimeout(shoutAnimateTimeout);
		/*
		var ltr = shoutStringCurrent.substr(0,1);
		shoutStringCurrent = shoutStringCurrent.substr(1)+ltr;
		shoutBox.innerHTML = shoutStringCurrent;
		*/
		var shoutSleeve = document.getElementById('shoutSleeve');
		if (shoutSleeve != null) {
			var width=shoutSleeve.offsetWidth;
			//if (width<1000) { width=1000; }
			currentSleeveLeft--;
			if ( currentSleeveLeft < ((width-500)*-1)) { currentSleeveLeft=918; }
			shoutSleeve.style.left=currentSleeveLeft+'px';
			shoutAnimateTimeout = window.setTimeout('shoutAnimate()',10);
		}
	}
}

// ******* Comment
function getCommentForm() {
	getInterface('conf/conducta/app/comments.php?getCommentForm','commentFormContainer');	
}
function commentFormSubmit() {
	var obj = document.getElementById('commentTextarea');
	if (obj != null) {
		var comment = obj.value;
		if (comment.length>1) {
			var obj2 = document.getElementById('author');
			var author='';
			if (obj2 != null) {
				author = obj2.value;	
			}
			getInterface('conf/conducta/app/comments.php?comment='+comment+'&author='+author,'commentFormContainer');	
		}
	}
}
function commentShow(clickedRow) {
	var obj = document.getElementById('liveCommentList');
	if (obj != null) {
		for (var i=0; i<obj.childNodes.length; i++) {
			if (obj.childNodes[i] != clickedRow) {
				//obj.childNodes[i].style.height='20px';
				obj.childNodes[i].style.whiteSpace = "nowrap";
			}
		}
	}
	if (clickedRow != null) {
		//alert(clickedRow.style.height );
//		if (clickedRow.style.height !='auto') {
		if (clickedRow.style.whiteSpace != "normal") {
//			clickedRow.style.height='auto';	
			clickedRow.style.whiteSpace = "normal";
		} else {
//			clickedRow.style.height='20px';
			clickedRow.style.whiteSpace = "nowrap";
		}
	}
}
// *********** Mailing List
function sendMailingListConfirm(accept,vk) {
	dragEnabled=true;
	var p = siteRoot+"conf/conducta/app/mailingList.php?accept="+accept+"&vk="+vk;
	getInterface(p,'content01');
}
function mlfClick(id) {
	// onfocus and onblur. get form element and check for default (unlabelled) value
	if (!id) return false;
	var input = document.getElementById(id);
	if (input != null) {
		switch (id) {
			case "nameMailingList":
				if (input.value=="name") {
					input.value="";
					input.style.color="black";
				}
			break;
			case "email":
				if (input.value=="email") {
					input.value="";
					input.style.color="black";
				}
			break;
			case "where":
				if (input.value=="location") {
					input.value="";
					input.style.color="black";
				}
			break;
		}
	}
	return true;
}
function mlfBlur(id) {
	// onfocus and onblur. get form element and check for default (unlabelled) value
	if (!id) return false;
	var input = document.getElementById(id);
	if (input != null) {
		switch (id) {
			case "nameMailingList":
				if (input.value=="") {
					input.value="name";
					input.style.color="grey";
				}
			break;
			case "email":
				if (input.value=="") {
					input.value="email";
					input.style.color="grey";
				}
			break;
			case "where":
				if (input.value=="") {
					input.value="location";
					input.style.color="grey";
				}
			break;
		}
	}
	return true;
}
// *********** GLC
function getApplicationBar() {
	populate('content01','Loading Application Bar..');
	// conf/glc/windows.php
//	debugResponse = true;
	getData('/home/william/public_html/conf/glc/conf/app/dataSource.php','page','&init=1');
//	getData('glc/index.php','page','&init=1');
}
function getOrderList() {
	getInterface('conf/conducta/app/dataSource/orders.php','orders');
}
function getOrderDetail(soid) {
	getInterface('conf/conducta/app/dataSource/orders.php?soid='+soid,'orders');
}
function appWinsRefresh() {
	
	for (var i=0; i<appDivIdArray.length; i++) {
		appClose(appDivIdArray[i]);
	}
	
}
function playerGalleryPopulate(txt) {
	var obj = document.getElementById('playerGallery');
	if (obj==null || obj.innerHTML == '') {
		populate('galleryDisplay',txt);
	}
	
	var obj = document.getElementById('playerGallery');
	if (obj != null) {
		/*
		obj.style.position = "relative";
		obj.style.width = "auto";
		obj.style.overflow="hidden";
		obj.style.right = "0px";
		obj.style.display="block"; */
	}
}
function hidePlayerGallery() {
	var obj = document.getElementById('playerGallery');
	if (obj != null) {
		/*
		obj.style.position = "absolute";
		obj.style.width = "180px";
		obj.style.overflow="hidden";
		obj.style.right = "0px";
		obj.style.display="none"; */
	}
}
function showShopPanel() {
//trace('showShopPanel');
	var obj1=document.getElementById('shopPanel');
	var obj2=document.getElementById('content01');
	if (obj1 != null && obj2 != null) {
		obj1.style.display='block';
		obj2.style.display='none';
		obj1.style.opacity=1;
		obj2.style.opacity=1;
	} else {
		if (obj1 == null) { alert('no shop panel');	}
		if (obj2 == null) { alert('no content01');	}
	}

}
function showContent01() {

	var obj1=document.getElementById('shopPanel');
	var obj2=document.getElementById('content01');
	if (obj1 != null && obj2 != null) {
		obj1.style.display='none';
		obj2.style.display='block';
		obj1.style.opacity=1;
		obj2.style.opacity=1;
	}
	var obj10 = document.getElementById('onPageMediaPlayer');
	if (obj10 != null) {
		var player=obj10.style;
		player.opacity=1;
	}
}
function listElements() {
	var divs=document.getElementsByTagName('div');
	var str = '';
	for (i=0; i<divs.length; i++) {
		if (divs[i].id ) {
		str += "<br />"+divs[i].id ;
		}
	}
	trace(str);
}
function imgToggle(objid,w,h,w1,h1) {
	if (objid) {
		var obj = document.getElementById(objid);
		if (obj != null) {
			if (obj.offsetWidth==w) {
				if (w1 > 500) {
					obj.style.width = '500px';
					obj.style.height = 'auto';
				} else {
					obj.style.width=w1+'px';
					obj.style.height=h1+'px';
				}
			} else {
				obj.style.width=w+'px';
				obj.style.height=h+'px';
			}
		}
	}
}
function blowUp(obj,w) {
	if (obj != null) {
		if (obj.offsetWidth==w) {
			obj.style.width="100%";
			obj.style.height="auto";
		} else {
			obj.style.width=w+'px';
			obj.style.height="auto";
		}
	}
}
function searchFormSubmitFunction(path) {
	var str = 'ss='+document.getElementById('ss').value;
	str+='&searchSubmitted=1&funcMode=ajax';
	//str = dataSourcePath + "?" + str;
	var obj = document.getElementById('searchLabel');
	if (obj != null) { obj.innerHTML='Searching'; }
	//sendToServer(str);
	getData('index.php','page',str);// 
}
function pageBodyScrollSet() {
	var obj=document.getElementById('pageBody');
	if (obj != null) {
		obj.style.height = (obj.offsetHeight+1)+'px';
	}
	window.scrollTo(0,0);
}
function hideSearchResults() {
	/*
	var obj = document.getElementById('searchResults');
	if (obj != null) {
		obj.innerHTML = '';
	}
	*/
	appOpenClose('seachResults','');
}
function sledge(sledgeState) {
	/*
	
	This has been superceeded by the logic within the eNbb
	.. where we cross fade the pages - not slide 'cos that stagger horribly (in FFx)
	
<sledge1>
<sledge2>
start sledge1 off screen
slide sledge2 of the stage
and slide sledge1 onto the screen
	*/
	
}

function scrollPageBodyToTop() {
	var obj=document.getElementById('pageBody');
	if (obj != null) {
		obj.scrollTop=0;
	}
}
function tellAFriend(productId) {
	
}
function clearConductaTrace() {
	var obj=document.getElementById('errorReport');
	if (obj!=null) {
		obj.innerHTML = '';
	}
}
function trace(txt) {
	var obj=document.getElementById('errorReport');
	
	if (obj!=null) {
		var str = obj.innerHTML;
		obj.innerHTML='trace: '+txt+'<br />'+str; //+'<br />'+obj.innerHTML;
	}
}
function traceError(div,t) {
	if (div) {
		var obj = document.getElementById(div);
		if (obj != null) {
			obj.innerHTML = t+"<br />"+obj.innerHTML;
		} else {
			alert('error report');
		}
	}
}

// *************** Aux & Universal App / Content Window Operations ****************
var currentDragDivID;
function getMouseXY(e) {
	if (IE) { // including IE8 or we have positional problems
		tempX = event.clientX + document.body.scrollLeft;
		tempY = event.clientY + document.body.scrollTop;
		//clearConductaTrace();
		//trace('x: '+tempX+' y: '+tempY);
	} else { 
		tempX = e.pageX;
		tempY = e.pageY;
	}  
	if (tempX < 0){tempX = 0;}
	if (tempY < 0){tempY = 0;}  
	
	if (animatePageActive) {
		animatePage();
		//currentDragDivID
	}
	if (resizeDivActive) {
		animatePage();
	}
	if (resizeContDivActive) {
		animatePage();
	}
	if (currentDragDivID != null) {
		doTheDrag();
	}
	// Aria 5
	/*
	tempXA5 = tempX;
	tempYA5 = tempY;

	if (animatePageActiveA5) {
		animateA5Page();
	}
	if (resizeDivActiveA5) {
		animateA5Page();
	}
	*/
	
	
	return true
}


function animatePage() {
	// drag / resize a bubble or application window
	if (currentDragDiv !=null) {
		if (!noAnimation) {
			if (animatePageActive) {
			//	if(isNaN(offsetY)) { offsetY=0; };
				if (isNaN(tempY-offsetY)) { offsetY=tempY+currentDragDiv.offsetHeight+40;}
				if (isNaN(tempX-offsetX)) { offsetX=100; }
				if (currentDragDiv) {
					if (tempX-offsetX) { currentDragDiv.style.left = (tempX-offsetX)+'px'; }
					if (tempY-offsetY) { currentDragDiv.style.top = (tempY-offsetY)+'px'; }
				}
			}
			if (currentResizeDiv!=null && resizeDivActive && currentResizeContent) {
				var anch=document.getElementById('applicationDiv');
				if (anch == null) { return; }
				var anchorLeft=anch.offsetLeft; //+containerLeftSpace;
				var anchorTop=anch.offsetTop;
				//alert('applicationDiv offset top: '+anchorTop);
				var newWidth=tempX-currentResizeDiv.offsetLeft-anchorLeft;
				var newHeight=tempY-currentResizeDiv.offsetTop-anchorTop;
				var changeWidth=newWidth-currentResizeDiv.offsetWidth;
				var changeHeight=newHeight-currentResizeDiv.offsetHeight;
				// now resize the contents & scrolll bar
				if (currentResizeContent) {
				var cont=document.getElementById(currentResizeContent);
				}
				if (currentResizeScrollbar) {
				var scr=document.getElementById(currentResizeScrollbar);
				}
				if (cont!=null) {
					if (!isInDock(currentResizeDiv.id)){
						cont.style.height=(newHeight-30)+'px';
					}
				}
				if (scr!=null) {
					if (!isInDock(currentResizeDiv.id)){
						scr.style.height=(newHeight-50)+'px';
					}
				}
				newWidth+=50;
				newHeight+=15;
				currentResizeDiv.style.width=newWidth+'px';
				if (!isInDock(currentResizeDiv.id)){
					currentResizeDiv.style.height=newHeight+'px';
				}
			}
			if (resizeContDivActive) {
				var anch=document.getElementById('applicationDiv');
				if (anch == null) { return; }
				var anchorLeft=anch.offsetLeft+containerLeftSpace;
				var newWidth=tempX-currentResizeDiv.offsetLeft-anchorLeft;
				var newHeight=tempY-currentResizeDiv.offsetTop;
				var changeWidth=newWidth-currentResizeDiv.offsetWidth;
				var changeHeight=newHeight-currentResizeDiv.offsetHeight;
				// now resize the contents & scrolll bar
				if (currentResizeContent) {
				var cont=document.getElementById(currentResizeContent);
				}
				if (currentResizeScrollbar) {
				var scr=document.getElementById(currentResizeScrollbar);
				}
				if (cont!=null) {
					cont.style.height=(newHeight-50)+'px';			
				}
				if (scr!=null) {
					if (!isInDock(currentResizeDiv.id)){
						scr.style.height=(newHeight-50)+'px';
					}
				}
				newWidth+=0;
				newHeight+=15;
				currentResizeDiv.style.width=newWidth+'px';
				currentResizeDiv.style.height=newHeight+'px';	
			}
		} else {
			trace('animation is off');
		}
	}
	
}

function openContent(pageurl,position) {
	// call up a new content window into div 'contentWindows'
	// populated with this pageurl's content01
	// and scroll to the position
	additionToDiv=true;
	var prospectId = pageurl.substr(0,pageurl.length-4);
	prospectId = prospectId.replace("/","-"); // must be the same as in contentWindow.php
	if (prospectId) {
		var obj = document.getElementById(prospectId);
		if (obj == null) {
			contDivIdArray.push(prospectId+'Div');
			contDivMaxHeightArray.push(350);
			var str = siteRoot+'conf/conducta/app/contentWindow.php?pageurl='+pageurl+'&position='+position+'&y='+tempY+'&x='+tempX;
			var contentHolderDiv='contentWindows';
			switch(position) {
				case 'position1': contentHolderDiv='contentWindows'; break;
				case 'position2': contentHolderDiv='catWindows'; break;
				case 'position3': contentHolderDiv='vidWindows'; break;
			}
			var check = document.getElementById(contentHolderDiv);
			//trace(str);
			if (check != null) {
				getInterface(str,contentHolderDiv);
			} else {
				trace('div '+contentHolderDiv+' missing. bubble not generated');
			}
		} else {
			//trace(prospectId+' already open');
		}
	}
}

var appDelOpenCloseId='';
var appDelOpenCloseCom = '';

function appDelayedOpenClose(id,com) {
	appDelOpenCloseId=id;
	appDelOpenCloseCom=com;
	var str="appDelayedOpenClose2()";
	window.setTimeout(str,1000);
}
function appDelayedOpenClose2() {
	appOpenClose(appDelOpenCloseId,appDelOpenCloseCom);
}
function removeDivFromDock(id) {
	if (id) {
		var obj=document.getElementById(id);
		if (obj != null) {
			removeFromDock(obj);
		}
	}
}
function removeFromDock(obj) {
	for (var i=0; i<isDockedArray.length; i++) {
		if (obj.id==isDockedArray[i]) {
			isDockedArray[i]='';
			isDockedArray.splice(i,1);
			return;
		}
	}
}
function addToDock(obj) {
	isDockedArray.push(obj.id);
}
function isInDock(id) {
	for (var i=0; i<isDockedArray.length; i++) {
		if (isDockedArray[i]==id) {
			return true;
		}
	}
	
	return false;
}
// var HistoryType=''; see historyAndFavorites.js
function showSearchResults() {
	var obj=document.getElementById('searchResultsDiv');
	if (obj!=null) {
		obj.style.display="block";
		obj.style.height="400px";
	}
}
function hideSearch() {
	var obj=document.getElementById('searchResultsDiv');
	if (obj!=null) {
		obj.style.display="none";
		obj.style.height="400px";
	}
}
var msgChkCountdown = 60;
var msgCheckTimeoutId=null;
var msgChkTimerTimeoutId=null;
function setMsgCheckCycle() {
	msgChkCountdown=60;
	window.clearTimeout(msgCheckTimeoutId);
	window.clearTimeout(msgChkTimerTimeoutId);
	msgCheckTimeoutId = window.setTimeout('msgCheck()',60000);
	msgChkTimerTimeoutId = window.setTimeout('msgChkTimer()',1000);
}
function msgCheck() {
	getInterface(msgFormPath,'messagesWinContent');
	setMsgCheckCycle();
}
function msgChkTimer() {
	var obj=document.getElementById('messagesDivTitleLabel');
	msgChkCountdown--;
	if (obj != null) {
//		obj.innerHTML = "My Messages "+msgChkCountdown;
	}
	if (msgChkCountdown <0) {
		setMsgCheckCycle();
	} else {
		msgChkTimerTimeoutId = window.setTimeout('msgChkTimer()',1000);
	}
}
function openMsg(msgid) {
	getInterface(msgFormPath+'?msgid='+msgid,'messages');
}
function newMessage() {
	getInterface(msgFormPath+'?new','messages');
}
function postNewMessage() {
	postFormData('msgNew');
}

// *************** Page Management ****************
var lastCommand='init';

function locationHandler() {
	window.clearTimeout(locationTimeoutId);
	var ie8trace=false;
	if (IE && (browserVersion=='7' || browserVersion=='8')) {
		ie8trace=true;
	}
	if (conducta) {
		
		var consider = String(window.location.href);
		// trap any double hash!
		if (consider.indexOf('##') >-1) {
			consider = consider.substr(consider.indexOf('#')+1);
			window.location.hash=consider;
		}
		
		if (consider.indexOf('#') >-1) {
			consider = consider.substr(consider.indexOf('#'));
		} else {
			consider = null;
		}
		if (consider !=null && consider.indexOf('.php') !=-1) {
			if (lastLocation != String(document.location)) {
				lastCommand = "";
				lastLocation = String(document.location);
				locationChangeGeneralFunction();
			}
		} 
		if (!lastCommand) { lastCommand=String(document.location);}
		if (consider !=null 
				&& consider != "top" 
				&& consider.indexOf('.php') ==-1) {
			
			if ( lastCommand && lastCommand != String(document.location)) {
				lastCommand = String(document.location);
				getErgonetData(dataSourceA5,consider);		
			}
			
		}
		
		if (urlCheckCounter>=urlChecksPerMin) {
			bannerCallOnTimer();
			urlCheckCounter=0;
		}
		locationTimeoutId=window.setTimeout('locationHandler()',urlCheckIntervalMsec);
		urlCheckCounter++;
	} else {
		var hashString=window.location.hash;
		hashString = hashString.substr(1);
		if (hashString.indexOf("&") !== -1) {
			hashString = hashString.substr(0,hashString.indexOf("&"));
		}
		if (hashString.indexOf("?") !== -1) {
			hashString = hashString.substr(0,hashString.indexOf("?"));
		}
		
		if (lastHash != hashString) {
			lastHash = hashString;
			var str = "func="+hashString;
			str = dataSourcePath + "?" + str;
			sendToServer(str);
		}	
	}
}
function getErgonetData(path,url) {
	
	var arr = url.split('/');
	var uri = arr[arr.length-1];
	var hash = uri.split('#');
	var f = hash[hash.length-1];
	// ha
	if (f !="top") {
		if (f && f != 'p') {
	//		trace(path + "?func="+f);
//			sendToServerAria5(path + "?func="+f);
		}
	}
}
function locationChangeGeneralFunction() {
	var locationString = String(document.location); // String(window.location);
	var n=locationString.length;
	hashString='';
	var comArray = new Array();
	if (locationString.indexOf('#')!=-1) {
		hashString=window.location.hash;
		hashString=hashString.substr(1);
		comArray = hashString.split(',');
		
	} else {
		var str='';
		str=locationString.substr(locationString.indexOf(tld)+tld.length+1);
		if (!str || str.indexOf('.php')==-1) { str = defaultGetDataPath;}
		var p = str.substr(str.indexOf('.php')+5);
		if (p) { str=str.substr(0,str.indexOf('.php')+4); }
		comArray[0]=str;
		locationString=str;
		comArray[1]='doc';
		comArray[2]=p;
	}
	var ariaFilePath=comArray[0];
	if (!ariaFilePath) {ariaFilePath=defaultGetDataPath;}
	var type=comArray[1];
	if (!type) { type='product'; }
	var params=''; 
	if (comArray[2]) { params=comArray[2];}
	params+='&funcMode=ajax';
	HistoryType = type; 
	if (debugResponse) {
	alert('locationChangeGeneralFunction calls: '+ariaFilePath);
	}
//alert(String(document.location));
//	trace('ariaFilePath: '+ariaFilePath);
/*
		if the adress has a hash in it # then we need to convert that and then, on return from server, move the page sroll to that point.

*/
	if (ariaFilePath.indexOf("#") !== -1) {
		var goAnchor = ariaFilePath.substr(ariaFilePath.indexOf("#")+1);
		//trace('goAnchor: '+goAnchor);
		ariaFilePath = ariaFilePath.substr(0,ariaFilePath.indexOf("#"));
		ariaFilePath = ariaFilePath+'&goAnchor='+goAnchor;
	//	trace('ariaFilePath: '+ariaFilePath);
	}
	var lcn = String(document.location);
	getData(ariaFilePath,type,params);// params+='&funcMode=ajax';
	
}

function goAnchor(anchorName) {
	var objs = document.getElementsByName(anchorName);
	
	if (objs.length) {
		var px = objs[0].offsetTop;
		var obj = document.getElementById('content01');
		if (obj != null) {
			var cpx = obj.offsetTop;
			px += cpx;
		}
		//trace('anchorName: '+anchorName+', px: '+px);
		window.scrollBy(0,px);
	}
}
var minutesToCheckBanner='';
var minutesToCheckBannerArray = minutesToCheckBanner.split(',');
function bannerCallOnTimer() {
	var timeNow=new Date();
	var minute=timeNow.getMinutes();
	for (var i=0; i<minutesToCheckBannerArray.length; i++) {
		if (minute == minutesToCheckBannerArray[i]) {
			loadProgramBanner(true);
		}
	}
}

function clearDiv(d) {
	if (d) {
		var obj = document.getElementById(d);
		if (obj != null) {
			obj.innerHTML='';
		}
	}
}
var inc1=0;
var theString1='';
var intv1;
var inc2=0;
var theString2='';
var intv2;
var inc3=0;
var theString3='';
var intv3;
var theArray=new Array(9,7,5,3,0,3,5,7,9);
function populatePreceed(d,t) {
	var element = document.getElementById(d);
	if (element != null) {
		element.innerHTML = t + element.innerHTML;
	}
}
function populate(d,t) {
//	trace('div: '+d);
	if (fadeContentTransition) {
		switch (d) {
			case 'content01':
				div=d;
				theString1=t;
				inc1=0;
				intv1=window.setInterval("writeContent1Out()",1);
				writeContent1Out();
			break;
			case 'content02':
				div=d;
				theString2=t;
				inc2=0;
				intv2=window.setInterval("writeContent2Out()",1);
				writeContent2Out();
			break;
	/*		case 'shopPanel':
				div=d;
				theString3=t;
				inc3=0;
				intv3=window.setInterval("writeContent3Out()",1);
				writeContent3Out();
			break; */
			default:
				var element = document.getElementById(d);
				if (element != null) {
					element.innerHTML = t;
				} else {
					//trace('not found '+d);	
				}
			break;
		}
	} else {
		var element = document.getElementById(d);
		if (element != null) {
			//trace('found: '+d);
			element.innerHTML = t;
		} else {
			//trace('not found: '+d);	
		}
	}
}
function nonPopTrace(t) { 
	var obj = document.getElementById('errorReport');
	if (obj != null) {
		obj.innerHTML = obj.innerHTML + '<br />'+t;
	}
}
function writeContent1Out() {
	//nonPopTrace(theArray[inc1]+' '+inc1);
	if (inc1 >= (theArray.length)-1) {
		window.clearInterval(intv1);
		var obj=document.getElementById('content01');
		if (obj !=null) {
			obj.style.opacity= 1;
			obj.innerHTML = theString1;
		}
		theString1='';
		inc1=0;
	}
	var obj=document.getElementById('content01');
	if (obj !=null) {
		if (theArray[inc1]>0) {
			obj.style.opacity= theArray[inc1]/10;
		} else {
			obj.style.opacity= 0;
			obj.innerHTML = theString1;
		}
	}
	inc1++;
}

function writeContent2Out() {
	if (inc2 >= (theArray.length)-1) {
		window.clearInterval(intv2);
		var obj=document.getElementById('content02');
		if (obj !=null) {
			obj.style.opacity= 1;
			obj.innerHTML = theString2;
		}
		theString2='';
		inc2=0;
	}
	var obj=document.getElementById('content02');
	if (obj !=null) {
		if (theArray[inc2]>0) {
			obj.style.opacity= theArray[inc2]/10;
		} else {
			obj.style.opacity= 0;
			obj.innerHTML = theString2;
		}
	}
	inc2++;
}

function writeContent3Out() {
	if (inc3 >= (theArray.length)-1) {
		window.clearInterval(intv3);
	//	var obj=document.getElementById('shopPanel');
	//	if (obj !=null) {
	//		obj.style.opacity= 1;
	//		obj.innerHTML = theString3;
	//	}
		theString3='';
		inc3=0;
	}
	var obj=document.getElementById('shopPanel');
	if (obj !=null) {
		if (theArray[inc3]>0) {
			obj.style.opacity= theArray[inc3]/10;
		} else {
			obj.style.opacity= 0;
			obj.innerHTML = theString3;
		}
	}
	inc3++;
}





function populateParent(d,t) {
	if (d) {
		var element = document.getElementById(d);
		if (element != null) {
			var id = element.parentNode.id;
			populate(id,t);
		}
	}
}
function changeAnchorLabel(id,txt) {
	if (id) {
		var obj=document.getElementById(id);
		if (obj!=null) {
			obj.innerHTML=txt;
		}
	}
}
function showHideDiv(id,showHide) {
	var obj='';
	obj=document.getElementById(id);
	if (obj != null) {
		switch(showHide) {
			case "show":
				obj.style.visibility='visible';
				obj.style.display='block';
			break;
			case "hide":
				obj.style.visibility='hidden';
				obj.style.display='none';
			break;
		}
	}
}
function getObject(id) {
	if (id) {
		var obj = document.getElementById(id);
		if (obj != null) {
			return obj;
		} else {
			return false;
		}
	}
	return false;
}

function showRecordsetSelectorChange() {
	var obj = document.getElementById('showRecordsetSelector');
	if (obj != null) {
		var selectedValue=obj.value;
		//alert(selectedValue);
		window.location=selectedValue;
	}
}

//*******  members resend password help.php
var formCheckReturnValue=false;

function checkResendPassEmail() {
  var obj=document.getElementById('em');
  if (obj.value != '') {
    if (obj.value == "") {
      return;
    } else {
      formCheckReturnValue=true;
//	  var params = "em="+obj.value;
//	  debug=true;
	  var str = resendPasswordScript;
	  var params = "&em="+obj.value;
	  postInterface(str,params,'content01');
    }
  } else {
	trace('missing: email');  
  }
}


// *********  Listen Again *****
function openPlayList(compid) {
	// send a message to the server to collect a list of paths associated with aria.comp.compid
	// the returned data passes into enFlash ? or pushes itself into windows media player / real player ? wot.
	// sendToActionScript(something)
	//getInterface()
}
function setPlayback(argsPipeString) {
	//
	var pth='';
	if (argsPipeString.indexOf("|")) {
		var args = argsPipeString.split('|');
		
		for(var i=0; i<args.length; i++) {
			//alert(args[i]);
			pth=args[i];
			pth = args[0];
		}
	} else {
		pth = argsPipeString;
	}
	if (pth) {
		var ver01 = "<OBJECT ID=\"RVOCX\" CLASSID=\"clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA\" WIDTH=300 HEIGHT=120><PARAM NAME=\"CONTROLS\" VALUE=\"All\"><PARAM NAME=\"CONSOLE\" VALUE=\"one\"><EMBED SRC=\""+pth+"\" WIDTH=300 HEIGHT=120 NOJAVA=true AUTOSTART=true CONTROLS=All CONSOLE=one></OBJECT>";
	
//	realPlayerObjectContainer.innerHTML = "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" width=\"218\" height=\"20\" id=\"palavaTrackPlayer\" align=\"middle\"><param name=\"allowScriptAccess\" value=\"sameDomain\" /><param name=\"movie\" value=\"/conf/flash/player_solo_v02_short.swf\" /><param name=\"quality\" value=\"high\" /><param name=\"wmode\" value=\"transparent\" /><param name=\"bgcolor\" value=\"#ffffff\" /><embed src=\"/conf/flash/player_solo_v02_short.swf\" quality=\"high\" wmode=\"transparent\" bgcolor=\"#ffffff\" width=\"218\" height=\"20\" name=\"palavaTrackPlayer\" swLiveConnect=true align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" /></object>";
	
		//setPlayerSource('clip0=9999|||/'+pth+'|mp3|||||&clipRcds=1');
		//setPlayerSource('clip0=167|Sunday||'+pth+'|mp3|00:03:04||||2000&clipRcds=1');
	
	} else {
		realPlayerObjectContainer.innerHTML = "No Tune";
	}
	
	
	
}
function setPlayerSource(s) {
	// this works for the track player (short)
	window.document.palavaTrackPlayer.SetVariable("clip0", s); 

	// this works for Nat's player ??
//	sendToActionScript(s);
	//alert(s);
}; 
// ***********  FORUM *********
function block_show_hide_alt(n) {
	if (n) {
		obj1 = document.getElementById(n);
		if (obj1!=null) {
			if (obj1.style) { 
				obj1=obj1.style;
				if(obj1.visibility=='visible') {
					obj1.visibility = 'hidden';
				} else {
					obj1.visibility = 'visible';
				}
			}
		}
	}
}
function forumListExpandCollapse(n,l) {
	if (n) {
		obj1 = document.getElementById(n);
		if (obj1!=null) {
			if (obj1.style) { 
				obj1=obj1.style;
				if(obj1.display=='none') {
					obj1.display = 'block';
				} else {
					obj1.display = 'none';
				}
			}
		}
	}
	if (l) {
		obj2 = document.getElementById(l);
		if (obj2!=null) {
			if (obj2.innerHTML.indexOf("[+]") != -1) {
				obj2.innerHTML="[-]";
			} else {
				obj2.innerHTML="[+]";
			}
		} else {
			alert("can't find: "+l);
		}
	}
}
/* Just for the old school */
function safemail(name, domain, display) {
displayed=(typeof(display)=="undefined") ? name+"@"+domain : display
document.write('<a href=mailto:' + name + '@' + domain + '>' + displayed + '</a>');
}
var initGalleryWidth="1px";
var initGalleryHeight="1px";
function shrinkGalleryContainerDiv() {
	var obj = document.getElementById('galleryContainer');
	if (obj != null) { obj.style.display="none"; }
	var obj = document.getElementById('galleryIndexContainer');
	if (obj != null) { obj.style.display="none"; }
	var obj = document.getElementById('screen');
	if (obj != null) { obj.style.display="none"; }
	var obj = document.getElementById('screenOverlay');
	if (obj != null) { obj.style.display="none"; }
}

/*
function shrinkGalleryContainerDiv() {
//	trace('shrinkGalleryContainerDiv');
//	if (galleryIsPopulated) {
		var obj = document.getElementById('galleryContainer');
		if (obj != null) {
			obj.style.zIndex=0;
			if (obj.innerHTML !="") {
				var feature01=document.getElementById('feature01');
				if (feature01 != null) {
					feature01.innerHTML = obj.innerHTML;
					//obj.innerHTML = "";
//					obj.style.width="0px";
//					obj.style.height="0px";
//					obj.style.left="0px";
//					obj.style.bottom="0px";
					obj.style.display="none";
					//var galCont = obj.style;
					var galCont = feature01.style;
//					galCont.position="relative";
//					galCont.width="300px";
//					galCont.height="124px";
//					galCont.left="0px";
//					galCont.top="0px";
					var obj2 = document.getElementById('screen');
					var obj3 = document.getElementById('screenLayoutTable');
					var obj4 = document.getElementById('scroller');
					var obj5 = document.getElementById('transport');
					var obj6 = document.getElementById('screenedImage');
					var obj7 = document.getElementById('screenOverlay');
					if (obj5 !=null) {
						var transportBar = obj5.style;
			//			transportBar.bottom="0px";
			//			transportBar.left="0px";
						transportBar.display='none';
					}
					if (obj6 != null) {
						obj6.src="/graphics/spacer.gif";
						obj6.style.width="1px";
						obj6.style.height="1px";
					}
					if (obj4 != null) {
						var scroller = obj4.style;
	//					scroller.top="10px";
	//					scroller.width="290px";
						scroller.overflow="hidden";
					}
					if (obj2 != null) {
						var screenDiv=obj2.style;
						screenDiv.height="1px";
						switchOfScreen=true;
						screenDiv.display='none';
			
					}
					if (obj7 != null) {
						var screenDiv=obj7.style;
						screenDiv.height="1px";
						switchOfScreen=true;
						screenDiv.display='none';
					}
				}
			}
		} else {
			trace("galleryContainer not found");
		}
//	}
}
*/
function showGalleryContainerDiv() {
//	trace('showGalleryContainerDiv');
	//var content01=document.getElementById("content01");
	//if (content01 != null) {
	//	content01.innerHTML="";
	//}
	var obj = document.getElementById('galleryContainer');
	if (obj != null) {
	//	obj.style.zIndex=100;
	//	var feature01=document.getElementById('feature01');
		// removed:   && switchOfScreen
	//	if (feature01 != null && switchOfScreen) {
	//		if (feature01.innerHTML) {
	//			obj.innerHTML = feature01.innerHTML;
	//			feature01.innerHTML="";
	//			feature01.style.height="1px";
	//		}
	//	}
		
		var galCont = obj.style;
		galCont.display="block";
		galCont.position="absolute";
//		galCont.top="5px";
//		galCont.left="0px";
//		galCont.width="800px";
//		galCont.height="500px";
	//	#galleryContainer {background-image:url(%sgraphics/frostFaint.png); }
	//	galCont.backgroundImage=galleryContainerBackgroundImage; 
		var obj2 = document.getElementById('screen');
		var obj3 = document.getElementById('screenLayoutTable');
		var obj4 = document.getElementById('scroller');
		var obj5 = document.getElementById('transport');
		var obj6 = document.getElementById('screenedImage');
		var obj7 = document.getElementById('screenOverlay');
		var obj8 = document.getElementById('screenImage');
		var obj9 = document.getElementById('galleryIndexContainer');
		var obj10 = document.getElementById('onPageMediaPlayer');
		if (obj4 != null) {
			/* see gallery.php - css is written according to prefs */
			var scroller = obj4.style;
//			scroller.top="10px";
//			scroller.width="99%";
		}
		if (obj2 != null) {
			var screenDiv=obj2.style;
			screenDiv.height=screenHeight+'px';
			screenDiv.display='block';
			switchOfScreen=false;
			
		}
		if (obj5 != null) {
			var transport=obj5.style;
			transport.display='block';
			//transport.left="20px";
		}
		if (obj6 != null) {
			var screenDiv=obj6.style;
			screenDiv.height=screenHeight+'px';
			screenDiv.display='block';
			switchOfScreen=false;
		}
		if (obj7 != null) {
			var screenDiv=obj7.style;
			screenDiv.height=screenHeight+'px';
			screenDiv.display='block';
			switchOfScreen=false;
		}
		if (obj8 != null) {
			var screenDiv=obj8.style;
			screenDiv.height=screenHeight+'px';
			screenDiv.display='block';
			switchOfScreen=false;
		}
		if (obj9 != null) {
			var screenDiv=obj9.style;
			//screenDiv.height=screenHeight+'px';
			screenDiv.display='block';
			switchOfScreen=false;
		}
		if (obj10 != null) {
			var player=obj10.style;
			player.opacity=0;
//			trace('opacity 0');
		} else {
//			trace('obj10 null');
		}
//trace('nextImage');
		nextImage();
	} else { trace("galleryContainer not found"); }
}
/* webcam */
function openWebCamWindow()
{
	var new_window = window.open(webcamWindowUrl,'webcam','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=500,height=400');
}
function setContent01Width(widthString) {
	var obj=document.getElementById('content01');
	if (obj!=null && widthString != '') {
		obj.style.width=widthString;
	}
}
/* ------------  Members ------------ */
var formCheckReturnValue=false;
function checkRegForm() {
	var ob1 = document.getElementById('regName');
	var ob2 = document.getElementById('regEmail');
	var ob3 = document.getElementById('regShortName');

	if (ob1 !=null && ob2 != null) {
		if (ob1.value != '' && ob2.value != '' && ob3.value != '') {
			if (ob1.value.length > 6 && ob2.value.length > 5) {
				// get the form values and send to server
//				postFormData('regForm'); // no - have a bespoke using getInterface
				// shopRegistrationFormPath
				
				var paramStr = "&regName="+ob1.value;
				paramStr += "&regEmail="+ob2.value;
				paramStr += "&regShortName="+ob3.value;
				paramStr += "&regSubmit=1";

	//			postDataToDiv(registrationFormPath, paramStr, 'content01');
	//			postData(registrationFormPath,'page', paramStr);
				postInterface(registrationFormPath,paramStr,'content01');
				
				formCheckReturnValue = false;
			} else {
				alert('Please provide your full name, a \'log in\' name and your email address');
				ob1.select();
				formCheckReturnValue = false;
			}
		} else {
			alert('Please fill in your name, \'log in\' name and your email address');
			ob1.select();
			formCheckReturnValue = false;
		}
	} else {
		alert('system error');
		formCheckReturnValue = false;
	}
}
function checkShopRegForm() {
	var ob1 = document.getElementById('regName');
	var ob2 = document.getElementById('regEmail');
	var ob3 = document.getElementById('regShortName');
	var ob4 = document.getElementById('rtn');
	var ob5 = document.getElementById('ref');
	var ob6 = document.getElementById('soid');
	if (ob1 !=null && ob2 != null) {
		//  && ob4.value != '' && ob5.value != '' && ob6.value != ''
		if (ob1.value != '' && ob2.value != '' && ob3.value != '' ) {
			if (ob1.value.length > 6 && ob2.value.length > 5) {
				// get the form values and send to server
//				postFormData('regForm'); // no - have a bespoke using getInterface
				// shopRegistrationFormPath
				
				var paramStr = "&regName="+ob1.value;
				paramStr += "&regEmail="+ob2.value;
				paramStr += "&regShortName="+ob3.value;
				paramStr += "&rtn="+ob4.value;
				paramStr += "&ref="+ob5.value;
				paramStr += "&soid="+ob6.value;
				paramStr += "&regSubmit=1";
				//alert(paramStr);
				// old - out !! postDataToDiv(shopRegistrationFormPath, paramStr, 'shopPanel');
				//trace(shopRegistrationFormPath+" "+paramStr);
				postData(shopRegistrationFormPath,'page', paramStr);
				formCheckReturnValue = false;
			} else {
				alert('Please provide your full name, a \'log in\' name and your email address');
				ob1.select();
				formCheckReturnValue = false;
			}
		} else {
			alert('Please fill in your name, \'log in\' name and your email address');
			ob1.select();
			formCheckReturnValue = false;
		}
	} else {
		alert('system error');
		formCheckReturnValue = false;
	}
}
function postLoginData(modus) {
	var ob1 = document.getElementById('name');
	var ob2 = document.getElementById('psw');
	var ob3 = document.getElementById('rtn');
	var ob4 = document.getElementById('ref');
	var ob5 = document.getElementById('soid');
	var ob6 = document.getElementById('userDomain');
	var paramStr = "&name="+ob1.value;
	paramStr += "&psw="+ob2.value;
	if (ob3 != null) {
	paramStr += "&rtn="+ob3.value;
	}
	if (ob4 != null) {
	paramStr += "&ref="+ob4.value;
	}
	if (ob5 != null) {
	paramStr += "&soid="+ob5.value;
	}
	if (ob6 != null) {
	paramStr += "&userDomain="+ob6.value;
	}
	paramStr += "&loginSubmit=1";
	switch(modus) {
		case "shopLogin":
	//		postDataToDiv(shopLoginScript, paramStr, 'shopPanel');
			postData(shopLoginPath, 'page', paramStr);
		break;
		case "memberLogin":
	//		postDataToDiv(memberLoginScript, paramStr, 'content01');
	//		postData(memberLoginScript, 'page', paramStr);
			postData(memberLoginPath, 'page', paramStr);
		break;
		case "community":
			postData(communityLoginPath, 'page', paramStr);
		break;
	}
}
function checkoutProceed() {
	postFormData('checkoutProceedForm');
}
/* --------------------------  Form Handling ---------------------- */
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function postFormData(context) 
{
	// postData(ariaFilePath,type,params)
	var divName = ""; // postDataToDiv
	var fieldArray= new Array();
	var checksArray = new Array();
	var path = dataSourcePath;
	var type = "page";
	var paramArray = new Array();
	var params = "";
	switch(context)
	{
		case "enquiriesForm":
			path = enquiriesFormPath;
			var fields = "nameEnq,emailEnq,enquiriesText,enquiryType,docidEnq";
			var fldValuesArray = new Array(5);
			var checksArray = new Array(0);
			var fieldArray = fields.split(',');
			var fldObj;
			
			for (var i=0; i<fieldArray.length; i++)
			{
				if (fieldArray[i] != 'enquiryType') {
					fldObj = document.getElementById(fieldArray[i]);
					if (fldObj != null) {
						fldValuesArray[i] = fldObj.value;
	
						if (fldObj.id == 'emailEnq') {
							if (fldObj.value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1) { 
								// invalid address
								var obj  = document.getElementById('enqFormMsg');
								if (obj != null) {
									obj.innerHTML = "invalid email address";
									window.setTimeout("document.getElementById('enqFormMsg').innerHTML=''",3000);
								}
								break;
								return false;
							}
						}
					} // end if fldObj != null
				} else {
					var radioObj = document.getElementById(fieldArray[i]);
					if (radioObj != null) {
						var enquiryTypeString =getCheckedValue(document.enquiriesForm.enquiryType);
						//trace('enquiryTypeString: '+enquiryTypeString);
						fldValuesArray[i] = enquiryTypeString;
					}
				}
				
			}
			if (!fldValuesArray[0] || !fldValuesArray[1] || !fldValuesArray[2]) {
				fldValuesArray= new Array();
				var obj  = document.getElementById('enqFormMsg');
				if (obj != null && !obj.innerHTML) {
					obj.innerHTML = "please complete the form.";
					window.setTimeout("document.getElementById('enqFormMsg').innerHTML=''",3000);
				}
			}
		break;
		case "mailingListJoin":
			path = mailingListFormPath;
			var fields = "nameMailingList,email,where,joinMailList";
			var fldValuesArray = new Array(4);
			var checksArray = new Array(0);
			var fieldArray = fields.split(',');
			var fldObj;
			
			for (var i=0; i<fieldArray.length; i++)
			{
				fldObj = document.getElementById(fieldArray[i]);
				if (fldObj != null) {
					fldValuesArray[i] = fldObj.value;
					if (fldObj.id == 'email') {
						if (fldObj.value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1) { 
							// invalid address
							fldObj.value = "invalid address";
							break;
							return false;
						}
					}
				}
			}
		break;
		case "searchForm":
		
		break;
		case "memberLogin":
			path = memberLoginPath;
			var fields = "name,psw,loginSubmit";
			var fldValuesArray = new Array(3);
			var checksArray = new Array(0);
			var fieldArray = fields.split(',');
			var fldObj;
			for (var i=0; i<fieldArray.length; i++)
			{
				fldObj = document.getElementById(fieldArray[i]);
				if (fldObj != null)
				{
					fldValuesArray[i] = fldObj.value;
				}
			}
		break;
		case "shopLogin":
			path = shopLoginPath;
			var fields = "name,psw,loginSubmit";
			var fldValuesArray = new Array(3);
			var checksArray = new Array(0);
			var fieldArray = fields.split(',');
			var fldObj;
			for (var i=0; i<fieldArray.length; i++)
			{
				fldObj = document.getElementById(fieldArray[i]);
				if (fldObj != null)
				{
					fldValuesArray[i] = fldObj.value;
				}
			}
		break;
		case "memberPrefs":
			path = memberPrefsPath;
			// look out - checkboxes!
			var checks = "sendMeTheNewsletter,allowMyProfileToBeSeen";
			var fields = "prefSubmit";
			var fldValuesArray = new Array(3);
			var fieldArray = fields.split(',');
			var fldObj;
			for (var i=0; i<fieldArray.length; i++)
			{
				fldObj = document.getElementById(fieldArray[i]);
				if (fldObj != null){
					fldValuesArray[i] = fldObj.value;
				}
			}
			var chkValuesArray = new Array(3);
			var checksArray = checks.split(',');
			var chkObj;
			for (var i=0; i<checksArray.length; i++)
			{
				chkObj = document.getElementById(checksArray[i]);
				if (chkObj != null)
				{
					chkValuesArray[i] = chkObj.checked;
				}
			}
		break;
		case "contactUpdate":
			path = contactUpdatePath;
			var fields = "linm,name1,name2,name3,name4,name5,name6,prefix,suffix,ad1,ad2,ad3,ad4,zip,cntry,adw1,adw2,adw3,adw4,workzip,workcntry,title,dept,tel,teladd,mob,fax,pager,em,em2,em3,em4,homecell2,emailtype,web,web2,web3,parents,children,reception,screen,homecell,hometeladd,homefax,hempref,hscreen,editAdrid,contactSubmitChk";
			var fieldArray = fields.split(',');
			var checksArray = new Array(0);
			var fldValuesArray = new Array(fieldArray.length);
			var fldObj;
			for (var i=0; i<fieldArray.length; i++)
			{
				fldObj = document.getElementById(fieldArray[i]);
				if (fldObj != null)
				{
					fldValuesArray[i] = fldObj.value;
				}
			}
		break;
		case "changePassword":
			// NO - see: checkChangePasswordForm()
			path = changePasswordPath;
			var fields = "name,psw,newPsw1,newPsw2,changePasswordSubmitted";
			var fldValuesArray = new Array(5);
			var checksArray = new Array(0);
			var fieldArray = fields.split(',');
			var fldObj;
			for (var i=0; i<fieldArray.length; i++)
			{
				fldObj = document.getElementById(fieldArray[i]);
				if (fldObj != null)
				{
					fldValuesArray[i] = fldObj.value;
				}
			}
		break;
		case "performerForm":
			path = performerFormPath;
			// see members/dsmp_04
			var fields = "afnm,amnm,alnm,ano,credits,artnat,res,artsx,em,web2,adrid,page,editaid,performerFormSubmit,new"; // case 0
		/*
			var fields = ""; // case 1 - must cycle skills ???
			var fields = ""; // case 2 - image editor
			var fields = ""; // case 3 - interview - not written
			var fields = ""; // case 4 - biography - not written
		*/
			var fldValuesArray = new Array(5);
			var checksArray = new Array(0);
			var fieldArray = fields.split(',');
			var fldObj;
			for (var i=0; i<fieldArray.length; i++)
			{
				fldObj = document.getElementById(fieldArray[i]);
				if (fldObj != null)
				{
					fldValuesArray[i] = fldObj.value;
				}
			}
		break;
		case "actForm":
			var bnm = document.getElementById('bnm');
			if (bnm == null || bnm.value == "") { noteRS('Please enter a Band Name'); return false; }
			path = actFormPath;
			// see members/dsmp_04
//			var fields = "bnm,company,bdn,credit01,country,em,web2,web,company,adrid,page,editbid,actFormSubmit,bndtypid,new"; // case 0
			var fields = "bnm,company,bndtypid04,bdn,media1,media2,credit01,country,em,web1,web2,web3,web4,web5,web6,adrid,page,editbid,actFormSubmit,new"; // case 0
			var checks = "rs1,rs2";
		/*
			var fields = ""; // case 1 - must cycle skills ???
			var fields = ""; // case 2 - image editor
			var fields = ""; // case 3 - interview - not written
			var fields = ""; // case 4 - biography - not written
		*/
			var fldValuesArray = new Array(18);
			var fieldArray = fields.split(',');
			var fldObj;
			for (var i=0; i<fieldArray.length; i++)
			{
				fldObj = document.getElementById(fieldArray[i]);
				if (fldObj != null)
				{
					fldValuesArray[i] = fldObj.value;
				}
			}
			var chkValuesArray = new Array(2);
			var checksArray = checks.split(',');
			var chkObj;
			for (var i=0; i<checksArray.length; i++)
			{
				chkObj = document.getElementById(checksArray[i]);
				if (chkObj != null)
				{
					if (chkObj.checked) {
						chkValuesArray[i] = 1;
					} else {
						chkValuesArray[i] = 0;
					}
				}
			}
		break;
		case "peopleForm":
			path = peopleFormPath;
			var fields = "fnm,mnm,lnm,notes,credits,nat,res,sex,em,web2,adrid,page,editpeopleid,new,peopleFormSubmit"; // case 0
			var fldValuesArray = new Array(5);
			var checksArray = new Array(0);
			var fieldArray = fields.split(',');
			var fldObj;
			for (var i=0; i<fieldArray.length; i++)
			{
				fldObj = document.getElementById(fieldArray[i]);
				if (fldObj != null)
				{
					fldValuesArray[i] = fldObj.value;
				}
			}
		break;
		case "profileForm":
			//path = profileFormPath;
			path = profileDisplayPath+"?func=profile";
			divName = 'profile';
			var fldValuesArray = new Array();
			var checksArray = new Array();
			var fieldArray = new Array();
			var n=document.forms['profileForm'].elements.length;
			var paramsArray = new Array();
			var str='';
			for (var i=0; i<n; i++) {
				if (document.forms['profileForm'].elements[i].name != 'undefined') {
					fldValuesArray[i]=document.forms['profileForm'].elements[i].value;
					fieldArray[i]=document.forms['profileForm'].elements[i].id;
				}
			}		
		break;
		case "checkout":
			path = shopCheckoutAcceptPath;
			var fldValuesArray = new Array();
			var checksArray = new Array();
			var fieldArray = new Array();
			var n=document.forms['checkoutForm'].elements.length;
			var paramsArray = new Array();
			var str='';
			for (var i=0; i<n; i++) {
				if (document.forms['checkoutForm'].elements[i].name != 'undefined') {
					//str = document.forms['checkoutForm'].elements[i].name+'='+document.forms['checkoutForm'].elements[i].value;
					fldValuesArray[i]=document.forms['checkoutForm'].elements[i].value;
					fieldArray[i]=document.forms['checkoutForm'].elements[i].id;
				}
				//formSaveReportAlert=true;
			}
		break;
		case "checkoutAddressForm":
			path = shopCheckoutPath;
			divName = 'shopPanel';
			var fldValuesArray = new Array();
			var checksArray = new Array();
			var fieldArray = new Array();
			/* secondary email field : ema */
			var em = document.getElementById('em');
			var ema = document.getElementById('ema');
			if (em != null && ema != null) {
				if (em.value != ema.value) {
					alert('Please check your email address');
					return false;
				}
			}
			var n=document.forms['checkoutAddressForm'].elements.length;
			var paramsArray = new Array();
			var str='';
			fldValuesArray.push('checkoutAddressFormSubmit');
			fieldArray.push('func');
			for (var i=0; i<n; i++) {
				if (document.forms['checkoutAddressForm'].elements[i].name != 'undefined') {
					//str = document.forms['checkoutForm'].elements[i].name+'='+document.forms['checkoutForm'].elements[i].value;
					if (document.forms['checkoutAddressForm'].elements[i].id != "func" ) {
						fldValuesArray[i+1]=document.forms['checkoutAddressForm'].elements[i].value;
						fieldArray[i+1]=document.forms['checkoutAddressForm'].elements[i].id;
					}
				}
				//paramsArray.push(str);
			}
			
		break;
		case "checkoutProceedForm":
			path = shopCheckoutPath;
			divName = 'shopPanel';
			
			var fldValuesArray = new Array();
			var checksArray = new Array();
			var fieldArray = new Array();
			var n=document.forms['checkoutProceedForm'].elements.length;
			var paramsArray = new Array();
			var str='';
			for (var i=0; i<n; i++) {
				if (document.forms['checkoutProceedForm'].elements[i].name != 'undefined') {
					//str = document.forms['checkoutForm'].elements[i].name+'='+document.forms['checkoutForm'].elements[i].value;
					fldValuesArray[i]=document.forms['checkoutProceedForm'].elements[i].value;
					fieldArray[i]=document.forms['checkoutProceedForm'].elements[i].id;
				}
				//paramsArray.push(str);
			}
			var checkoutNotes = '';
			var checkoutNotesObj = document.getElementById('checkoutNotes');
			if (checkoutNotesObj != null) {
				checkoutNotes = checkoutNotesObj.value;
				fldValuesArray[i+1] = checkoutNotes;
				fieldArray[i+1] = 'checkoutNotes';
			}
		break;
		case "msgNew":
			path = msgFormPath;
			var fldValuesArray = new Array();
			var checksArray = new Array();
			var fieldArray = new Array();
			var n=document.forms['msgForm'].elements.length;
			var paramsArray = new Array();
			var str='';
			for (var i=0; i<n; i++) {
				if (document.forms['msgForm'].elements[i].name != 'undefined') {
					//str = document.forms['checkoutForm'].elements[i].name+'='+document.forms['checkoutForm'].elements[i].value;
					fldValuesArray[i]=document.forms['msgForm'].elements[i].value;
					fieldArray[i]=document.forms['msgForm'].elements[i].id;
				}
				//paramsArray.push(str);
			}
		break;
		case "eventForm":
			path = eventFormPath;
			var fields = "title,dtDayFrom,dtMonthFrom,dtYearFrom,dtDayTo,dtMonthTo,dtYearTo,tmst,tmen,bkdn,bkstatid,bktypid,premid,place,tel,contact,url01txt,url01,url02txt,url02,url03txt,url03,orgid,bkid,eventFormSubmit,new";
			var fldValuesArray = new Array(26);
			var checksArray = new Array(0);
			var fieldArray = fields.split(',');
			var fldObj;
			for (var i=0; i<fieldArray.length; i++)
			{
				fldObj = document.getElementById(fieldArray[i]);
				if (fldObj != null)
				{
					fldValuesArray[i] = fldObj.value;
				}
			}
		break;
		case "regForm":
			path = registrationFormPath;
			var fields = "regName,regShortName,regEmail,regSubmit";
			var fldValuesArray = new Array(4);
			var checksArray = new Array(0);
			var fieldArray = fields.split(',');
			var fldObj;
			for (var i=0; i<fieldArray.length; i++)
			{
				fldObj = document.getElementById(fieldArray[i]);
				if (fldObj != null)
				{
					fldValuesArray[i] = fldObj.value;
				}
			}
		break;
		case "organisationForm":
			path = organisationFormPath;
			var fields = "orgname,orgtypeid,intro,contact,country,text1,text2,text3,text4,evsstatusnotes,orgid,orgFormSubmit";
			var fldValuesArray = new Array(12);
			var checksArray = new Array(0);
			var fieldArray = fields.split(',');
			var fldObj;
			for (var i=0; i<fieldArray.length; i++)
			{
				fldObj = document.getElementById(fieldArray[i]);
				if (fldObj != null)
				{
					fldValuesArray[i] = fldObj.value;
				}
			}
		break;
		case "newsForm":
			path = newsFormPath;
			var fields = "doctitle,docname,doctypid,summary,docbodyhtml,author,docdate,docid,docFormSubmit,new";
			var fldValuesArray = new Array(9);
			var checksArray = new Array(0);
			var fieldArray = fields.split(',');
			var fldObj;
			for (var i=0; i<fieldArray.length; i++)
			{
				fldObj = document.getElementById(fieldArray[i]);
				if (fldObj != null)
				{
					fldValuesArray[i] = fldObj.value;
				}
			}
		break;
		case "vacForm":
			path = vacFormPath;
			var fields = "jobtitle,brief,orgid,contact,vacid,vacancyFormSubmit,new";
			var fldValuesArray = new Array(9);
			var checksArray = new Array(0);
			var fieldArray = fields.split(',');
			var fldObj;
			for (var i=0; i<fieldArray.length; i++)
			{
				fldObj = document.getElementById(fieldArray[i]);
				if (fldObj != null)
				{
					fldValuesArray[i] = fldObj.value;
				}
			}
		break;
		case "venueForm":
			path = venueFormPath;
			var fields = "premnm,premtypid,description,venueSubmit,premid,venueFormSubmit,new";
			var fldValuesArray = new Array(7);
			var checksArray = new Array(0);
			var fieldArray = fields.split(',');
			var fldObj;
			for (var i=0; i<fieldArray.length; i++)
			{
				fldObj = document.getElementById(fieldArray[i]);
				if (fldObj != null)
				{
					fldValuesArray[i] = fldObj.value;
				}
			}
		break;
	} // end switch
	var formSaveReport='';
	if (fieldArray.length>0 && fldValuesArray.length>0)
	{
		for (var i=0; i<fieldArray.length; i++)
		{
			if (fieldArray[i]) {
				formSaveReport += fieldArray[i] + "=" + fldValuesArray[i]+", ";
				paramArray.push(fieldArray[i] + "=" + fldValuesArray[i]);
			}
		}
	}
//	alert(formSaveReport);
	if (checksArray.length>0 && chkValuesArray.length>0)
	{
		for (var i=0; i<checksArray.length; i++)
		{
			if (checksArray[i]) {
				paramArray.push(checksArray[i] + "=" + chkValuesArray[i]);
			}
		}
	}
	params = paramArray.join("&");
//trace(params);
//trace('divName: '+divName);
	if (params)
	{
		if (divName) {
//			if (eNbbCall) {
//				postDataToDiv(path,params,divName); // setAnyInnerHtml
//				trace('setAnyInnerHtml');
//			} else {
				postInterface(path,params,divName); // evaluateServerResponse
//				trace('evaluateServerResponse');
//			}
//			
		} else {
			postData(path,type,params);
//			trace('postData');
		}
	}
	return true;
}

function submitPerformerForm() {
	postFormData('performerForm');
}
function submitActForm() {
	
	postFormData('actForm');
}
function submitPeopleForm() {
	postFormData('peopleForm');
}
function submitProfileForm() {
	postFormData('profileForm');
}
function submitEventsForm() {
	postFormData('eventForm');
}
function submitOrganisationForm() {
	postFormData('organisationForm');
}
function submitNewsForm() {
	postFormData('newsForm');
}
function submitVacancyForm() {
	postFormData('vacForm');
}
function submitVenueForm() {
	postFormData('venueForm');
}
function imageUploadFormSubmit() {
	
}
function episodeNameEditFieldSave(path,fieldId,id) {
	var name='';
	var obj=document.getElementById(fieldId);
	if (obj!=null && path) {
		name=obj.value;
		if (!name) { name='no name'; }
		var params='compnm='+name;
//		postData(path,'page',params);
//		id = 'eEn1015'
		getInterface(path+'&'+params,id);
	}
}
function trackNameEditFieldSave(path,fieldId,id,trackCreditTextFieldID) {
	var name='';
	var obj=document.getElementById(fieldId);
	if (obj!=null && path) {
		name=obj.value;
		if (!name) { name='no name'; }
		var params='scompnm='+name;
		
		//'trackCreditText'+scompid
		if (trackCreditTextFieldID) {
			var obj = document.getElementById(trackCreditTextFieldID);
			if (obj != null) {
				var trackCreditText = obj.value;
				params += '&caa='+trackCreditText;
			}
		}
		
		getInterface(path+'&'+params,id);
	}
}
function newTrack(compid) {
	
	var thisDivID = 'newEpisodeFileRow'+compid;
	var thisDiv = document.getElementById(thisDivID);
	var thisDivParent=thisDiv.parentNode;
	var newElement = document.createElement("div");
	
	var ran_unrounded=Math.random()*1000;
	var ran_number=Math.floor(ran_unrounded); 
	
	var newElementId = "eEnS"+ran_number;
	newElement.id = newElementId;
	newElement.className = "editEpisodeFileRow";
	newElement.innerHTML = "A New Row";
	
//	thisDivParent.appendChild(newElement);
	thisDivParent.insertBefore(newElement,thisDiv);
	
	var params = 'func=newTrack&compid='+compid+'&newDiv='+newElementId;
	getInterface(showEditAgainPath+'?'+params, 'evaluate');
}
function replacePopulate(target,newId,content,editLink) {
	var targetDiv = document.getElementById(	target );
	if (targetDiv != null) {
		var thisDivParent=targetDiv.parentNode;
		var newElement = document.createElement("div");
		newElement.id = newId;
		newElement.className = "editEpisodeFileRow";
		newElement.innerHTML = content;
		thisDivParent.insertBefore(newElement,targetDiv);
		
		var newElement = document.createElement("div");
		newElement.className = "trackEditLink";
		newElement.innerHTML = editLink;
		thisDivParent.insertBefore(newElement,targetDiv);
	//	thisDivParent.appendChild(newElement);
		thisDivParent.removeChild(targetDiv);
	}
	
}
function uploadTrack(scompid) {
	//populate('trackUpload'+scompid,'something here ');
	var params = 'func=uploadTrack&scompid='+scompid;
	getInterface(showEditAgainPath+'?'+params,'trackUpload'+scompid);
}
function creditTrack(scompid) {
	var params = 'func=creditTrack&scompid='+scompid;
	getInterface(showEditAgainPath+'?'+params,'trackCredit'+scompid);
}
function changeSubject(v,pid,p) {
	var params='func=getSubjectList&subject='+v+'&pid='+pid+'&p='+p;
	div='subjectList';
//	getData(,'page',params);
	getInterface(showEditAgainPath+'?'+params,div);
}
function addAssociation(v,pid,p,id) {
	var params='func=addAssociation&subject='+v+'&pid='+pid+'&p='+p+'&id='+id;
	div='selectedAssociations';
	getInterface(showEditAgainPath+'?'+params,div);
}
function removeAssoc(v,pid,p,id) {
	var params='func=removeAssociation&subject='+v+'&pid='+pid+'&p='+p+'&id='+id;
	div='selectedAssociations';
	getInterface(showEditAgainPath+'?'+params,div);
}
function saveShowDescriptionTextArea(pid,textAriaId,divToReFill) {
	var params='func=saveShowDescription&pid='+pid;
	var obj = document.getElementById(textAriaId);
	var description='';
	if (obj != null) {
		description = obj.value;
		params+='&pdn='+description;
		div=divToReFill;
		getInterface(showEditAgainPath+'?'+params,div);
	}

}
function deleteRecord(u,t,k,i,msg) {
	var delete_warning_message = "Delete this Record ?";
	temp=window.confirm("'"+msg+"' "+delete_warning_message);
	if(temp == true) {
		document.return_value=false;
		//alert('?delid='+i+'&amp;t='+t+'&amp;k='+k);
		//document.location.replace('?delid='+i+'&t='+t+'&k='+k);
		var params = '&t='+t+'&k='+k+'&delid='+i
	//	getInterface(com,'');
		getData(u,'page',params);
	}
}
var formCheckReturnValue=false;
function checkChangePasswordForm() {
	var n=6;
	var ob1 = document.getElementById('name');
	var ob2 = document.getElementById('psw');
	var ob3 = document.getElementById('newPsw1');
	var ob4 = document.getElementById('newPsw2');
	if (ob1 !=null && ob2 != null && ob3 != null && ob4 != null) {
		var proceed = true;
		if (ob1.value == '') {
			alert('Please fill in your \'log in\' name or email address');
			ob1.select(); proceed = false; formCheckReturnValue = false; return;
		}
		if (ob2.value == '') {
			alert('Please fill in your current password');
			ob2.select(); proceed = false; formCheckReturnValue = false; return;
		}
		if (ob3.value == '') {
			alert('Please fill in your new password');
			ob3.select(); proceed = false; formCheckReturnValue = false; return;
		}
		if (ob4.value == '') {
			alert('Please repeat your new password');
			ob4.select(); proceed = false; formCheckReturnValue = false; return;
		}
		if (!proceed) {
			formCheckReturnValue = false;
		} else {
			if (ob4.value != ob3.value) {
				alert('The new password did not match your repeated new password. Please try again.');
				ob3.value=''; ob4.value='';
				ob3.select(); formCheckReturnValue = false; return;
			} else {
				if (ob3.value.length < n) {
					alert('The password you have chosen is not long enough. please enter a password of '+n+' or more characters');
					ob3.value=''; ob4.value='';
					ob3.select(); formCheckReturnValue = false; return;
				} else {
					postFormData('changePassword');
					formCheckReturnValue = false; return;
				}
			}
		}
	} else {
		alert('system error');
		formCheckReturnValue = false;
	}
}

var lastCommand='';
function pageInit() {
	// load the seach button images
	if (!lastCommand) { lastCommand=String(document.location);}
	 jsReady = true;
	 //moverObj = document.getElementById('rightColumn');
	 currentDragDiv = null; //document.getElementById('rightColumn');
	 pageBodyResize();
	// runNewsTicker();
//	 
	 var feature01 = document.getElementById('feature01');
	 if (feature01 != null) {
		var str = feature01.innerHTML;
		if (str.length > 6) {
		 if (animateRightColumn) {
			rightColumnShow();
			billboardInitialise("feature01");
		 }			
		}
	 }
	
	// initArtImages();
	/*var objects = document.getElementsByTagName('div');
	for (var i=0; i<objects.length; i++) {
		objects[i].addEventListener("click",reportDiv,true);
	}*/
}

function glcInit() {
	var obj = document.getElementById('glcSidebar');
	if (obj != null) {
		// populate the div glcSidebar
		getData('glc/conf/app/dataSource.php','page','&init=1');
//		trace(siteRoot+'conf/glc/conf/app/dataSource.php');
		window.clearTimeout(glcInitDelayObj);
	}
}
function reportDiv() {
	alert("Div: "+this.id)
}
/*--------- to do with Flash Player talking to the page */
var jsReady = false;
var moverObj;
var moverObjStartTop=205;
var moverObjStartHeight=490;
function isReady() {
 return jsReady;
}

function thisMovie(movieName) {
 if (navigator.appName.indexOf("Microsoft") != -1) {
	 return window[movieName];
 } else {
	 return document[movieName];
 }
}
function sendToActionScript(value) {
 //thisMovie("FlashJavaScript").sendToActionScript(value);
 //alert("Send to Action Script: "+value);
 if (thisMovie("flashRadioPlayer") != null) {
 	thisMovie("flashRadioPlayer").sendToActionScript(value);
	//alert("Send to Action Script: "+value);
 } else {
//	alert("flashRadioPlayer not found!");
 }
}

function setFlashPlaybackUrl(value) {
	thisMovie("flashRadioPlayer").setFlashPlaybackUrl(value);
}
function sendToJavaScript(value) {
//         document.forms["form1"].output.value += "ActionScript says: " + value + "\n";
	var str=(moverObjStartTop+value)+'px';
	//var str=value+'px';
	var hght=(moverObjStartHeight-value)+"px";
	moverObj.style.top=str;
	moverObj.style.height=hght;
	//var ss=document.getElementById('content02');
	//ss.innerHTML=str;
}
function  getPageDataFromFlash(value) {
	getData(value,'page','');
}
// Track upload:
function flashTrackUploadReturn(scompid) {
	var s1 = showEditAgainPath+'?func=saveScomp&scompid='+scompid+'&div=trackNameEditField'+scompid;
	var s2 = 'trackNameEditField'+scompid;
	var s3 = 'eEnS'+scompid;
	var s4 = 'trackCreditText'+scompid;
	trackNameEditFieldSave(s1,s2,s3,s4);

}
// Rising stars:
//function flashUploadReturn(bid) {
//	if (bid) {
//	getInterface('/conf/conducta/app/members/getActImage.php?bid='+bid,'membersActEditImage');
//	} else {
//	trace('no band ID');	
//	}
//}

function open_window(url,n,w,h) {
var openString = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width='+w+',height='+h;
mywin = window.open(url,n,openString);
}
var fieldsetsArray = new Array();
var fieldsetHeightArray = new Array();
var frame=0;
var totalFrame=10;
var obj=null;
var moveMeI=2;
var intervalObj=null;
var currentFieldSetObj=0;
var targetHeight=0;
var currentHeight=0;
var mode = 0;
function collapseFieldsets() {
	fieldsetsArray = document.getElementsByTagName('fieldset');
	var height=0;
//	trace('collapse fieldsets');
	frame=0;
	window.clearInterval(intervalObj);
	intervalObj=null;
	for (var i=0; i<fieldsetsArray.length; i++) {
//		trace('fld: '+i);
		if ( fieldsetsArray[i].className !="doNotCollapse") {
			height = fieldsetsArray[i].offsetHeight;
			fieldsetHeightArray.push(height);
			fieldsetsArray[i].style.height='15px';
			fieldsetsArray[i].style.overflow='hidden';
			fieldsetsArray[i].onclick=function() { animateFieldset(this); }
			
			for (var j=0; j<fieldsetsArray[i].childNodes.length; j++) {
				var obj = fieldsetsArray[i].childNodes[j];
				if (obj != null && obj.style && obj.nodeName !="LEGEND") {
					obj.style.opacity= 0;
				}
			}
			
		}
	}
}
function animateFieldset(obj) {
	window.clearInterval(intervalObj);
	intervalObj=null;
	for (var i=0; i<fieldsetsArray.length; i++) {
		if (fieldsetsArray[i] == obj) {
			currentFieldSetObj=obj;
			currentHeight=0;
			targetHeight = fieldsetHeightArray[i]-20;
			if (fieldsetsArray[i].offsetHeight ==null || (fieldsetsArray[i].style.height == '15px') ) {
				mode=0;
			} else {
				targetHeight=15;
				mode=1;
			}
			moveMe();
		}
	}
}
function moveMe(){
	if (currentFieldSetObj!=null){
		intervalObj=window.setInterval("stepAnimateFieldset()",100);
	}
}

function stepAnimateFieldset(){
	if (frame < totalFrame){
		var newHeight=0;
		if (mode==0) {
			// show the child nodes
			for (var i=0; i<currentFieldSetObj.childNodes.length; i++) {
				var obj = currentFieldSetObj.childNodes[i];
				if (obj != null && obj.style && obj.nodeName !="LEGEND") {
					obj.style.opacity=frame / totalFrame;
				}
			}
			newHeight=currentFieldSetObj.offsetHeight + ((targetHeight-currentFieldSetObj.offsetHeight)/2);
		} else {
			newHeight=(currentFieldSetObj.offsetHeight-targetHeight) / 2;
			// hide the child nodes
			for (var i=0; i<currentFieldSetObj.childNodes.length; i++) {
				var obj = currentFieldSetObj.childNodes[i];
				if (obj != null && obj.style && obj.nodeName !="LEGEND") {
					obj.style.opacity= (totalFrame - frame) / totalFrame;
				}
			}
		}
		if (newHeight < 16) {
			newHeight=15; 
			for (var i=0; i<currentFieldSetObj.childNodes.length; i++) {
				var obj = currentFieldSetObj.childNodes[i];
				if (obj != null && obj.style && obj.nodeName !="LEGEND") {
					obj.style.opacity= 0;
				}
			}
		}
		currentFieldSetObj.style.height=(newHeight)+'px';
		frame++;		
	} else {
		window.clearInterval(intervalObj);
		frame=0;
		if (mode == 1) {
			// hide the child nodes
			for (var i=0; i<currentFieldSetObj.childNodes.length; i++) {
				var obj = currentFieldSetObj.childNodes[i];
				if (obj != null && obj.style && obj.nodeName !="LEGEND") {
					obj.style.opacity=0;
				}
			}
		}
		
	}
}

// Draft Double Menu Flyout Functions - 2010-01-24

var dblMenuChildIds = new Array(); // note that this is an array of <ul> elements corresponding to each <li> in the dblMenFirstLevel
var lastSelectedChildId='zone1';
var currentSelectedMenuHeadId='tmrLiIdZone1';
var dblMenuTabColorsArray = new Array();

function dblMenuChildren(zoneid) {
	var n= dblMenuChildIds.length;
	for ( var i=0; i<n; i++ ) {
	//	trace('id: '+zoneid+', dblMenuChildIds: '+dblMenuChildIds[i]);
		if ( (zoneid == dblMenuChildIds[i]) || ('zone'+zoneid == dblMenuChildIds[i]) ) {
			display(dblMenuChildIds[i]);
			crossfade( dblMenuChildIds[i], lastSelectedChildId );
			lastSelectedChildId = dblMenuChildIds[i];
		} else {
			hide(dblMenuChildIds[i]);
		}
	}
}
function headingHighlight(parentId,childID) {
	// dblMenuTabColorsArray is passed by doubleMenu.php
	// the position of the top level Li within it's parent is a lookup index for dblMenuTabColorsArray 
	// set color this way
	var obj =document.getElementById('dblMenFirstLevel');
	var backgroundColor = "transparent";
	if (obj != null) {
		for (var i=0; i<obj.childNodes.length; i++) {
			if (obj.childNodes[i].id == parentId) {
				var obj2 = obj.childNodes[i];
				backgroundColor = dblMenuTabColorsArray[i];
			}
		}
	}
}
function unHeadingHighlight(parentId) {
	var headingLi = document.getElementById(parentId);
	if (headingLi != null ) {
//		headingLi.style.backgroundColor="#000000";
	}
}
function dblMenuInit(currentRowId,zoneid) {
	currentZoneid = zoneid;
	display(currentRowId);
	dblMenuChildren(currentRowId);
}
function display(id) {
	var obj=document.getElementById(id);
	if (obj != null) {
		obj.style.display="block";
	}
}
function hide(id) {
	var obj=document.getElementById(id);
	if (obj != null) {
		obj.style.display="none";
		obj.style.opacity=0;
	}
}
var dblMenuTimeoutId=null;
var dblMenuCntr = 0;
var dblMenuCycles = 10;
var xfadeObj1=null;
var xfadeObj2=null;
function crossfade( newId, oldId ) {
	if (newId == oldId) {
		xfadeObj1=document.getElementById(newId);
		if (xfadeObj1 != null) {
			if (xfadeObj1.style.opacity<0.9) {
				oldId='';	
			}
		}
	}
	if (newId && newId != oldId) {
		xfadeObj1=document.getElementById(newId);
		if (oldId) { xfadeObj2=document.getElementById(oldId); }
		if (xfadeObj1 != null) {
			if (!xfadeObj1.style.opacity) {
				xfadeObj1.style.opacity = 0;
			}
			dblMenuTimeoutId = window.setTimeout("crossfadeStep()",100);
		}
	}
}
function crossfadeStep() {
	window.clearTimeout(dblMenuTimeoutId);
	if (dblMenuCntr < dblMenuCycles) {
		dblMenuTimeoutId = window.setTimeout("crossfadeStep()",60);
		if ( xfadeObj1 != null ) {
			xfadeObj1.style.opacity = ( dblMenuCntr / dblMenuCycles );
		}
		if ( xfadeObj2 != null) {
			var op = 	( ( dblMenuCycles - dblMenuCntr ) / dblMenuCycles );
			xfadeObj2.style.opacity = op;
		}
		dblMenuCntr++;
	} else {
		if ( xfadeObj1 != null ) {
			xfadeObj1.style.opacity = 1;
		}
		if ( xfadeObj2 != null) {
			xfadeObj2.style.opacity = 	0;
		}
		dblMenuCntr = 0;
	}	
}
var fadePopFadeContent = '';
var fadePopFadeObject = null;
var fadePopOpacity=1;
var fadePopTimeout=null;
var fadePopFrames = new Array(9,7,5,3,0,3,5,7,9);
var fadePopCounter = 0;
function fadeOutPopFadeIn(obj,content) {
	// called by getInterface -> setAnyInnerHtml xhr sequence
	// args object and dom fragment.
	if (obj && content) {
		fadePopFadeObject = obj;
		fadePopFadeContent = content;
		fadePopTimeout = window.setTimeout('fadePopStep()',20);
	}
}
function fadePopStep() {
	clearTimeout(fadePopTimeout);
	if (fadePopCounter < (fadePopFrames.length-1) ) {
		if (fadePopFrames[fadePopCounter]) {
			fadePopFadeObject.style.opacity=fadePopFrames[fadePopCounter]/10;
		} else {
			fadePopFadeObject.style.opacity=0;
	/*		
	
	i wish this worked!!
	
	if (fadePopFadeObject.childNodes.length) {
				// grab the existing firstChild Position and write to new firstChild
				var top=0; var left=0;
				top = fadePopFadeObject.firstChild.offsetTop;
				left = fadePopFadeObject.firstChild.offsetLeft;
			
				fadePopFadeObject.removeChild(fadePopFadeObject.firstChild);
				
				var newElement=document.createElement('div');
				newElement.innerHTML=fadePopFadeContent;
				var element = newElement.firstChild;
				if (element != null) {
					fadePopFadeObject.appendChild(element);
					// find the div with class catWin .. 'cos js just can't do the child thing!
					for (var i=0; i<fadePopFadeObject.childNodes.length; i++) {
						var str = fadePopFadeObject.childNodes[i].className;
						if (str =='catWin' || str =='contWin') {
	
							fadePopFadeObject.childNodes[i].style.top=top+'px';
							fadePopFadeObject.childNodes[i].style.left=left+'px'
						}
					}
				}
				*/
//			} else {
				fadePopFadeObject.innerHTML=fadePopFadeContent;
	//		}
		}
		fadePopCounter++;
		fadePopTimeout = window.setTimeout('fadePopStep()',20);
	} else {
		fadePopFadeObject.style.opacity=1;
		clearTimeout(fadePopTimeout);
		fadePopCounter = 0;
		fadePopOpacity =1;
		fadePopTimeout=null;
		fadePopFadeObject = null;
		fadePopFadeContent = '';
	}
}
function compareAndPopulate(div, markup) {
	var content = "";
	var targetDiv = document.getElementById(div);
	if (targetDiv != null) {
		content = targetDiv.innerHTML;
		if (content.length < 10) {
			targetDiv.innerHTML = markup;
		}
	}
}
 /************  Richt Column Animate **********/

var rightColumnAnimationDistance = 0;
var rightColumnMaxWidth = 400;
var rightColumnMinWidth = 0;
var rightColFrame = 0;
var rightColTotalFrame = 20;
var moveMeI=2;
var rcInt=null;
var rightColumnIsOpen = false;



function rightColStep() {
//	obj=document.getElementById("rightColumn");
//	traceErgodev('w: '+obj.offsetWidth+', mxw: '+rightColumnMaxWidth+' min: '+rightColumnMinWidth);
//	traceErgodev('frame: '+rightColFrame+', total: '+rightColTotalFrame);
				  
	if (rightColFrame < rightColTotalFrame) {
		obj=document.getElementById("rightColumn");
		obj2 = document.getElementById('content01');
//		traceErgodev('w: '+obj.offsetWidth+' rightColumnMinWidth: '+rightColumnMinWidth);
		
		if ( obj.offsetWidth <= rightColumnMaxWidth) {
			
			if ( obj.offsetWidth >= rightColumnMinWidth) {
				// get bigger
				var moveMeX=0;
				moveMeI=rightColumnAnimationDistance-obj.offsetWidth;
				moveMeI=moveMeI/4;
				moveMeX=obj.offsetWidth+moveMeI;
				moveMeX=Math.floor(moveMeX);
				obj.style.width=moveMeX+"px";
		//		obj2.style.width=(obj2.offsetWidth-moveMeI)+'px';
	//			traceErgodev('w1: '+obj.style.width);
				rightColFrame++;
			} else {
				// set to smallest
				obj.style.width=rightColumnMinWidth+'px';
			//	obj2.style.width="90%";
				window.clearInterval(rcInt);
	//		traceErgodev('end1');
				rightColFrame=0;
			//	rightColumnIsOpen = false;
			}
			
		} else {
			
			// get bigger	
	//		obj2.style.width="60%";
			obj.style.width=rightColumnMaxWidth+'px';
			
			window.clearInterval(rcInt);
//			traceErgodev('end2');
			rightColFrame=0;
		//	rightColumnIsOpen = true;
			
			
		}
	} else {
		window.clearInterval(rcInt);
//		traceErgodev('end3');
		rightColFrame=0;
		//if (rightColumnIsOpen) {
		//	rightColumnIsOpen = false;
		//} else {
		//	rightColumnIsOpen = true;	
		//}
	}
	
}
function rightColumnShow() {
	var obj = document.getElementById('rightColumn');
	
	if (obj != null) {
		//obj.style.display="block";
	//	rightColumnIsOpen = true;
		rightColumnShowHide( true );
	}
}
function rightColumnHide() {
	
	var obj = document.getElementById('rightColumn');
	if (obj != null) {
		//obj.style.display="none";
	//	rightColumnIsOpen = false;
		rightColumnShowHide( false );
	}
}
function rightColumnShowHide( bool ){
	var obj=document.getElementById("rightColumn");
	var obj2 = document.getElementById('content01');
//	traceErgodev('yrrr');
	if ( obj!=null ) {
		if ( bool ) {
			// open it
			//obj.style.width=(rightColumnMaxWidth-2)+'px';
			obj.style.width="400px";
			obj2.style.width="40%";
			rightColumnMaxWidth=rightColumnMaxWidth;
		} else {
			// close it
			//obj.style.width=(rightColumnMinWidth-2)+'px';
			obj.style.width="1px";
			obj2.style.width="90%";
			rightColumnAnimationDistance=0;
			
		}
		rightColFrame = 0;
//		rcInt=window.setInterval("rightColStep()",100); //100 is delay		
	} else {
//		traceErgodev('rightColumn: c\'est nes pas la!');
	}
}


function traceErgodev( txt ) {
	if (document.domain == 'ergodev1.co.uk') {
		var obj=document.getElementById('errorReport');
		
		if (obj!=null) {
			var str = obj.innerHTML;
			obj.innerHTML='trace: '+txt+'<br />'+str; //+'<br />'+obj.innerHTML;
		}
	}
}


function newsTickerShow(bool) {
	
	var nt = document.getElementById('newsTicker');
	if (nt != null) {
		if (bool) {
			nt.style.display = 'block';	
		} else {
			nt.style.display = 'none';	
		}
	}
	
}


//**********************   Billboard *******************//
var billboardImgArray = new Array();
function billboardInitialise(divId) {
	if (divId) {
		var displayDiv = document.getElementById(divId);
		if (displayDiv != null) {
			billboardImgArray = displayDiv.getElementsByTagName('img');
		}
	}
	
	if (billboardImgArray.length) {
	//	trace('billboard');
		billboardImgArray[0].style.display="block";
		for (var i=1; i<billboardImgArray.length; i++) {
			billboardImgArray[i].style.display="none";
		}
		billboardRun();
	}
}
var billboardTimeout=null;
function billboardRun() {
	billboardImgArray[0].style.display = "block";
	billboardTimeout = window.setInterval('billboardRotate()',3500);
}

var nextBillboard=0;
var thisBillboard = 0;
function billboardRotate() {
	thisBillboard = nextBillboard;
	for (var i=0; i<billboardImgArray.length; i++) {
		
		if ( i == thisBillboard ) {
			billboardImgArray[i].style.display = "block";
			nextBillboard = i+1;
			if ( (nextBillboard >= billboardImgArray.length) ) {
				nextBillboard = 0;
			}
		} else {
			billboardImgArray[i].style.display = "none";
		}
	}
	
}
//**********************   End Billboard *******************//



function sharethis(id,url,title)
{
txt='<a href="http://www.facebook.com/sharer.php?u='+url+'" target="_blank" title="Facebook">'
txt=txt+'<img src="/lib/graphics/share_facebook.gif" border="0" width="16px" height="16px" style="margin-right:4px" /></a>';
txt=txt+'<a href="http://twitter.com/home?status=Currently reading '+url+'" target="_blank" title="Twitter">';
txt=txt+'<img src="/lib/graphics/share_twitter.gif" border="0" width="16px" height="16px" style="margin-right:4px" /></a>';
txt=txt+'<a href="mailto:?&amp;subject='+title+'&amp;body='+url+'" target="_blank" title="E-mail">';
txt=txt+'<img src="/lib/graphics/share_email.gif" border="0" width="16px" height="16px" style="margin-right:4px" /></a>';
txt=txt+'<a href="http://delicious.com/save?v=5&noui&jump=close&url='+url+'&title='+title+'" target="_blank" title="Delicious">';
txt=txt+'<img src="/images/share_delicious.gif" border="0" width="16px" height="16px" style="margin-right:4px" /></a>';
txt=txt+'<a href="http://www.reddit.com/submit?url='+url+'" target="_blank" title="Reddit">';
txt=txt+'<img src="/lib/graphics/share_reddit.gif" border="0" width="16px" height="16px" style="margin-right:4px" /></a>';
txt=txt+'<a href="http://digg.com/submit?url='+url+'&amp;title='+title+'" target="_blank" title="Digg">';
txt=txt+'<img src="/lib/graphics/share_digg.gif" border="0" width="16px" height="16px" style="margin-right:4px" /></a>';
txt=txt+'<a href="http://www.stumbleupon.com/submit?url='+url+'%26title%3D'+title+'" target="_blank" title="Stumbleupon">';
txt=txt+'<img src="/lib/graphics/share_stumbleupon.gif" border="0" width="16px" height="16px" /></a>';
document.getElementById(id).innerHTML=txt;
}

















