// Ergonet JavaScript Document for Aria 5
// Copyright Ergonet Ltd. Glastonbury, 2010.
// Author: Sam Welbourne, Jay Pritchard.
// Notes:
// no overlap with conducta/lib. - see libOverlapConducta.js
// the following set in dataSourceA5Editor.php : 
// var targetDivA5 = $targetDivA5 
var dataSourcePathA5=dataSourceA5; // declared in header 
var conducta = false;
var lookupDomain=document.domain;
var xmlhttp=false;
var pathForTheRecord='';
var xhr=true;
var autoXhrMode=true;
var locationTimeoutId=null;
var lastHash='';
var permDivs = Array('menuPermanent','menuTop','notesDiv','debugDiv','errorNote','indexContainer','bubbleBar','ergonetMenu','bubbleManager','loggedInMessage','logoutLinkContainer','onPageMediaPlayer');
var excludeFromDepth = Array('menuPermanent','menuTop','notesDiv','debugDiv','errorNote','indexContainer','bubbleBar','loggedInMessage','logoutLinkContainer','onPageMediaPlayer');
var browser;
var browserVersion;
var operatingSystem;
var xmlhttp;
var oldBrowserMode=false;
var IE6=false;
var operatingSystem='', browser='', browserVersion='', IE=false, ns=false, win=false, mac=false;
var isLoggedIn=false;

function bubManScrollGet() {
	var bubManCont = document.getElementById('bubManContent');
	if (bubManCont != null) {
		return bubManCont.scrollTop;
	} else {
		return 0;
	}
	
}
function bubManScrollSet(val) {
	var bubManCont = document.getElementById('bubManContent');
	if (bubManCont != null) {
		bubManCont.scrollTop = val;
	}
}
function set_def_q() {
if (document.getElementById("def_td") != null) {
document.getElementById("def_td").bgColor = "#FF0000";
}
}
function previewpagepath() {
var root_path = '<?php echo $rooturl; ?>';
var obj = document.forms.page_form.pageurl;
var pagepath = obj.value;
var pathpreview_content = "<a href='"+root_path+pagepath+"' target='_blank'>"+root_path+pagepath+"</a>";
document.getElementById("pathpreview").innerHTML = pathpreview_content;
}
function addHtmToContent01(Htm) {
	var obj = document.forms.page_form.content01;
	var currentText = obj.value;
	obj.value = currentText+Htm;
	obj.focus();
}
function replaceLineReturns(m) {
	var obj = document.forms.page_form.content01;
	var currentText = obj.value;
	var lines_array = currentText.split('\n');
	if (lines_array.length > 1) {
		var n=0;
		var processedText = '';
		for(var i=0; i<lines_array.length; i++) {
			n= lines_array[i].length;
		//	alert(lines_array[i].substr((n-1),1));
			if (lines_array[i].substr((n-1),1) == ">") {
				processedText += lines_array[i]+"\n";
			} else {
				// if the next member of the array is void then only add </p>
				// if the next member of the array is not null then add <p>
				switch (m) {
				case 'p':
				if (!lines_array[i+1]) {
					processedText += lines_array[i]+"";
				} else {
					processedText += lines_array[i]+"</p>\n\n<p>";
				}
				break;
				case 'li':
				if (!lines_array[i+1]) {
					processedText += lines_array[i]+"</li>\n";
				} else {
					processedText += lines_array[i]+"\n<li>";
				}
				break;
				case 'br':
				if (!lines_array[i+1]) {
					processedText += lines_array[i]+"</br>\n";
				} else {
					processedText += lines_array[i]+"\n<br>";
				}
				break;
				}
			}
		}
	} else {
		processedText = currentText;
	}
//	processedText = currentText.replace(/([\r\n])+/g, "<br>\n");
//	alert(processedText);
	obj.value = processedText;
	obj.focus();
}
function replaceab() {
var a=document.getElementById('replacea').value;
var b=document.getElementById('replaceb').value;
var replacemessage="Replace '"+a+"' with '"+b+"' ?";
if (!b) {
	replacemessage= "Delete instances of: "+a;
}
	temp=window.confirm(replacemessage);
	if(temp == true) {
		var obj = document.forms.page_form.content01;
		var currentText = obj.value;
		//var searchobj = eval('/"'+a+'"/g');
		//a="'"+a+"'";
		var searchobj = new RegExp(a, "g");
		//alert(searchobj);
		processedText = currentText.replace(searchobj, b);
		obj.value = processedText;
	}
}
/*
/home/william/public_html/conf/aria5/app/dataSource.php?func=saveEns&newVariable=websitePreviewUrlA5&newValue=
*/
function ensmSave(varName) {
	//trace('varName: '+varName);
	var str = "";
	var obj=document.getElementById(varName);
	if (obj != null) {
		//trace('obj val: '+obj.value);
		if (obj.type=="checkbox") {
			var val = 'false';
			if (obj.checked) val='true';
			str = "&newVariable="+varName + "&newValue=" +val;
		} else {
			str = "&newVariable="+varName + "&newValue=" + obj.value;
			
		}
		//trace('str: '+str);
		str = dataSourcePathA5 + "?func=saveEns" + str;
//		trace(str);
		sendToServerAria5(str);
	}	
}

function setDefSetMode(sw) {
	// systemDefaultsList
	switch(sw) {
	case "domain":
		str = dataSourcePathA5 + "?func=systemDefaultsList&defSetMode=domain";
		sendToServerAria5(str);
	break;
	case "all":
		str = dataSourcePathA5 + "?func=systemDefaultsList&defSetMode=all";
		sendToServerAria5(str);
	break;
	default:
		var str = "<div id=\"systemDefaultsListWide\"><div class=\"defSetModeLinkDiv\"><a href=\"javascript:setDefSetMode('domain')\">Edit Settings for "+lookupDomain+"</a></div>";
		str += "<div class=\"defSetModeLinkDiv\"><a href=\"javascript:setDefSetMode('all')\">Edit Settings for all domains</a></div></div>";
		var systemDefaultsList = document.getElementById('systemDefaultsList');
		systemDefaultsList.innerHTML = str;
	break;
	}
}

function setValueOfInput(cntrl,val) {
	if (cntrl) {
		var obj = document.getElementById(cntrl);
		if (obj != null) {
			if (obj.type == 'checkbox') {
				if (val=='true') {
					obj.checked=true;
				} else {
					obj.checked=false;
				}
			} else {
				obj.value=val;
			}
		}
	}
	var obj = document.getElementById('ens_'+cntrl);
	if (obj != null) {
		obj.style.color='#FF0000';
	}
}

function aria5menu() {
	var str = "func=aria5menu";
	str = dataSourcePathA5 + "?" + str;
	sendToServerAria5(str);
}


var hiders = new Array('bubManContent','bubManMid','bubManTop','bubManCloseLink','bubManScrollDown');

function bubbleManager(bool) {
	//trace('bubbleManager');
	var bubMan = document.getElementById('bubbleManager');
	var bubManBot = document.getElementById('bubManBot');
	var bubManCont = document.getElementById('bubManContent');
	var obj = null;
	if (bubMan != null) {
		
		if (bool) {
			
			var str = "func=bubbleManager";
			str = dataSourcePathA5 + "?" + str;
			sendToServerAria5(str);

			if (bubMan.style.height != bubManMaxHeight+"%") {
				
				bubManSlide(true);
				bubManBot.style.backgroundImage="url(/lib/aria5/graphics/skin/default/bubManBot.png)";
				bubManBot.style.height="10%";
				
				for (var i=0; i<hiders.length; i++) {
					obj = document.getElementById(hiders[i]);
					if (obj != null) { obj.style.display='block'; }
				}
			
			}
		} else {
		//	bubMan.style.height='40px';
			bubManSlide(false);
			
		}
		
	}
}
function bubManScrollDown() {
	var bubManCont = document.getElementById('bubManContent');
	bubManCont.scrollTop += 100;
}
function bubManScrollUp() {
	var bubManCont = document.getElementById('bubManContent');
	bubManCont.scrollTop -= 100;
}

var bubManSlidePeriod=null;
var bubManSlideCount=1;
var bubManSlideMax=11;
var bubManHeight=0;
var bubManMaxHeight=90;
var bubManMinHeight=5;
var bubManObj = null;

function bubManSlide(bool) {
	
	bubManObj = document.getElementById('bubbleManager');
	bubManSlideCount=1;
	if (bubManObj != null) {
		if (bool) {
			bubManHeight = bubManMinHeight;
		} else {
			bubManHeight = bubManMaxHeight;
		}
		bubManSlidePeriod = window.setInterval(bubManSlideStep,30,bool);
	}
}

function bubManSlideStep(bool) {
	if (bubManSlideCount < bubManSlideMax) {
		var inc = (bubManMaxHeight - bubManMinHeight) / bubManSlideMax;
		if (bool) {
			// opening
			bubManObj.style.height = (inc*bubManSlideCount)+"%";
			bubManObj.style.opacity = (((100 / bubManSlideMax)*bubManSlideCount)/100);
		} else {
			// closing
			bubManObj.style.height = (bubManMaxHeight - (inc*bubManSlideCount))+"%";
			bubManObj.style.opacity = (1- ((100 / bubManSlideMax)*bubManSlideCount)/100);
		}
		bubManSlideCount++;
	} else {
		bubManSlideCount=1;
		window.clearInterval(bubManSlidePeriod);
		if (bool) {
			bubManObj.style.height = bubManMaxHeight+"%";
			bubManObj.style.opacity = 1;
		} else {
			bubManObj.style.height = bubManMinHeight+"%";
			bubManObj.style.opacity = 1;
			var bubManBot = document.getElementById('bubManBot');
			bubManBot.style.backgroundImage="none";
			var bubManCont = document.getElementById('bubManContent');
			
			bubManBot.style.height="40px";
			bubManCont.innerHTML='';
			
			for (var i=0; i<hiders.length; i++) {
				obj = document.getElementById(hiders[i]);
				if (obj != null) { obj.style.display='none'; }
			}
			
		}
	}
}

var shakes=7;
var shakeCounter=1;
var loginDivObj = null;
var shakeInterval = null;

function animateLoginFail() {
	loginDivObj = document.getElementById('loginDiv');
	if (loginDivObj != null) {
		//shakeLoginDiv();
		shakeInterval = window.setInterval(shakeLoginDiv,60);
	}
}

function shakeLoginDiv() {
	if (shakeCounter / 2 != Math.floor(shakeCounter / 2)) {
		loginDivObj.style.left = (loginDivObj.offsetLeft + 5) + 'px';
	} else {
		loginDivObj.style.left = (loginDivObj.offsetLeft - 5) + 'px';	
	}
	
	shakeCounter ++;
	if (shakeCounter > shakes) {
		shakeCounter = 1;
		window.clearInterval(shakeInterval);
	} 
}

function ergonetMenu() {
	var obj=document.getElementById('ergonetMenu');
	var obj1=document.getElementById('ergMenuMid');
	var obj2=document.getElementById('ergMenuBot');
	if (obj != null) {
		obj.style.zIndex=1000;
		if (obj.offsetHeight != 20) {
			obj.style.height = '20px';
			if (obj1 != null) {
				obj1.style.display='none';
			}
			if (obj2 != null) {
				obj2.style.display='none';
			}
		} else {
			var h = '250px';
			if (isLoggedIn) {h = '450px';}
			obj.style.height = h;
			if (obj1 != null) {
				obj1.style.display='block';
			}
			if (obj2 != null) {
				obj2.style.display='block';
			}
		}
	}
}
function logoutLink() {
	var obj = document.getElementById('logoutLinkContainer');
	if (obj != null) {
		obj.innerHTML = "<a href='?logout'>Log Off</a>";	
	}
}
function userNameFocus() {
	window.setTimeout("userNameFocusNow()",1000);
}
function userNameFocusNow() {
	var obj = document.getElementById('username');
	if (obj !=null) {
		obj.focus();
	} else {
		//trace('missing username field');	
	}
}
function passwordFocus() {
	var obj = document.getElementById('password');
	if (obj !=null) {
		obj.focus();
	} else {
//		trace('missing password field');	
	}
}

function contactSolo(adrid,p) {
	if (!p) p=0;
	var str = "func=contactSolo&adrid="+ adrid+"&p="+p;
	str = dataSourcePathA5 + "?" + str;
	sendToServerAria5(str);
}

function initSideMenu() {
	var str = "func=initSideMenu";
	str = dataSourcePathA5 + "?" + str;
	sendToServerAria5(str);
}
function setMyCommunity() {
	var str = "func=initCommunity";
	str = dataSourcePathA5 + "?" + str;
	sendToServerAria5(str);
}

function submitHomeSearchForm() {
	var str = '';
	var fldArr = new Array('homeSeachArea', 'homeFilterSelect', 'homeSearchString');
	var obj='';
	for (var i=0; i<fldArr.length; i++) {
		if (obj = document.getElementById(fldArr[i])) {
			if (str) {str += '&'; }
			str += fldArr[i]+'='+obj.value;
		}
	}
	if (str){
		//trace('homeIndex&'+str);
		sendFunc('homeIndex&'+str);
	}
}
function homeIndexFirst() { sendFunc('homeIndexFirst'); }
function homeIndexPrevious() { sendFunc('homeIndexPrevious'); }
function homeIndexNext() { sendFunc('homeIndexNext'); }
function homeIndexLast() { sendFunc('homeIndexLast'); }

//function userManage() { sendFunc('userManage'); }
function userSolo(uid) { sendToServerAria5(dataSourcePathA5 + "?func=userSolo&uid="+ uid);}
function bookingSolo(bkid) { sendToServerAria5(dataSourcePathA5 + "?func=bookingSolo&bkid="+ bkid);}

