//'--------------  Client Side Javascript for National Caravan Council A.Tickner-------------------



function jsTrim(strInput)
{
	var strResult;
	var objRegex = new RegExp("(^\\s+)|(\\s+$)");
	strResult = strInput.replace(objRegex, "");
	return(strResult);
}




//'--------------------------------------------------------------------------------------
//'    AUTHOR        : Anthony Tickner [anthonyt@dva.co.uk]
//'    DATE          : 8th November 2001 
//'    FUNCTION NAME : confirmSearch()
//'    COMMENTS      : 
  
//'    make sure we have a vaild os grid ref
 
//' -------------------------------------------------------------------------------------


function confirmSearch()
 {
    var str ="" +document.frmSearch.lstArea.value;
    if(str.indexOf("888888")>-1)
    {
      if (confirm("This search may take several moments.\n\nClick OK to Continue.")) 
      {
       document.frmSearch.submit();
      }
    } 
    else
    {
      document.frmSearch.submit();
     
    }
    
    
 }//Function End



//'--------------------------------------------------------------------------------------
//'    AUTHOR        : Anthony Tickner [anthonyt@dva.co.uk]
//'    DATE          : 8th November 2001 
//'    FUNCTION NAME : test()
//'    COMMENTS      : 
  
//'    make sure we have a vaild os grid ref
 
//' -------------------------------------------------------------------------------------



function testOS()
{

var go = true;

var str = new String(document.frmChange.txtmemberOS.value);
var len =parseInt(str.length); 

if(len == 0)
  return false;

if( len < 8 &&  len >0)
{
 alert("OS Reference too short, try again.");
 go = false;
}

if( len > 8)
{
 alert("OS Reference too long, try again.");
 go = false;
}




var a = parseInt(str.charCodeAt(0));

if(a < 65 || a > 96)
 {
 alert("Grid should start with UpperCase characters.");
 go = false;
 } 
  
a =   parseInt(str.charCodeAt(1));

if(a < 65 || a > 96)
 {
 alert("Grid should start with UpperCase characters.");
 go = false;
 } 

try
{  
a = parseInt(str.substring(2,str.length));

if(isNaN(a))
{
     alert("The OS grid reference is not correct.");
     go = false;
 }
}
catch(e){
          alert("The OS grid reference is not correct.");
          go = false;
         }  

if(go == true)
 return true;
else
  return false;  

}







//'--------------------------------------------------------------------------------------
//'    AUTHOR        : Anthony Tickner [anthonyt@dva.co.uk]
//'    DATE          : 8th November 2001 
//'    FUNCTION NAME : pop(type,id)
//'    COMMENTS      : 
  
//'    pop up a more info window
 
//' -------------------------------------------------------------------------------------

function pop(str,id)
{
 var page = "../home/moreinfo.asp?action="+str;
 page += "&id="+id;
 window.open(page,'','status=no,scrollbars=yes,resizable=yes,toolbar=no,menubar=no,location=no,top=0,left=0,width=450,height=400');

}
//' -------------------------------------------------------------------------------------


//'--------------------------------------------------------------------------------------
//'    AUTHOR        : Anthony Tickner [anthonyt@dva.co.uk]
//'    DATE          : 8th November 2001 
//'    FUNCTION NAME : popNews(id)
//'    COMMENTS      : 
  
//'    pop up a more info window
 
//' -------------------------------------------------------------------------------------

function popNews(id)
{
 var page = "../NCC_Admin/moreinfo.asp";
 page += "?id="+id;
 window.open(page,'','status=no,scrollbars=yes,resizable=yes,toolbar=no,menubar=no,location=no,top=0,left=0,width=450,height=400');

}
//' -------------------------------------------------------------------------------------





//'--------------------------------------------------------------------------------------
//'    AUTHOR        : Anthony Tickner [anthonyt@dva.co.uk]
//'    DATE          : 1st November 2001 
//'    FUNCTION NAME : reshow()
//'    COMMENTS      : 
  
