// JavaScript Document

function updateentry(IDofrecord){
document.ucd.actiontype.value = "updateentry";
document.ucd.recordID.value = IDofrecord;
document.ucd.submit(); 
}
function copyentry(IDofrecord){
document.ucd.actiontype.value = "copyentry";
document.ucd.recordID.value = IDofrecord;
document.ucd.submit(); 
}
function deleteentry(IDofrecord){
var agree=confirm("DELETE THIS ?");
if (agree) {
document.ucd.actiontype.value = "deleteentry";
document.ucd.recordID.value = IDofrecord;
document.ucd.submit(); }
else
	{return ;}
}
function addentry(IDofrecord){
document.ucd.actiontype.value = "addentry";
document.ucd.recordID.value = IDofrecord;
document.ucd.submit(); 
}
function restoreentry(IDofrecord, IDofrestore, ActionPassValue){
document.ucd.actiontype.value = "restoreentry";
document.ucd.actionpass.value = ActionPassValue;
document.ucd.recordID.value = IDofrecord;
document.ucd.restoreID.value = IDofrestore;
document.ucd.submit(); 
}

function switchDiv(div_id)
{
  var styleObject = getStyleObject(div_id);
  if (styleObject)
  {
  if(styleObject.display == 'block') {
    changeObjectDisplay(div_id,"none");
	} else {
	  menuclose();
    changeObjectDisplay(div_id,"block");
	}
  }
}

// function getStyleObject(string) -> returns style object
//  given a string containing the id of an object
//  the function returns the stylesheet of that object
//  or false if it can't find a stylesheet.  Handles
//  cross-browser compatibility issues.
function getStyleObject(objectId) {
  // checkW3C DOM, then MSIE 4, then NN 4.
  if(document.getElementById && document.getElementById(objectId)) {
  return document.getElementById(objectId).style;
   }
   else if (document.all && document.all(objectId)) {  
  return document.all(objectId).style;
   } 
   else if (document.layers && document.layers[objectId]) { 
  return document.layers[objectId];
   } else {
  return false;
   }
}

function changeObjectDisplay(objectId, newDisplay) {
    // first get a reference to the cross-browser style object 
    // and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
  styleObject.display = newDisplay;
  return true;
    } else {
  // we couldn't find the object, so we can't change its visibility
  return false;
    }
}

function toggleObjectDisplay(objectId) {
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
  if(styleObject.display == 'block') {
	  styleObject.display = 'none';
    } else {
	  styleObject.display = 'block';
	}
  return true;
    } else {
  return false;
    }
}


function getStyleClass (className) {
  if (document.all) {
    for (var s = 0; s < document.styleSheets.length; s++)
      for (var r = 0; r < document.styleSheets[s].rules.length; r++)
        if (document.styleSheets[s].rules[r].selectorText == '.' + 
className)
          return document.styleSheets[s].rules[r];
  }
  else if (document.getElementById) {
    for (var s = 0; s < document.styleSheets.length; s++)
      for (var r = 0; r < document.styleSheets[s].cssRules.length; r++)
        if (document.styleSheets[s].cssRules[r].selectorText == '.' + 
className)
          return document.styleSheets[s].cssRules[r];
  }
  return null;
}


function movelayer(lid, yto, yspeed, ydelay) {
var dc = document;
var layerobj=dc.getElementById?dc.getElementById(lid):dc.all?dc.all[lid]:dc.layers[lid];
if(dc.layers)layerobj.style=layerobj;
layerobj.y = parseInt(layerobj.style.top);
if(yto < layerobj.y) yspeed=-yspeed

window.slidelayer=function(){
		if( Math.abs(yto-layerobj.y) > Math.abs(yspeed) ) {
		layerobj.y += yspeed;
		layerobj.style.top = layerobj.y + 'px';
		setTimeout("slidelayer()", ydelay); }
		else {
		layerobj.style.top = yto + 'px'; }
}
slidelayer();
}

