
//theForm.elements[theName].value = theValue;


function ImagePreload() {
	if (typeof(arguments) != 'undefined') {
		for (i=0; i<arguments.length; i++ ) {
			if (typeof(arguments[i]) == "object") {
				for (k=0; k<arguments[i].length; k++) {
					var oImage = new Image;
					oImage.src = arguments[i][k];
				}
			}
 
			if (typeof(arguments[i]) == "string") {
				var oImage = new Image;
				oImage.src = arguments[i];
			}
		}
	}
}


ImagePreload('images/tnav_seps_lr.gif' ,   'images/ln_bot_o.gif' , 'images/ln_bg_o.gif' , 'images/ln_bg_o_1.gif' , 'images/ln_bg_s.gif' , 'images/ln_bg_s_1.gif' , 'images/tour_o.jpg' , 'images/download_o.gif' , 'images/dr_top.gif' , 'images/dr_bg_u.gif' , 'images/dr_bg_o.gif' , 'images/dr_ft_u.gif' , 'images/dr_ft_o.gif' , 'images/dr_bg_str.gif' );


function appForm(){
	
		if (document.form1.Forename.value=="" || document.form1.Forename.value=="undefined"){
		alert('Please enter a Forename.');
	}else if (document.form1.Surname.value=="" || document.form1.Forename.value=="undefined"){
		alert('Please enter a Surname.');
	}else if ((document.form1.EmailAddress.value=="" || document.form1.EmailAddress.value=="undefined") && (document.form1.TelephoneNumber.value=="" || document.form1.TelephoneNumber.value=="undefined")){
		alert('Please enter an Email Address or Telephone Number.');
	}else{
	document.form1.submit();
	}
	
}
function changeStyle(theTarg,theNewStyle){
document.getElementById(theTarg).className = theNewStyle;	
}
function goAlert(x){
	if(x=='noFileYet'){
		alert('The file does not yet exist');
	}
	if(x=='cantEditSiteMap'){
		alert('The site map can not be edited as it is automatically generated by the site.');
	}
	
	if(x=='itsaFormPageCantEdit'){
		alert('The file can not be edited because it contains a form.');
	}
}
function writToLayer(text,id){
	document.getElementById(id).innerHTML = text;
//x = document.getElementById(id);
		//x.innerHTML = '';
		//x.innerHTML = text;

}

function openWindow(x){
	//if(y==undefined){
		//y="_top";
		window.location =x;
//	}else{
		//window.open(x, 'KFTRA  &amp; Residents Associations');
	//}
	
}
window.curtopnav=0;
curleftnav=0;
function setTopNav(x){
	
	
	//window.curtopnav=x;
	window.curtopnav=window.realTopNavId[x];
	//alert(x+'|'+window.realTopNavId[x]);
	//alert(window.curtopnav);
changeStyle(("topnavlink"+window.curtopnav), "topnavlinkactive");
rollTopNavOver(window.curtopnav,"nodrop");
}
function setLeftNav(y){
	//writToLayer(y,'writeme');
	//alert(y);
curleftnav=y;
//changeStyle(("leftnav"+y), "leftnavo");
if(y!=0){
changeStyle(("leftnavlink"+y), "leftnavlinkactive");
leftNavOv(y);
}
//alert('DONE');

}
function adjustDrops(){

	topNavPos=document.getElementById('topnav').offsetLeft;
	navWidth=document.getElementById('topnav').offsetWidth;
	
	//drop7

	//alert(navWidth);
	//alert('WTF');
	for(i=1;document.getElementById('drop'+i+'but1');i++){
		dropLeftPos=document.getElementById('drop'+i).offsetLeft;
		dropWidth=document.getElementById('drop'+i+'but1').offsetWidth;
		tabWidth=document.getElementById('topnavtab'+i).offsetWidth;
		sepWidth=document.getElementById('topnavsep'+i).offsetWidth;
			if(dropLeftPos+dropWidth>navWidth){
		//alert(sepWidth);
		newDropPos=(0-dropWidth)+tabWidth+sepWidth+(sepWidth*.5);
		document.getElementById('drop'+i).style.marginLeft = newDropPos+'px';	
	}
	}
}
function setPageUp(x,s,i){
if(x=='admin'){
	window.deleteList=new Array;
	dropDown1isActive=true;
dropDown2isActive=true;
dropDown3isActive=true;
dropDown4isActive=true;
dropDown5isActive=true;
dropDown6isActive=true;
dropDown7isActive=true;
dropDown8isActive=true;
dropDown9isActive=true;

window.pageMode='admin';

setTopNav(window.curtopnav);
//window.contentChanged='no';
//alert("nn");
//alert('SETPAGE');


}else{
	
window.pageMode='public';

//curleftnav=3;
//changeStyle(("leftnavlink"+curleftnav), "leftnavlinkactive");
//leftNavOv(curleftnav);
//tf();

dropDown1isActive=true;
dropDown2isActive=true;
dropDown3isActive=true;
dropDown4isActive=true;
dropDown5isActive=true;
dropDown6isActive=true;
dropDown7isActive=true;
dropDown8isActive=true;
dropDown9isActive=true;

setTopNav(s);
	
setLeftNav(i);
//writToLayer('GONNA FILL THIS','writeme');

writeRecent();//

adjustDrops();
}
}