function bookingEdit() { sendFunc('bookingEdit'); }
function bookingFinancial() { sendFunc('bookingFinancial'); }
function bookingEngagement() { sendFunc('bookingEngagement'); }
function bookingContract() { sendFunc('bookingContract'); }
function bookingContact() { sendFunc('bookingContact'); }
function bookingSales() { sendFunc('bookingSales'); }
function bookingPurchasing() { sendFunc('bookingPurchasing'); }
function bookingFunctions() { sendFunc('bookingFunctions'); }

function diaryDay() { sendFunc('diaryDay'); }
function diaryDayEdit() { sendFunc('diaryDayEdit'); }
function diaryDayEditNext() { sendFunc('diaryDayEditNext'); }
function diaryDayEditPrev() { sendFunc('diaryDayEditPrev'); }
function diaryDayNext() { sendFunc('diaryDayNext'); }
function diaryDayPrevious() { sendFunc('diaryDayPrevious'); }
function diaryDaySave() { sendFunc('diaryDaySave'); }
function diaryMonth() { sendFunc('diaryMonth'); }
function diaryMonthNext() { sendFunc('diaryMonthNext'); }
function diaryMonthPrevious() { sendFunc('diaryMonthPrevious'); }
function diaryYear() { sendFunc('diaryYear'); }
function diaryYearNext() { sendFunc('diaryYearNext'); }
function diaryYearPrev() { sendFunc('diaryYearPrev'); }
function diaryMonthDayEdit() { sendFunc('diaryMonthDayEdit'); }
function diaryMonthDayEditNext() { sendFunc('diaryMonthDayEditNext'); }
function diaryMonthDayEditPrev() { sendFunc('diaryMonthDayEditPrev'); }
function diaryMonthDayEditSave() { sendFunc('diaryMonthDayEditSave'); }
function diaryYearSymbolEdit() { sendFunc('diaryYearSymbolEdit'); }
function diaryYearSymbolEditSave() { sendFunc('diaryYearSymbolEditSave'); }

function artistPreview() { sendFunc('artistPreview'); }
function artistEdit() { sendFunc('artistEdit'); }
function artistDetails() { sendFunc('artistDetails'); }
function artistSkills() { sendFunc('artistSkills'); }
function artistStatus() { sendFunc('artistStatus'); }
function artistMeasurements() { sendFunc('artistMeasurements'); }
function artistAssociations() { sendFunc('artistAssociations'); }
function artistFunctions() { sendFunc('artistFunctions'); }
function artistUploads() { sendFunc('artistUploads'); }

function artistSolo(aid) { sendToServerAria5(dataSourcePathA5 + "?func=artistSolo&aid="+ aid);}

function wbSetPage(str) { 
	//trace(dataSourcePathA5 + "?func=wbSetPage&"+ str);
	sendToServerAria5(dataSourcePathA5 + "?func=wbSetPage&"+ str);
}
function wbPageSolo(str) { 
	sendToServerAria5(dataSourcePathA5 + "?func=wbPageSolo&"+ str);
}

/* tony */
function userCommandGroupSet(appid,cgid,uid) { 
	trace("userCommandGroupSet&appid="+ appid + "&cgid="+ cgid + "&uid="+uid);
	sendFunc("userCommandGroupSet&appid="+ appid + "&cgid="+ cgid + "&uid="+uid); 
	
}
function userCommandDenialSet(comid,uid) { sendFunc("userCommandDenialSet&comid="+ comid + "&uid="+uid); }  
function userPreview() { sendFunc("userPreview"); }
function userNew() { sendFunc("userNew"); }
function userDelete() { sendFunc("userDelete"); }

function userEdit() { sendFunc("userEdit"); }
function userCommandGroups() { sendFunc("userCommandGroups"); }
function userProjectGroups() { sendFunc("userProjectGroups"); }
function userFileSystem() { sendFunc("userFileSystem"); }
function userContact() { sendFunc("userContact"); }
function userDenials() { sendFunc("userDenials"); }
function userFunctions() { sendFunc("userFunctions"); }

function userList() { sendFunc("userList"); } // not needed normally ? init effectively
function userListFirst() { sendFunc("userListFirst"); }
function userListPrevious() { sendFunc("userListPrevious"); }
function userListNext() { sendFunc("userListNext"); }
function userListLast() { sendFunc("userListLast"); }
//function userListSearch() { sendFunc("userListSearch,userListFirst"); } // called using post
function userListFilter() { sendFunc("userListFilter,userListFirst"); }
function userListClearSearch() { sendFunc("userListClearSearch,userListFirst"); }

function projectList() { sendFunc('projectListView'); }
function projectSolo(prjid) { sendFunc("projectSolo&prjid="+ prjid); }
function projectListFirst() { sendFunc('projectListFirst'); }
function projectListPrevious() { sendFunc('projectListPrevious'); }
function projectListNext() { sendFunc('projectListNext'); }
function projectListLast() { sendFunc('projectListLast'); }
function projectListSearch() { sendFunc('projectListSearch'); }
function projectListClearSearch() { sendFunc('projectListClearSearch'); }
function projectListFilter() { sendFunc('projectListFilter'); }

function projectEdit() { sendFunc('projectEdit'); }
function projectGroups() { sendFunc('projectGroups'); }
function projectMembers() { sendFunc('projectMembers'); }
function projectDiary() { sendFunc('projectDiary'); }

function projectNew() { sendFunc('projectNew'); }
function projectDelete() { sendFunc('projectDelete'); }
function projectPictureLookup() { sendFunc('projectPictureLookup'); }
function projectGroupNew() { sendFunc('projectGroupNew'); }
function projectGroupSave() { sendFunc('projectGroupSave'); }
function projectGroupDelete() { sendFunc('projectGroupDelete'); }
function projGrpMemAdd() { sendFunc('projGrpMemAdd'); }
function projGrpMemDelete() { sendFunc('projGrpMemDelete'); }
function projDiaryMonthViewPrevious() { sendFunc('projDiaryMonthViewPrevious'); }
function projDiaryMonthViewNext() { sendFunc('projDiaryMonthViewNext'); }
function projDiaryMonthViewDayEdit() { sendFunc('projDiaryMonthViewDayEdit'); }
function projDiaryMonthViewDayPrevious() { sendFunc('projDiaryMonthViewDayPrevious'); }
function projDiaryMonthViewDayNext() { sendFunc('projDiaryMonthViewDayNext'); }

function todo() { sendFunc('todo'); }
function todoList() { sendFunc('todoList'); }
function todoSolo(todoid) { sendFunc('todoSolo&todoid='+todoid); }

function courseList() { sendFunc('courseList'); }
function courseListFirst() { sendFunc('courseListFirst'); }
function courseListPrevious() { sendFunc('courseListPrevious'); }
function courseListNext() { sendFunc('courseListNext'); }
function courceListLast() { sendFunc('courceListLast'); }
function courseListSearch() { sendFunc('courseListSearch'); }
function courseListFilter() { sendFunc('courseListFilter'); }

function courseSolo(crsid) { sendFunc('courseSolo&crsid='+crsid); }
function courseSoloEdit() { sendFunc('courseSoloEdit'); }
function courseSoloDetails() { sendFunc('courseSoloDetails'); }
function courseSoloSchedule() { sendFunc('courseSoloSchedule'); }
function courseSoloRegister() { sendFunc('courseSoloRegister'); }
function courseSoloTerms() { sendFunc('courseSoloTerms'); }
function courseSoloProduct() { sendFunc('courseSoloProduct'); }

function actSolo(bid) { sendFunc('actSolo&bid='+bid); }
function actSoloEdit() { sendFunc('actSoloEdit'); }
function actSoloDetails() { sendFunc('actSoloDetails'); }


// and while we're at it lets do a load of list init calls
function eventList() { sendFunc('eventList'); }
function eventSolo(bkid) { sendFunc('eventSolo&bkid='+bkid); }
function bookingList() { sendFunc('bookingList'); }
function forumList() { sendFunc('forumList'); }
function threadList() { sendFunc('threadList'); }
function messageList() { sendFunc('messageList'); }
function shoutList() { sendFunc('shoutList'); }
function contactList() { sendFunc('contactList'); }
function contactHistoryList() { sendFunc('contactHistoryList'); }





function productNew() { sendFunc('productNew'); }
function productDelete() {
	var pidObj = document.getElementById('pid');
	if ( pidObj != null ) {
		var pid = pidObj.value;
		if (pid) {
			sendFunc('productDelete&pid='+pid);
		} else {
			trace('No Product Id');
		}
	}
}
function productDuplicate() { sendFunc('productDuplicate'); }
function productOwnership() { sendFunc('productOwnership'); }
function productSuspend() { sendFunc('productSuspend'); }
function productPreview() { sendFunc('productPreview'); }
function catalogueList() { sendFunc('catalogueList'); }
function productList() { sendFunc('productList'); }
function productVersions() { sendFunc('productVersions'); }
function productPlaylists() { sendFunc('productPlaylists'); }
function productTracks() { sendFunc('productTracks'); }
function productCategories() { sendFunc('productCategories'); }
function productAssets() { sendFunc('productAssets'); }
function productEditor() {sendFunc('productEditor');}
function productSolo(pid) { sendFunc('productSolo&pid='+pid); }

function lookup(tbl,fld) { 
	var rand = Math.floor((Math.random())*1000000);
	var str = "lookup&getBub=8&rcdset="+tbl+"&obj="+fld+"&rand="+rand;
	sendFunc(str);
}
function lookupFirst() { sendFunc('lookupFirst'); }
function lookupPrevious() { sendFunc('lookupPrevious'); }
function lookupNext() { sendFunc('lookupNext'); }
function lookupLast() { sendFunc('lookupLast'); }
function lookupSearch() { sendFunc('lookupSearch'); }
function lookupFilter() { sendFunc('lookupFilter'); }
function lookupclearSearch() { sendFunc('lookupclearSearch'); }


function paymentGatewayList() { sendFunc('paymentGatewayList'); }
function shopFeedList() { sendFunc('shopFeedList'); }
function jobsList() { sendFunc('jobsList'); }
function orderList() { sendFunc('orderList'); }
function despatchList() { sendFunc('despatchList'); }





function websiteConstantList() { sendFunc('websiteConstantList'); }
function websiteFeedList() { sendFunc('websiteFeedList'); }
function websiteMenuList() { sendFunc('websiteMenuList'); }
function websiteMenuRowList() { sendFunc('websiteMenuRowList'); }
function websitePageList() { sendFunc('websitePageList'); }
function mediaPlayerList() { sendFunc('mediaPlayerList'); }
function playlistList() { sendFunc('playlistList'); }
function trackList() { sendFunc('trackList'); }
function videoList() { sendFunc('videoList'); }
function galleryList() { sendFunc('galleryList'); }
function imageList(domReq) { sendFunc('imageList&domReq='+domReq); }
function mediaFeedList() { sendFunc('mediaFeedList'); }
function artistList() { sendFunc('artistList'); }
function actList() { sendFunc('actList'); }
function scheduleList() { sendFunc('scheduleList'); }
function fileList() { sendFunc('fileList'); }
function screenLabelList() { sendFunc('screenLabelList'); }
function recordsetList() { sendFunc('recordsetList'); }
function archiveList() { sendFunc('archiveList'); }
function systemDefaultList() { sendFunc('systemDefaultList'); }

