function ExistingUser(){	var theBase = document.getElementsByTagName('base')[0].href;	window.location.href=theBase + '?open&login';}function UserDetailsOpenFlat(unid, path){	var theBase = document.getElementsByTagName('base')[0].href	window.location.href=path +'/0/' + unid + '?editdocument&sys=' + document.forms[0].SystemName.value;}function NetDetailsOpenFlat(unid){	var theBase = document.getElementsByTagName('base')[0].href	window.location.href=theBase +'all/0/' + unid + '?opendocument';}function PrintVersion(){	//var theBase = document.getElementsByTagName('base')[0].href	var newurl=document.forms[0].Path_Info.value + '&print=P';	//window.location.href=theBase +'pageprint?openform&type=' + type + '&ID=' + id;	//window.open(newurl); 	window.open( newurl, "_blank", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, width=850, height=700" ) }function OpenPrintPage(type,id){	var theBase = document.getElementsByTagName('base')[0].href	var newurl=theBase +'pageprint?openform&type=' + type + '&ID=' + id;	//window.location.href=theBase +'pageprint?openform&type=' + type + '&ID=' + id;	window.open(newurl); }function is_doc_valid(){	//init the validator	Validator.init( "_UserDetails", "form_top" );				Validator.fields=			[				{name: "FirstName", message: "Please enter your first name."},				{name: "Surname", message: "Please enter you surname."},				{name: "email", message: "Please enter your email address."},				{name: "Password", type: "custom", expression: "password()", message: "Please enter and confirm your password."},			/*	{name: "UserName", type: "custom", expression: "username()", message: "A user name of first initial and surname has already been used. Please accept the suggested user name or enter an alternative."} */			/*	{name: "content", message: "Please add content."}, */ 			];		var is_valid = false ; 	if( Validator.validate() ) {		is_valid = true;	} 		//	if (content_l3()) {				//	} else {	//			is_valid = false;	//	}				//var is_user_valid = content_authorise();		//if( is_user_valid ) {		//	is_valid = true;		//	debug( "VALID" );	//	} else {	//		is_valid = false;	//		debug( "NOT VALID" );	//	}	//	} else {//		is_valid = false ; //	}	return is_valid;			}			function password(){	/*	--check is same password has been entered twice.	*/	if (document.forms[0].Password.value == ""){	return_value = false;	} else {			if (document.forms[0].Password_1.value == ""){				return_value = false;			} else {				if (document.forms[0].Password.value != document.forms[0].Password_1.value ){						return_value = false;					} else {					return_value = true;					}			}		}		return return_value;	}		function username(){	/*	--check user name ok.	*/	if (document.forms[0].Password.value == ""){	return_value = false;	} else {			if (document.forms[0].Password_1.value == ""){				return_value = false;			} else {				if (document.forms[0].Password.value != document.forms[0].Password_1.value ){						return_value = false;					} else {					return_value = true;					}			}		}		return return_value;	}				function Reminder(path){	//var theBase = document.getElementsByTagName('base')[0].href	var sys = document.forms[0].Path_Info.value;	window.location.href=path + '/password_rem?OpenForm&sys=' + document.forms[0].SystemName.value; }function CheckAccessCode(){	var theBase = document.getElementsByTagName('base')[0].href	$('validText').style.display = "none"	pars=$H(		{			code: $F("AccessCode")		}	);	var ajax_req = new Ajax.Request( 	theBase + "CheckAccessCode?openagent",				{method: 'get', parameters: pars.toQueryString(), onComplete: handle_related_response}	);	}function handle_check_access(status, path){	//var theBase = document.getElementsByTagName('base')[0].href		if (status == "failed"){					$('validText').style.display = "block";					alert("Invalid access code, or code already used. Please retry");		}else{					//var sys = document.forms[0].get_db_path.value;					window.location.href=path + '/UserDetails?OpenForm&code=' + status + '&sys=' + document.forms[0].SystemName.value; return false;		}}function handle_related_response( response ) {	eval( response.responseText ) ; }function doUserSearch(){	if ( $F( "search_field" ) != "" ) {			pars=$H(				{					searchThis: $F( "search_field" )				}			);		var ajax_req = new Ajax.Request( 		"usersearch?openagent",		{method: 'get', parameters: pars.toQueryString(), onSuccess: handleResponse, onFailure:handleError}	);	}}function doPassSearch(){	if ( $F( "search_field" ) != "" ) {			pars=$H(				{					searchThis: $F( "search_field" )				}			);		var ajax_req = new Ajax.Request( 		"passsearch?openagent",		{method: 'get', parameters: pars.toQueryString(), onSuccess: handleResponse, onFailure:handleError}	);	}}function doContractSearch(){	if ( $F( "search_field" ) != "" ) {			pars=$H(				{					searchThis: $F( "search_field" )				}			);		var ajax_req = new Ajax.Request( 		"contractsearch?openagent",		{method: 'get', parameters: pars.toQueryString(), onSuccess: handleResponse, onFailure:handleError}	);	}}function handleError() {	alert ("An error occured while trying to search, please try again.")}function handle_return_usersearch( strResults ) {	if( strResults == "no_docs" ) {	alert ("No docs")		var get_div = $("searchResults");		get_div.innerHTML= "";	} else {	alert ("Docs")		var get_div = $("searchResults");		get_div.innerHTML= strResults;	}}function returnResult( strResults, divName ) {		var get_div = $(divName)	get_div.style.display = "block"	get_div.innerHTML= strResults + "<br>"	}function UserDetails(unid){	var theBase = document.getElementsByTagName('base')[0].href		if (unid == "New") {	var modal_url = theBase + "UserDetails?openform";	}else {	var modal_url = "0/" + unid + "?editdocument";	}		var opts = get_window_opts( 'UserDetails', 600, 500 ) ;	show_window( modal_url, opts );}function ContractDetails(unid){	var theBase = document.getElementsByTagName('base')[0].href		if (unid == "New") {	var modal_url = theBase + "CompanyContract?openform";	}else {	alert("unid = " + unid);	var modal_url = theBase+ "0/" + unid + "?editdocument";	}		var opts = get_window_opts( 'CompanyContract', 600, 500 ) ;	show_window( modal_url, opts );}function forumTopic(unid){		var theBase = document.getElementsByTagName('base')[0].href		if (unid == "New1") {		//alert("new 1");		var modal_url = theBase + "NewInput?openform&L=1";		var opts = get_window_opts( 'NewInput1', 600, 500 ) ;	} else {		if (unid.substring(0,3) == "New") {			//alert("new 2 " +  unid.substring(4) );			var intnum = unid.indexOf( "|" );			var stropt = "NewInput" + unid.substring(3, intnum);  				var modal_url = theBase + "NewInput?openform&L=2&code=" + unid.substring(intnum+1) +"&New=Y";			var opts = get_window_opts( stropt, 600, 500 ) ;		}else {			if (unid.substring(0,4) == "Edit") {		//		alert("edit " +  unid.substring(4) );				var intnum = unid.indexOf( "|" );				var stropt = "NewInput" + unid.substring(4 , intnum);  					//	var modal_url = theBase + "NewInput?editform&L=2&code=" + unid.substring(intnum+1);					var modal_url = "0/" + unid.substring(intnum+1) + "?editdocument";								var opts = get_window_opts( stropt, 600, 500 ) ;			}else {							var intnum = unid.indexOf( "|" );				var modal_url = theBase + "forumpath?openform&code=" + unid.substring(intnum+1);		//		var modal_url = "0/" + unid + "?opendocument";				var opts = get_window_opts( 'forumpath', 900, 700 ) ;			}				}		}	//	var opts = get_window_opts( 'NewInput', 600, 500 ) ;	show_window( modal_url, opts );}function forumDraft(unid){		var theBase = document.getElementsByTagName('base')[0].href			if (unid.substring(0,4) == "Edit") {		//		alert("edit " +  unid.substring(4) );				var intnum = unid.indexOf( "|" );				var stropt = "NewInput" ;			//	var modal_url = theBase + "NewInput?editform&L=2&code=" + unid.substring(intnum+1);					var modal_url = "0/" + unid.substring(intnum+1) + "?editdocument";								var opts = get_window_opts( stropt, 600, 500 ) ;			}else {								var intnum = unid.indexOf( "|" );				var modal_url = theBase + "forumpath?openform&code=" + unid.substring(intnum+1);		//		var modal_url = "0/" + unid + "?opendocument";				var opts = get_window_opts( 'NewInput', 600, 500 ) ;			}				//	var opts = get_window_opts( 'NewInput', 600, 500 ) ;	show_window( modal_url, opts );}function get_window_opts( id, w, h ){	return {		id: id, 		width: w,		height: h, 		minWidth: w,		minHeight: h,		className: 'alphacube',		recenterAuto: false,		draggable: true,		minimizable: false, 		maximizable: false,		showEffect:Element.show,		hideEffect: Effect.Fade	}}function show_window( url, opts ){	win = new Window( opts );	win.setDestroyOnClose( true );	win.setAjaxContent( url, {method: 'get'}, true, true);}