function swapimage(im,imo) {
if (browser.isIE4up) document.images[im].filters.blendTrans.apply()
document.images[im].src=imo
if (browser.isIE4up) document.images[im].filters.blendTrans.play()
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

var win=null;
function NewWindow(theURL,winName,w,h,pos,features){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+features;
win=window.open(theURL,winName,settings);
}

function atoz(title){
URLpopup='AtoZpopup.asp?title='+title;
LeftPosition=(screen.width)?(screen.width-400)/2:100;
TopPosition=(screen.height)?(screen.height-300)/2:100;
featurespopup = 'width=400,height=300,top='+LeftPosition+',left='+TopPosition+',scrollbars=yes,resizable=yes,status=0,titlebar=0,toolbar=0';
window.open(URLpopup,'',featurespopup);	
}

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 P7AniMagic(el,x,y,a,b,c,s) { //v2.9 PVII-Project Seven Development
 var xx,yy,i,g,elo=el,f="",m=false,d="",pa='px';if(document.layers||window.opera){pa='';}
 x=parseInt(x);y=parseInt(y);var t='g.p7Magic=setTimeout("P7AniMagic(\''+elo+'\','; 
 if((g=MM_findObj(el))!=null){d=(document.layers)?g:g.style;}else{return;}
 if(parseInt(s)>0){eval(t+x+','+y+','+a+','+b+','+c+',0)",' + s+')');return;}
 xx=parseInt(d.left);if(isNaN(xx)){if(g.currentStyle){xx=parseInt(g.currentStyle.left);
 }else if(document.defaultView&&document.defaultView.getComputedStyle){
 xx=parseInt(document.defaultView.getComputedStyle(g,"").getPropertyValue("left"));}
 if(isNaN(xx)){xx=0;}}yy=parseInt(d.top);if(isNaN(yy)){if(g.currentStyle){yy=parseInt(g.currentStyle.top);
 }else if(document.defaultView&&document.defaultView.getComputedStyle){
 yy=parseInt(document.defaultView.getComputedStyle(g,"").getPropertyValue("top"));}
 if(isNaN(yy)){yy=0;}}if(c==1){x+=xx;y+=yy;m=true;c=0;}else if(c==2){m=false;
 if(g.p7Magic){clearTimeout(g.p7Magic);}}else{i=parseInt(a);if(g.p7Magic){clearTimeout(g.p7Magic);}
 if(xx<x){xx+=i;m=true;if(xx>x){xx=x;}}if(xx>x){xx-=i;m=true;if(xx<x){xx=x;}}
 if(yy<y){yy+=i;m=true;if(yy>y){yy=y;}}if(yy>y){yy-=i;m=true;if(yy<y){yy=y;}}}
 if(m){d.left=xx+pa;d.top=yy+pa;eval(t+x+','+y+','+a+','+b+','+c+',0)",'+b+')');}
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

/*
This script is written by Eric (Webcrawl@usa.net) - dynamicdrive.com
*/
function printit() {

if (window.print){
    window.print() ;  
} else {
    var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
    WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    WebBrowser1.outerHTML = "";  
}

}

function lite(obj) {
 if(document.all&&!window.opera) {
  obj.filters.blendTrans.apply();
  obj.filters.blendTrans.play();
 }
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

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_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 MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}


/***********************************************
* Disable "Enter" key in Form script- By Nurul Fadilah(nurul@REMOVETHISvolmedia.com)
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
function handleEnter (field, event, step) {
		var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		if (keyCode == 13) {
			var i;
			for (i = 0; i < field.form.elements.length; i++)
				if (field == field.form.elements[i])
					break;
			i = (i + step) % field.form.elements.length;
			field.form.elements[i].focus();
			return false;
		} 
		else
		return true;
	}      

var bmurl
var bmtitle
function addbookmark(){
bmtitle=document.title
bmurl=window.location.href
if (document.all) {
window.external.AddFavorite(bmurl,bmtitle)
}
else if (window.sidebar) {
window.sidebar.addPanel(bmtitle, bmurl, "")
}
}

var textsizetype = "medium"
function textsize(type){
if (type=='small'){
unsetActiveStyleSheet('sizesmall')	
unsetActiveStyleSheet('sizemedium')
unsetActiveStyleSheet('sizelarge')
setActiveStyleSheet('sizesmall')
textsizetype = "small"
}
if (type=='medium'){
unsetActiveStyleSheet('sizesmall')	
unsetActiveStyleSheet('sizemedium')
unsetActiveStyleSheet('sizelarge')
setActiveStyleSheet('sizemedium')
textsizetype = "medium"
}
if (type=='large'){
unsetActiveStyleSheet('sizesmall')	
unsetActiveStyleSheet('sizemedium')
unsetActiveStyleSheet('sizelarge')
setActiveStyleSheet('sizelarge')
textsizetype = "large"
}
savecookies()
}

var contrasttype = "Colour"
function textcontrast(type){
unsetActiveStyleSheet('Colour')	
unsetActiveStyleSheet('contrastBlackWhite')
unsetActiveStyleSheet('contrastWhiteBlack')	
unsetActiveStyleSheet('contrastBlackYellow')
unsetActiveStyleSheet('contrastYellowBlack')	
unsetActiveStyleSheet('contrastBlackPink')

if (type=='Colour'){
setActiveStyleSheet('contrastColour')
contrasttype = "Colour"
}
if (type=='BlackWhite'){
setActiveStyleSheet('contrastBlackWhite')
contrasttype = "BlackWhite"
}
if (type=='WhiteBlack'){
setActiveStyleSheet('contrastWhiteBlack')
contrasttype = "WhiteBlack"
}
if (type=='BlackYellow'){
setActiveStyleSheet('contrastBlackYellow')
contrasttype = "BlackYellow"
}
if (type=='YellowBlack'){
setActiveStyleSheet('contrastYellowBlack')
contrasttype = "YellowBlack"
}
if (type=='BlackPink'){
setActiveStyleSheet('contrastBlackPink')
contrasttype = "BlackPink"
}
savecookies()
}

function setActiveStyleSheet(title) {
   var i, a, main;
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
     if(a.getAttribute("rel").indexOf("style") != -1
        && a.getAttribute("title")) {
       if(a.getAttribute("title") == title) a.disabled = false;
     }
   }
}
function unsetActiveStyleSheet(title) {
   var i, a, main;
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
     if(a.getAttribute("rel").indexOf("style") != -1
        && a.getAttribute("title")) {
       if(a.getAttribute("title") == title) a.disabled = true;
     }
   }
}

var animationoff = "on"
function toggleani() {
if (animationoff == "off") {
animationoff = "on" }
else {
animationoff = "off" }
savecookies()
}

var pagewidth = 'variable'
function togglewidth() {
	if (pagewidth == 'variable') {
	document.getElementById("wholepage").style.width='1000px' 
	pagewidth = 'fixed' ;}
	else {
	document.getElementById("wholepage").style.width='100%'
	pagewidth = 'variable' ;}
	savecookies()
}

function savescrap(scrap) {
	var Scrapbook = findcookie('Scrapbook')
	var datenow = new Date();
    datenow.setTime(datenow.getTime()+(30*24*60*60*1000));//first number is days to keep
	if (Scrapbook == null)  {Scrapbook = '';}	
	Scrapbook = Scrapbook+"~"+scrap;	
	alert('Scrapbook:'+Scrapbook.replace(/~/g,"\n"))	
	document.cookie = "Scrapbook="+Scrapbook+';expires='+datenow.toGMTString()+'; path=/';

}


function savecookies() {
	var datenow = new Date();
    datenow.setTime(datenow.getTime()+(30*24*60*60*1000));//first number is days to keep
	document.cookie = "CUPcontrols=#"+pagewidth+"#"+textsizetype+"#"+contrasttype+"#;expires="+datenow.toGMTString()+"; path=/";
}

function getcookies() {
	    var cookiestring = findcookie('CUPcontrols')
	    if (cookiestring != null)  {
		var cookiebits = cookiestring.split('#'); 
		var pagewidthwas;
		pagewidthwas = cookiebits[1];
		if (pagewidthwas == 'fixed') togglewidth();
		textsizetype = cookiebits[2];
		if (textsizetype == 'small') textsize('small');			
		if (textsizetype == 'medium') textsize('medium');		
		if (textsizetype == 'large') textsize('large');
		contrasttype = cookiebits[3];
		if (contrasttype == 'Colour') textcontrast('Colour');		
		if (contrasttype == 'BlackWhite') textcontrast('BlackWhite');
		if (contrasttype == 'WhiteBlack') textcontrast('WhiteBlack');		
		if (contrasttype == 'BlackYellow') textcontrast('BlackYellow');		
		if (contrasttype == 'YellowBlack') textcontrast('YellowBlack');
		if (contrasttype == 'BlackPink') textcontrast('BlackPink');			
}
		else {
/*		if (screen.width>1030)togglewidth();  */
}
}