// and for each list view it's method handles
function todoListFirst() { sendFunc('todoListFirst'); }
function todoListPrevious() { sendFunc('todoListPrevious'); }
function todoListNext() { sendFunc('todoListNext'); }
function todoListLast() { sendFunc('todoListLast'); }
function todoListSearch() { sendFunc('todoListSearch'); }
function todoListFilter() { sendFunc('todoListFilter'); }
function eventListFirst() { sendFunc('eventListFirst'); }
function eventListPrevious() { sendFunc('eventListPrevious'); }
function eventListNext() { sendFunc('eventListNext'); }
function eventListLast() { sendFunc('eventListLast'); }
function eventListSearch() { sendFunc('eventListSearch'); }
function eventListFilter() { sendFunc('eventListFilter'); }
function bookingListFirst() { sendFunc('bookingListFirst'); }
function bookingListPrevious() { sendFunc('bookingListPrevious'); }
function bookingListNext() { sendFunc('bookingListNext'); }
function bookingListLast() { sendFunc('bookingListLast'); }
function bookingListSearch() { sendFunc('bookingListSearch'); }
function bookingListFilter() { sendFunc('bookingListFilter'); }
function forumListFirst() { sendFunc('forumListFirst'); }
function forumListPrevious() { sendFunc('forumListPrevious'); }
function forumListNext() { sendFunc('forumListNext'); }
function forumListLast() { sendFunc('forumListLast'); }
function forumListSearch() { sendFunc('forumListSearch'); }
function forumListFilter() { sendFunc('forumListFilter'); }
function threadListFirst() { sendFunc('threadListFirst'); }
function threadListPrevious() { sendFunc('threadListPrevious'); }
function threadListNext() { sendFunc('threadListNext'); }
function threadListLast() { sendFunc('threadListLast'); }
function threadListSearch() { sendFunc('threadListSearch'); }
function threadListFilter() { sendFunc('threadListFilter'); }
function messageListFirst() { sendFunc('messageListFirst'); }
function messageListPrevious() { sendFunc('messageListPrevious'); }
function messageListNext() { sendFunc('messageListNext'); }
function messageListLast() { sendFunc('messageListLast'); }
function messageListSearch() { sendFunc('messageListSearch'); }
function messageListFilter() { sendFunc('messageListFilter'); }
function shoutListFirst() { sendFunc('shoutListFirst'); }
function shoutListPrevious() { sendFunc('shoutListPrevious'); }
function shoutListNext() { sendFunc('shoutListNext'); }
function shoutListLast() { sendFunc('shoutListLast'); }
function shoutListSearch() { sendFunc('shoutListSearch'); }
function shoutListFilter() { sendFunc('shoutListFilter'); }
function contactListFirst() { sendFunc('contactListFirst'); }
function contactListPrevious() { sendFunc('contactListPrevious'); }
function contactListNext() { sendFunc('contactListNext'); }
function contactListLast() { sendFunc('contactListLast'); }
function contactListSearch() { sendFunc('contactListSearch'); }
function contactListFilter() { sendFunc('contactListFilter'); }
function contactHistoryListFirst() { sendFunc('contactHistoryListFirst'); }
function contactHistoryListPrevious() { sendFunc('contactHistoryListPrevious'); }
function contactHistoryListNext() { sendFunc('contactHistoryListNext'); }
function contactHistoryListLast() { sendFunc('contactHistoryListLast'); }
function contactHistoryListSearch() { sendFunc('contactHistoryListSearch'); }
function contactHistoryListFilter() { sendFunc('contactHistoryListFilter'); }
function catalogueListFirst() { sendFunc('catalogueListFirst'); }
function catalogueListPrevious() { sendFunc('catalogueListPrevious'); }
function catalogueListNext() { sendFunc('catalogueListNext'); }
function catalogueListLast() { sendFunc('catalogueListLast'); }
function catalogueListSearch() { sendFunc('catalogueListSearch'); }
function catalogueListFilter() { sendFunc('catalogueListFilter'); }
function productListFirst() { sendFunc('productListFirst'); }
function productListPrevious() { sendFunc('productListPrevious'); }
function productListNext() { sendFunc('productListNext'); }
function productListLast() { sendFunc('productListLast'); }
function productListSearch() { sendFunc('productListSearch'); }
function productListFilter() { sendFunc('productListFilter'); }
function assetsListFirst() { sendFunc('assetsListFirst'); }
function assetsListPrevious() { sendFunc('assetsListPrevious'); }
function assetsListNext() { sendFunc('assetsListNext'); }
function assetsListLast() { sendFunc('assetsListLast'); }
function assetsListSearch() { sendFunc('assetsListSearch'); }
function assetsListFilter() { sendFunc('assetsListFilter'); }

function paymentGatewayListFirst() { sendFunc('paymentGatewayListFirst'); }
function paymentGatewayListPrevious() { sendFunc('paymentGatewayListPrevious'); }
function paymentGatewayListNext() { sendFunc('paymentGatewayListNext'); }
function paymentGatewayListLast() { sendFunc('paymentGatewayListLast'); }
function paymentGatewayListSearch() { sendFunc('paymentGatewayListSearch'); }
function paymentGatewayListFilter() { sendFunc('paymentGatewayListFilter'); }
function shopFeedListFirst() { sendFunc('shopFeedListFirst'); }
function shopFeedListPrevious() { sendFunc('shopFeedListPrevious'); }
function shopFeedListNext() { sendFunc('shopFeedListNext'); }
function shopFeedListLast() { sendFunc('shopFeedListLast'); }
function shopFeedListSearch() { sendFunc('shopFeedListSearch'); }
function shopFeedListFilter() { sendFunc('shopFeedListFilter'); }
function jobsListFirst() { sendFunc('jobsListFirst'); }
function jobsListPrevious() { sendFunc('jobsListPrevious'); }
function jobsListNext() { sendFunc('jobsListNext'); }
function jobsListLast() { sendFunc('jobsListLast'); }
function jobsListSearch() { sendFunc('jobsListSearch'); }
function jobsListFilter() { sendFunc('jobsListFilter'); }
function orderListFirst() { sendFunc('orderListFirst'); }
function orderListPrevious() { sendFunc('orderListPrevious'); }
function orderListNext() { sendFunc('orderListNext'); }
function orderListLast() { sendFunc('orderListLast'); }
function orderListSearch() { sendFunc('orderListSearch'); }
function orderListFilter() { sendFunc('orderListFilter'); }
function despatchListFirst() { sendFunc('despatchListFirst'); }
function despatchListPrevious() { sendFunc('despatchListPrevious'); }
function despatchListNext() { sendFunc('despatchListNext'); }
function despatchListLast() { sendFunc('despatchListLast'); }
function despatchListSearch() { sendFunc('despatchListSearch'); }
function despatchListFilter() { sendFunc('despatchListFilter'); }
function websiteConstantListFirst() { sendFunc('websiteConstantListFirst'); }
function websiteConstantListPrevious() { sendFunc('websiteConstantListPrevious'); }
function websiteConstantListNext() { sendFunc('websiteConstantListNext'); }
function websiteConstantListLast() { sendFunc('websiteConstantListLast'); }
function websiteConstantListSearch() { sendFunc('websiteConstantListSearch'); }
function websiteConstantListFilter() { sendFunc('websiteConstantListFilter'); }
function websiteFeedListFirst() { sendFunc('websiteFeedListFirst'); }
function websiteFeedListPrevious() { sendFunc('websiteFeedListPrevious'); }
function websiteFeedListNext() { sendFunc('websiteFeedListNext'); }
function websiteFeedListLast() { sendFunc('websiteFeedListLast'); }
function websiteFeedListSearch() { sendFunc('websiteFeedListSearch'); }
function websiteFeedListFilter() { sendFunc('websiteFeedListFilter'); }
function websiteMenuListFirst() { sendFunc('websiteMenuListFirst'); }
function websiteMenuListPrevious() { sendFunc('websiteMenuListPrevious'); }
function websiteMenuListNext() { sendFunc('websiteMenuListNext'); }
function websiteMenuListLast() { sendFunc('websiteMenuListLast'); }
function websiteMenuListSearch() { sendFunc('websiteMenuListSearch'); }
function websiteMenuListFilter() { sendFunc('websiteMenuListFilter'); }
function websiteMenuRowListFirst() { sendFunc('websiteMenuRowListFirst'); }
function websiteMenuRowListPrevious() { sendFunc('websiteMenuRowListPrevious'); }
function websiteMenuRowListNext() { sendFunc('websiteMenuRowListNext'); }
function websiteMenuRowListLast() { sendFunc('websiteMenuRowListLast'); }
function websiteMenuRowListSearch() { sendFunc('websiteMenuRowListSearch'); }
function websiteMenuRowListFilter() { sendFunc('websiteMenuRowListFilter'); }
function websitePageListFirst() { sendFunc('websitePageListFirst'); }
function websitePageListPrevious() { sendFunc('websitePageListPrevious'); }
function websitePageListNext() { sendFunc('websitePageListNext'); }
function websitePageListLast() { sendFunc('websitePageListLast'); }
function websitePageListSearch() { sendFunc('websitePageListSearch'); }
function websitePageListFilter() { sendFunc('websitePageListFilter'); }
function mediaPlayerListFirst() { sendFunc('mediaPlayerListFirst'); }
function mediaPlayerListPrevious() { sendFunc('mediaPlayerListPrevious'); }
function mediaPlayerListNext() { sendFunc('mediaPlayerListNext'); }
function mediaPlayerListLast() { sendFunc('mediaPlayerListLast'); }
function mediaPlayerListSearch() { sendFunc('mediaPlayerListSearch'); }
function mediaPlayerListFilter() { sendFunc('mediaPlayerListFilter'); }
function playlistListFirst() { sendFunc('playlistListFirst'); }
function playlistListPrevious() { sendFunc('playlistListPrevious'); }
function playlistListNext() { sendFunc('playlistListNext'); }
function playlistListLast() { sendFunc('playlistListLast'); }
function playlistListSearch() { sendFunc('playlistListSearch'); }
function playlistListFilter() { sendFunc('playlistListFilter'); }
function trackListFirst() { sendFunc('trackListFirst'); }
function trackListPrevious() { sendFunc('trackListPrevious'); }
function trackListNext() { sendFunc('trackListNext'); }
function trackListLast() { sendFunc('trackListLast'); }
function trackListSearch() { sendFunc('trackListSearch'); }
function trackListFilter() { sendFunc('trackListFilter'); }
function videoListFirst() { sendFunc('videoListFirst'); }
function videoListPrevious() { sendFunc('videoListPrevious'); }
function videoListNext() { sendFunc('videoListNext'); }
function videoListLast() { sendFunc('videoListLast'); }
function videoListSearch() { sendFunc('videoListSearch'); }
function videoListFilter() { sendFunc('videoListFilter'); }
function galleryListFirst() { sendFunc('galleryListFirst'); }
function galleryListPrevious() { sendFunc('galleryListPrevious'); }
function galleryListNext() { sendFunc('galleryListNext'); }
function galleryListLast() { sendFunc('galleryListLast'); }
function galleryListSearch() { sendFunc('galleryListSearch'); }
function galleryListFilter() { sendFunc('galleryListFilter'); }
function imageListFirst() { sendFunc('imageListFirst'); }
function imageListPrevious() { sendFunc('imageListPrevious'); }
function imageListNext() { sendFunc('imageListNext'); }
function imageListLast() { sendFunc('imageListLast'); }
function imageListSearch() { sendFunc('imageListSearch'); }
function imageListFilter() { sendFunc('imageListFilter'); }
function mediaFeedListFirst() { sendFunc('mediaFeedListFirst'); }
function mediaFeedListPrevious() { sendFunc('mediaFeedListPrevious'); }
function mediaFeedListNext() { sendFunc('mediaFeedListNext'); }
function mediaFeedListLast() { sendFunc('mediaFeedListLast'); }
function mediaFeedListSearch() { sendFunc('mediaFeedListSearch'); }
function mediaFeedListFilter() { sendFunc('mediaFeedListFilter'); }

function artistListFirst() { sendFunc('artistListFirst'); }
function artistListPrevious() { sendFunc('artistListPrevious'); }
function artistListNext() { sendFunc('artistListNext'); }
function artistListLast() { sendFunc('artistListLast'); }
function artistListSearch() { sendFunc('artistListSearch'); }
function artistListFilter() { sendFunc('artistListFilter'); }

function actListFirst() { sendFunc('actListFirst'); }
function actListPrevious() { sendFunc('actListPrevious'); }
function actListNext() { sendFunc('actListNext'); }
function actListLast() { sendFunc('actListLast'); }
function actListSearch() { sendFunc('actListSearch'); }
function actListFilter() { sendFunc('actListFilter'); }

function scheduleListFirst() { sendFunc('scheduleListFirst'); }
function scheduleListPrevious() { sendFunc('scheduleListPrevious'); }
function scheduleListNext() { sendFunc('scheduleListNext'); }
function scheduleListLast() { sendFunc('scheduleListLast'); }
function scheduleListSearch() { sendFunc('scheduleListSearch'); }
function scheduleListFilter() { sendFunc('scheduleListFilter'); }
function fileSolo(fileid) { sendFunc('fileSolo&fileid='+fileid);}

function fileListFirst() { sendFunc('fileListFirst'); }
function fileListPrevious() { sendFunc('fileListPrevious'); }
function fileListNext() { sendFunc('fileListNext'); }
function fileListLast() { sendFunc('fileListLast'); }
function fileListSearch() { sendFunc('fileListSearch'); }
function fileListFilter() { sendFunc('fileListFilter'); }

