<!--

function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function mo(objButton){
	if(objButton.className=='btnO'){
		objButton.className='btn';
	}
	else if(objButton.className=='btn'){
		objButton.className='btnO';
	}
}

function initEditor1(strInitContent){
	document.getElementById("objPage").contentWindow.document.designMode = 'On';
	document.getElementById("objPage").contentWindow.document.getElementById("textBody").innerHTML = strInitContent;
}

function initEditor2(strInitContent){
	document.getElementById("objPage").contentWindow.document.designMode = 'On';
}

function doSimpleFormat(strCmd,strArg){
	strDoc = eval("document.getElementById('objPage').contentWindow.document");
	strDoc.execCommand(strCmd, false, strArg);
}

function doValidateLink(objF){
	if(!objF.name.value){
		alert("Please enter the name of the website");
		objF.name.focus();
		return false;
	}
	if(!objF.url.value){
		alert("Please enter the website's address");
		objF.url.focus();
		return false;
	}

}

function doValidateLogin(objF){
	if(!objF.username.value){
		alert("Please enter your username");
		objF.username.focus();
		return false;
	}
	if(!objF.password.value){
		alert("Please enter your password");
		objF.password.focus();
		return false;
	}
}

function doValidateNewPass(objF){
	if(!objF.username.value){
		alert("Please enter your username");
		objF.username.focus();
		return false;
	}
	if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(objF.email.value)){
		alert("Please enter a valid email address");
		objF.email.focus();
		return false;
	}
}

function doValidateFAQ(objF){
	if(!objF.no.value){
		alert("Please enter a question number");
		objF.no.focus();
		return false;
	}
	if(!objF.q.value){
		alert("Please enter a question");
		objF.q.focus();
		return false;
	}

}

function doValidateDelete(objF){
	if(!objF.password.value){
		alert("Please enter your password");
		objF.password.focus();
		return false;
	}
}

function doFullscreen(strURL){
	window.open(strURL, '', 'left=0,top=0,width='+screen.width+',height='+(screen.height-80)+', fullscreen=no, status=yes, scrollbars=yes');
	return false;
}

function doConfirm(strMessage){
	
}

function doNewDocument(doConf){
	if(doConf == "n"){
		document.location.href='index.php?ref=c3RyQWN0aW9uPWFkZCZzdHJNZWRpYT11c2VyX2RvYw==';
	}
	else{
		var conf = confirm("Are you sure you wish to create a new document?\r\nYou will lose any changes made to the currently open document.");
		if(conf){
			document.location.href='index.php?ref=c3RyQWN0aW9uPWFkZCZzdHJNZWRpYT11c2VyX2RvYw==';
		}
		return false;
	}
}

function doOpenDocument(doConf){
	if(doConf == "n"){
		window.parent.opener.location.href='index.php?ref=c3RyQWN0aW9uPXVwZGF0ZSZzdHJNZWRpYT11c2VyX2RvYw==';
		this.parent.window.close();
	}
	else{
		var conf = confirm("Are you sure you wish to open another document?\r\nYou will lose any changes made to the current document.");
		if(conf){
			window.parent.opener.location.href='index.php?ref=c3RyQWN0aW9uPXVwZGF0ZSZzdHJNZWRpYT11c2VyX2RvYw==';
			this.parent.window.close();
		}
		return false;
	}
}

function doSaveDocument(){
	objTemp = document.forms[0].title;
	var strNewName = prompt("What name should we save this document under?",objTemp.value);
	if(strNewName){
		objTemp.value = strNewName;
		document.forms[1].export_name.value = strNewName;
		strDocBody = document.getElementById('document').contentWindow.document.getElementById('docbody').innerHTML;
		document.forms[0].body.value = strDocBody;
		//window.parent.opener.location.href='index.php?ref=c3RyQWN0aW9uPXVwZGF0ZSZzdHJNZWRpYT11c2VyX2RvYw==';
		//this.parent.window.close();
	}
	else{
		return false;
	}
}

function doExport(strType){
	strDocBody = document.getElementById('document').contentWindow.document.getElementById('docbody').innerHTML;
	document.forms[1].export_type.value = strType;
	document.forms[1].export_body.value = strDocBody;
}

function doExit(doConf){
	if(doConf == "n"){
		this.parent.window.close();
	}
	else{
		var conf = confirm("Are you sure you wish to exit?\r\nYou will lose any changes made to the current document.");
		if(conf){
			this.parent.window.close();
		}
		return false;
	}
}