//'    rebuild page with exrtra drop down
 
//' -------------------------------------------------------------------------------------




function reshow()
{

 
 var id = parseInt(document.frmSearch.lstCat.selectedIndex);
 var aid = parseInt(document.frmSearch.lstArea.selectedIndex);
 
 
 if(id<=5)
 id = id+1;

 
 if(id > 5 && id <= 8)
 id = 0;
 
 if(id >= 9)
  id = id - 3;
 
 
 
 if(aid==0)
 location.href="../members/index.asp?id="+id;
 else
 {
 //aid += 4;
 location.href="../members/index.asp?id="+id+"&aid="+aid+"&area=true";
 }
}


//'--------------------------------------------------------------------------------------
//'    AUTHOR        : Anthony Tickner [anthonyt@dva.co.uk]
//'    DATE          : 25th October 2001 
//'    FUNCTION NAME : goMinder()
//'    COMMENTS      : 
  
//'    Go and send reminder email
 
//' -------------------------------------------------------------------------------------




function goMinder()
{
  var name = document.frmLogin.txtUName.value; 
  
  if(name =="")
   alert("Please Enter your Member ID");
  else
   location.href="./reminder.asp?mid="+name; 


}



//'--------------------------------------------------------------------------------------
//'    AUTHOR        : Anthony Tickner [anthonyt@dva.co.uk]
//'    DATE          : 22nd August 2001 
//'    FUNCTION NAME : swapClass(form element,elemnet name);
//'    COMMENTS      : 
  
//'    do mouseover
 
//' -------------------------------------------------------------------------------------


function swapClass(obj, str) 
{
  if(str =="bOver")
  obj.style.background = "#ffffff";
  else
  obj.style.background = "#008bb4";
  
}
//' -------------------------------------------------------------------------------------


//'--------------------------------------------------------------------------------------
//'    AUTHOR        : Anthony Tickner [anthonyt@dva.co.uk]
//'    DATE          : 22nd August 2001 
//'    FUNCTION NAME : replace(inString,"strRplace","strWITH");
//'    COMMENTS      : 
  
//'    Replace a section of text
 
//' -------------------------------------------------------------------------------------

// Replace, ideal for getting rid of apostrophes
function replace(strInString,strReplaceText , strWith )
 {
 
  var tokenlength = strReplaceText.length;
  var retStr = "";

		 for( i = 0; i< strInString.length;i++)
		{ 
            
			if(strInString.substring(i,i+tokenlength).indexOf(strReplaceText) > -1)
			{
            
				for( j=0; j < strWith.length; j++)
				{
				retStr += strWith.charAt(j);
				}
               i = i + tokenlength;
			    
			}
           retStr += strInString.charAt(i);
		  } 
 return retStr;
}
//' -------------------------------------------------------------------------------------



//'--------------------------------------------------------------------------------------
//'    AUTHOR        : Anthony Tickner [anthonyt@dva.co.uk]
//'    DATE          : 22nd August 2001 
//'    FUNCTION NAME : showPreview(form element);
//'    COMMENTS      : 
  
//'    Show a preview pane of HTML in Form
 
//' -------------------------------------------------------------------------------------



function showPreview(obj)
{
var objTxt = obj;
var page = "./htmlPreview.asp";
page +="?objtxt=";
page +=escape(objTxt);
window.open(page,'','status=no,scrollbars=yes,resizable=yes,toolbar=no,menubar=no,location=no,top=0,left=0,width=380,height=400');

}

//' -------------------------------------------------------------------------------------

//'--------------------------------------------------------------------------------------
//'    AUTHOR        : Anthony Tickner [anthonyt@dva.co.uk]
//'    DATE          : 24th August 2001 
//'    FUNCTION NAME : popMsg(id);
//'    COMMENTS      : 
  
//'    Show a preview pane of HTML in Form
 
//' -------------------------------------------------------------------------------------