///////////////////////////////////////////////////////////////////////////////////////////top nav

function timeOutTopNav(x){

if(window.timingOutTopNav==1){
clearTimeout(shutDD);
}
window.timingOutTopNav=1;
shutDD = setTimeout('closeOpenDDimmediately()', x);

}
function stopTimeOutTopNav(){
if(window.timingOutTopNav==1){
clearTimeout(shutDD);
}

}
/////////////////
function closeOpenDDimmediately(){
//closeRolledTab();
if(this["dropDown"+curroll+"isActive"]==true){
//detectclass = document.getElementById("drop"+curroll).className;
//if(detectclass=="tvavdropvis"){
		
changeStyle(("drop"+curroll), "dropboxinv");		
stopTimeOutTopNav();
window.aDropIsOut=0;
//}
	
}

}
//////////////////
function testForObjectXXX(Id){
  var o = document.getElementById(Id);
  if (o){
    
// alert("ok!");
 return true;
    
  }else{
	 return false;
}

}



function testForObject(Id){
 
  if (document.getElementById(Id)){
    
// alert("ok!");
 return true;
    
  }else{
	 return false;
}
}


function rollTopNavOver(x,y){	
//if(dropOut==true){
//clearTimeout(shutDD);
//closeOpenDDimmediately();
//alert('ROLLED!');

//}

//writToLayer('GONNA FILL THIS','writeme');
if(window.aDropIsOut==1){
//stopTimeOutTopNav();
closeOpenDDimmediately();
//alert("WTF2");
//alert('ROLLED!');

}
curroll =x;
//curroll = window.realTopNavId[x];

//alert(x+' : '+curroll);
//writToLayer(x+' : '+curroll,'writeme');
//testForObject("wr");

if(testForObject("wr")){
	//alert('FOUND');

writToLayer('<br><br>X='+x+' , Y='+y,'wr');

}
	//testForObject(("drop"+x+"but1"))
//alert(this["dropDown"+x+"isActive"]);
if(this["dropDown"+curroll+"isActive"]==true && y!="nodrop" && testForObject(("drop"+x+"but1"))){
//detectclass = document.getElementById("tnavdrop"+x).className.split(' ');

changeStyle(("drop"+curroll), "dropboxvis");
//dropOut=true;
window.aDropIsOut=1;

}

changeStyle(("topnavtab"+curroll), "topnavtabover");
if(window.curtopnav == (curroll-1) && window.curtopnav!=0){
changeStyle(("topnavsep"+curroll), "topnavsepboth");
changeStyle(("topnavsep"+(curroll+1)), "topnavsepleft");
}else if(window.curtopnav == (x+1)){
changeStyle(("topnavsep"+(curroll+1)), "topnavsepboth");
changeStyle(("topnavsep"+curroll), "topnavsepright");
}else{	
changeStyle(("topnavsep"+(curroll+1)), "topnavsepleft");
changeStyle(("topnavsep"+curroll), "topnavsepright");
}

}

function changeImage(theTarg,theImage){
document.getElementById(theTarg).src=theImage;	
}



function rollTopNavOut(){
	//writToLayer('GONNA FILL THIS','writeme');
if(this["dropDown"+curroll+"isActive"]==true){
timeOutTopNav(1000);
}//else{
	//closeRolledTab();
//}
closeRolledTab();
}
function rollTopNavMove(){
	
}