function doRevealParas(intDivID){
	//alert(intDivID);
	if(document.getElementById("section"+intDivID).innerHTML == ""){
		alert("This section is currently empty.");
	}
	else{
		if(document.getElementById("section"+intDivID).style.display == "block"){
			document.getElementById("link"+intDivID).innerHTML = "<img src=\"../images/tools/expand.gif\" border=\"0\" width=\"59\" height=\"10\">";
			document.getElementById("section"+intDivID).style.display = 'none';
		}
		else{
			document.getElementById("link"+intDivID).innerHTML = "<img src=\"../images/tools/contract.gif\" border=\"0\" width=\"59\" height=\"10\">";
			document.getElementById("section"+intDivID).style.display = 'block';
			document.getElementById("tick"+intDivID).innerHTML = "&nbsp; &nbsp;<img src=\"../images/tools/tick.gif\" width=\"19\" height=\"14\">";
		}
	}
}

function doRefreshPara(strIDCode){
	document.getElementById('para').contentWindow.document.location.href='para.php?d='+strIDCode;
}

function hilitePara(intPara){
	document.getElementById("para"+intPara).style.background='#eeeeee';
}

function dehilitePara(intPara){
	document.getElementById("para"+intPara).style.background='#ffffff';
}

function insertPara(strParaBody,intSection){
	document.getElementById("ctick"+intSection).innerHTML = "&nbsp; &nbsp;<img src=\"../images/tools/ctick.gif\" width=\"19\" height=\"14\">";
	objDocWindow = window.parent.document.getElementById('document').contentWindow.document;
	intParaID = objDocWindow.forms[0].paracount.value;
	intParaID++;
	strParaBody = strParaBody.replace(/\[\[DATA\]\]/g,"<span class=\"hilite\" onClick=\"modifyPara("+intParaID+",this)\">");
	strParaBody = strParaBody.replace(/\[\[\/DATA\]\]/g,"</span>");
	objDocWindow.getElementById('docbody').innerHTML += ""+
	"<span id=\"holder"+intParaID+"\"><table cellspacing=\"0\" cellpadding=\"0\" width=\"100%\"><tr>"+
	"<td><p id=\"para"+intParaID+"\" onMouseOver=\"hilitePara("+intParaID+");\" onMouseOut=\"dehilitePara("+intParaID+");\" class=\"medium\">"+strParaBody+"</p></td>"+
	"<td width=\"100\" align=\"center\" onMouseOver=\"hilitePara("+intParaID+");\" onMouseOut=\"dehilitePara("+intParaID+");\">"+
	"<a href=\"javascript:;\"><img src=\"../images/tools/up.gif\" border=\"0\" alt=\"Move Up\" title=\"Move Up\" onClick=\"swapPara("+intParaID+",'up')\"></a> &nbsp;"+
	"<a href=\"javascript:;\"><img src=\"../images/tools/dn.gif\" border=\"0\" alt=\"Move Down\" title=\"Move Down\" onClick=\"swapPara("+intParaID+",'down')\"></a> &nbsp;"+
	"<a href=\"javascript:;\"><img src=\"../images/tools/rm.gif\" border=\"0\" alt=\"Remove\" title=\"Remove\" onClick=\"deletePara("+intParaID+")\"></a>"+
	"</td></tr></table><br></span>";
	objDocWindow.forms[0].paracount.value = intParaID;

window.parent.document.getElementById('document').contentWindow.scrollTo(0, 100000);
	//objFocus = eval("objDocWindow.forms[1].anc1");
	//alert(objDocWindow.getElementById('docbody').innerHTML);
	//alert(objFocus);
	//objFocus.focus();
}

function deletePara(intHolder){
	document.getElementById("holder"+intHolder).innerHTML = '';
}

function swapPara(intPara,strDir){
	objDocWindow = window.parent.document.getElementById('document').contentWindow.document;
	intNumParas = 100;//objDocWindow.forms[0].paracount.value;
	arrIDs = new Array();
	for(i=0;i<=intNumParas;i++){
		if(objDocWindow.getElementById("para"+i) != null){
			//alert(objDocWindow.getElementById("para"+i));
			arrIDs.push(i);
			if(i==intPara){
				intTemp = arrIDs.length-2;
				intPrevPara = arrIDs[intTemp];
				intNextID = arrIDs.length;
			}
		}
	}
	intNextPara = arrIDs[intNextID];
	var strPara1 = "para"+intPara;
	if(strDir == "up"){
		var strPara2 = "para"+intPrevPara;
	}
	else{
		var strPara2 = "para"+intNextPara;
	}
	//alert("Your para is "+intPara+". The para before it is "+intPrevPara+". The para after it is "+intNextPara);
	if(document.getElementById(strPara2) == null){
		window.status = "Error: Paragraph cannot be moved "+strDir+ " any further!";
		return false;
	}
	strTemp1 = document.getElementById(strPara1).innerHTML;
	strTemp2 = document.getElementById(strPara2).innerHTML;
	document.getElementById(strPara1).innerHTML = strTemp2;
	document.getElementById(strPara2).innerHTML = strTemp1;
}

function modifyPara(intPara,objSpan){
	var strNewText = prompt("Please enter your new text, then click OK",objSpan.innerHTML);
	if(strNewText){
		replaceText(intPara,objSpan.innerHTML,strNewText,objSpan);
	}
}