function popMsg(id)
{

var objid = id;
var page = "./message.asp";
page +="?id=";
page +=escape(objid);
window.open(page,'','status=no,scrollbars=yes,resizable=yes,toolbar=no,menubar=no,location=no,top=0,left=0,width=450,height=400');


}
//' -------------------------------------------------------------------------------------

//'--------------------------------------------------------------------------------------
//'    AUTHOR        : Anthony Tickner [anthonyt@dva.co.uk]
//'    DATE          : 23rd August 2001 
//'    FUNCTION NAME : upLoad()
//'    COMMENTS      : 
  
//'    Open the upload Image Window
 
//' -------------------------------------------------------------------------------------


function upload()
{
var page ="./uploadImage.asp";
window.open(page,'','status=no,scrollbars=yes,resizable=no,toolbar=no,menubar=no,location=no,left=0,top=0,width=600,height=200');
}

//' -------------------------------------------------------------------------------------


//'--------------------------------------------------------------------------------------
//'    AUTHOR        : Anthony Tickner [anthonyt@dva.co.uk]
//'    DATE          : 23rd August 2001 
//'    FUNCTION NAME : upLoadR()
//'    COMMENTS      : 
  
//'    Open the upload Image Window
 
//' -------------------------------------------------------------------------------------


function uploadR()
{

var page ="./uploadImageR.asp";
window.open(page,'','status=no,scrollbars=yes,resizable=no,toolbar=no,menubar=no,location=no,left=0,top=0,width=600,height=200');
}

//' -------------------------------------------------------------------------------------



//'--------------------------------------------------------------------------------------
//'    AUTHOR        : Anthony Tickner [anthonyt@dva.co.uk]
//'    DATE          : 23rd August 2001 
//'    FUNCTION NAME : upLoadE()
//'    COMMENTS      : 
  
//'    Open the upload Image Window
 
//' -------------------------------------------------------------------------------------


function uploadE()
{
var page ="./uploadImageE.asp";
window.open(page,'','status=no,scrollbars=yes,resizable=no,toolbar=no,menubar=no,location=no,left=0,top=0,width=600,height=200');
}

//' -------------------------------------------------------------------------------------




//'--------------------------------------------------------------------------------------
//'    AUTHOR        : Anthony Tickner [anthonyt@dva.co.uk]
//'    DATE          : 10th October 2001 
//'    FUNCTION NAME : upLoadPic()
//'    COMMENTS      : 
  
//'    Open the upload Image Window
 
//' -------------------------------------------------------------------------------------


function uploadPic(obj)
{
var page ="./uploadPic.asp?tagid="+obj;
window.open(page,'','status=no,scrollbars=yes,resizable=no,toolbar=no,menubar=no,location=no,left=0,top=0,width=600,height=200');
}

//' -------------------------------------------------------------------------------------

//'--------------------------------------------------------------------------------------
//'    AUTHOR        : Anthony Tickner [anthonyt@dva.co.uk]
//'    DATE          : 10th October 2001 
//'    FUNCTION NAME : upLoadPicM()
//'    COMMENTS      : 
  
//'    Open the upload Image Window
 
//' -------------------------------------------------------------------------------------


function uploadPicM(obj)
{
var page ="./uploadPicM.asp?tagid="+obj;
window.open(page,'','status=no,scrollbars=yes,resizable=no,toolbar=no,menubar=no,location=no,left=0,top=0,width=600,height=200');
}

//' -------------------------------------------------------------------------------------


//'--------------------------------------------------------------------------------------
//'    AUTHOR        : Anthony Tickner [anthonyt@dva.co.uk]
//'    DATE          : 10th October 2001 
//'    FUNCTION NAME : upLoadPicR()
//'    COMMENTS      : 
  
//'    Open the upload Image Window
 
//' -------------------------------------------------------------------------------------


function uploadPicR(obj)
{
var page ="./uploadPicR.asp?tagid="+obj;
window.open(page,'','status=no,scrollbars=yes,resizable=no,toolbar=no,menubar=no,location=no,left=0,top=0,width=600,height=200');
}