function findcookie(nameof) {
  var namefind = nameof + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(namefind) == 0) return c.substring(namefind.length,c.length);
  }
  return null;
}

var zoompoint=new Array()
zoompoint[0]=0.5
zoompoint[1]=0.75
zoompoint[2]=1
zoompoint[3]=1.5
zoompoint[4]=2
zoompoint[5]=3
zoompoint[6]=4
zoompoint[7]=8
zoompoint[8]=12
zoompoint[9]=16
var zoomfactor = 2
function zoomin () {
	if (zoomfactor<zoompoint.length-1) zoomfactor++;
	if (document.getElementById("fixedwidth")) {
	if (zoomfactor == 2) {
	document.getElementById("wholepage").style.width='100%' }
	else {
	document.getElementById("wholepage").style.width='1000px' }
	}
document.getElementById("wholepage").style.zoom=zoompoint[zoomfactor]; 
if (document.getElementById("flyouts")) {
document.getElementById("flyouts").style.zoom=zoompoint[zoomfactor]; }
}
function zoomout () {
	if (zoomfactor>0) zoomfactor--;
	if (document.getElementById("fixedwidth")) {
	if (zoomfactor == 2) {
	document.getElementById("wholepage").style.width='100%' }
	else {
	document.getElementById("wholepage").style.width='1000px' }
	}
document.getElementById("wholepage").style.zoom=zoompoint[zoomfactor]; 
if (document.getElementById("flyouts")) {
document.getElementById("flyouts").style.zoom=zoompoint[zoomfactor]; }
}