function closeRolledTab(){
if(curroll!=window.curtopnav || window.curtopnav==undefined){
changeStyle(("topnavtab"+curroll), "topnavtabup");


if(window.curtopnav == (curroll-1) && window.curtopnav!=0){	
changeStyle(("topnavsep"+curroll), "topnavsepleft");
changeStyle(("topnavsep"+(curroll+1)), "topnavsepnone");
}else if(window.curtopnav == (curroll+1)){
changeStyle(("topnavsep"+(curroll+1)), "topnavsepright");
changeStyle(("topnavsep"+curroll), "topnavsepnone");
}else{	
changeStyle(("topnavsep"+(curroll+1)), "topnavsepnone");
changeStyle(("topnavsep"+curroll), "topnavsepnone");
}
}	
}
///////////////////////////////////////////////////////////////////////////////////////////DROP DOWN
function dropOver(x,y){
	//writToLayer('x:'+x+' , curtopnav:'+window.curtopnav+' , y:'+y,'writeme');
	changeStyle(("drop"+x+"but"+y), "tvavdropbuto");
	changeStyle(("drop"+x+"ft"+y), "tvavdropfto");
	//changeImage(("drop1ft"+x),"images/dr_ft_o.gif");
	if(x==window.curtopnav && y!=window.curleftnav && window.pageMode!='admin'){
		leftNavOv(y);
		changeStyle("leftnavlink"+y, "topnavlinkactive");
	}
}
function dropOut(x,y){
	changeStyle(("drop"+x+"but"+y), "tvavdropbutu");
	changeStyle(("drop"+x+"ft"+y), "tvavdropftu");
	//changeImage(("drop1ft"+x),"images/dr_ft_u.gif");
	if(x==window.curtopnav && y!=window.curleftnav && window.pageMode!='admin'){
		leftNavOut(y);
		changeStyle("leftnavlink"+y, "leftnavlink");
	}
}

///////////////////////////////////////////////////////////////////////////////////////////cont links
function rollLinkOver(x){
currolllink = x;
changeStyle(("linkout"+x), "linkouto");
changeImage(("linkend"+x),"images/link_bg_end_o.gif");
}
function rollLinkOut(){
changeStyle(("linkout"+currolllink), "linkoutu");
changeImage(("linkend"+currolllink),"images/link_bg_end_u.gif");
}

function rollDlOver(x){
currolldl = x;
changeStyle(("dlbox"+x), "dlboxo");

//changeImage(("dlend"+x),"images/dl_bg_end_o.gif");
}
function rollDlOut(){
	changeStyle(("dlbox"+currolldl), "dlboxu");
//changeStyle(("dlout"+currolldl), "dloutu");
//changeImage(("dlend"+currolldl),"images/dl_bg_end_u.gif");
}

//tov=0;
function dropDivOver(x){
	//tov++;
	//writToLayer("ROLLDOVER"+tov,'writeme');
	stopTimeOutTopNav()
}
//tou=0;
function dropDivOut(x){
	//tou++;
	if(this["dropDown"+curroll+"isActive"]==true){
timeOutTopNav(500);
};
}
m=0;
function dropTestMove(x){
	m++;
	//writToLayer("MOVED"+m,'writeme');
}

////////////////////////////////////LEFT NAV
function leftNavOut(x){
if(curleftnav!=x || curleftnav==0){
	changeStyle(("leftnav"+x), "leftnavu");
changeStyle(("leftnavbot"+x), "leftnavbotu");
//changeStyle(("leftnavtext"+x), "lntexto");
}
}
function leftNavOv(x){
	//writToLayer('x:'+x,'writeme');
	if(x==1){
		changeStyle(("leftnav"+x), "leftnavotop");
	}else{
		changeStyle(("leftnav"+x), "leftnavo");
	}

changeStyle(("leftnavbot"+x), "leftnavboto");
//changeStyle(("leftnavlink"+x), "leftnavlinkactive");
}
//////////////////////////////////////////////////////////////////////rec
function createCookie(name, value, days){
	//alert("MAKING COOKIE");

  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
    }
  else var expires = "";
  document.cookie = name+"="+value+expires+"; path=/";


	if(!document.cookie){
		//alert('NO COOKIES');
		window.cookieBlocked='yes';
	}
	//alert('MADE:'+document.cookie);
}

function readCookie(cookieName) {

 var theCookie=""+document.cookie;
 var ind=theCookie.indexOf(cookieName);
 if (ind==-1 || cookieName=="") return ""; 
 var ind1=theCookie.indexOf(';',ind);
 if (ind1==-1) ind1=theCookie.length; 
 return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}