//' -------------------------------------------------------------------------------------




//'--------------------------------------------------------------------------------------
//'    AUTHOR        : Anthony Tickner [anthonyt@dva.co.uk]
//'    DATE          : 10th October 2001 
//'    FUNCTION NAME : upLoadPicE()
//'    COMMENTS      : 
  
//'    Open the upload Image Window
 
//' -------------------------------------------------------------------------------------


function uploadPicE(obj)
{
var page ="./uploadPicE.asp?tagid="+obj;
window.open(page,'','status=no,scrollbars=yes,resizable=no,toolbar=no,menubar=no,location=no,left=0,top=0,width=600,height=200');
}

//' -------------------------------------------------------------------------------------





//'--------------------------------------------------------------------------------------
//'    AUTHOR        : Anthony Tickner [anthonyt@dva.co.uk]
//'    DATE          : 23rd August 2001 
//'    FUNCTION NAME : upLoadFile()
//'    COMMENTS      : 
  
//'    Open the upload Image Window
 
//' -------------------------------------------------------------------------------------


function upLoadFile()
{
var page ="./uploadfile.asp";
window.open(page,'','status=no,scrollbars=yes,resizable=no,toolbar=no,menubar=no,location=no,left=0,top=0,width=600,height=200');
}

//' -------------------------------------------------------------------------------------



//'--------------------------------------------------------------------------------------
//'    AUTHOR        : Anthony Tickner [anthonyt@dva.co.uk]
//'    DATE          : 23rd August 2001 
//'    FUNCTION NAME : upLoadFileR()
//'    COMMENTS      : 
  
//'    Open the upload Image Window into the Resource Cat
 
//' -------------------------------------------------------------------------------------


function upLoadFileR()
{
var page ="./uploadfiler.asp";
window.open(page,'','status=no,scrollbars=yes,resizable=no,toolbar=no,menubar=no,location=no,left=0,top=0,width=600,height=200');
}

//' -------------------------------------------------------------------------------------



//'--------------------------------------------------------------------------------------
//'    AUTHOR        : Anthony Tickner [anthonyt@dva.co.uk]
//'    DATE          : 23rd August 2001 
//'    FUNCTION NAME : upLoadFileE()
//'    COMMENTS      : 
  
//'    Open the upload Image Window into the Resource Cat
 
//' -------------------------------------------------------------------------------------


function upLoadFileE()
{
var page ="./uploadfileE.asp";
window.open(page,'','status=no,scrollbars=yes,resizable=no,toolbar=no,menubar=no,location=no,left=0,top=0,width=600,height=200');
}

//' -------------------------------------------------------------------------------------



//'--------------------------------------------------------------------------------------
//'    AUTHOR        : Anthony Tickner [anthonyt@dva.co.uk]
//'    DATE          : 23rd August 2001 
//'    FUNCTION NAME : upLoadFileFree()
//'    COMMENTS      : 
  
//'    Open the upload Image Window
 
//' -------------------------------------------------------------------------------------


function upLoadFileFree()
{
var page ="./uploadfilefree.asp";
window.open(page,'','status=no,scrollbars=yes,resizable=no,toolbar=no,menubar=no,location=no,left=0,top=0,width=600,height=200');
}

//' -------------------------------------------------------------------------------------

//'--------------------------------------------------------------------------------------
//'    AUTHOR        : Anthony Tickner [anthonyt@dva.co.uk]
//'    DATE          : 23rd August 2001 
//'    FUNCTION NAME : upLoadFileSecure()
//'    COMMENTS      : 
  
//'    Open the upload Image Window
 
//' -------------------------------------------------------------------------------------


function upLoadFileSecure()
{
var page ="./uploadfile.asp";
window.open(page,'','status=no,scrollbars=yes,resizable=no,toolbar=no,menubar=no,location=no,left=0,top=0,width=600,height=200');
}

//' -------------------------------------------------------------------------------------