function replaceText(intPara,strOldText,strNewText,objPara){
	strTemp = objPara.innerHTML;
	objPara.className='hiliteC';
	objPara.innerHTML = strTemp.replace(strOldText,strNewText);
}

function doValidateParagraph(objF){
	if(!objF.summary.value){
		alert("Please enter a short summary for your paragraph.");
		objF.summary.focus();
		return false;
	}
	strTemp =document.getElementById('objPage').contentWindow.document.body.innerHTML;
	//strTemp = strTemp.replace(/\<span style=\"font\-weight\: bold\;\"\>/ig,"[[DATA]]");
	//	strTemp = strTemp.replace(/\<\/span\>/ig,"[[/DATA]]");
	//strTemp = strTemp.replace(/\<b\>/ig,"[[DATA]]");
	//strTemp = strTemp.replace(/\<\/b\>/ig,"[[/DATA]]");
	//strTemp = strTemp.replace(/\<strong\>/ig,"[[DATA]]");
	//strTemp = strTemp.replace(/\<\/strong\>/ig,"[[/DATA]]");
	//strTemp = strTemp.replace(/\r\n/g,"");
	strTemp = strTemp.replace(/\<br\>/g,"\r\n");
	objF.body.value = strTemp;
}

function doValidateAdminAccount(objF){
	if(!objF.contact_title.value){
		alert("Please fill in the following field: Title.");
		objF.contact_title.focus();
		return false;
	}
	if(!objF.contact_forename.value){
		alert("Please fill in the following field: Forename.");
		objF.contact_forename.focus();
		return false;
	}
	if(!objF.contact_surname.value){
		alert("Please fill in the following field: Surname.");
		objF.contact_surname.focus();
		return false;
	}
	if(!objF.contact_position.value){
		alert("Please fill in the following field: Position.");
		objF.contact_position.focus();
		return false;
	}
	if(!objF.company.value){
		alert("Please fill in the following field: Company.");
		objF.company.focus();
		return false;
	}
	if(!objF.address.value){
		alert("Please fill in the following field: Address.");
		objF.address.focus();
		return false;
	}
	if(!objF.postcode.value){
		alert("Please fill in the following field: Postcode.");
		objF.postcode.focus();
		return false;
	}
	if(objF.fsa_no.value.length != 6){
		alert("Please fill in the following field: FSA Number (6 digits).");
		objF.fsa_no.focus();
		return false;
	}
	if(!objF.regulated[0].checked){
		if(!objF.regulated[1].checked){
			alert("Please fill in the following field: Regulated by FSA.");
			objF.regulated[0].focus();
			return false;
		}
	}
	if(!objF.network[0].checked){
		if(!objF.network[1].checked){
			alert("Please fill in the following field: Part of a Network.");
			objF.network[0].focus();
			return false;
		}
	}
	if(objF.network[0].checked){
		if(!objF.network_name.value){
			alert("Please fill in the following field: Network Name.");
			objF.network_name.focus();
			return false;
		}
	}
	if(!objF.telephone.value){
		alert("Please fill in the following field: Telephone Number.");
		objF.telephone.focus();
		return false;
	}
	if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(objF.email.value)){
		alert("Please provide a valid email address.");
		objF.email.focus();
		return false;
	}
}

function doValidateAdminUser(objF){
	
	if(!objF.title.value){
		alert("Please fill in the following field: Title.");
		objF.title.focus();
		return false;
	}
	
	if(!objF.forename.value){
		alert("Please fill in the following field: Forename.");
		objF.forename.focus();
		return false;
	}
	
	if(!objF.surname.value){
		alert("Please fill in the following field: Surname.");
		objF.surname.focus();
		return false;
	}
	
	if(!objF.position.value){
		alert("Please fill in the following field: Position.");
		objF.position.focus();
		return false;
	}
	
	if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(objF.email.value)){
		alert("Please provide a valid email address.");
		objF.email.focus();
		return false;
	}
	
	if(!objF.username.value){
		alert("Please fill in the following field: Username.");
		objF.username.focus();
		return false;
	}
	
	if(objF.add.value == "y"){
		if(!objF.password.value){
			alert("Please fill in the following field: Password.");
			objF.password.focus();
			return false;
		}
		else{
			if(objF.password.value != objF.confirm.value){
				alert("Password and confirmation do not match.");
				objF.confirm.focus();
				return false;
			}
		}
	}
}

function openWindow(theURL,winName,features, myWidth, myHeight, isCenter){
	if(window.screen)if(isCenter)if(isCenter=="true"){
		var myLeft = (screen.width-myWidth)/2;
		var myTop = (screen.height-myHeight)/2;
		features+=(features!='')?',':'';
		features+=',left='+myLeft+',top='+myTop;
	}
	window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
}

//-->