// Browser Detect  v2.1.6
// documentation: http://www.dithered.com/javascript/browser_detect/index.html
// license: http://creativecommons.org/licenses/by/1.0/
// code by Chris Nott (chris[at]dithered[dot]com)


function BrowserDetect() {
   var ua = navigator.userAgent.toLowerCase(); 

   // browser engine name
   this.isGecko       = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
   this.isAppleWebKit = (ua.indexOf('applewebkit') != -1);

   // browser name
   this.isKonqueror   = (ua.indexOf('konqueror') != -1); 
   this.isSafari      = (ua.indexOf('safari') != - 1);
   this.isOmniweb     = (ua.indexOf('omniweb') != - 1);
   this.isOpera       = (ua.indexOf('opera') != -1); 
   this.isIcab        = (ua.indexOf('icab') != -1); 
   this.isAol         = (ua.indexOf('aol') != -1); 
   this.isIE          = (ua.indexOf('msie') != -1 && !this.isOpera && (ua.indexOf('webtv') == -1) ); 
   this.isMozilla     = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
   this.isFirebird    = (ua.indexOf('firebird/') != -1);
   this.isNS          = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && !this.isOpera && !this.isSafari && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );
   
   // spoofing and compatible browsers
   this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
   this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);
   
   // rendering engine versions
   this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
   this.equivalentMozilla = ( (this.isGecko) ? parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) ) : -1 );
   this.appleWebKitVersion = ( (this.isAppleWebKit) ? parseFloat( ua.substring( ua.indexOf('applewebkit/') + 12) ) : -1 );
   
   // browser version
   this.versionMinor = parseFloat(navigator.appVersion); 
   
   // correct version number
   if (this.isGecko && !this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('/', ua.indexOf('gecko/') + 6) + 1 ) );
   }
   else if (this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
   }
   else if (this.isIE && this.versionMinor >= 4) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
   }
   else if (this.isKonqueror) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
   }
   else if (this.isSafari) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('safari/') + 7 ) );
   }
   else if (this.isOmniweb) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('omniweb/') + 8 ) );
   }
   else if (this.isOpera) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera') + 6 ) );
   }
   else if (this.isIcab) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab') + 5 ) );
   }
   
   this.versionMajor = parseInt(this.versionMinor); 
   
   // dom support
   this.isDOM1 = (document.getElementById);
   this.isDOM2Event = (document.addEventListener && document.removeEventListener);
   
   // css compatibility mode
   this.mode = document.compatMode ? document.compatMode : 'BackCompat';

   // platform
   this.isWin    = (ua.indexOf('win') != -1);
   this.isWin32  = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
   this.isMac    = (ua.indexOf('mac') != -1);
   this.isUnix   = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
   this.isLinux  = (ua.indexOf('linux') != -1);
   
   // specific browser shortcuts
   this.isNS4x = (this.isNS && this.versionMajor == 4);
   this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
   this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
   this.isNS4up = (this.isNS && this.versionMinor >= 4);
   this.isNS6x = (this.isNS && this.versionMajor == 6);
   this.isNS6up = (this.isNS && this.versionMajor >= 6);
   this.isNS7x = (this.isNS && this.versionMajor == 7);
   this.isNS7up = (this.isNS && this.versionMajor >= 7);
   
   this.isIE4x = (this.isIE && this.versionMajor == 4);
   this.isIE4up = (this.isIE && this.versionMajor >= 4);
   this.isIE5x = (this.isIE && this.versionMajor == 5);
   this.isIE55 = (this.isIE && this.versionMinor == 5.5);
   this.isIE5up = (this.isIE && this.versionMajor >= 5);
   this.isIE6x = (this.isIE && this.versionMajor == 6);
   this.isIE6up = (this.isIE && this.versionMajor >= 6);
   
   this.isIE4xMac = (this.isIE4x && this.isMac);
}
var browser = new BrowserDetect();


function pressdetect(){
document.form1.detectpress.value = "pressed";
}

function noAlpha(obj){
	reg = /[^0-9.-]/g;
	obj.value =  obj.value.replace(reg,"");
}
function AlphaNumeric(obj){
	reg = /[^0-9^A-Z^a-z .@&_-]/g;
	obj.value =  obj.value.replace(reg,"");
}