//'--------------------------------------------------------------------------------------
//'    AUTHOR        : Anthony Tickner [anthonyt@dva.co.uk]
//'    DATE          : 23rd August 2001 
//'    FUNCTION NAME : resourceLookup()
//'    COMMENTS      : 
  
//'    Open the upload Image Window
 
//' -------------------------------------------------------------------------------------


function resourceLookup()
{
var page ="./resourceLookup.asp";
window.open(page,'','status=no,scrollbars=yes,resizable=no,toolbar=no,menubar=no,location=no,left=0,top=0,width=700,height=200');

}
//' -------------------------------------------------------------------------------------


//'--------------------------------------------------------------------------------------
//'    AUTHOR        : Anthony Tickner [anthonyt@dva.co.uk]
//'    DATE          : 23rd August 2001 
//'    FUNCTION NAME : eventLookup()
//'    COMMENTS      : 
  
//'    Open the upload Image Window
 
//' -------------------------------------------------------------------------------------


function eventLookUp()
{
var page ="./eventLookUp.asp";
window.open(page,'','status=no,scrollbars=yes,resizable=no,toolbar=no,menubar=no,location=no,left=0,top=0,width=700,height=200');

}
//' -------------------------------------------------------------------------------------




//'--------------------------------------------------------------------------------------
//'    AUTHOR        : Anthony Tickner [anthonyt@dva.co.uk]
//'    DATE          : 23rd August 2001 
//'    FUNCTION NAME : articleLookup()
//'    COMMENTS      : 
  
//'    Open the upload Image Window
 
//' -------------------------------------------------------------------------------------


function articleLookup()
{
var page ="./articleLookup.asp";
window.open(page,'','status=no,scrollbars=yes,resizable=no,toolbar=no,menubar=no,location=no,left=0,top=0,width=700,height=200');

}
//' -------------------------------------------------------------------------------------





//'--------------------------------------------------------------------------------------
//'    AUTHOR        : Anthony Tickner [anthonyt@dva.co.uk]
//'    DATE          : 23rd August 2001 
//'    FUNCTION NAME : upLoad()
//'    COMMENTS      : 
  
//'    Open the upload Image Window
 
//' -------------------------------------------------------------------------------------


function uploadA()
{
var page ="./uploadImageA.asp";
window.open(page,'','status=no,scrollbars=yes,resizable=no,toolbar=no,menubar=no,location=no,left=0,top=0,width=600,height=200');
}

//' -------------------------------------------------------------------------------------





//'--------------------------------------------------------------------------------------
//'    AUTHOR        : Anthony Tickner [anthonyt@dva.co.uk]
//'    DATE          : 23rd August 2001 
//'    FUNCTION NAME : upLoadFileFreeA()
//'    COMMENTS      : 
  
//'    Open the upload Image Window
 
//' -------------------------------------------------------------------------------------


function upLoadFileFreeA()
{
var page ="./uploadfilefreeA.asp";
window.open(page,'','status=no,scrollbars=yes,resizable=no,toolbar=no,menubar=no,location=no,left=0,top=0,width=600,height=200');
}

//' -------------------------------------------------------------------------------------

//'--------------------------------------------------------------------------------------
//'    AUTHOR        : Anthony Tickner [anthonyt@dva.co.uk]
//'    DATE          : 23rd August 2001 
//'    FUNCTION NAME : upLoadFileSecure()
//'    COMMENTS      : 
  
//'    Open the upload Image Window
 
//' -------------------------------------------------------------------------------------


function upLoadFileSecureA()
{
var page ="./uploadfileA.asp";
window.open(page,'','status=no,scrollbars=yes,resizable=no,toolbar=no,menubar=no,location=no,left=0,top=0,width=600,height=200');
}

//' -------------------------------------------------------------------------------------


//'--------------------------------------------------------------------------------------
//'    AUTHOR        : Anthony Tickner [anthonyt@dva.co.uk]
//'    DATE          : 23rd August 2001 
//'    FUNCTION NAME : articleUploadA()
//'    COMMENTS      : 
  
