		
		// REGISTRATION AND MANAGEMENT CONSOLE
		// -----------------------++++++++++++++++++++++++++++-----------------------
		
		// If loading an existing account, init with an Account ID: init(AccountID);
		
		// -----------------------++++++++++++++++++++++++++++-----------------------
		
		
		var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();
		
		var iInvalidCount = 0;
		
		var iPrimaryStep = 1; // Indicates the current step on the timeline
		
		var lGlob_AccountID = null;
		var sGlob_EmailAddress = null;
		var sGlob_FullName = null;
		
		var sRegProxy = "";
		
		function get(s){
			return document.getElementById(s);
		}
		
		function validate(o,r,t,minimum,m){
		
			setValid(o); // As default, set as valid
			
			if(o.tagName == "SELECT"){ 
			// This is a SELECT element
				// Check not empty
				if(o.selectedIndex != -1){
					if((r == true || r == "true") && o[o.selectedIndex].value == ""){
						setInvalid(o,"Required field.");
						return false;
					}
				}
			}else{ 
			// This is NOT a SELECT element
				minimum = parseInt(minimum);
				// Check not empty
				if((r == true || r == "true") && o.value == ""){
					setInvalid(o,"Required field.");
					return false;
				}
				if(o.value != ""){
					// Check min length
					if((r == true || r == "true") && o.value.length < minimum){
						setInvalid(o,"This fields needs to be at least " + minimum + " characters long.");
						return false;
					}
					// Check matching
					if((r == true || r == "true") && m != ""){
						var mO = get(m);
						if(mO){
							setValid(mO);
							if(o.value != mO.value && mO.value != ""){
								setInvalid(o,"Does not match.");
								return false;
							}
						}
					}
					// Check type
					if(t != ""){
						switch(t){
						case "email":
							if(o.value.indexOf("@") == -1 || o.value.indexOf(".") == -1){
								setInvalid(o,"Not a valid email address.");
								return false;
							}
							break;
						}
					}
					// Remove unwanted characters
					o.value = makeFriendly(o.value,o);
				}
			}
		}
		
		function makeFriendly(s,o){
			if(!o){
				return "";
			}
			if(!s){
				return "";
			}
			while(s.indexOf("&") != -1){
				s = s.replace("&","and");
			}
			while(s.indexOf("+") != -1){
				s = s.replace("+","");
			}
			while(s.indexOf("'") != -1){
				s = s.replace("'","");
			}
			while(s.indexOf("\"") != -1){
				s = s.replace("\"","");
			}
			while(s.indexOf("<") != -1){
				s = s.replace("<","");
			}
			while(s.indexOf(">") != -1){
				s = s.replace(">","");
			}
			return s;
		}
		
		function validateAll(){
			
			iInvalidCount = 0;
			get("InvalidCount").value = iInvalidCount;
			
			var o = aSections[currNav][1]; // This is the div containing the form elements
			var inputs = o.getElementsByTagName("input"); // All input elements within div object
			var selects = o.getElementsByTagName("select"); // All select elements within div object
			
			for(i=0;i<inputs.length;i++){
				if((inputs[i].onblur + "").indexOf("validate") != -1){
					if(o.style.display == "block"){
						
						if(navigator.appName=='Netscape'){
							inputs[i].focus();
							inputs[i].blur();
						}else{
							sFunc = inputs[i].onblur + "";
							sFunc = sFunc.replace("this,",",this,");
							sFunc = sFunc.replace(");",",'','',''");
							aFunc = sFunc.split(",");
							validate(inputs[i],makeFriendly(aFunc[2],inputs[i]),makeFriendly(aFunc[3],inputs[i]),makeFriendly(aFunc[4],inputs[i]),makeFriendly(aFunc[5],inputs[i]));
						}
						
					}
				}
			}
			
			for(i=0;i<selects.length;i++){
				if((selects[i].onblur + "").indexOf("validate") != -1){
					if(o.style.display == "block"){
						
						if(navigator.appName=='Netscape'){
							selects[i].focus();
							selects[i].blur();
						}else{
							sFunc = selects[i].onblur + "";
							sFunc = sFunc.replace("this,",",this,");
							sFunc = sFunc.replace(");",",'','',''");
							aFunc = sFunc.split(",");
							validate(selects[i],makeFriendly(aFunc[2],selects[i]),makeFriendly(aFunc[3],selects[i]),makeFriendly(aFunc[4],selects[i]),makeFriendly(aFunc[5],selects[i]));
						}
						
					}
				}
			}
			
		}
		
		function showLoading(){
			var o = get("lB");
			o.style.left = ((screen.width/2) - (o.style.width/2)) + "px";
			o.style.top = (document.documentElement.scrollTop + 300) + "px";
			o.style.display = "block";
		}
		function hideLoading(){
			get("lB").style.display = "none";
		}
		
		function showAccTypes(bln){
			get("AccountTypeDivAll").style.display = "block";
			get("AccountTypeNewLink").style.display = "none";
			if(bln){
				get("AccountTypeNewLinkCancel").style.display = "block";
				var btnS = get("btnNav");
				get("navContainer").innerHTML = "";
				get("navContainer").appendChild(btnS); // append btn to form top
				get("dProfileSel").style.display = "none";
				buildNavB(0);
			}
		}
		function hideAccTypes(bln){
			if(bln && get("prof_btns_" + iAccountType)){
				var btnS = get("btnNav");
				get("prof_btns_" + iAccountType).innerHTML = "";
				get("prof_btns_" + iAccountType).appendChild(btnS); // append btn to form top
				get("dProfileSel").style.display = "block";
				buildNavB(2);
			}
			get("AccountTypeDivAll").style.display = "none";
			get("AccountTypeNewLinkCancel").style.display = "none";
			get("AccountTypeNewLink").style.display = "block";
		}
		
		function load_AccountTypes(AccountID,blnLoad){
			DynamicLoad(sRegProxy + "http://www.useimagine.com/imagine2/api/register_component/register_get_accountdetails.asp","dAccountID", "buildProfileOptions()", "AccountID=" + AccountID + "&Get_AccountTypes=Y");
			blnUpdateMode = true;
			if(blnLoad == true){
				//selNav(0,false);
				hideAccTypes(false);
				get("AccountPP_2").style.display = "none";
				get("AccountPP_1").style.display = "block";
				aSections[0][1].style.display = "block";
				aSections[1][1].style.display = "block";
			}
		}
		
		function load_Extra(){
			showLoading();
			DynamicLoad(sRegProxy + "http://www.useimagine.com/imagine2/api/register_component/register_get_accountdetails.asp","dTemp", "load_Extra_Process(true);", "CardHolderID=" + iAccountType + "&Get_Extra=Y");
		}
		function load_Extra_Process(b){
			var s = get("dTemp").innerHTML;
			if(s.indexOf("|") != -1){
				var a = s.split("|");
				for(i=0;i<a.length;i++){
					if(a[i] != ""){
						var a2 = a[i].split("]]");
						get("Profile_OwnEquipment").value = a2[0];
						get("Resume_Bio").value = a2[1];
						get("Resume_Guilds").value = a2[2];
						get("Resume_Awards").value = a2[3];
						get("Resume_Education").value = a2[4];
						get("Resume_Achievements").value = a2[5];
						get("Resume_Website1").value = a2[6];
						get("Resume_Website1Name").value = a2[7];
						get("Resume_Website2").value = a2[8];
						get("Resume_Website2Name").value = a2[9];
						get("Resume_Website3").value = a2[10];
						get("Resume_Website3Name").value = a2[11];
						//get("Resume_CV").value = a2[12];
					}
				}
			}
			if(b)load_Student();
		}
		
		function load_Student(){
			showLoading();
			DynamicLoad(sRegProxy + "http://www.useimagine.com/imagine2/api/register_component/register_get_accountdetails.asp","dTemp", "load_Student_Process(true);", "CardHolderID=" + iAccountType + "&Get_Student=Y");
		}
		function load_Student_Process(b){
			var s = get("dTemp").innerHTML;
			if(s.indexOf("|") != -1){
				var a = s.split("|");
				for(i=0;i<a.length;i++){
					if(a[i] != ""){
						var a2 = a[i].split("]]");
						get("Student_IsStudent").value = a2[0];
						get("Student_Institute").value = a2[1];
						get("Student_StudentNo").value = a2[2];
						get("Student_Course").value = a2[3];
					}
				}
			}
			if(b)load_Genre();
		}
		
		function load_Genre(){
			showLoading();
			DynamicLoad(sRegProxy + "http://www.useimagine.com/imagine2/api/register_component/register_get_accountdetails.asp","dTemp", "load_Genre_Process(true);", "CardHolderID=" + iAccountType + "&Get_Genre=Y");
		}
		function load_Genre_Process(b){
			var s = get("dTemp").innerHTML;
			if(s.indexOf("|") != -1){
				var a = s.split("|");
				for(i=0;i<a.length;i++){
					if(a[i] != ""){
						var a2 = a[i].split("]]");
						var checks = get("dProfile").getElementsByTagName("input");
						for(j=0;j<checks.length;j++){
							if(checks[j].id == "Profile_Genre" && checks[j].value == a2[0]){
								checks[j].checked = true;
								checks[j].defaultChecked = true;
								var sO = "Profile_Genre_" + a2[0] + "_" + a2[1];
								var o = get(sO);
								rate("set",o);
							}
						}
					}
				}
			}
			//load_Speciality();
			if(b){
				load_Exposure();
				loadPP();
				loadCV();
			}
		}
		
		function load_Speciality(){
			showLoading();
			DynamicLoad(sRegProxy + "http://www.useimagine.com/imagine2/api/register_component/register_get_accountdetails.asp","dTemp", "load_Speciality_Process();", "CardHolderID=" + iAccountType + "&Get_Speciality=Y");
		}
		function load_Speciality_Process(){
			var s = get("dTemp").innerHTML;
			if(s.indexOf("|") != -1){
				var a = s.split("|");
				for(i=0;i<a.length;i++){
					if(a[i] != ""){
						var a2 = a[i].split("]]");
						var checks = get("dProfile").getElementsByTagName("input");
						for(j=0;j<checks.length;j++){
							if(checks[j].id == "Profile_Speciality" && checks[j].value == a2[0]){
								checks[j].checked = true;
								checks[j].defaultChecked = true;
								var sO = "Profile_Speciality_" + a2[0] + "_" + a2[1];
								var o = get(sO);
								rate("set",o);
							}
						}
					}
				}
			}
			load_Exposure();
		}
		
		function load_Exposure(){
			showLoading();
			DynamicLoad(sRegProxy + "http://www.useimagine.com/imagine2/api/register_component/register_get_accountdetails.asp","dTemp", "load_Exposure_Process();", "CardHolderID=" + iAccountType + "&Get_Exposure=Y");
		}
		function load_Exposure_Process(){
			var checks = get("dExposure").getElementsByTagName("input");
			for(j=0;j<checks.length;j++){
				if(checks[j].id == "Exposure"){
					afterRem(checks[j]);
					if(checks[j].disabled == true){
						checks[j].checked = true;
						checks[j].defaultChecked = true;
					}
				}
			}
			var s = get("dTemp").innerHTML;
			if(s.indexOf("|") != -1){
				var a = s.split("|");
				for(i=0;i<a.length;i++){
					if(a[i] != ""){
						var a2 = a[i].split("]]");
						for(j=0;j<checks.length;j++){
							if(checks[j].id == "Exposure" && checks[j].value == a2[0]){
								checks[j].checked = true;
								checks[j].defaultChecked = true;
								get("Exposure_Approved" + a2[0]).value = a2[1];
								if(a2[1] == "Y"){
									var n = document.createElement("img");
									n.src = "images/approved-y.gif";
									n.title = "Approved.";
									after(n,checks[j]);
								}else if(a2[1] == "X"){
									var n = document.createElement("img");
									n.src = "images/approved-x.gif";
									n.title = "Disapproved.";
									after(n,checks[j]);
								}else{
									var n = document.createElement("img");
									n.src = "images/approved-n.gif";
									n.title = "Waiting on approval.";
									after(n,checks[j]);
								}
							}
						}
					}
				}
			}
			load_Credits();
		}
		
		function load_Credits(){
			showLoading();
			DynamicLoad(sRegProxy + "http://www.useimagine.com/imagine2/api/register_component/register_get_accountdetails.asp","dTemp", "load_Credits_Process(true);", "CardHolderID=" + iAccountType + "&Get_Credits=Y");
		}
		function load_Credits_Process(b){
			var s = get("dTemp").innerHTML;
			if(s.indexOf("|") != -1){
				var a = s.split("|");
				for(i=0;i<a.length;i++){
					if(a[i] != ""){
						var a2 = a[i].split("]]");
						aCredits[aCreditsIndex] = new Array(7);
						aCredits[aCreditsIndex][0] = a2[0];
						aCredits[aCreditsIndex][1] = a2[1];
						aCredits[aCreditsIndex][2] = a2[2];
						aCredits[aCreditsIndex][3] = a2[3];
						aCredits[aCreditsIndex][4] = a2[4];
						aCredits[aCreditsIndex][5] = a2[5];
						aCredits[aCreditsIndex][6] = a2[6];
						
						var sN = document.createElement("div");
						sN.className = "lRow";
						
						var sW = document.createElement("div");
						sW.innerHTML = aCredits[aCreditsIndex][4] + "&nbsp;";
						sW.className = "lCol";
						sN.appendChild(sW);
						
						var sW2 = document.createElement("div");
						sW2.innerHTML = aCredits[aCreditsIndex][0] + "&nbsp;";
						sW2.className = "lCol";
						sN.appendChild(sW2);
						
						var sW3 = document.createElement("div");
						sW3.innerHTML = aCredits[aCreditsIndex][1] + "&nbsp;";
						sW3.className = "lCol";
						sN.appendChild(sW3);
						
						var sW4 = document.createElement("div");
						sW4.innerHTML = aCredits[aCreditsIndex][2] + "&nbsp;";
						sW4.className = "lCol";
						sN.appendChild(sW4);
						
						var sW5 = document.createElement("div");
						sW5.innerHTML = "<a onclick='credits_Rem(" + aCreditsIndex + ",this)' class='btn'>Remove</a>";
						sW5.className = "lCol";
						sN.appendChild(sW5);
			
						get("dCreditsList").appendChild(sN);
						aCreditsIndex++;
					}
				}
			}
			if(b)load_Agency();
		}
		
		function load_Agency(){
			showLoading();
			DynamicLoad(sRegProxy + "http://www.useimagine.com/imagine2/api/register_component/register_get_accountdetails.asp","dTemp", "load_Agency_Process(true);", "CardHolderID=" + iAccountType + "&Get_Agency=Y");
		}
		function load_Agency_Process(b){
			var s = get("dTemp").innerHTML;
			if(s.indexOf("|") != -1){
				var a = s.split("|");
				for(i=0;i<a.length;i++){
					if(a[i] != ""){
						var a2 = a[i].split("]]");
						
						if(a2[1] != "Freelancers" && a2[1] != "Freelancer"){
							
							get("dAgency_1").style.display = "block";
							get("Agency_HaveAgency").checked = true;
							get("Agency_HaveAgency").defaultChecked = true;
							
							aAgency[aAgencyIndex] = new Array(7);
							aAgency[aAgencyIndex][0] = a2[0];
							aAgency[aAgencyIndex][1] = "";
							aAgency[aAgencyIndex][2] = "";
							aAgency[aAgencyIndex][3] = "";
							aAgency[aAgencyIndex][4] = a2[2];

							var sN = document.createElement("div");
							sN.className = "lRow";
							
							var sW = document.createElement("div");
							sW.innerHTML = "" + a2[1];
							sW.className = "lCol";
							sN.appendChild(sW);
							
							var sW2 = document.createElement("div");
							if(aAgency[aAgencyIndex][4] == "Y"){ // Check if is default
								sW2.innerHTML = "(Default)";
							}else{
								sW2.innerHTML = "-";
							}
							sW2.className = "lCol";
							sN.appendChild(sW2);
							
							var sW3 = document.createElement("div");
							sW3.innerHTML = "<a onclick='agency_Rem(" + aAgencyIndex + ",this)' class='btn'>Remove</a>";
							sW3.className = "lCol";
							sN.appendChild(sW3);
				
							get("dAgencyList").appendChild(sN);
							aAgencyIndex++;
							
						}else{
							
							get("Agency_Freelance").checked = true;
							get("Agency_Freelance").defaultChecked = true;
							get("Agency_ContactNo").value = a2[3];
							get("Agency_EmailAddress").value = a2[4];
							get("Agency_CellNo").value = a2[5];
							if(a2[2] == "Y"){ // Check if is default
								get("Agency_DefaultFL").checked = true;
								get("Agency_DefaultFL").defaultChecked = true;
							}else{
								get("Agency_DefaultFL").checked = false;
								get("Agency_DefaultFL").defaultChecked = false;
							}
							
							
						}
					}
				}
			}
			//selNav(2,true);
			//selNav(1,true);
			if(b)load_ExposureAll();
		}
		
		function clearAll(){
		
			// Clear form
			var o;
			for(j=2;j<aSections.length;j++){ // Do not reset the first two sections
				o = aSections[j][1];
				if(o != null){
					var inputs = o.getElementsByTagName("input");
					for(i=0;i<inputs.length;i++){
						if((inputs[i].type == "checkbox" || inputs[i].type == "radio") && inputs[i].disabled != "disabled"){
							inputs[i].checked = false;
							inputs[i].defaultChecked = false;
						}
						if(inputs[i].type == "text" || inputs[i].type == "hidden"){
							inputs[i].value = "";
						}
					}
					var selects = o.getElementsByTagName("select");
					for(i=0;i<selects.length;i++){
						if(selects[i].id != "Credits_Country" && selects[i].id != "Credits_Year"){
							selects[i].selectedIndex = 0;
						}
					}
					var textareas = o.getElementsByTagName("textarea");
					for(i=0;i<textareas.length;i++){
						textareas[i].value = "";
					}
					var images = o.getElementsByTagName("img"); // Reset start ratings
					for(i=0;i<images.length;i++){
						if(images[i].src.indexOf("rating_") != -1 && images[i].src.indexOf("_off.gif") == -1){
							images[i].src = images[i].src.replace(".gif","_off.gif");
						}
					}
				}
			}
			
			if(bCredits){
				// Clear credits
				aCreditsIndex = 0;
				aCredits = [];
				remAll(get("dCreditsList"));
			}
			
			if(bAgency){
				// Clear agents
				aAgencyIndex = 0;
				aAgency = [];
				remAll(get("dAgencyList"));
				get("dAgency_1").style.display = "none";
			}
			
			
		}
		
		function lockAccountInfo(){
			//get("Account_FirstName").readOnly = true;
			//get("Account_Surname").readOnly = true;
			get("Account_EmailAddress").readOnly = true;
			get("Account_ConfirmEmailAddress").readOnly = true;
			get("Account_Password").readOnly = true;
			get("Account_ConfirmPassword").readOnly = true;
			//get("Account_Gender").disabled = true;
			//get("Account_DOB_Year").disabled = true;
			//get("Account_DOB_Month").disabled = true;
			//get("Account_DOB_Day").disabled = true;
			//get("Account_Country").disabled = true;
			//get("Account_City").disabled = true;
			//get("Account_Region").disabled = true;
			//get("Account_Area").disabled = true;
			/*
			for (i = 0; i < document.regForm.elements.length; i++){
				if (document.regForm.elements[i].type == "checkbox" && document.regForm.elements[i].id == "Account_Type"){
					document.regForm.elements[i].disabled = true;
				}
			}
			*/
		}
		
		function saveAccount(){
			// Save account (Create account)
			var PostData = "";
			PostData = PostData + "Account_FirstName=" + get("Account_FirstName").value;
			PostData = PostData + "&Account_AgencyID=0";
			PostData = PostData + "&Account_Surname=" + get("Account_Surname").value;
			PostData = PostData + "&Account_Gender=" + get("Account_Gender")[get("Account_Gender").selectedIndex].value;
			PostData = PostData + "&Account_Country=" + get("Account_Country")[get("Account_Country").selectedIndex].text;
			//PostData = PostData + "&Account_City=" + get("Account_City")[get("Account_City").selectedIndex].text;
			//PostData = PostData + "&Account_Area=" + get("Account_Area")[get("Account_Area").selectedIndex].text;
			PostData = PostData + "&Account_EmailAddress=" + get("Account_EmailAddress").value;
			PostData = PostData + "&Account_Password=" + get("Account_Password").value;
			PostData = PostData + "&Account_DOB_Year=" + get("Account_DOB_Year")[get("Account_DOB_Year").selectedIndex].value;
			PostData = PostData + "&Account_DOB_Month=" + get("Account_DOB_Month")[get("Account_DOB_Month").selectedIndex].value;
			PostData = PostData + "&Account_DOB_Day=" + get("Account_DOB_Day")[get("Account_DOB_Day").selectedIndex].value;
			PostData = PostData + "&Account_Region=" + get("Account_Region")[get("Account_Region").selectedIndex].text;
			PostData = PostData + "&Account_Type=";
			if(blnUpdateMode){
				PostData = PostData + "&AccountID=";
			}
			for (i = 0; i < document.regForm.elements.length; i++){
				if (document.regForm.elements[i].type == "checkbox" && document.regForm.elements[i].id == "Account_Type"){
					if(document.regForm.elements[i].checked == true){
						PostData = PostData + document.regForm.elements[i].value + "]]";
					}
				}
			}
			PostData = PostData + "&ExposureID=" + lExposureID;
			PostData = encodeQS(PostData);
			var sSrc = 
			DynamicLoad(sRegProxy + "http://www.useimagine.com/imagine2/api/register_component/register_save_account.asp","dAccountID", "checkProfile()", PostData);
		}
		
		function checkProfile(){
			var sS = get("dAccountID").innerHTML;
			
			get("dAccountMade").style.display = "none";
			get("dAccount").style.display = "block";
			get("iBtnSubmit").style.display = "block";
			get("iBtnApproval").style.display = "block";
			
			if(sS=="EMAIL_EXISTS"){
				blnNoGo = true;
				get("iBtnApproval").style.display = "none";
				setInvalid(get("Account_EmailAddress"),"<b>Account not created.</b><br><span style='color:#666666;'>An account already exists for this email address. If you have signed up on our partner network, for example Real Time Resources or Imagine, you can <a class='link' onClick='menuSel(document.getElementById(\"MenuSel_Login\")); DynDuo(\"dyn-login.asp\",\"dyn-blank.asp\",\"\");'>use that login here</a>. If you have forgotten your password, <a class='link' onClick='menuSel(document.getElementById(\"MenuSel_Login\")); DynDuo(\"dyn-login-reminder.asp\",\"dyn-blank.asp\",\"\");'>click here</a> to have us resend it to you.</span>");
			}else{
				blnNoGo = true;
				get("dAccountMade").style.display = "block";
				get("dAccount").style.display = "none";
				get("iBtnSubmit").style.display = "none";
				get("iBtnApproval").style.display = "none";
			}
		}
		
		function saveAll(){
			// Save all data in form (account already created)
			
			var blnReload = false;
			
			var qS = "AccountID=" + lGlob_AccountID + "&CardHolderID=" + iAccountType;
			qS = qS + "&ExposureID=" + lExposureID;
			var aS = (sChanges + "|").split("|");
			for(x=0;x<aS.length;x++){
				if(aS[x] != ""){
					switch(aS[x]){
						
						case "Account":
							qS += "&Save_Account=Y";
							qS += "&Account_AgencyID=0";
							qS += "&Account_FirstName=" + get("Account_FirstName").value;
							qS += "&Account_Surname=" + get("Account_Surname").value;
							qS += "&Account_Gender=" + get("Account_Gender")[get("Account_Gender").selectedIndex].value;
							qS += "&Account_Country=" + get("Account_Country")[get("Account_Country").selectedIndex].text;
							qS += "&Account_EmailAddress=" + get("Account_EmailAddress").value;
							qS += "&Account_DOB_Year=" + get("Account_DOB_Year")[get("Account_DOB_Year").selectedIndex].value;
							qS += "&Account_DOB_Month=" + get("Account_DOB_Month")[get("Account_DOB_Month").selectedIndex].value;
							qS += "&Account_DOB_Day=" + get("Account_DOB_Day")[get("Account_DOB_Day").selectedIndex].value;
							qS += "&Account_Region=" + get("Account_Region")[get("Account_Region").selectedIndex].text;
							break;
					
						// Save Account Types
						case "AccountTypes":
							blnReload = true;
							qS += "&Save_AccountTypes=Y&AccountTypes_List=";
							for (i = 0; i < document.regForm.elements.length; i++){
								if (document.regForm.elements[i].type == "checkbox" && document.regForm.elements[i].id == "Account_Type"){
									qS += document.regForm.elements[i].value + "]]";
									qS += document.regForm.elements[i].checked + "]]";
									qS += document.regForm.elements[i].alt + "|";
								}
							}
							break;
					
						// Save Exposure selection
						case "Exposure":
							qS += "&Save_Exposure=Y&Exposure_List=";
							for (i = 0; i < document.regForm.elements.length; i++){
								if (document.regForm.elements[i].type == "checkbox" && document.regForm.elements[i].id == "Exposure"){
									if(document.regForm.elements[i].checked == true){
										qS += document.regForm.elements[i].value + "]]" + get("Exposure_Approved" + document.regForm.elements[i].value).value + "|";
									}
								}
							}
							break;
					
						// Save Genre selection
						case "Genre":
							qS += "&Save_Genre=Y&Genre_List=";
							for (i = 0; i < document.regForm.elements.length; i++){
								if (document.regForm.elements[i].type == "checkbox" && document.regForm.elements[i].id == "Profile_Genre"){
									if(document.regForm.elements[i].checked == true){
										qS += document.regForm.elements[i].value + "]]" + get("Profile_Genre_" + document.regForm.elements[i].value + "_P").value + "|";
									}
								}
							}
							break;
							
						// Save Speciality selection
						case "Speciality":
							qS += "&Save_Speciality=Y&Speciality_List=";
							for (i = 0; i < document.regForm.elements.length; i++){
								if (document.regForm.elements[i].type == "checkbox" && document.regForm.elements[i].id == "Profile_Speciality"){
									if(document.regForm.elements[i].checked == true){
										qS += document.regForm.elements[i].value + "]]" + get("Profile_Speciality_" + document.regForm.elements[i].value + "_P").value + "|";
									}
								}
							}
							break;
							
						// Save Agency selection
						case "Agency":
							qS += "&Save_Agency=Y";
							if(get("Agency_HaveAgency").checked == true){
								qS += "&Agency_HaveAgency=Y";
								qS += "&Agency_List=";
								for (i = 0; i < aAgency.length; i++){
									if(aAgency[i] != null){
										if(aAgency[i][4] == true){
											qS += aAgency[i][0] + "]]" + aAgency[i][1] + "]]" + aAgency[i][2] + "]]" + aAgency[i][3] + ",Y|";
										}else{
											qS += aAgency[i][0] + "]]" + aAgency[i][1] + "]]" + aAgency[i][2] + "]]" + aAgency[i][3] + ",N|";
										}
									}
								}
							}
							if(get("Agency_Freelance").checked == true){
								qS += "&Agency_Freelance=Y";
								qS += "&Agency_ContactNo=" + get("Agency_ContactNo").value;
								qS += "&Agency_EmailAddress=" + get("Agency_EmailAddress").value;
								qS += "&Agency_CellNo=" + get("Agency_CellNo").value;
								if(get("Agency_DefaultFL").checked == true){
									qS += "&Agency_Default=Y";
								}else{
									qS += "&Agency_Default=N";
								}
							}
							break;
							
						// Save Credits selection
						case "Credits":
							qS += "&Save_Credits=Y&Credits_List=";
							for (i = 0; i < aCredits.length; i++){
								if(aCredits[i] != null){
									qS += aCredits[i][0] + "]]" + aCredits[i][1] + "]]" + aCredits[i][2] + "]]" + aCredits[i][3] + "]]" + aCredits[i][4] + "]]" + aCredits[i][5] + "]]" + aCredits[i][6] + "|";
								}
							}
							break;
							
						// Save Extra info (Profile, resume, etc)
						case "Student":
							qS += "&Save_Student=Y";
							qS += "&Student_IsStudent=" + get("Student_IsStudent")[get("Student_IsStudent").selectedIndex].value;
							qS += "&Student_Institute=" + get("Student_Institute").value;
							qS += "&Student_StudentNo=" + get("Student_StudentNo").value;
							qS += "&Student_Course=" + get("Student_Course").value;
							break;
							
						// Save Extra info (Profile, resume, etc)
						case "Extra":
							qS += "&Save_Extra=Y";
							qS += "&Profile_OwnEquipment=" + get("Profile_OwnEquipment").value;
							qS += "&Resume_Bio=" + get("Resume_Bio").value;
							qS += "&Resume_Guilds=" + get("Resume_Guilds").value;
							qS += "&Resume_Awards=" + get("Resume_Awards").value;
							qS += "&Resume_Education=" + get("Resume_Education").value;
							qS += "&Resume_Achievements=" + get("Resume_Achievements").value;
							qS += "&Resume_Website1=" + get("Resume_Website1").value;
							qS += "&Resume_Website1Name=" + get("Resume_Website1Name").value;
							qS += "&Resume_Website2=" + get("Resume_Website2").value;
							qS += "&Resume_Website2Name=" + get("Resume_Website2Name").value;
							qS += "&Resume_Website3=" + get("Resume_Website3").value;
							qS += "&Resume_Website3Name=" + get("Resume_Website3Name").value;
							//qS += "&Resume_CV=" + get("Resume_CV").value;
							break;
						
					}
				}
			}
			qS = encodeQS(qS);
			DynamicLoad(sRegProxy + "http://www.useimagine.com/imagine2/api/register_component/register_save_accountdetails.asp","dSave", "saveDone(" + blnReload + ")", qS);
			setChanges(false);
			alert("Changes have been saved.");
		}
		
		function saveDone(b){
			// Insert any post save actions here
			if(b){
				alert("Please note that changes to your selected account profile types can take time to reflect.");
				hideAccTypes(true);
			}
		}
		
		function refreshAcc(){
			loadReg(lGlob_AccountID);
		}
		
		function encodeQS(s){
			while(s.indexOf(" ") != -1){
				s = s.replace(" ","+");
			}
			while(s.indexOf("\n") != -1){
				s = s.replace("\n","[br]");
			}
			return s;
		}
		
		var blnUpdateMode = false;
		var aAccountDetails = new Array(3);
		var blnNoGo = false; // Allow first load
		
		function postSaveAccount(){
			blnUpdateMode = true;
		}
		
		function buildProfileOptions(){
		
			// Build the profile type selection radio buttons
			var oS = get("dAccountID");
			
			var sS = oS.innerHTML;
			
			if(sS=="EMAIL_EXISTS"){
				blnNoGo = true;
				setInvalid(get("Account_EmailAddress"),"<b>Account not created.</b><br><span style='color:#666666;'>An account already exists for this email address. If you have signed up on our partner network, for example Real Time Resources or Imagine, you can <a class='link' onClick='menuSel(document.getElementById(\"MenuSel_Login\")); DynDuo(\"dyn-login.asp\",\"dyn-blank.asp\",\"\");'>use that login here</a>. If you have forgotten your password, <a class='link' onClick='menuSel(document.getElementById(\"MenuSel_Login\")); DynDuo(\"dyn-login-reminder.asp\",\"dyn-blank.asp\",\"\");'>click here</a> to have us resend it to you.</span>");
			}else{
				
				lockAccountInfo();
				
				blnNoGo = false;
				if(sS != ""){
					var aS = sS.split(";");
					var oD = get("dProfileSel_Options");
					oD.innerHTML = "";
					
					var aA1 = aS[1].split("]]");
					var aA2 = aS[2].split("]]");
					var aA3 = aS[3].split("]]");
					
					if(aS[1] != ""){
						for(x=0;x<aA1.length;x++){
							if(aA1[x] != ""){
								if(x==0){
									iAccountType = aA1[x];
									sAccountType = aA2[x];
									sDisplay = "block";
								}else{
									sDisplay = "none";
								}
								
								bColor2 = "#EEEEEE";
								
								// create main container div for profile
								elem = document.createElement("div");
								elem.id = "prof_" + aA1[x];
								elem.style.position = "relative";
								elem.style.width = "720px";
								elem.style.marginBottom = "20px";
								elem.style.border = "1px solid " + bColor2;
								
								//	create button div
									elem4 = document.createElement("div");
									elem4.id = "prof_btns_" + aA1[x];
									elem4.style.width = "359px";
									elem4.style.height = "35px";
									elem4.style.position = "absolute";
									elem4.style.right = "0px";
									elem4.style.textAlign = "right";
									elem4.style.backgroundColor = s_bgcolor;
									elem4.style.borderRight = "1px solid " + bColor2;
									elem4.style.borderBottom = "1px solid " + bColor2;
									elem4.style.padding = "4px";
									elem.appendChild(elem4);
								
								//	create title div
									elem2 = document.createElement("div");
									elem2.id = "prof_name_" + aA1[x];
									elem2.style.width = "359px";
									elem2.style.height = "35px";
									elem2.style.position = "absolute";
									elem2.style.left = "0px";
									elem2.innerHTML = "<img align='left' src='images/reg_icon_" + fIcon(aA2[x]) + ".gif' style='margin-right:6px;'><a onclick='setAccountType(" + aA1[x] + ",\"" + aA2[x] + "\");' style='font-size:14px;font-weight:bold;'>" + aA2[x] + "</a><br><span id='prof_status_" + aA1[x] + "' style='width:320px; overflow:hidden;'>-</span>";
									elem2.style.backgroundColor = s_bgcolor;
									elem2.style.borderLeft = "1px solid " + bColor2;
									elem2.style.borderBottom = "1px solid " + bColor2;
									elem2.style.padding = "4px";
									elem.appendChild(elem2);
								
								//	create tab div
									elem3 = document.createElement("div");
									elem3.id = "prof_tabs_" + aA1[x];
									elem3.style.width = "710px";
									elem3.style.height = "30px";
									elem3.style.display = sDisplay;
									elem3.style.marginTop = "10px";
									elem3.style.paddingLeft = "4px";
									elem2.style.position = "relative";
									elem.appendChild(elem3);
								
								//	create content div
									elem3 = document.createElement("div");
									elem3.id = "prof_info_" + aA1[x];
									elem3.style.width = "710px";
									elem3.style.height = "300px";
									elem3.style.overflow = "auto";
									elem3.style.display = sDisplay;
									elem3.style.padding = "4px";
									elem3.style.marginTop = "-9px";
									elem2.style.position = "relative";
									elem.appendChild(elem3);
									
								oD.appendChild(elem);
								elem = document.createElement("div");
								elem.innerHTML = "&nbsp;";
								elem.style.height = "10px";
								oD.appendChild(elem);
								
								checkSel("Account_Type",aA2[x]);
							}
						}
					}
					get("Account_EmailAddress").value = aA3[0];
					get("Account_ConfirmEmailAddress").value = aA3[0];
					get("Account_Password").value = aA3[1];
					get("Account_ConfirmPassword").value = aA3[1];
					get("Account_FirstName").value = aA3[2];
					get("Account_Surname").value = aA3[3];
					
					selectValue(get("Account_Gender"),aA3[4]);
					selectValue(get("Account_DOB_Year"),aA3[5]);
					selectValue(get("Account_DOB_Month"),aA3[6]);
					selectValue(get("Account_DOB_Day"),aA3[7]);
					selectValue(get("Account_Country"),aA3[9]);
					//loadCityValues(get("Account_Country"));
					//selectValue(get("Account_City"),aA3[10]);
					selectValue(get("Account_Region"),aA3[12]);
					
					//get("Account_Area").value = aA3[11];
					sGlob_EmailAddress = aA3[0];
					sGlob_Fullname = aA3[2] + " " + aA3[3];
					setPrimaryStep(aA3[8]);
					if(iPrimaryStep != 2 && iPrimaryStep != 4){
						if(aS[1] != ""){
							postSaveAccount();
							setAccountType(iAccountType,sAccountType);
						}else{
							loadPP()
						}
					}
					//selNav(2,true);
				}
			}
		}
		
		function fIcon(s){
			switch(s){
				
				case "Aerial Photography":
				case "Photographer":
				case "Underwater Cinematography":
					return "camera";
					break;
					
				case "Art Director":
				case "Colorist":
				case "Graphic Designer":
				case "Animator":
				case "Compositor":
				case "Illustrator":
				case "Production Designer":
				case "Storyboard Artist":
				case "Scenic Artist":
					return "paint";
					break;
					
				case "D.O.P":
				case "Director":
				case "Creative Director":
					return "megaphone";
					break;
					
				case "Set Builder":
				case "Set Designer":
				case "Set Dresser":
					return "hammer";
					break;
					
				case "Steadycam Operator":
				case "Cable-Cam Operator":
				case "Videographer":
				case "Camera Operator":
				case "Lighting Cameraman/woman":
					return "videocam";
					break;
					
				default:
					return "other";
					break;
					
			}
		}
		
		function selectValue(o,v){
			for(i=0;i<o.length;i++){
				if(o[i].value == v || o[i].text == v){
					o.selectedIndex = i;
					break;
				}
			}
		}
		
		function resendConfirmation(){
			var qS = "";
			qS = qS + "AccountID=" + lGlob_AccountID;
			qS = qS + "&ExposureID=" + lExposureID;
			qS = qS + "&Account_FullName=" + sGlob_FullName;
			qS = qS + "&Account_EmailAddress=" + sGlob_EmailAddress;
			DynamicLoad(sRegProxy + "http://www.useimagine.com/imagine2/api/register_component/register_resendemail.asp","dFormsDisplay", "", qS);
		}
		
		function setPrimaryStep(s){
			if(get("dFormsNavigationT")){
				get("dFormsNavigationT").style.display = "none";
			}
			switch(s){
				case "O":
					iPrimaryStep = 2;
					get("dFormsDisplay").innerHTML = "Account is awaiting verification. If you have not received your verification email, or you have lost the email, please <a onclick='resendConfirmation();'>click here</a> and we will resend it.";
					break;
				case "C":
					iPrimaryStep = 3;
					//get("dApproval").style.display = "block";
					break;
				case "A":
					iPrimaryStep = 4;
					get("prof_info_" + iAccountType).innerHTML = "Your profile has been sent to us to approve. This process can take anywhere from an hour, up to two working days.<br><br><span>Why Do I Have To Wait?</span><br>We monitor all profiles being created to ensure that the integrity of information is upheld.<br><br>Any Queries contact us on 021 674 0646 or <a href='mailto:signup@filmmakersguide.co.za'>signup@filmmakersguide.co.za</a><br>";
					break;
				case "AC":
					iPrimaryStep = 5;
					break;
				default:
					iPrimaryStep = 1;
					break;
			}
			hideLoading();
		}
		
		function checkSel(sId,sVal){
			for (i = 0; i < document.regForm.elements.length; i++){
				if (document.regForm.elements[i].type == "checkbox" && document.regForm.elements[i].id == sId && document.regForm.elements[i].value == sVal){
					document.regForm.elements[i].checked = true;
					document.regForm.elements[i].defaultChecked = true;
					document.regForm.elements[i].alt = "Y";
				}
			}
		}
		
		var iAccountType = 0;
		var sAccountType = "";
		var blnAccountSet = false;
		function setAccountType(s1,s2){
			
			if (blnAccountSet && iAccountType == s1) return false;
			
			blnAccountSet = true;
			
			if(blnChanges){
				if(window.confirm("Save changes to your '" + sAccountType + "' profile?")){
					saveAll();
				}
			}
			setChanges(false);
			
			if (get("prof_tabs_" + iAccountType)) get("prof_tabs_" + iAccountType).style.display = "none";
			if (get("prof_info_" + iAccountType)) get("prof_info_" + iAccountType).style.display = "none";
			
			iAccountType = s1;
			sAccountType = s2;
			
			if (get("prof_tabs_" + iAccountType)) get("prof_tabs_" + iAccountType).style.display = "block";
			if (get("prof_info_" + iAccountType)) get("prof_info_" + iAccountType).style.display = "block";
			
			get("dFormsNavigationT").style.display = "block";
			if (get("prof_tabs_" + iAccountType)) get("prof_tabs_" + s1).appendChild(get("dFormsNavigationT")); // append navigation to current sel
			
			var btnS = get("btnNav");
			if (get("prof_btns_" + iAccountType)) get("prof_btns_" + iAccountType).innerHTML = "";
			if (get("prof_btns_" + iAccountType)) get("prof_btns_" + iAccountType).appendChild(btnS); // append btn to current sel
			
			selNav(2,true);
			
			get("iBtnApproval").style.display = "none";
			
			//document.getElementById("dProfileSel_Head").innerHTML = "<b>&quot;" + sAccountType + "&quot; profile is currently loaded. Use the tabs to begin editing this profile, and click the Save button after changes are made.</b><br>&nbsp;<br>";
			/*
			var oRadios = get("dProfileSel").getElementsByTagName("input");
			for(i = 0;i < oRadios.length;i++){
				if(oRadios[i].value == iAccountType){
					oRadios[i].checked = true;
				}else{
					oRadios[i].checked = false;
				}
			}
			*/
			
			clearAll();
			load_Extra();
		}		
	
		function checkFormVal(b){
			
			validateAll();
			
			if(get("InvalidCount").value == "0"){
				pass = true;
			}else{
				pass = false;
			}
			
			var d = get("dFormValid");
			if(d){
				if(pass){
					d.style.display = "none";
				}else if(b){
					d.style.display = "block";
				}
			}
			return pass;
			
		}
		
		function setInvalid(o,em){
			var n = document.createElement("div");
			n.className = "invalid";
			n.innerHTML = "" + em;
			after(n,o);
			//o.style.backgroundColor = "#FFEEEE";
			iInvalidCount = iInvalidCount + 1;
			get("InvalidCount").value = iInvalidCount;
			//checkFormVal(false);
		}
		
		function setValid(o){
			//o.style.backgroundColor = "#FFFFFF";
			afterRem(o);
		}
		
		function after(elem,targetElem) {
			var parent = targetElem.parentNode;
			if (targetElem == parent.lastChild){
				parent.appendChild(elem);
			} else {
				parent.insertBefore(elem,targetElem.nextSibling);
			}
		}
		
		function afterRem(targetElem){
			var parent = targetElem.parentNode;
			if(parent.childNodes.length > 1){
				var x;
				for(x=1;x<=parent.childNodes.length-1;x++){
					elem = parent.childNodes[x];
					if(elem.tagName == "DIV" || elem.tagName == "IMG"){
						elem.parentNode.removeChild(elem);
					}
				}
			}
		}
		
		function inject(elem,targetElem){
			try {
				targetElem.add(elem, null); // standards compliant; doesn't work in IE
			}
			catch(ex) {
				targetElem.add(elem); // IE only
			}
		}
		
		function rem(o){
			o.parentNode.removeChild(o);
		}
		
		function remAll(o){
			//if(o.style.display == "block"){
				if(o.hasChildNodes()){
					while(o.childNodes.length >= 1){
						o.removeChild(o.firstChild);
					}
				}
			//}
		}
			
		var aSections = new Array();
		
		function init(AccountID){
			
			switch(BrowserDetect.browser){
			case "Firefox":
				if(parseInt(BrowserDetect.version) < 3){
					alert("Firefox version 3 or greater is recommended. Some features may not function properly.");
				}
				break;
			case "MSIE":
				if(parseInt(BrowserDetect.version) < 6){
					alert("Internet Explorer version 6 or greater is recommended. Some features will not function properly.");
				}
				break;
			case "Safari":
				if(parseInt(BrowserDetect.version) < 500){
					alert("Safari version 3 (500.0) or greater is recommended. Some features will not function properly.\n\nIf you do no have a Mac OS compatible with the latest Safari version, we recommend using Firefox instead (www.firefox.com)");
				}
				break;
			}
			
			lGlob_AccountID = AccountID
			
			var i = 0;
			
			if(bAccount){
				aSections[i] = new Array(2);
				aSections[i][0] = "Account";
				aSections[i][1] = get("dAccount");
				aSections[i][2] = null; // Parent section
				i++;
			}
			if(bProfileSel){
				aSections[i] = new Array(2);
				aSections[i][0] = "Profiles";
				aSections[i][1] = get("dProfileSel");
				aSections[i][2] = 0; // Parent section
				i++;
			}
			if(bProfile){
				aSections[i] = new Array(2);
				aSections[i][0] = "Profile Details";
				aSections[i][1] = get("dProfile");
				aSections[i][2] = 1; // Parent section
				i++;
			}
			if(bAgency){
				aSections[i] = new Array(2);
				aSections[i][0] = "Representation";
				aSections[i][1] = get("dAgency");
				aSections[i][2] = 1; // Parent section
				i++;
			}
			if(bCredits){
				aSections[i] = new Array(2);
				aSections[i][0] = "Credits";
				aSections[i][1] = get("dCredits");
				aSections[i][2] = 1; // Parent section
				i++;
			}
			if(bResume){
				aSections[i] = new Array(2);
				aSections[i][0] = "Resume";
				aSections[i][1] = get("dResume");
				aSections[i][2] = 1; // Parent section
				i++;
			}
			if(bStudent){
				aSections[i] = new Array(2);
				aSections[i][0] = "Student";
				aSections[i][1] = get("dStudent");
				aSections[i][2] = 1; // Parent section
				i++;
			}
			if(bImages){
				aSections[i] = new Array(2);
				aSections[i][0] = "Images";
				aSections[i][1] = get("dImages");
				aSections[i][2] = 1; // Parent section
				i++;
			}
			if(bVideo){
				aSections[i] = new Array(2);
				aSections[i][0] = "Video";
				aSections[i][1] = get("dVideo");
				aSections[i][2] = 1; // Parent section
				i++;
			}
			if(bExposure){
				aSections[i] = new Array(2);
				aSections[i][0] = "Exposure";
				aSections[i][1] = get("dExposure");
				aSections[i][2] = 1; // Parent section
				i++;
			}
			
			buildNav();
			
			if(AccountID){
				load_AccountTypes(AccountID,true);
			}else{
				showAccTypes(false);
				get("AccountPP_1").style.display = "none";
				get("AccountPP_2").style.display = "block";
				selNav(0,true);
				get("dFormsNavigationT").style.display = "none";
				setPrimaryStep();
			}
		
		}
		
		function buildNav(){
			
			var navT = get("dFormsNavigationT");
			var menuItems = document.createElement("ul");
			menuItems.id = "dFormsNavigationT_ul";
			
			var i;
			for(i=2;i<aSections.length;i++){
				
				var menuItem = document.createElement("li");
				menuItem.className = "tab";
				menuItem.innerHTML = "<a onClick='selNav(" + i + ",true)' class='tabA'>" + aSections[i][0] + "</a>";
				menuItems.appendChild(menuItem);

				
				/*
				var menuItem = document.createElement("div");
				menuItem.innerHTML = "<a onClick='selNav(" + i + ",true)' class='tabA'>" + aSections[i][0] + "</a>";
				menuItem.className = "tab";
				menuItem.setAttribute("onClick","selNav(" + i + ",true)");
				navT.appendChild(menuItem);
				*/
			}
			
			navT.appendChild(menuItems);
			
		}
		
		var currNav = 0; // Hold the currently loaded step
		
		function selNav(j,b){
			
			if(currNav!=0 && j==0 && blnChanges){
				if(window.confirm("Save changes to your '" + sAccountType + "' profile?")){
					saveAll();
				}
			}
		
			var blnCheck = checkFormVal(true);
		
			if(currNav == 0 && j != 0 && b && blnCheck && get("InvalidCount").value == "0" && blnUpdateMode != true){
				blnNoGo = true;
				saveAccount();
			}
			if(!blnCheck || get("InvalidCount").value != "0" || blnNoGo == true){

			}else{
			
				var navT = get("dFormsNavigationT_ul");
				var i;
				/*
				if(navigator.appName=='Netscape'){
					xF = 1
				}else{
					xF = 0
				}
				*/
				xF = 0;
				for(i=2;i<aSections.length;i++){
					if(navT.childNodes[(i - 2) + xF]){
						navT.childNodes[(i - 2) + xF].className = "tab";
						aSections[i][1].style.display = "none";
					}
				}
				if(j != 0){
					navT.childNodes[(j - 2) + xF].className = "tabSel";
				}
				aSections[j][1].style.display = "block";
				if(j != 0){
					get("prof_info_" + iAccountType).appendChild(aSections[j][1]); // append form to current sel
				}
			
				buildNavB(j);
				currNav = j;
				
				if(aSections[j][0] == "Images" && j != 0){
					if(bImages){
						try
						{
							window.imagesFrame.location.href = "http://www.digicastcards.com/packages/Analysis/Albums3/imageorder2.asp?agencyid=0&cardholderid=" + iAccountType + "&ExposureID=" + lExposureID;
						}
						catch(ex){
							var o = document.getElementById("imagesFrame");
							if(o){
								document.getElementById("imagesFrame").src = "http://www.digicastcards.com/packages/Analysis/Albums3/imageorder2.asp?agencyid=0&cardholderid=" + iAccountType + "&ExposureID=" + lExposureID;
							}else{
								alert("Could not load image manager. Please close your browser and try again.");	
							}
						}
					}
				}
				
			}
			
			//scroll(0,0);
			if(get("prof_info_" + iAccountType) && j != 0){
				get("prof_info_" + iAccountType).scrollTop = 0;
			}
			
		}
		
		function buildNavB(j){
			// Update the navigation buttons
			
			if(iPrimaryStep == 2 || iPrimaryStep == 4){
				return false;	
			}
			
			
			var bS = get("iBtnSubmit");
			var bA = get("iBtnApproval");
			var aL = aSections.length;
			if(j == 0){
				if(blnUpdateMode){
					bS.style.display = "block";
					bS.onclick = function(){saveAll()};
					bA.style.display = "none";
				}else{
					bS.src = "images/reg_submit.gif";
					bS.style.display = "block";
					bA.style.display = "none";
					bS.onclick = function(){selNav(j + 1,true)};
				}
			}else{
				if(blnUpdateMode){
					if(blnChanges){
						bS.style.display = "block";
					}else{
						bS.style.display = "none";
					}
					if(iPrimaryStep == 3){
						bA.style.display = "block";
					}else{
						bA.style.display = "none";
					}
				}else{
					bA.style.display = "block";
					bS.style.display = "block";
				}
				bS.onclick = function(){saveAll()};
			}
		}
		
		// Set details as changed/saved
		var blnChanges = false; // Holds whether there any changes to be saved
		var sChanges = ""; // Holds the sections that have been changed and need saving
		function setChanges(b,s){
			blnChanges = b;
			if(b){
				get("iBtnSubmit").style.display = "block";
			}else{
				get("iBtnSubmit").style.display = "none";
			}
			if(!b){
				sChanges = "";
			}else{
				if(sChanges.indexOf(s + "|") == -1){
					sChanges += s + "|";
				}
			}
		}
		
		// Hold all NEW credits added using the credits form
		var aCredits = new Array;
		var aCreditsIndex = 0;
		function credits_Store(){
			
			if(get("Credits_Type").selectedIndex == 0 || get("Credits_Project").value == "" || get("Credits_Role").value == ""){
				alert("Please supply for information about this credit.");
				return false;	
			}
			
			setChanges(true,"Credits");
			aCredits[aCreditsIndex] = new Array(7);
			aCredits[aCreditsIndex][0] = get("Credits_Type")[get("Credits_Type").selectedIndex].value; get("Credits_Type").selectedIndex = 0;
			aCredits[aCreditsIndex][1] = get("Credits_Project").value; get("Credits_Project").value = "";
			aCredits[aCreditsIndex][2] = get("Credits_Role").value; //get("Credits_Role").value = ""; // We'll keep this filled in for now, most likey going to be the same for CREW
			aCredits[aCreditsIndex][3] = get("Credits_Company").value; get("Credits_Company").value = "";
			aCredits[aCreditsIndex][4] = get("Credits_Year")[get("Credits_Year").selectedIndex].value; // get("Credits_Year").selectedIndex = 1;
			aCredits[aCreditsIndex][5] = get("Credits_Country")[get("Credits_Country").selectedIndex].value; get("Credits_Country").selectedIndex = 222; // South Africa
			aCredits[aCreditsIndex][6] = 0; // City

			var sN = document.createElement("div");
			sN.className = "lRow";
			
			var sW = document.createElement("div");
			sW.innerHTML = aCredits[aCreditsIndex][4] + "&nbsp;";
			sW.className = "lCol";
			sN.appendChild(sW);
			
			var sW2 = document.createElement("div");
			sW2.innerHTML = aCredits[aCreditsIndex][0] + "&nbsp;";
			sW2.className = "lCol";
			sN.appendChild(sW2);
			
			var sW3 = document.createElement("div");
			sW3.innerHTML = aCredits[aCreditsIndex][1] + "&nbsp;";
			sW3.className = "lCol";
			sN.appendChild(sW3);
			
			var sW4 = document.createElement("div");
			sW4.innerHTML = aCredits[aCreditsIndex][2] + "&nbsp;";
			sW4.className = "lCol";
			sN.appendChild(sW4);
			
			var sW5 = document.createElement("div");
			sW5.innerHTML = "<a onclick='credits_Rem(" + aCreditsIndex + ",this)' class='btn'>Remove</a>";
			sW5.className = "lCol";
			sN.appendChild(sW5);
			
			get("dCreditsList").appendChild(sN);
			
			aCreditsIndex++;
		}
		function credits_Rem(i,n){
			aCredits[i] = null;
			rem(n.parentNode.parentNode);
			setChanges(true,"Credits");

		}
		
		
		// Hold all NEW agencies added using the agency form
		var aAgency = new Array;
		var aAgencyIndex = 0;
		function agency_Store(){
			
			if(agency_DefaultCheck(1) == false){
				return false;
			}
			
			if(agency_DupCheck() == false){
				alert("You have already added this representative.");
				return false;
			}
			
			setChanges(true,"Agency");
			
			var s = get("Agency_ID")[get("Agency_ID").selectedIndex].text;
			
			if(s==""){
				alert("Please choose a representative.");
				return false;
			}
			
			aAgency[aAgencyIndex] = new Array(2);
			aAgency[aAgencyIndex][0] = get("Agency_ID")[get("Agency_ID").selectedIndex].value; get("Agency_ID").selectedIndex = 0;
			aAgency[aAgencyIndex][1] = ""
			aAgency[aAgencyIndex][2] = ""
			aAgency[aAgencyIndex][3] = ""
			aAgency[aAgencyIndex][4] = get("Agency_Default").checked; get("Agency_Default").checked = false; get("Agency_Default").defaultChecked = false;

			var sN = document.createElement("div");
			sN.className = "lRow";
			
			var sW = document.createElement("div");
			sW.innerHTML = s;
			sW.className = "lCol";
			sN.appendChild(sW);
			
			var sW2 = document.createElement("div");
			if(aAgency[aAgencyIndex][4]){ // Check if is default
				sW2.innerHTML = "(Default)";
			}else{
				sW2.innerHTML = "-";
			}
			sW2.className = "lCol";
			sN.appendChild(sW2);
			
			var sW3 = document.createElement("div");
			sW3.innerHTML = "<a onclick='agency_Rem(" + aAgencyIndex + ",this)' class='btn'>Remove</a>";
			sW3.className = "lCol";
			sN.appendChild(sW3);
			
			get("dAgencyList").appendChild(sN);
			aAgencyIndex++;
		}
		function agency_Rem(i,n){
			aAgency[i] = null;
			rem(n.parentNode.parentNode);
			setChanges(true,"Agency");
		}
		function agency_DupCheck(){
			for(x=0;x<aAgency.length;x++){
				if(aAgency[x] != null){
					if(aAgency[x][0] == get("Agency_ID")[get("Agency_ID").selectedIndex].value){
						return false;
					}
				}
			}
			return true;
		}
		function agency_DefaultCheck(m){
			var blnGo = false;
			if(m==1){ // Adding a agent representative
				if(get("Agency_Default").checked == true && get("Agency_DefaultFL").checked == true){
					alert("You cannot add a default agency if you have selected your freelance contact details as your default already. First unselect freelance as default contact method.");
					return false;
				}else if(get("Agency_Default").checked == true){
					for(x=0;x<aAgency.length;x++){
						if(aAgency[x] != null){
							if(aAgency[x][4] == true){
								if(blnGo == false){
									if(confirm("You have already selected another agent as your default. Would you prefer this agent as your default?") == true){
										blnGo = true;
									}else{
										blnGo = false;
										return false;
									}
								}
								if(blnGo == true){
									aAgency[x][4] = false;
									get("dAgencyList").childNodes[x].childNodes[1].innerHTML = "-";
								}
							}
						}
					}
				}
			}else{ // Selecting freelance as default?
				if(get("Agency_DefaultFL").checked == true){
					for(x=0;x<aAgency.length;x++){
						if(aAgency[x][4] == true){
							if(blnGo == false){
								if(confirm("Would you prefer to be contacted at these contact details instead? Doing so will deselect any agents as your default.") == true){
									blnGo = true;
								}else{
									blnGo = false;
									return false;
								}
							}
							if(blnGo == true){
								aAgency[x][4] = false;	
								get("dAgencyList").childNodes[x].childNodes[1].innerHTML = "-";
							}
						}
					}
				}
			}
			return true;
		}
		
		// Rating system (stars)
		function rate(action,o){
			var s = ""; // To hold the id of the start img obj
			var aPnt = o.id.split("_");
			xM = aPnt[3];
			switch(action){
				case "hi":
					for(x=1;x<=xM;x++){
						s = aPnt[0] + "_" + aPnt[1] + "_" + aPnt[2] + "_" + x;
						get(s).src=get(s).src.replace('_off.gif','.gif');
					}
					break;
				case "lo":
					for(x=1;x<=3;x++){
						s = aPnt[0] + "_" + aPnt[1] + "_" + aPnt[2] + "_" + x;
						if(get(s).src.indexOf("_off.gif") == -1){
							get(s).src=get(s).src.replace('.gif','_off.gif');
						}
					}
					s = aPnt[0] + "_" + aPnt[1] + "_" + aPnt[2] + "_P";
					if(get(s).value != ""){
						s = aPnt[0] + "_" + aPnt[1] + "_" + aPnt[2] + "_" + get(s).value;
						rate('hi',get(s));
					}
					break;
				case "set":
					for(x=1;x<=3;x++){
						s = aPnt[0] + "_" + aPnt[1] + "_" + aPnt[2] + "_" + x;
						if(get(s).src.indexOf("_off.gif") == -1){
							get(s).src=get(s).src.replace('.gif','_off.gif');
						}
					}
					for(x=1;x<=xM;x++){
						s = aPnt[0] + "_" + aPnt[1] + "_" + aPnt[2] + "_" + x;
						get(s).src=get(s).src.replace('_off.gif','.gif');
					}
					s = aPnt[0] + "_" + aPnt[1] + "_" + aPnt[2] + "_P";
					get(s).value = xM;
					break;
			}
		}
		
		function setAgent(o){
			if(o.checked){
				get("dAgency_1").style.display = "block";
			}else{
				get("dAgency_1").style.display = "none";
			}
		}
		
		function setAgentEmail(){
			get("Agency_EmailAddress").value = get("Account_EmailAddress").value;
		}
		
		function loadReg(AccountID){
			
			switch(iPRoxyMethod){
				case 1:
					sRegProxy = "proxy/proxy_asp.asp?uri=";
					break;
				case 2:
					sRegProxy = "proxy/proxy_php.asp?uri=";
					break;
				case 3:
					sRegProxy = "proxy/proxy_aspdotnet.aspx?uri=";
					break;
			}
			
			// Reset variables
			iInvalidCount = 0;
			iPrimaryStep = 1;
			lGlob_AccountID = null;
			sGlob_EmailAddress = null;
			sGlob_FullName = null;
			blnChanges = false;
			sChanges = "";
			currNav = 0;
			aSections = new Array();
			// ******************
			
			DynamicLoad(sRegProxy + 'http://www.useimagine.com/imagine2/api/register_component/registerNew.asp?ExposureID=' + lExposureID,sRegBlock,'init(' + AccountID + ')');	
			
		}
		
		function setForApproval(o){
			//if(o.checked){
				
					if(blnChanges){
						if(confirm("Save changes first?")==true){
							saveAll();
						}
					}
					
					showLoading();
			
					// get list of exposure
					var eL = "&ExposureList=";
					for (i = 0; i < document.regForm.elements.length; i++){
						if (document.regForm.elements[i].type == "checkbox" && document.regForm.elements[i].id == "Exposure"){
							if(document.regForm.elements[i].checked == true){
								eL += document.regForm.elements[i].value + "]]";
							}
						}
					}
					// ----------------------------
					DynamicLoad(sRegProxy + 'http://www.useimagine.com/imagine2/api/register_component/register_requestapprovalNew.asp','dTemp','setPrimaryStep("A")',encodeQS('AccountID=' + lGlob_AccountID + '&EmailAddress=' + sGlob_EmailAddress + '&Fullname=' + sGlob_Fullname + "&ExposureID=" + lExposureID + "&CardHolderID=" + iAccountType + eL));
				
			//}
		}
		
		function loadCityValues(o){
			
			return false; // Force exit - function no longer in use
			
			showLoading();
			if(o[o.selectedIndex].value != ""){
				
				remAll(get("Account_City"));
				elem = document.createElement("option");
				elem.value = "";
				elem.text = "- loading list -"
				inject(elem,get("Account_City"));
				
				/*
				remAll(get("Account_Area"));
				elem = document.createElement("option");
				elem.value = "";
				elem.text = "- loading list -"
				inject(elem,get("Account_Area"));
				*/
				
				DynamicLoad(sRegProxy + 'http://www.useimagine.com/imagine2/api/values_get_cities.asp','dTemp','showCityValues(\'' + o.id + '\');','as=text&country=' + o[o.selectedIndex].value);
			}else{
				
				remAll(get("Account_City"));
				//remAll(get("Account_Area"));
				hideLoading();
			}
				
		}
		function showCityValues(o){
			/*
			o = get(o);
			var oC = get("Account_City");
			var s = get("dTemp").innerHTML;
			var a = s.split("|");
			remAll(oC);
			for(x=0;x<a.length;x++){
				a2 = a[x].split(",");
				if(a2[2]){
					elem = document.createElement("option");
					elem.value = a2[0];
					elem.text = a2[2];
					inject(elem,get("Account_City"));
				}
			}
			//loadAreaValues(o.id);
			*/
			hideLoading();
		}
		
		function loadAreaValues(o){
			o = get(o);
			DynamicLoad(sRegProxy + 'http://www.useimagine.com/imagine2/api/values_get_towns.asp','dTemp','showAreaValues(\'' + o.id + '\');','as=text&country=' + o[o.selectedIndex].value);
		}
		function showAreaValues(o){
			o = get(o);
			var oC = get("Account_Area");
			var s = get("dTemp").innerHTML;
			var a = s.split("|");
			remAll(oC);
			for(x=0;x<a.length;x++){
				a2 = a[x].split(",");
				if(a2[2]){
					elem = document.createElement("option");
					elem.value = a2[0];
					elem.text = a2[2];
					inject(elem,get("Account_Area"));
				}
			}
			hideLoading();
		}
		
		function uploadCV(){
			var fld = window.open('http://www.useimagine.com/imagine2/api/register_component/register_cvuploadNew.asp?AccountID=' + lGlob_AccountID + '&EmailAddress=' + sGlob_EmailAddress + '&Fullname=' + sGlob_Fullname + "&ExposureID=" + lExposureID + "&CardHolderID=" + iAccountType,'cvupload','width=320,height=130,resize=no,top='+ (screen.height/2 - 15) +',left=' + (screen.width/2 - 150));
		}
		
		function loadCV(){
			get("cvFrame").src = "http://www.useimagine.com/imagine2/api/register_component/register_cvuploadNew.asp?" + encodeQS('AccountID=' + lGlob_AccountID + "&CardHolderID=" + iAccountType + '&EmailAddress=' + sGlob_EmailAddress + "&ExposureID=" + lExposureID);
		}
		
		function uploadPP(){
			var fld = window.open('http://www.useimagine.com/imagine2/api/register_component/register_ppupload.asp?AccountID=' + lGlob_AccountID + '&EmailAddress=' + sGlob_EmailAddress + '&Fullname=' + sGlob_Fullname + "&ExposureID=" + lExposureID,'ppupload','width=320,height=130,resize=no,top='+ (screen.height/2 - 15) +',left=' + (screen.width/2 - 150));
		}
		
		function loadPP(){
			window.ppFrame.location.href = "http://www.useimagine.com/imagine2/api/register_component/register_ppuploadNew.asp?" + encodeQS('AccountID=' + lGlob_AccountID + "&CardHolderID=" + iAccountType + '&EmailAddress=' + sGlob_EmailAddress + "&ExposureID=" + lExposureID);
			
		}
		
		function agency_addrequest(){
			DynamicLoad(sRegProxy + 'http://www.useimagine.com/imagine2/api/register_component/register_agencyaddrequest.asp','dTemp','agency_hiderequest()',encodeQS('agency_new_name=' + get('Agency_New_Name').value + '&agency_new_tel=' + get('Agency_New_Tel').value));
		}
		
		function agency_hiderequest(){
			get('dAgencyNew').style.display = 'none';
			if(get('Agency_ID').selectedIndex == 1){
				get('Agency_ID').selectedIndex = 0;
			}
		}
		
		function agency_showrequest(){
			get('dAgencyNew').style.display = 'block';
		}
		
		function accounttype_addrequest(){
			sEmail = get("Account_EmailAddress").value;
			sName = get("Account_FirstName").value + " " + get("Account_Surname").value;
			if(sEmail == "" || sName == ""){
				alert("You need to enter your name and email address in order to request additional account types.");
				return false;
			}
			DynamicLoad(sRegProxy + 'http://www.useimagine.com/imagine2/api/register_component/register_accounttypeaddrequest.asp','dTemp','accounttype_hiderequest()',encodeQS('accounttype_new_name=' + get('AccountType_New_Name').value + '&accounttype_new_email=' + sEmail + '&accounttype_new_requestor=' + sName + '&exposureid=' + lExposureID));
		}
		
		function accounttype_hiderequest(){
			get('dAccountTypeNew').style.display = 'none';
		}
		
		function accounttype_showrequest(){
			get('dAccountTypeNew').style.display = 'block';
		}
		
		var timer_leA = 0;
		function load_ExposureAll(){
			var oS = get("dAccountID");
			var sS = oS.innerHTML;
			var aS = sS.split(";");
			var aA1 = aS[1].split("]]");
			var aA2 = aS[2].split("]]");
			var aA3 = aS[3].split("]]");
			var sCHIDList = "";
			for(x=0;x<aA1.length;x++){
				if(aA1[x] != ""){
					get("prof_status_" + aA1[x]).innerHTML = "";
					sCHIDList = sCHIDList + aA1[x] + "|";
				}
			}
			DynamicLoad(sRegProxy + "http://www.useimagine.com/imagine2/api/register_component/register_get_accountdetails.asp","dTemp", "load_ExposureAll_Process('" + sCHIDList + "')", "CardHolderID=" + sCHIDList + "&Get_ExposureAll=Y&ExposureID=" + lExposureID);
		}
		function load_ExposureAll_Process(sCHIDList){
			iStatusCount = 0;
			var iC = "";
			var s = get("dTemp").innerHTML;
			var a = s.split("|");
			for(i=0;i<a.length;i++){
				if(a[i] != ""){
					var a2 = a[i].split("]]");
					if(a2[0] != "" && a2[1] != ""){
						if(a2[0] == iC){
							iStatusCount = iStatusCount + 1;
						}else{
							iStatusCount = 0;
						}
						if(iStatusCount != 0){
							sSep = "]]";
						}else{
							sSep = "";
						}
						get("prof_status_" + a2[0]).innerHTML = get("prof_status_" + a2[0]).innerHTML + sSep + a2[1];
						if(a2[0] == iAccountType){
							if(get("prof_status_" + a2[0]).innerHTML == "has images"){
								get("iBtnApproval").src = "images/reg_submit_blue.gif";
							}else{
								get("iBtnApproval").src = "images/reg_submit.gif";
							}
							if((get("prof_status_" + a2[0]).innerHTML).indexOf("has images") == -1){
								get("iBtnApproval").style.display = "none";
							}else{
								if((get("prof_status_" + a2[0]).innerHTML).indexOf("live") == -1){
									get("iBtnApproval").style.display = "block";
								}else{
									get("iBtnApproval").style.display = "none";
								}
							}
						}
						iC = a2[0];
					}
				}
			}
			hideLoading();
			window.clearTimeout(timer_leA);
			timer_leA = window.setTimeout("load_ExposureAll()",20000);
		}