function splitCookieToArray(){
tmp=readCookie("KFTRA");
cookieArray=tmp.split(':');	
//alert(cookieArray);
window.cookielength=cookieArray.length;
}
function updateCookie(){
//alert(window.curPageLoc);
splitCookieToArray();
if(cookieArray[0]!=window.curPageLoc+"#"+window.curPageTitle){
tmp2=readCookie("KFTRA");
//cookieInsert="("+window.curPageLoc+","window.curPageTitle+")";
//cookieInsert="("+window.curPageLoc+"|"window.curPageTitle;
//cookieInsert=window.curPageLoc+","+window.curPageTitle;
cookieInsert=window.curPageLoc+"#"+window.curPageTitle;
//createCookie("KFTRA", cookieInsert+":"+tmp2, 1);
createCookie("KFTRA", cookieInsert+":"+tmp2, 1);
}
//createCookie("KFTRA", window.curPageLoc+":"+tmp2, 1);
//createCookie("KFTRA", (sc_title+""+sc_url)+":"+tmp2, 1);
//splitCookieToArray();
}
function setCookies(){

if(document.cookie==false){
	//alert('no cookie');
	//cookieInsert=window.curPageLoc+"#"+window.curPageTitle;
//createCookie("KFTRA", cookieInsert, 1);
createCookie("KFTRA", "index.php#index.php", 1);
//alert("NEW COOKIE");
}else{
	//alert("OLD COOKIE");
updateCookie();
}
splitCookieToArray();
}

function writeHistoryItem(x){
	tmp=cookieArray[x];
	//alert(cookieArray[x]);
buildArray=tmp.split('#');	
	
	
	//window.tmpString+=
	//window.RecString+=cookieArray[x][0];
//window.tmpString='<?php include "templates/recent1.php"; ?>';
//window.tmpString+=
if(x>0){
	//if(x<3 ){
tmpString='<div class="recentsep"><img src="images/spacer.gif" width="190" height="1" alt=""></div><div class="recenttext"><div class="summaryu" id="recbox';
}else{
	tmpString='<div class="recenttext"><div class="summaryu" id="recbox';
}

//tmpString='<div class="recenttext"><div class="summaryu" id="recbox';
tmpString+=x;
tmpString+='"  onmouseover="javascript:textBoxOv(\'recbox';
tmpString+=x;
tmpString+='\')" onmouseout="javascript:textBoxOu(\'recbox';
tmpString+=x;
tmpString+='\')" onClick="javascript:openWindow(\'';

tmpString+=buildArray[0];

tmpString+='\')">';
tmpString+=buildArray[0];

tmpString+='<br><a href="';
tmpString+=buildArray[0];
tmpString+='" id="recbox';
tmpString+=x;
tmpString+='link">See Again...</a></div></div>';
//tmplength=cookieArray.length;
//if(x>0){
	//if(x<3 ){
//window.tmpString+='<div class="recentsep"><img src="images/spacer.gif" width="190" height="1" alt=""></div>';
//}
window.RecString+=tmpString;

//window.RecString+='HMM';




}
function writeHistoryItemXX(x){
	mainSection=cookieArray[x].charAt(0);
subSection=cookieArray[x].charAt(1);
theTxt=mainsectionNames[mainSection];
if(this["leftnav"+mainSection][subSection][1]){
theTxt=theTxt+" / "+this["leftnav"+mainSection][subSection][1];
}

window.RecString+='<div class="righttcolrecitem" id="rec'+x+'" name="rec'+x+'" onmouseover="recRollOver('+x+')"  onmouseout="recRollOut('+x+')" onclick="javascript:openUrl('+mainSection+','+subSection+')">'+theTxt+'<br /><a href="index.html?'+mainSection+"."+subSection+'" id="reclnk'+x+'" name="reclnk'+x+'" class="rec">&gt;&gt; view again</a></div>';

}
function writeRecent(){
	if(window.cookieBlocked!='yes'){
	//alert('writeRecent');


setCookies();
if(window.cookieBlocked!='yes'){
window.RecString="";





 recount=0;
 while(recount<5 && recount<window.cookielength){
	   writeHistoryItem(recount);
recount++; 
   }
//alert(window.RecString);
//window.RecString='NEW TEXT';
writToLayer(window.RecString,"recentinner");

changeStyle("recent", "recentvis");
changeStyle("recentfoot", "recentvis");
	}}
}
function writeRecentXX(){
	setCookies();
	window.RecString='WRITING';
writToLayer(window.RecString,"recent");
}
////////////////////////////////////////////////////////SUMMARY
function textBoxOv(x){
changeStyle(x, "summaryo");
changeStyle(x+"link", "activelink");
}
function textBoxOu(x){
changeStyle(x, "summaryu");
changeStyle(x+"link", "");

}
//////////////////////////////////////////////////////////////
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 doNothing(){}