//'    Open the upload Image Window
 
//' -------------------------------------------------------------------------------------


function articleLookupA()
{
var page ="./articleLookupA.asp";
window.open(page,'','status=no,scrollbars=yes,resizable=no,toolbar=no,menubar=no,location=no,left=0,top=0,width=700,height=200');

}
//' -------------------------------------------------------------------------------------


//'--------------------------------------------------------------------------------------
//'    AUTHOR        : Anthony Tickner [anthonyt@dva.co.uk]
//'    DATE          : 23rd August 2001 
//'    FUNCTION NAME : removeUrl(id,urlElement,urlTitle,hid)
//'    COMMENTS      : 
  
//'    Remove
 
//' -------------------------------------------------------------------------------------


function removeUrl(id,urlElement,urlTitle,hid)
{
     var str = hid.value;
     var index =0;
     var tmpStr ="";
     var len = str.length;
     var inArray = new Array();
    
     for(c=0;c<len;c++)
     {
        if(str.charAt(c) != ",")
        {
         tmpStr += str.charAt(c); 
        }
        else
        {
         inArray[index] = tmpStr;
         tmpStr ="";
         index++;
        } 
     }
str ="";

for(i=0;i<inArray.length;i++)
{
 if(i != parseInt(id))
  str +=inArray[i]+",";
 else
   i++; 
} 
hid.value = str;



// Set Current Form Values
urlElement.value="#Deleted";
urlTitle.value="#Deleted";

alert("The changes will not take effect until you hit the [update] button.\nIf you decide you don't want to delete, just click the [cancel /done] button.");
}

//' -------------------------------------------------------------------------------------


  

//'--------------------------------------------------------------------------------------
//'    AUTHOR        : Anthony Tickner [anthonyt@dva.co.uk]
//'    DATE          : 30th July 2001 
//'    FUNCTION NAME : setPageLoaded();
//'    COMMENTS      : 
  
//'    Hide our DHTML status message
 
//' -------------------------------------------------------------------------------------
function setPageLoaded()
{

if(navigator.appName == "Netscape")
document.layers.page_id.visibility="hide";
else
document.all.page_id.style.visibility ="hidden";
}
//'--------------------------------------------------------------------------------------


//'--------------------------------------------------------------------------------------
//'    AUTHOR        : Anthony Tickner [anthonyt@dva.co.uk]
//'    DATE          : 1ST August 2001 
//'    FUNCTION NAME : confirm?????();
//'    COMMENTS      :  4 Functions below
  
//'    Returnr True or False to confirm action
 
//' -------------------------------------------------------------------------------------


function checkUpdate(thisItem)
{

if(thisItem.value=="" || thisItem.value=="undefined")
{
alert("Can't leave browse box empty, please try again.");
return false;
}
else 
return true;
}


function checkBrute(thisItem)
{
if(thisItem.value=="" || thisItem.value=="undefined")
{
alert("Can't leave browse box empty, please try again.");
return false;
}
else
{
alert("Warning! you may  overwite an existing file.");
return true;
}
}



function confirmInsert() {
	if (confirm("Are you sure you want to add this record into the database?\n\nIf you are sure Click OK to Continue."  )) {
		return true; 
	}
	else 
		return false;
}

function confirmCancel() {
	if (confirm("Are you sure you are done?\n\nIf you are sure Click OK to Continue."  )) {
		return true; 
	}
	else 
		return false;
}

function confirmDelete() {
	if (confirm("Are you sure you want to delete this record from the database?\n\nIf you are sure Click OK to Continue."  )) {
		return true;
	}
	else 
		return false;
}

function confirmUpdate() {
	if (confirm("Are you sure you want to update this record?\n\nIf you are sure Click OK to Continue."  )) {
		return true;
	}
	else 
		return false;
}

//'--------------------------------------------------------------------------------------


//' ---------------------------- MacroMedia Generated Javascript ------------------------





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_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_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.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];}

}

//'-------------------------------- ENd MacroMedia Functions ----------------------------