function screenLabelListFirst() { sendFunc('screenLabelListFirst'); }
function screenLabelListPrevious() { sendFunc('screenLabelListPrevious'); }
function screenLabelListNext() { sendFunc('screenLabelListNext'); }
function screenLabelListLast() { sendFunc('screenLabelListLast'); }
function screenLabelListSearch() { sendFunc('screenLabelListSearch'); }
function screenLabelListFilter() { sendFunc('screenLabelListFilter'); }
function recordsetListFirst() { sendFunc('recordsetListFirst'); }
function recordsetListPrevious() { sendFunc('recordsetListPrevious'); }
function recordsetListNext() { sendFunc('recordsetListNext'); }
function recordsetListLast() { sendFunc('recordsetListLast'); }
function recordsetListSearch() { sendFunc('recordsetListSearch'); }
function recordsetListFilter() { sendFunc('recordsetListFilter'); }
function archiveListFirst() { sendFunc('archiveListFirst'); }
function archiveListPrevious() { sendFunc('archiveListPrevious'); }
function archiveListNext() { sendFunc('archiveListNext'); }
function archiveListLast() { sendFunc('archiveListLast'); }
function archiveListSearch() { sendFunc('archiveListSearch'); }
function archiveListFilter() { sendFunc('archiveListFilter'); }
function systemDefaultListFirst() { sendFunc('systemDefaultListFirst'); }
function systemDefaultListPrevious() { sendFunc('systemDefaultListPrevious'); }
function systemDefaultListNext() { sendFunc('systemDefaultListNext'); }
function systemDefaultListLast() { sendFunc('systemDefaultListLast'); }
function systemDefaultListSearch() { sendFunc('systemDefaultListSearch'); }
function systemDefaultListFilter() { sendFunc('systemDefaultListFilter'); }
// well those were the list view method handlers
// ... phew .. but we forgot all the clear search commands
function bookingListClearSearch() { sendFunc('bookingListClearSearch'); }
function todoListClearSearch() { sendFunc('todoListClearSearch'); }
function courseListClearSearch() { sendFunc('courseListClearSearch'); }
function eventListClearSearch() { sendFunc('eventListClearSearch'); }
function forumListClearSearch() { sendFunc('forumListClearSearch'); }
function threadListClearSearch() { sendFunc('threadListClearSearch'); }
function messageListClearSearch() { sendFunc('messageListClearSearch'); }
function shoutListClearSearch() { sendFunc('shoutListClearSearch'); }
function contactListClearSearch() { sendFunc('contactListClearSearch'); }
function contactHistoryListClearSearch() { sendFunc('contactHistoryListClearSearch'); }
function catalogueListClearSearch() { sendFunc('catalogueListClearSearch'); }
function productListClearSearch() { sendFunc('productListClearSearch'); }
function assetsListClearSearch() { sendFunc('assetsListClearSearch'); }
function paymentGatewayListClearSearch() { sendFunc('paymentGatewayListClearSearch'); }
function shopFeedListClearSearch() { sendFunc('shopFeedListClearSearch'); }
function jobsListClearSearch() { sendFunc('jobsListClearSearch'); }
function orderListClearSearch() { sendFunc('orderListClearSearch'); }
function despatchListClearSearch() { sendFunc('despatchListClearSearch'); }
function websiteConstantListClearSearch() { sendFunc('websiteConstantListClearSearch'); }
function websiteFeedListClearSearch() { sendFunc('websiteFeedListClearSearch'); }
function websiteMenuListClearSearch() { sendFunc('websiteMenuListClearSearch'); }
function websiteMenuRowListClearSearch() { sendFunc('websiteMenuRowListClearSearch'); }
function websitePageListClearSearch() { sendFunc('websitePageListClearSearch'); }
function mediaPlayerListClearSearch() { sendFunc('mediaPlayerListClearSearch'); }
function playlistListClearSearch() { sendFunc('playlistListClearSearch'); }
function trackListClearSearch() { sendFunc('trackListClearSearch'); }
function videoListClearSearch() { sendFunc('videoListClearSearch'); }
function galleryListClearSearch() { sendFunc('galleryListClearSearch'); }
function mediaFeedListClearSearch() { sendFunc('mediaFeedListClearSearch'); }
function artistListClearSearch() { sendFunc('artistListClearSearch'); }
function actListClearSearch() { sendFunc('actListClearSearch'); }
function scheduleListClearSearch() { sendFunc('scheduleListClearSearch'); }
function fileListClearSearch() { sendFunc('fileListClearSearch'); }
function userListClearSearch() { sendFunc('userListClearSearch'); }
function screenLabelListClearSearch() { sendFunc('screenLabelListClearSearch'); }
function recordsetListClearSearch() { sendFunc('recordsetListClearSearch'); }
function archiveListClearSearch() { sendFunc('archiveListClearSearch'); }
// that'll do for now on the 'clearSearch front !!

//tony epasses functions
function ticketList() { sendFunc('ticketList'); }
function ticketSolo(ticid) { sendFunc("ticketSolo&ticid="+ ticid); }
function ticketListFirst() { sendFunc('ticketListFirst'); }
function ticketListPrevious() { sendFunc('ticketListPrevious'); }
function ticketListNext() { sendFunc('ticketListNext'); }
function ticketListLast() { sendFunc('ticketListLast'); }
function ticketListSearch() { sendFunc('ticketListSearch'); }
function ticketListClearSearch() { sendFunc('ticketListClearSearch'); }
function ticketListFilter() { sendFunc('ticketListFilter'); }

function ticketPreview() { sendFunc('ticketPreview'); }
function ticketNew() { sendFunc('ticketNew'); }
function ticketEdit() { sendFunc('ticketEdit'); }
function ticketAdjust() { sendFunc('ticketAdjust'); }
function ticketAssign() { sendFunc('ticketAssign'); }
function ticketDelete() { sendFunc('ticketDelete'); }



function sendFunc(f) { sendToServerAria5(dataSourcePathA5 + "?func="+f); }

function setLibrary(libId) {
	sendFunc("setLibrary&libId="+ libId);
}
function setSubject(libId,libsId) {
	sendFunc("setSubject&libId="+libId+"&libsId="+ libsId);
}

function in_array(needle, haystack, strict) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: in_array('van', ['Kevin', 'van', 'Zonneveld']);
    // *     returns 1: true
 
    var found = false, key, strict = !!strict;
 
    for (key in haystack) {
        if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {
            found = true;
            break;
        }
    }
 
    return found;
}

function getAllBubbles(t) {
	// these are all gonna get removed - change of bubble Wrap.
//	trace('getAllBubbles('+t+') for recording purposes');
	var container = document.getElementById(targetDivA5);
	var bubblesArray = Array();
	if (container != null) {
		var elements = container.getElementsByTagName('div');
		for (var i=0; i<elements.length; i++) {
		//	
			if (elements[i].id != null && elements[i].id != '' && document.getElementById(elements[i].id) != null ) {
				
				if (elements[i].parentNode==container) {
					
					if ( !in_array(elements[i].id, permDivs, true)) {
						// must be of class 'bubble'
						
						if (elements[i].className == 'bubble') {
							
								bubblesArray.push(elements[i]);
					//			trace(elements[i].id);
							
						}
					}
				}
			}
		}
	}
	return bubblesArray;
}
function getAllDepthBubbles() {
	var container = document.getElementById(targetDivA5);
	var bubblesArray = Array();
	if (container != null) {
		var elements = container.getElementsByTagName('div');
		for (var i=0; i<elements.length; i++) {
			if ((elements[i].className == "bubble" ||
					elements[i].id == "bubbleManager" ||
						elements[i].id == "ergonetMenu")) {
//			if (elements[i].id != null && elements[i].id != '' && document.getElementById(elements[i].id) != null ) {
				
				if (elements[i].parentNode==container) {
					
					if ( !in_array(elements[i].id, excludeFromDepth, true)) {
						bubblesArray.push(elements[i]);
					}
				}
			}
		}
	}
	return bubblesArray;
}
function getNonAnchoredBubbles(t) {
	// these are all gonna get faded - change of bubble Wrap.
//trace('getNonAnchoredBubbles('+t+')');
	var container = document.getElementById(targetDivA5);
	var bubblesArray = Array();
	var found=false;
	if (container != null) {
		var elements = container.getElementsByTagName('div');
		for (var i=0; i<elements.length; i++) {
		//	
			if (elements[i].id != null && elements[i].id != '' && document.getElementById(elements[i].id) != null ) {
				
				if (elements[i].parentNode==container) {
					
					if ( !in_array(elements[i].id, permDivs, true)) {
						// must be of class 'bubble'
						
						if (elements[i].className == 'bubble') {
							/*
							if ( !in_array(elements[i],bubblesArray, true) &&
									!in_array(elements[i],bubbleAnchorArray,true)) {
								bubblesArray.push(elements[i]);
								//trace(elements[i].id);
							}*/
							found=false;
							for(var j=0; j<bubblesArray.length; j++) {
								if (elements[i].id == bubblesArray[j].id) {found=true; break;}
							}
							for(var j=0; j<bubbleAnchorArray.length; j++) {
								if (elements[i].id == bubbleAnchorArray[j].id) {found=true; break;}
							}
							if (!found) {
								bubblesArray.push(elements[i]);
							}
						}
					}
				}
			}
		}
//		trace('--');
	}
/*	var bubbleAnchorArrayString =  ""; //bubbleAnchorArray.join(', '); - no! objects
	for(var i=0; i<bubbleAnchorArray.length; i++) {
		bubbleAnchorArrayString += bubbleAnchorArray[i].id +', ';
	}
	trace('not in anchors: '+bubbleAnchorArrayString);
	var bubblesArrayString = ""; // bubblesArray.join(', '); - no! objects
	for(var i=0; i<bubblesArray.length; i++) {
		bubblesArrayString += bubblesArray[i].id +', ';
	}
	trace('fade these: '+bubblesArrayString);
	*/
	return bubblesArray;
}
var isFading=false;
var fadeValue=1;
var fadeOutTimeout=null;
var fadeArray = new Array();


//var fadeMonitorCounter=0;
// fadeBubbles bubFade.
function fadeOutBubbles() {
	fadeArray = getNonAnchoredBubbles('fade out');
	fadeOutTimeout = window.setTimeout("fadeOutBubblesStep()",20);
}
function fadeOutBubblesStep() {
	if (faderMode=='fade') {
//		fadeMonitorCounter++;
		//var fadeArray = getAllBubbles('fade out');
//trace('out '+fadeMonitorCounter);		
		if (fadeValue==1) { isFading=true; }
		fadeValue = fadeValue - 0.2;
		if (fadeValue>0.1 && isFading) {
			for (var i=0; i<fadeArray.length; i++) {
				fadeArray[i].style.opacity = fadeValue;
			}
			//trace('fade Out: '+fadeValue);
			fadeOutTimeout = window.setTimeout("fadeOutBubblesStep()",20);
		} else {
			for (var i=0; i<fadeArray.length; i++) {
				
				fadeArray[i].style.opacity = 0;
				
			}
			fadeValue=1;
			clearTimeout(fadeOutTimeout);
		}
	} else {
		
	}
}
// faderMode is the conducta control
var faderMode = "fade"; // or fade .. or whatever

var fadeInValue=0;
var fadeInTimeout=null;

// called by bubbleWrap->run()
function fadeInBubbles() {
	//fadeArray = getAllBubbles('fadeIn');
	//fadeMonitorCounter++;
//	trace('in '+fadeMonitorCounter);	
	fadeArray = getNonAnchoredBubbles('fadeIn');
//	trace('fade in: '+fadeArray.length);
	fadeInTimeout = window.setTimeout("fadeInBubblesStep()",20);
}
function fadeInBubblesStep() {
	if (faderMode=='fade') {
		// global fadeArray
		isFading=false;
		fadeInValue = fadeInValue + 0.2;
//		trace('fadeArrayLength: '+fadeArray.length);
		if (fadeInValue<1) {
			for (var i=0; i<fadeArray.length; i++) {
				
					fadeArray[i].style.opacity = fadeInValue;
		//			trace('opacity: '+fadeArray[i].id);
				
			}
			
			fadeInTimeout = window.setTimeout("fadeInBubblesStep()",20);
		} else {
			for (var i=0; i<fadeArray.length; i++) {
				fadeArray[i].style.opacity = 1;
			}
			fadeInValue=0;
			clearTimeout(fadeInTimeout);
		}
	} else {
		
	}
	//trace('fade In: '+fadeInValue);
}
function flushBubbles() {
/*
		flush removes all divs with class bubble
*/
	
	var container = document.getElementById(targetDivA5);
	var removeArray = getNonAnchoredBubbles('flushBubbles');
	
	/*
	if (container != null) {
		var elements = container.getElementsByTagName('div');
		for (var i=0; i<elements.length; i++) {
		//	
			if (elements[i].id != null && document.getElementById(elements[i].id) != null ) {
				
				if (elements[i].parentNode==container) {
					
					if ( !in_array(elements[i].id,permDivs,true)) {
						removeArray.push(elements[i]);
					}
				}
			}
		}
	}
	*/
	for (var i=0; i<removeArray.length; i++) {
		
		dropNode(removeArray[i].id);
		//trace('remove: '+removeArray[i].id);
		if (in_array(removeArray[i].id,bubDivIdArray,true)) {
			removeFromAppDivs(removeArray[i].id);
		}
		
	}
}
function removeFromAppDivs(id) {
	for (var i=0; i<bubDivIdArray.length; i++) {
		if (bubDivIdArray[i]==id) {
			bubDivIdArray.splice(i,1);
			break;
		}
	}

}
function reload(lcn) {
	window.location.href = lcn;
}

function createDivs() {
	var args = arguments;
	var node=null;
	for (var i=0; i<args.length; i++) {
	//	alert(args[i]);
		makeNode(args[i],targetDivA5);
		if ( !in_array(args[i], permDivs, true)) {
		//	trace(args[i]);
			bubDivIdArray.push(args[i]);
		}
	}
}
function isInDiv(parent,child) {
	if ( (parent == "container" || parent == "") && targetDivA5 ) {
		parent = targetDivA5;	
	}
	if (!targetDivA5) {
		trace("no targetDivA5 - see lib settings");	
	}
	var obj=document.getElementById(parent);

	
	if (obj!=null && child) {
		for (var i=0; i<obj.childNodes.length; i++) {
			var div = obj.childNodes[i].id;
			if (div) {
//				trace('found: '+div);
				if ( div==child	) {
	//				trace('found: '+child);
	
	// If the div in question is actually anchored it will be found in anchoredBubblesStore
	// if it is founf there - and the parent IS targetDivA5
					
					
						return true;	
				   
				}
			}
		}
	} else {
		trace('isInDiv error: parent: '+parent+', child: '+child);	
	}
//	trace('isInDiv returns false parent: '+parent+', child: '+child);
	if (obj!=null) {
		if (inAnchorStore(child)){
			return true;
		} else {
			return false;
		}
	} else {
			return false;
		}
	}
function inAnchorStore(findId) {
	var obj=document.getElementById('anchoredBubblesStore');
	if (obj != null) {
		for (var i=0; i<obj.childNodes.length; i++) {
			if (obj.childNodes[i].id==findId) {
				return true;
			} else {
				return false;
			}
		}
	}
}
function addToDiv(div,content) {
	//trace('div: '+div+', content: '+content.replace(/</g,""));
//	trace('addToDiv: '+div);
	if (div) {
		var obj = document.getElementById(div);
//		if (obj != null) {
//			content = content.replace(/<div/g, "\n<div"); // just to make code view easier.
//			obj.innerHTML = obj.innerHTML + "\n" + content;
//		}
		if (obj != null) {	
			var newElement=document.createElement('div');
			newElement.innerHTML=content;
			var element = newElement.firstChild;
			if (element != null) {
				element.style.opacity='0';
				obj.appendChild(element);
			}
		}
	}
}
function dropNode(id) {
	if (id) {
		var obj = document.getElementById(id);
		if (obj != null) {
			var par = obj.parentNode;
			if (par!=null) {
				par.removeChild(obj);
			}
		}
	}
}
function getNode(id) {
	if (id) {
		var obj = document.getElementById(id);
		if (obj!=null) { return obj; } else { return false; }
	}
}
function makeNode(id,parent) {
	if (parent == "container") {
		parent = targetDivA5;	
	}
	var pObj=null;
	if (pObj=getNode(parent)) {
		var nodeObj=null;
		if (nodeObj = getNode(id))  {
			// trace('node already exists: '+id);
		} else {
			var newElement=document.createElement('div');
			if (newElement != null) {
			//	newElement.className=id+'Div';
				newElement.id=id;
				pObj.appendChild(newElement);
				var n= pObj.childNodes.length;
				if (!in_array(id, permDivs, true)) {
					newElement.style.zIndex=n;
				}
			//	trace('z: '+n);
		//		getContent(pObj,id);
				return newElement;
			}
		}
	} else {
		trace('parent node not found: '+parent);
		return false;
	}
}
function makeNodeOfClass(id,parentID,clss) {
	if (parentID != null) {
		var pObj='';
		if (pObj=getNode(parentID)) {
			var nodeObj=null;
			if (nodeObj = getNode(id))  {
				// trace('node already exists: '+id);
			} else {
				var newElement=document.createElement('div');
				if (newElement != null) {
					newElement.className=clss;
					newElement.id=id;
					pObj.appendChild(newElement);
			//		getContent(pObj,id);
					return newElement;
				}
			}
		} else {
			trace('parent node not found: '+parentID);
			return false;
		}
	}
}

function init() {
	BrowserDetect.init();
	browserVersion=BrowserDetect.version;
	operatingSystem=BrowserDetect.OS;	
	browser=BrowserDetect.browser;
	//if (browser=="Explorer") { IE=true;  }  alert(browser);
	if (document.layers)
	  document.captureEvents(Event.MOUSEMOVE);
	if (document.layers || document.all)
	  document.onmousemove = getMouseXYA5;
	if (document.addEventListener)
	  document.addEventListener('mousemove', getMouseXYA5, true);	
		
	if (window.addEventListener) {
		window.addEventListener('DOMMouseScroll', wheel, false);
		window.onmousewheel = document.onmousewheel = wheel;
	}
	
	if (!conducta) {
		if( !window.XMLHttpRequest && window.ActiveXObject ) {
			window.XMLHttpRequest = function() {
			var a = [ 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP', 'Msxml2.XMLHTTP.3.0', 'Msxml2.XMLHTTP.4.0', 'Msxml2.XMLHTTP.5.0' ],
			i = a.length; 
			while(i--) 
			{
				try {
				return new ActiveXObject( a[i] );
				alert(a[i]);
				} catch (e) { alert(e); }
				}
				return null;
			};
		}
		if( window.XMLHttpRequest ) {
		 xmlhttp = new XMLHttpRequest();  
		}
		if (createXMLHttpObject() && autoXhrMode) {
			xhr=true;
			locationTimeoutId=window.setInterval('locationHandler()',100);
			var str = "func=home,";
		//	if (preFunc !='') { str += preFunc ; }
			str = dataSourcePathA5 + "?" + str;
			sendToServerAria5(str);
		}
	
		
		if (!window.addEventListener) {    
			window.addEventListener = function (type, listener, useCapture) {        
				attachEvent('on' + type, function() { listener(event); });    
			};
		} else {
			document.addEventListener('mousemove', getMouseXYA5, true);
		}
		
//		ergonetMenu();
	}
}

// function to preview content01 in the website builder.

useTinyMce = false;
useFCKeditor = false;
useCKeditor = true;
var editor;
/*

CKEDITOR.config.toolbar_Basic = [ [ 'Source', '-', 'Bold', 'Italic' ] ];
CKEDITOR.config.toolbar_Full = [
['Source','-','Save','NewPage','Preview','-','Templates'],
['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
'/',
['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
['Link','Unlink','Anchor'],
'/',
['Styles','Format','Font','FontSize'],
]; 

CKEDITOR.config.toolbar = 'Basic';
CKEDITOR.config.baseHref = 'http://www.yourSite.com/path/'
CKEDITOR.config.toolbarStartupExpanded = false; 
*/
function createCKeditor ( inDiv , textareaID ) {
	var inDivObj = document.getElementById(inDiv);
	if (inDivObj != null) {
		var content = inDivObj.innerHTML;
		var config = {
toolbar:
[
 ['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', 'Table', '-', 'Link', 'Unlink'],  ['UIColor']
]
};
		inDivObj.innerHTML = '';
		var thisEditor = CKEDITOR.appendTo( inDivObj, config, content );
		
	}
	return thisEditor;
}

function postBubbleData(formName) {
	var paramArray = new Array();
	var fldValuesArray = new Array();
	var checksArray = new Array();
	var fieldArray = new Array();
	
	// used for select-multiple
	var options = new Array();
	
	if (document.forms[formName] != null) {
		var n=document.forms[formName].elements.length;
		var paramsArray = new Array();
		var str='';
		
		
		if (useTinyMce) {
			/*
			
			tiny mce retrieval here
			plus 'normal' retrieval
			
			
			*/
			var cntr=0;
			for (var i=0; i<n; i++) {
				
				var element = document.forms[formName].elements[i];
				
				var read=true;
				if (element.type ==undefined || element.type =="submit") {
					read=false;
				} else {
					//trace('<br />'+element.name+" :: "+element.id+" :: "+element.type);
				}
				if (element !=null && read) {
					if (element.type!="textarea") {
						if (element.type!="checkbox") {
							fldValuesArray[i]=element.value;
							fieldArray[i]=element.id;
						} else {
							fieldArray[i]=element.id;
							if (element.checked) {
								fldValuesArray[i]=element.value;
							} else {
								fldValuesArray[i]=0;
							}
						}
					} else {
						var ed = tinyMCE.get(element.id);
					//	ed.getContent();
						ed.setProgressState(0);
						fldValuesArray[i]=ed.getContent();
						fieldArray[i]=element.id;
					}
				}
			}	
		} else if (useFCKeditor) {
			/*
			
			fck retrieval here
			
			
			*/
		} else if (useCKeditor) {
			/*
			
			CKeditor retrieval here
			
			*/
			var cntr=0;
			for (var i=0; i<n; i++) {
				
				var element = document.forms[formName].elements[i];
//				trace('<br />'+element.name+" :: "+element.id+" :: "+element.type);
				var read=true;
				if (element.type ==undefined || element.type =="submit") {
					read=false;
				} else {
					//trace('<br />'+element.name+" :: "+element.id+" :: "+element.type);
				}
				if (element !=null && read) {
										if (element.type!="checkbox" && element.type!="radio" && element.type!="select-multiple") {
						fldValuesArray[cntr]=element.value;
						fieldArray[cntr]=element.id;
						
					} else {
						if (element.type=="checkbox") {
							fieldArray[cntr]=element.id;
							if (element.checked) {
								fldValuesArray[cntr]=element.value;
							} else {
								fldValuesArray[cntr]=0;
							}
						}
						
						if (element.type=="radio") {
							
							if (element.checked) {
								fieldArray[cntr]=element.id;
								fldValuesArray[cntr]=element.value;
								
							} 
						}
						if (element.type == "select-multiple"){
							var h=0;
							for (var j=0; j < element.options.length; j++) {	
								if(element.options[j].selected){
									//trace("mselect"+element.options[j].value);
									options[h]=element.options[j].value;
									h++;
								}
							}
							fldValuesArray[cntr]=options;
							fieldArray[cntr]=element.id;
						}
						
					}
					cntr++;
			//		} else {

						// where it says 'element' in the string below it's the id of the field - e.g. content01A5
						/*
						
						var editor_data = editor.getData();
						fieldArray[i]=element.id;
						trace('editor fld: '+fieldArray[i]+', save: '+editor_data.substr(0,100)+"..");
						fldValuesArray[i]=editor_data;
						
						CKEDITOR.remove( editor );
						
						*/
//						CKEDITOR.instances.element.destroy();
//						CKEDITOR.instances.element=null;
//					}



				}

			}	
			if (editor) {
				var editor_data = editor.getData();
				i++;
				fieldArray[i]="content01A5";
		//		trace('editor fld: '+fieldArray[i]+', save: '+editor_data.substr(0,100)+"..");
				fldValuesArray[i]=editor_data;
				
				CKEDITOR.remove( editor );
			}
		} else {
			/*
			
			'normal' fields retrieval here
			
			
			*/
			var cntr=0;
			for (var i=0; i<n; i++) {
				
				var element = document.forms[formName].elements[i];
				
				var read=true;
				if (element.type ==undefined || element.type =="submit") {
					read=false;
				} else {
					//trace('<br />'+element.name+" :: "+element.id+" :: "+element.type);
				}
				
				if (element !=null && read) {
					
					if (element.type!="checkbox" && element.type!="radio" && element.type!="select-multiple") {
						fldValuesArray[cntr]=element.value;
						fieldArray[cntr]=element.id;
						
					} else {
						if (element.type=="checkbox") {
							fieldArray[cntr]=element.id;
							if (element.checked) {
								fldValuesArray[cntr]=element.value;
							} else {
								fldValuesArray[cntr]=0;
							}
						}
						
						if (element.type=="radio") {
							
							if (element.checked) {
								fieldArray[cntr]=element.id;
								fldValuesArray[cntr]=element.value;
								
							} 
						}
						if (element.type == "select-multiple"){
							var h=0;
							for (var j=0; j < element.options.length; j++) {	
								if(element.options[j].selected){
									//trace("mselect"+element.options[j].value);
									options[h]=element.options[j].value;
									h++;
								}
							}
							fldValuesArray[cntr]=options;
							fieldArray[cntr]=element.id;
						}
						
					}
					cntr++;
				}
			}	
		}
		
		var formSaveReport='';
		if (fieldArray.length>0 && fldValuesArray.length>0) {
			for (var i=0; i<fieldArray.length; i++) {
				if (fieldArray[i]) {
				paramArray.push(fieldArray[i] + "=" + fldValuesArray[i]);
				}
			}
		}
		if (checksArray.length>0 && chkValuesArray.length>0) {
			for (var i=0; i<checksArray.length; i++) {
				paramArray.push(checksArray[i] + "=" + chkValuesArray[i]);
			}
		}
		params = paramArray.join("&");
//trace('post bubble: '+params);
		if (params) {
		//	xhrPost(params);
			postToServerA5(params);
		}
	} else {
		alert('cannot find: '+formName);
	}
}

var sendToServerAria5Counter=0;

function sendToServerAria5(uri) {
//	trace('^^^^^^^^^^^  sendTo Server : '+sendToServerAria5Counter+' ^^^^^^^^^^^^<hr>');
	sendToServerAria5Counter++;
	// Create an XMLHttpRequest and open it.
	// send the request with it's parameter string 
	// the response will be in the form of a string of javascript function calls
	// the response is then evaluated using eval(string)
	//trace(uri.indexOf('recordBubPos'));
	if (uri.indexOf('recordBubPos')==-1) {
//	note("<a href='"+uri+"'>"+uri+"</a>");
	}
	if (uri) {
		if (uri.substr(0,1) != "/") { uri="/"+uri; };
		xmlhttp = null;
		createXMLHttpObject();
		pathForTheRecord=uri;
		xmlhttp.open("GET", uri, true);
		xmlhttp.onreadystatechange = evaluateServerResponse; // NOTE: No Brackets on the end or it will NOT work.
		xmlhttp.initialise;
		xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
		//trace(uri);
		xmlhttp.send(null);
	}
}

function postToServerA5(params) {
	var uri = dataSourcePathA5;
	if (uri.substr(0,1) != "/") { uri="/"+uri; };
 //trace('post: '+params);
//	note(uri);
	pathForTheRecord=uri+" ? POST ? "+params;
//trace('path: '+pathForTheRecord);
	xmlhttp = null;
	createXMLHttpObject();
	xmlhttp.open("POST", uri, true);
	xmlhttp.onreadystatechange = evaluateServerResponse; // note the absence of brackets!
	xmlhttp.initialise;
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
	xmlhttp.send(params);
}

function evaluateServerResponse() {
	//trace(xmlhttp.responseText);	
	if (xmlhttp != null) {
		if ( xmlhttp.readyState == 4) {
				
			if (xmlhttp.status == 200) {
					
					var xhrString = xmlhttp.responseText;
		
					xhrString = xhrString.replace("\n",'');
			//		trace(xhrString);
					if (xhrString.indexOf('<!DOCTYPE HTML PUBLIC')!=-1) {
						
						note('Server-side error! - Doctype received');
						
					}
					if (xhrString.indexOf('<b>Warning</b>:')!=-1) {
						note('Server-side error! - Warning ');
						var n = xhrString.indexOf('<b>Warning</b>:');
						var str = xhrString.substr(n);
						str = str.substr(0,str.indexOf('on line')+16);
						str=str.replace(/<b>/g,"<br/><b>");
						trace(str);
				//		trace(xhrString);
						xhrString="";
			//			alert('server-side error! \n'+xhrString);
					}
					if (xhrString.indexOf('<b>Parse error</b>:')!=-1) {
						note('Server-side error! - parse error');
						
						trace(xhrString);
						xhrString="";
					}
					if (xhrString.indexOf('<b>Fatal error</b>:')!=-1) {
						note('Server-side error! - Fatal error');
						
						trace(xhrString);
						xhrString="";
					}
					if (xhrString.indexOf('<b>Notice</b>:')!=-1) {
						note('Server-side Notice');				
						trace(xhrString);
						xhrString="";
					}
					if (xhrString) {
						try {
							var scrollVal = bubManScrollGet();
							eval(xhrString);
							bubManScrollSet(scrollVal);
							
							xhrString='';
							xmlhttp = null;
						}
						catch(err) {
						/*		
							var xhrArray = xhrString.split(";");
							for (var i=0; i<xhrArray.length; i++) {
								try {
									eval(xhrArray[i]);
								} catch(err) {
									note(err);
									trace('<textarea style="background-color:DDDDDD;width:900px;height:600px">'+(xhrArray[i])+'</textarea>');
									
								}
							}
				*/	
							note(err);
							trace(xmlhttp.responseText);
			//				trace(xhrString);
							xhrString='';
							xmlhttp = null;
						
						}
					}
				
			} else {
				if (xmlhttp.status==0) {
					
				} else {
					trace("Error! code: "+xmlhttp.status+"\npath: "+pathForTheRecord+"\nresponse: "+xmlhttp.responseText+"\n");
					xmlhttp = null;
					window.clearTimeout(noteTimeout);
				}
			} // end state 200
		} else {
			if (xmlhttp.readyState == 3) {
	//			alert("code: "+xmlhttp.readyState+"\nRequested path: "+pathForTheRecord);
			}	
			
	//		alert("code: "+xmlhttp.readyState+"\nRequested path: "+pathForTheRecord);
		} // end ready state 4
	}
}

var noteTimeout=null;
//  if conducta ..
function note(t) {
	var obj=document.getElementById('errorNote');
	if (obj != null) {
		obj.innerHTML = t;
		window.clearTimeout(noteTimeout);
		noteTimeout = window.setTimeout('clearNote()',4000);
	}
}
function clearNote() {
	var obj=document.getElementById('errorNote');
	window.clearTimeout(noteTimeout);
	if (obj != null) {
		obj.innerHTML = '';
	}
}
function getSearchResultBubble( com, bwid, arg, id ) {
	var str = "func="+com+"&getBub="+ bwid+"&"+arg+"="+ id;
	str = dataSourcePathA5 + "?" + str;
	sendToServerAria5(str);
}
function getBubble( com, bwid ) {
	// does targetDiv exist ? if no then send a param to request it.
	var str = "func="+com+"&getBub="+ bwid;
	str = dataSourcePathA5 + "?" + str;
	sendToServerAria5(str);
}

var listPopArray = new Array();
var popListTargetObj = null;
var listPopTimeout = null;
function populateListAnimate(d,t) {
	var element = document.getElementById(d);
//	trace("text: "+t);
	clearTimeout(listPopTimeout);
	if (element != null) {
		element.innerHTML='';
		listPopArray = t.split("<div class=\"popList ");
		popListTargetObj = element;
		listPopTimeout = window.setTimeout("popList()",1);
	}	
	
}
function popList() {
	// animate drawing the list out down the page
	clearTimeout(listPopTimeout);
	if (listPopArray.length) {
		
		popListTargetObj.innerHTML += "<div class=\"popList " + listPopArray.shift();
		listPopTimeout = window.setTimeout("popList()",1);
	} else {
		
	}
}
var fadeList=null;
var listContent='';
var listDivId='';
var fadeListScrollSwitch=false;
function populateListFade(d,t,scr) {
	var element = document.getElementById(d);
	if (element != null) {
		fadeList=element;
		listContent=t;
		listDivId=d;
		if (scr) {
			fadeListScrollSwitch = true;
		} else {
			fadeListScrollSwitch = false;
		}
		fadeOutList();
	}
}
var isFadingList=false;
var fadeValueList=1;
var fadeOutTimeoutList=null;
function fadeOutList() {
	clearTimeout(fadeOutTimeoutList);
	if (fadeValueList==1) { isFadingList=true; }
	fadeValueList = fadeValueList - 0.2;
	if (fadeValueList>0.3 && isFadingList) {
		fadeList.style.opacity = fadeValueList;
		fadeOutTimeoutList = window.setTimeout("fadeOutList()",5);
	} else {
		fadeList.style.opacity = 0;
		fadeValueList=1;
		if (!fadeListScrollSwitch) {
			fadeList.innerHTML=listContent;	
		} else {
			populateListAnimate(listDivId,listContent);
		}
		fadeInTimeoutList = window.setTimeout("fadeInList()",10);
	}
}
var fadeInValueList=0;
var fadeInTimeoutList=null;
function fadeInList() {
	clearTimeout(fadeInTimeoutList);
	isFadingList=false;
	fadeInValueList = fadeInValueList + 0.2;
	if (fadeInValueList<1) {
		fadeList.style.opacity = fadeInValueList;
		fadeInTimeoutList = window.setTimeout("fadeInList()",50);
	} else {
		fadeList.style.opacity = 1;
		fadeInValueList=0;
	}
}
// lib functions by Sam Welbourne -- see also in dataSource.php
// lib functions from Jay Pritchard -- see also in dataSource.php

var popFormJsObj = new Object();
var my_store_elements 		= null;
var my_form_element_objs 	= new Object();
var my_form_element_tagnames 	= new Object();
var my_form_mixed_objs 		= new Object();


function initialiseFormElements() {
	
	popFormJsObj=new Object();
	if (document.getElementById('form_element_store')) {
		my_store_elements = document.getElementById('form_element_store').getElementsByTagName('*');
	}
	for (y=0;y<=my_store_elements.length-1;y++){
		elementname		=	my_store_elements[y].getAttribute('name');
		if( (elementname=='') || (elementname==null) || (elementname=='null') ){
			// do nothing
		}else{
			my_form_element_tagnames[elementname]	=	my_store_elements[y].nodeName;
			testnode	=	my_store_elements[y].parentNode;
			for(var j=0;j<20;j++){
				testnodename	=	testnode.nodeName;
				if(testnodename == 'SPAN'){
					my_form_mixed_objs[elementname]	=	testnode.childNodes;
					break;
				}else{
					testnode	= testnode.parentNode;
				}
			}
			my_form_element_objs[elementname]	=	my_store_elements[y];
		}
	}
}

//Assign form element to settings item based on datatype
var popFormJsObj = new Object();

function populateForm(divId,formcontent){	
	if (formcontent) {
		for (y in formcontent) {
			this_elementname				=	uitypes[datatypes[formcontent[y].datatype].uitid].element_name;
			form_element_source				=	my_form_element_objs[this_elementname];
			// target, named form element target
			form_fragment_source			=	my_form_mixed_objs[this_elementname];
			// peers and children within the templated uiType see formElements.php
			formfielddata					=	(formcontent[y].value!='')?formcontent[y].value:'';
			var thisfieldname				=	formcontent[y].name;
			labeltext		=	(formcontent[y].label!='')?formcontent[y].label:'{No label }';
			//labeltext		=  '['+formcontent[y].datatype+'] '+labeltext;
			
//			labeltext		=  '<span style="color:#FFFFFF">'+formcontent[y].name.substr(0,(formcontent[y].name.length -2))+'</span> '+labeltext;
			var theLabelDiv = document.createElement('DIV');
			theLabelDiv.innerHTML = labeltext;
			
			
			
			
			theLabelDiv.className="aria5LabelDiv";
			document.getElementById(divId).appendChild(theLabelDiv);
			var elementref=copyFragment(divId,form_fragment_source,this_elementname);
			var eventString = "";
			var eventArray = new Array();
			if (elementref == null) {
				
		//		trace( "null element: "+labeltext);
				
			} else {
				
				elementref.setAttribute('id',thisfieldname);
				elementref.setAttribute('name',thisfieldname);
				eventString = formcontent[y].events;
				eventArray = eventString.split("|");
				for(var i=0; i<eventArray.length-1; i+=2) {
					eventName = eventArray[i];
					eventCall = eventArray[i+1];
					if (eventName && eventCall) {
						elementref.setAttribute(eventName,eventCall);
					}
				}
				elementref.setAttribute('class',formcontent[y].cssClass);
				if (formcontent[y].isDisabled) {
					elementref.setAttribute('disabled','disabled');
				}
				if ( (datatypes[formcontent[y].datatype].uitid == 3) || (datatypes[formcontent[y].datatype].uitid == 4) ) {
					//trace(formcontent[y].optionArray);
					if ( (formcontent[y].optionArray != null) && (formcontent[y].optionArray.length==0) ) {
						elementref.options[0].text='not selectable';
					}
					if (formcontent[y].optionArray != null) {
						var n=0;
						for ( var i=0; i< formcontent[y].optionArray.length-1; i+=2 ) {
							var opt = new Option(formcontent[y].optionArray[i+1],formcontent[y].optionArray[i]);
							elementref.options[n]=opt;
							
							if (formcontent[y].value && (formcontent[y].optionArray[i]==formcontent[y].value) ) {
								elementref.selectedIndex = n;
							}
							n++;
						}
					} else {
						trace('popForm option array is null');	
					}
				}
				element_needs_value_setting		=	(1)?true:false;
				if (element_needs_value_setting) {
					switch(form_element_source.nodeName) {
					case 'TEXTAREA':
						elementref.innerHTML=htmlentities(formfielddata);
					break;
					case 'INPUT':
						if(elementref.getAttribute('type')=='checkbox'){
							if(this_elementname=='checkbox_2'){
									//1 or 0
									elementref.checked=(formfielddata=='1')?true:false;
								}else{
									// true or false
									elementref.checked=(formfielddata=='true')?true:false;
								}
						}else{
							elementref.setAttribute('value',formfielddata);
						}
					break;
					default:
						elementref.setAttribute('value',formfielddata);
					}					
				}
				if(uitypes[datatypes[formcontent[y].datatype].uitid].uiname=='textRow2'){
					// CUSTOM behaviour: Do box with link
					
					switch(valtypes[datatypes[formcontent[y].datatype].vtid].description)
					{
					case 'Top level directory':
						thisurl=niceprefixwithslash(formcontent[y].value);
					break;
					case 'url':
						thisurl=niceprefixwithprotocol(formcontent[y].value,'http://');
					break;
					case 'Email Address':
						thisurl=niceprefixwithprotocol(formcontent[y].value,'mailto://');
					break;
					case 'uri':
						thisurl=niceprefixwithslash(formcontent[y].value);
					break;		
					default:
						thisurl=niceprefixwithslash(formcontent[y].value);
					}
					elementref.nextSibling.nextSibling.setAttribute('href',thisurl);
					
				}
	
	
	
			}
		}
	}
}
function copyFragment(divId,mysourcefragment,elmntName) {
	var elementref=null;
	var obj = document.getElementById(divId);
	if (obj != null) {
		
		for (i=0; i<mysourcefragment.length; i++){
			var the_clone = mysourcefragment[i].cloneNode(true);
			obj.appendChild(the_clone);
			if(mysourcefragment[i].nodeName==my_form_element_tagnames[elmntName]){
				
			}
			if (mysourcefragment[i].name && (mysourcefragment[i].name == mysourcefragment[i].name)) {
			//	trace(' found name: '+mysourcefragment[i].name );
				elementref=obj.lastChild;
			}
			
		}
		if (!elementref) {
			trace('copyFragment not matched: '+my_form_element_tagnames[elmntName]+' in: '+elmntName);	
			for (i=0; i<mysourcefragment.length; i++){
				trace("name: "+elmntName);
			}
		}
	} else {
		trace('copyFragment "add to" obj not found: '+divId);	
	}
	return elementref;
}


function niceprefixwithslash(this_string){
	if (this_string) {
	return (this_string.charAt(0)=='/')?this_string:'/'+this_string;
	} else {
	return "";	
	}
}

function niceprefixwithprotocol(this_string,protocol){
	return this_string=(this_string.substring(0,7)==protocol)?this_string:protocol+this_string;
}

function node_editor(form_item){
	preceding_form_item_id=form_item.previousSibling.id;

	nodeAsString	=	(document.getElementById(preceding_form_item_id).value!='')?document.getElementById(preceding_form_item_id).value:'{not set}';
	govalidate(nodeAsString);
}

function govalidate(fragment)
{
  openwindow("http://validator.w3.org/check?prefill=1&doctype=XHTML 1.0 Strict&fragment="+escape(fragment),'validationresults');
} 

function openwindow(url,name)
{
  mywindow = window.open (url, name,"location=1,status=1,scrollbars=1,resizable=1, width=800,height=800");
 mywindow.focus();	
} 





function htmlentities (string, quote_style) {
    // Convert all applicable characters to HTML entities  
    // 
    // version: 909.322
    // discuss at: http://phpjs.org/functions/htmlentities    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: nobbler
    // +    tweaked by: Jack
    // +   bugfixed by: Onno Marsman    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    bugfixed by: Brett Zamir (http://brett-zamir.me)
    // +      input by: Ratheous
    // -    depends on: get_html_translation_table
    // *     example 1: htmlentities('Kevin & van Zonneveld');    // *     returns 1: 'Kevin &amp; van Zonneveld'
    // *     example 2: htmlentities("foo'bar","ENT_QUOTES");
    // *     returns 2: 'foo&#039;bar'
    var hash_map = {}, symbol = '', tmp_str = '', entity = '';
    tmp_str = string.toString();    
    if (false === (hash_map = this.get_html_translation_table('HTML_ENTITIES', quote_style))) {
        return false;
    }
    hash_map["'"] = '&#039;';    for (symbol in hash_map) {
        entity = hash_map[symbol];
        tmp_str = tmp_str.split(symbol).join(entity);
    }
        return tmp_str;
}

function get_html_translation_table (table, quote_style) {
    // Returns the internal translation table used by htmlspecialchars and htmlentities  
    // 
    // version: 909.322
    // discuss at: http://phpjs.org/functions/get_html_translation_table    // +   original by: Philip Peterson
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: noname
    // +   bugfixed by: Alex
    // +   bugfixed by: Marco    // +   bugfixed by: madipta
    // +   improved by: KELAN
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
    // +      input by: Frank Forte    // +   bugfixed by: T.Wild
    // +      input by: Ratheous
    // %          note: It has been decided that we're not going to add global
    // %          note: dependencies to php.js, meaning the constants are not
    // %          note: real constants, but strings instead. Integers are also supported if someone    
    // %          note: chooses to create the constants themselves.
    // *     example 1: get_html_translation_table('HTML_SPECIALCHARS');
    // *     returns 1: {'"': '&quot;', '&': '&amp;', '<': '&lt;', '>': '&gt;'}
    
    var entities = {}, hash_map = {}, decimal = 0, symbol = '';    var constMappingTable = {}, constMappingQuoteStyle = {};
    var useTable = {}, useQuoteStyle = {};
    
    // Translate arguments
    constMappingTable[0]      = 'HTML_SPECIALCHARS';    
    constMappingTable[1]      = 'HTML_ENTITIES';
    constMappingQuoteStyle[0] = 'ENT_NOQUOTES';
    constMappingQuoteStyle[2] = 'ENT_COMPAT';
    constMappingQuoteStyle[3] = 'ENT_QUOTES';
     useTable       = !isNaN(table) ? constMappingTable[table] : table ? table.toUpperCase() : 'HTML_SPECIALCHARS';
    useQuoteStyle = !isNaN(quote_style) ? constMappingQuoteStyle[quote_style] : quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT';
 
    if (useTable !== 'HTML_SPECIALCHARS' && useTable !== 'HTML_ENTITIES') {
        throw new Error("Table: "+useTable+' not supported');        // return false;
    }
 
    entities['38'] = '&amp;';
    if (useTable === 'HTML_ENTITIES') {        entities['160'] = '&nbsp;';
        entities['161'] = '&iexcl;';
        entities['162'] = '&cent;';
        entities['163'] = '&pound;';
        entities['164'] = '&curren;';        entities['165'] = '&yen;';
        entities['166'] = '&brvbar;';
        entities['167'] = '&sect;';
        entities['168'] = '&uml;';
        entities['169'] = '&copy;';        entities['170'] = '&ordf;';
        entities['171'] = '&laquo;';
        entities['172'] = '&not;';
        entities['173'] = '&shy;';
        entities['174'] = '&reg;';        entities['175'] = '&macr;';
        entities['176'] = '&deg;';
        entities['177'] = '&plusmn;';
        entities['178'] = '&sup2;';
        entities['179'] = '&sup3;';        entities['180'] = '&acute;';
        entities['181'] = '&micro;';
        entities['182'] = '&para;';
        entities['183'] = '&middot;';
        entities['184'] = '&cedil;';        entities['185'] = '&sup1;';
        entities['186'] = '&ordm;';
        entities['187'] = '&raquo;';
        entities['188'] = '&frac14;';
        entities['189'] = '&frac12;';        entities['190'] = '&frac34;';
        entities['191'] = '&iquest;';
        entities['192'] = '&Agrave;';
        entities['193'] = '&Aacute;';
        entities['194'] = '&Acirc;';        entities['195'] = '&Atilde;';
        entities['196'] = '&Auml;';
        entities['197'] = '&Aring;';
        entities['198'] = '&AElig;';
        entities['199'] = '&Ccedil;';        entities['200'] = '&Egrave;';
        entities['201'] = '&Eacute;';
        entities['202'] = '&Ecirc;';
        entities['203'] = '&Euml;';
        entities['204'] = '&Igrave;';        entities['205'] = '&Iacute;';
        entities['206'] = '&Icirc;';
        entities['207'] = '&Iuml;';
        entities['208'] = '&ETH;';
        entities['209'] = '&Ntilde;';        entities['210'] = '&Ograve;';
        entities['211'] = '&Oacute;';
        entities['212'] = '&Ocirc;';
        entities['213'] = '&Otilde;';
        entities['214'] = '&Ouml;';        entities['215'] = '&times;';
        entities['216'] = '&Oslash;';
        entities['217'] = '&Ugrave;';
        entities['218'] = '&Uacute;';
        entities['219'] = '&Ucirc;';        entities['220'] = '&Uuml;';
        entities['221'] = '&Yacute;';
        entities['222'] = '&THORN;';
        entities['223'] = '&szlig;';
        entities['224'] = '&agrave;';        entities['225'] = '&aacute;';
        entities['226'] = '&acirc;';
        entities['227'] = '&atilde;';
        entities['228'] = '&auml;';
        entities['229'] = '&aring;';        entities['230'] = '&aelig;';
        entities['231'] = '&ccedil;';
        entities['232'] = '&egrave;';
        entities['233'] = '&eacute;';
        entities['234'] = '&ecirc;';        entities['235'] = '&euml;';
        entities['236'] = '&igrave;';
        entities['237'] = '&iacute;';
        entities['238'] = '&icirc;';
        entities['239'] = '&iuml;';        entities['240'] = '&eth;';
        entities['241'] = '&ntilde;';
        entities['242'] = '&ograve;';
        entities['243'] = '&oacute;';
        entities['244'] = '&ocirc;';        entities['245'] = '&otilde;';
        entities['246'] = '&ouml;';
        entities['247'] = '&divide;';
        entities['248'] = '&oslash;';
        entities['249'] = '&ugrave;';        entities['250'] = '&uacute;';
        entities['251'] = '&ucirc;';
        entities['252'] = '&uuml;';
        entities['253'] = '&yacute;';
        entities['254'] = '&thorn;';        entities['255'] = '&yuml;';
    }
 
    if (useQuoteStyle !== 'ENT_NOQUOTES') {
        entities['34'] = '&quot;';    }
    if (useQuoteStyle === 'ENT_QUOTES') {
        entities['39'] = '&#39;';
    }
    entities['60'] = '&lt;';    entities['62'] = '&gt;';
 
 
    // ascii decimals to real symbols
    for (decimal in entities) {        symbol = String.fromCharCode(decimal);
        hash_map[symbol] = entities[decimal];
    }
    
    return hash_map;}
	// End Lib functions from Jay Pritchard
	
	/* from Aria4 js. */
function clearGalleryImageControl(imgObjId,cntrlID,labelObjId,glid) {
	var ob1 = document.getElementById(imgObjId);
	var ob2 = document.getElementById(cntrlID);
	var ob3 = document.getElementById(labelObjId);
	if (ob1 != null && ob2 != null && ob3 != null) {
		ob1.src='';
		ob1.alt='';
		ob2.value = 0;
		ob3.innerHTML='';
		var params = 'func=clearGalleryControl&glid='+glid;
		//postFormData('dataSource.php','page',params);
		postToServerA5(params);
	}
}
/*
html > body > div #container > div #productEditorDiv .bubble > div #productEditor .bubbleContent bubbleA > div #productSolo > div .prodSoloCol > div #productPictures > div #prodSoloPictureContent > div #prodSoloThumbnails > div .galleryEntry > img #imgCntrl9075
*/
function clearImageControl(imgObjId,cntrlID,labelObjId,pid) {
	var ob1 = document.getElementById(imgObjId);
	var ob2 = document.getElementById(cntrlID);
	var ob3 = document.getElementById(labelObjId);
	if (ob1 != null && ob2 != null && ob3 != null) {
		ob1.src='';
		ob1.alt='';
		ob2.value = 0;
		ob3.innerHTML='';
		var params = 'func=clearGalleryControl&pid='+pid;
		//postFormData('dataSource.php','page',params);
		postToServerA5(params);
	}
}
delayedArgs='';
getProductGalleryDelayedTimeout=null;
function flashUploadReturn() {
	var sw = flashUploadReturn.arguments[0];
	var pid = flashUploadReturn.arguments[1];
	delayedArgs='func=productSolo&pid='+pid;
	getProductGalleryDelayedTimeout = window.setTimeout('getDelayedCommand()',1000);
}
function getDelayedCommand() {
	// populate the gallery dic - it's called picid
	// retrieve the thumbnail file associated with the galleryline records that, in turn, are associated by quoting the pid.
	var params =delayedArgs;
	str = dataSourcePathA5 + "?" + params;
	sendToServerAria5(str);
//	getData('dataSource.php','page',params);
}
function clean(str) {
	if (str != '') {
		str = str.replace("&nbsp;"," ");
		str = str.replace("&pound;","GBP ");
		str = str.replace("&","and");
	}
	return str;
}

function expandCollapse(div,lbl,t,t1) {
	var obj=document.getElementById(div);
	var label = document.getElementById(lbl);
	if (obj != null) {
		obj=obj.style;
		if (obj.display=="none") {
			obj.display="block";
			if (label != null) {
				if (label.innerHTML.substr(1)=='>') {
					label.innerHTML="V"+label.innerHTML.substr(4);
				}
				if (t) {
					label.innerHTML=t;
				}
			}
		} else {
			obj.display="none";
			if (label != null) {
				if (label.innerHTML.substr(1)=='V') {
					label.innerHTML=">"+label.innerHTML.substr(1);
				}
				if (t1) {
					label.innerHTML=t1;
				}
			}
			
		}
	}
}




function postFormCollectData(formName,params) {
	var paramArray = new Array(params);
	var fldValuesArray = new Array();
	var checksArray = new Array();
	var fieldArray = new Array();
	var n=document.forms[formName].elements.length;
	var paramsArray = new Array();
	var str='';
	if (useTinyMce) {
		var cntr=0;
		for (var i=0; i<n; i++) {
			
			var element = document.forms[formName].elements[i];
			
			var read=true;
			if (element.type ==undefined || element.type =="submit") {
				read=false;
			} else {
				//trace('<br />'+element.name+" :: "+element.id+" :: "+element.type);
			}
			if (element !=null && read) {
				if (element.type!="textarea") {
					if (element.type!="checkbox") {
						fldValuesArray[i]=element.value;
						fieldArray[i]=element.id;
					} else {
						fieldArray[i]=element.id;
						if (element.checked) {
							fldValuesArray[i]=element.value;
						} else {
							fldValuesArray[i]=0;
						}
					}
				} else {
					var ed = tinyMCE.get(element.id);
				//	ed.getContent();
					ed.setProgressState(0);
					fldValuesArray[i]=ed.getContent();
					fieldArray[i]=element.id;
				}
			}
		}	
	} else if (useFCKeditor) {
		
	} else {
		var cntr=0;
		for (var i=0; i<n; i++) {
			
			var element = document.forms[formName].elements[i];
			
			var read=true;
			if (element.type ==undefined || element.type =="submit") {
				read=false;
			} else {
				//trace('<br />'+element.name+" :: "+element.id+" :: "+element.type);
			}
			
			if (element !=null && read) {
				if (element.type!="checkbox") {
					fldValuesArray[cntr]=element.value;
					fieldArray[cntr]=element.id;
					
				} else {
					fieldArray[cntr]=element.id;
					if (element.checked) {
						fldValuesArray[cntr]=element.value;
					} else {
						fldValuesArray[cntr]=0;
					}
				}
				cntr++;
			}
		}		
	}
	/*
		var boh =document.getElementById('boh');
		var bav =document.getElementById('bav');
		if (boh !=null) {
			fldValuesArray[cntr]=boh.value;
			fieldArray[cntr]="boh";
			cntr++;
		}
		if (bav !=null) {
			fldValuesArray[cntr]=bav.value;
			fieldArray[cntr]="bav";
		}
		*/
	var formSaveReport='';
	if (fieldArray.length>0 && fldValuesArray.length>0) {
		for (var i=0; i<fieldArray.length; i++) {
			paramArray.push(fieldArray[i] + "=" + fldValuesArray[i]);
		}
	}
	if (checksArray.length>0 && chkValuesArray.length>0) {
		for (var i=0; i<checksArray.length; i++) {
			paramArray.push(checksArray[i] + "=" + chkValuesArray[i]);
		}
	}
	params = paramArray.join("&");
//	trace(params);
	if (params) {
	//	xhrPost(params);
		//trace('path revision for Aria5 needed');
//		postFormData('dataSource.php','page',params);
		postToServerA5(params);
	}
}





function formSubmit(formName) {
	switch(formName) {
		case "productSoloForm":
		
		// see similar in /productBuilder.js postFormCollectDataProductBuilder()
		postFormCollectData("productSoloForm","func=productBuild");
	
		break;
		case "searchForm": break;
		case "lookupPopSearchForm": 
			var obj = document.getElementById('lss');
			if (obj != null) {
				var obj2=document.getElementById('rcdset');
				var rcdsetnm='';
				if (obj2 != null) {
					rcdsetnm=obj2.value;
				}
				
				var obj3=document.getElementById('obj');
				var targetObj='';
				if (obj3 != null) {
					targetObj=obj3.value;
				}
				
				var obj4=document.getElementById('imgObjId');
				var imgObjId='';
				if (obj4 != null) {
					imgObjId=obj4.value;
				}
				
				var obj4=document.getElementById('labelObjId');
				var labelObjId='';
				if (obj4 != null) {
					labelObjId=obj4.value;
				}
				
				var params='func=lookup&lss='+obj.value;
				params+='&rcdset='+rcdsetnm;
				params+='&obj='+targetObj;
				params+='&imgObjId='+imgObjId;
				params+='&labelObjId='+labelObjId;
		//		trace(params);
				//postFormData('dataSource.php','page',params);
				postToServerA5(params);
			} else { alert('no lss'); }
		break;
		case "complNewForm":
			var obj1 = document.getElementById('compnm');
			var obj2 = document.getElementById('complid');
			var obj3 = document.getElementById('complPid');
			var obj4 = document.getElementById('compNewCctid');
			if (obj1 !=null && obj2 != null && obj3 !=null && obj4 != null) {
				var params = 'func=addCompl&complid='+obj2.value+'&complPid='+obj3.value+'&compnm='+clean(obj1.value)+'&compNewCctid='+obj4.value;
				//postFormData('dataSource.php','page',params);
				postToServerA5(params);
			}
		break;
		case "productAttributeForm":
			var obj = document.getElementById('productAttributeUpdate');
			if (obj != null && obj.value=='comp') {
				var objArray = new Array('compnm','cunc','price','compBoh','compBav','compdur','compdn','compid','mcid','picid','bid','cctid','rcdstat','rcdpub','compPrice','compBid','compPicid','compMcid','compCctid','compCunc');
				var paramArray=new Array();
				for (var i=0; i<objArray.length; i++) {
					var obj=document.getElementById(objArray[i]);
					if (obj != null) {
						paramArray[i]=objArray[i]+'='+obj.value;
					}
				}
				var params = paramArray.join('&') + '&func=productVersionSolo&productAttributeUpdate=comp';
				//postFormData('dataSource.php','page',params);
				postToServerA5(params);
			} else {
				trace('productAttributeForm submit fault');
			}
		break;
		case "productVersionForm":
			var obj = document.getElementById('productVersionUpdate');
			if (obj != null && obj.value=='prdver') {
				//var objArray = new Array('compnm','cunc','price','compBoh','compBav','compdur','compdn','compid','mcid','picid','bid','cctid','rcdstat','rcdpub','compPrice','compBid','compPicid','compMcid','compCctid','compCunc');
				var objArray = new Array('prdverName','prdverCost','prdverPrice','prdverOnhand','prdverAvail','verid');
				var paramArray=new Array();
				for (var i=0; i<objArray.length; i++) {
					var obj=document.getElementById(objArray[i]);
					if (obj != null) {
						paramArray[i]=objArray[i]+'='+obj.value;
					}
				}
				var params = paramArray.join('&') + '&func=productVersionSolo&productVersionUpdate=prdver';
				trace(params);
				trace('path revision for Aria5 needed');
//				postFormData('dataSource.php','page',params);
			} else {
				trace('productVersionForm submit fault');
			}
		break;
		case "productPlaylistForm":
			var obj = document.getElementById('productPlaylistUpdate');
			if (obj != null && obj.value=='comp') {
				var objArray = new Array('compnm','cunc','compdur','compdn','compid','mcid','picid','bid','company','cctid','rcdstat','rcdpub');
				var paramArray=new Array();
				for (var i=0; i<objArray.length; i++) {
					var obj=document.getElementById(objArray[i]);
					if (obj != null) {
						paramArray[i]=objArray[i]+'='+obj.value;
					}
				}
				var params = paramArray.join('&') + '&func=playListSolo&productPlaylistUpdate=comp';
				//postFormData('dataSource.php','page',params);
				postToServerA5(params);
			} else {
				trace('productPlaylistForm submit fault');
			}
		break;
		case "productListSearchForm":  
			var obj = document.getElementById('plss');
			if (obj != null) {
				var obj2=document.getElementById('rcdsetnm');
				var rcdsetnm='';
				if (obj2 != null) {
					rcdsetnm=obj2.value;
				}
				var params='func=productList&plss='+obj.value;
				if (rcdsetnm) {
					params +='&rcdsetnm='+rcdsetnm;
				}
				//postFormData('dataSource.php','page',params);
				postToServerA5(params);
			} else { alert('no plss'); }
		break;
		case "inCatalogueListEditor":
			var obj0=document.getElementById('rid');
			var obj1=document.getElementById('rdn');
			var obj2=document.getElementById('parentCatalogueID');
			var obj3=document.getElementById('pathField');
			var obj4=document.getElementById('rcdstat');
			var obj5=document.getElementById('rcdpub');
			var obj6=document.getElementById('pcdn');

			if (useFCKeditor) {
				var inst = FCKeditorAPI.GetInstance("pcdn");
				var pcdnStr = inst.GetHTML();
			} else {
				var pcdnStr='';
			}
			var obj7=document.getElementById('picid1');
			var obj8=document.getElementById('picid2');
			var obj9=document.getElementById('sortorder');
			
			if (obj0 !=null) {
				var category = String(obj1.value);
				category = category.replace("&","and");
				//trace("category: "+category);
	//			var pcdn = String(obj6.value);
				pcdn = pcdnStr.replace("&","and");
				var params = "func=catalogueBuild&insertKey=rcdsetEditor&rid=";
				if (obj7 !=null) {
					params +=obj0.value + "&rdn="+category+"&parentCatalogueID="+obj2.value+"&pathField="+obj3.value+"&rcdstat="+obj4.value+"&rcdpub="+obj5.value +"&pcdn="+pcdn+"&picid1="+obj7.value+"&picid2="+obj8.value+"&sortorder="+obj9.value;
					
				} else {
					trace(obj0.value + "&rdn="+category+"&parentCatalogueID="+obj2.value+"&pathField="+obj3.value+"&rcdstat="+obj4.value+"&rcdpub="+obj5.value +"&pcdn="+pcdn+"&picid1= [ void ] &picid2="+obj8.value+"&sortorder="+obj9.value);
				}
				// func=catalogueBuild&insertKey=rcdsetEditor&rid=&add_field=&path_field=&rcdstat=&rcdpub=
				//alert(params);
				//postFormData('dataSource.php','page',params);
				postToServerA5(params);
			} else { }
		break;
		case "fileSoloForm":
			
		break;
	}
}
function addPct() {
	
}
function addCompl() {
	var obj0=document.getElementById('pid');
	if (obj0 !=null) {
		var params = "func=addCompl&pid="+obj0.value;
		//trace('path revision for Aria5 needed');
//		postFormData('dataSource.php','page',params);
		postToServerA5(params);
	}
}


function displayProductView(bool) {
	/*
	var obj=document.getElementById('pageBody');
	if (obj != null) {
		obj=obj.style;
		if (bool) {
			obj.display="block";
		} else {
			obj.display="none";
		}
	}
	*/
}
function displayListView(bool) {
	/*
	var obj=document.getElementById('listView');
	if (obj != null) {
		obj=obj.style;
		if (bool) {
			obj.display="block";
		} else {
			obj.display="none";
		}
	}
	*/
}
function displayCatalogView(bool) {
	/*
	var obj=document.getElementById('catalogView');
	if (obj != null) {
		obj=obj.style;
		if (bool) {
			obj.display="block";
		} else {
			obj.display="none";
		}
	}
	*/
}
function displayLibraryView(bool) {
	/*
	var obj=document.getElementById('libraryView');
	if (obj != null) {
		obj=obj.style;
		if (bool) {
			obj.display="block";
		} else {
			obj.display="none";
		}
	}
	*/
}
function displayInventoryView(bool) {
	/*
	var obj=document.getElementById('inventoryView');
	if (obj != null) {
		obj=obj.style;
		if (bool) {
			obj.display="block";
		} else {
			obj.display="none";
		}
	}
	*/
}
/*
function populate(d,t) {
	var obj=document.getElementById(d);
	if (obj != null) {
		obj.innerHTML = t;
	}
}
function note(t) {
	var obj=document.getElementById('notesDiv');
	if (obj != null) {
		obj.innerHTML = t;
	}
}*/
function populateParent(d,t) {
	//trace(d);
	var element = document.getElementById(d);
//	trace("text: "+t);
	if (element != null) {
		t = t.replace(/<div/g, "\n<div");
		element = element.parentNode;
		element.innerHTML = t;
	} else {
		// do this on the server - pre-empt this circumstance
		/*
		
		if $com->targetDiv does not exist then we need it to be forced into existance
		this only relates to use of the bubble Manager
		therefore when we call 'child' windows we can send the call including a switch for 'wrap in new bubble' true or false.
		
		*/
	}
}
function setValue(id,val) {
	var obj = document.getElementById(id);
	if (obj != null) {
		
		if (obj.type=='checkbox') {
			if (val==1) { obj.checked=true; } else { obj.checked=false; }
		} else if (obj.type=='select' || obj.type=='select-one') {
			if (obj.options.length > 0) {
				obj.options[0].selected = true;
			//	trace('name: '+obj.id+' val: '+val);
				for (var i=0; i<obj.options.length; i++) {
					if (obj.options[i].value == val) { obj.options[i].selected=true; }
				}
			}
		} else {
			obj.value = val;
		}
	}
}
function deleteCatRcd(pcid,desc) {
	temp=window.confirm("'"+desc+"'\ndelete this record?");
	if(temp == true) {
		var params = "func=catalogueBuild&deletePcid="+pcid;
		trace('path revision for Aria5 needed');
//		getData('dataSource.php','page',params);
	}
}
function addToCatalogue(pid) {
	obj = document.getElementById('newPrdPcid');
	if (obj != null) {
		var newPrdPcid = obj.value;
		if (newPrdPcid && pid) {
			var params = "func=productBuild&newPrdPcid="+newPrdPcid+"&pid="+pid;
			trace('path revision for Aria5 needed');
//			getData('dataSource.php','page',params);
		}
	}
}
function removeFromCatalogue(pid,pctlid) {
	if (pid && pctlid) {
		var params="func=productBuild&deletePctlid="+pctlid+"&pid="+pid;
		trace('path revision for Aria5 needed');
//		getData('dataSource.php','page',params);
	}
}
function newCatalogue() {
	var params="func=catalogueBuild&new=1";
	trace('path revision for Aria5 needed');
//	getData('dataSource.php','page',params);
}
function pctActive(pcid,active) {
	var activeStr = '0';
	if (!active || active==0) { activeStr='1'; }
	var params="func=viewCascadingCatalogue&activePcid="+pcid+"&active="+activeStr;
	trace('path revision for Aria5 needed');
	//getData('dataSource.php','page',params);
}

function lookupReturn( cntrlID, recordID, imgObjId, filePath, labelObjId, label ) {
	var idFld = document.getElementById(cntrlID);
	if (idFld != null) {
		idFld.value = recordID;
		var imgObj = document.getElementById(imgObjId);
		if (imgObj != null) {
			imgObj.src = '/'+filePath;
		}
		var labelObj = document.getElementById(labelObjId);
		if (labelObj != null) {
			labelObj.innerHTML = label;
		}
	} else {
		trace("Missing Object: "+cntrlID);
	}
}

function clearLookup() {
	populate('listView','');
}

function changeSubject(v,pid,p) {
	var params='func=productBuild&func=getSubjectList&subject='+v+'&pid='+pid+'&p='+p;
	trace('path revision for Aria5 needed');
	//getData('/aria/product/lib/associate.php','page',params);
}
function addAssociation(v,pid,p,id) {
	var params='func=productBuild&func=addAssociation&subject='+v+'&pid='+pid+'&p='+p+'&id='+id;
	trace('path revision for Aria5 needed');
	//getData('/aria/product/lib/associate.php','page',params);
}
function removeAssoc(v,pid,p,id) {
	var params='func=productBuild&func=removeAssociation&subject='+v+'&pid='+pid+'&p='+p+'&id='+id;
	trace('path revision for Aria5 needed');
	//getData('/aria/product/lib/associateImage.php','page',params);
}

function flashUploadReport(arg) {
	trace(arg);
	addPictureAssoc(arg);
}

function addPictureAssoc(arg) {
	var params='func=addAssociation&pid='+pid+'&uplFileName='+arg;
	trace('path revision for Aria5 needed');
	//getData('/aria/product/lib/associateImage.php','page',params);
}

// Files Application Solo
function play(url,n,ft,w,h) {
url += "&ft="+ft;
var openString = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1';
if (w>0 && h>0) {
openString += ',width='+w+',height='+h;
} else {
openString += ',width=400,height=100'; 
}
mywin = window.open(url,n,openString);
}
//"blowup('description','380px','60px','380px','194px')"
function blowup(n,x,y,x1,y1) {
	var obj = document.getElementById(n);
	if (obj != null) {
	obj = obj.style;
		if (obj.width==x) {
		obj.width=x1;
		} else {
		obj.width=x;
		}
		if (obj.height==y) {
		obj.height=y1;
		} else {
		obj.height=y;
		}
	}
}
function toggleviews(n) {
	var obj = document.getElementById(n);
	if (obj != null) {
		obj = obj.style;
		//alert(obj.visibility);
		if (obj.visibility=='visible') {
			obj.visibility='hidden';
		} else {
			obj.visibility='visible';
		}
	} else {
		alert('object not found: '+n);
	}
}

function imageTagRewrite(obj) {
	if (obj != null) {
		var alt = obj.alt;
		var title = obj.title;
		var src = title;
		var img = '<img src="'+src+'" alt="'+alt+'" title="'+alt+'" />'
		obj.parentNode.style.border="1px dashed Grey";
		
		obj.parentNode.innerHTML = img;
		
	//	trace('dunnit');
	}
}
	
function return_id(fld,rcdid,txt) {
	var obj1;
	var obj2;

	obj1=document.getElementById(fld);
	obj2=document.getElementById(fld+"Txt");

	if (obj1 != null) {
		obj1.value = rcdid;
	} else {
		trace("Selection Cannot be saved, Object not found: "+fld);
	}
	if (obj2 != null) {
		// obj2.value = txt;
		obj2.innerHTML = txt;
	} else {
		trace("Selection Cannot be saved, Object not found: "+fld+"Txt");
	}
}
function return_txt(fld,txt) {
	obj1=document.getElementById(fld);
	if (obj1 != null) {
		obj1.value = txt;
	}
}
function setCursor() {
	document.forms.search_form.ss.select();
}

	
	
	
	
	
	

