function submitenter(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;
if (keycode == 13)
   {
   myfield.form.submit();
   return false;
   }
else
   return true;
}


function clearDefaultandCSS(el) {
           if (el.defaultValue==el.value) el.value = ""
           // If Dynamic Style is supported, clear the style
              if (el.style) el.style.cssText = ""
									}


// This is important for Sesame logout
function logOut ( selectedtype ) {
  document.logout.cookie_control.value = selectedtype ;
  document.logout.submit() ;
}



// Used for opening simple small screen-centered browser windows
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
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+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);}



// Used for validating sensitive links
function clickdecision(message, url){
if(confirm(message)) location.href = url;
}





// Define Ajax actions - http://www.prototypejs.org/learn/introduction-to-ajax
var ajaxperiod = 1200; // seconds; "7" was too heavy for the system (esp. because it was far too often triggering a heel counter script that had just 1 second chance to run every minute but Ajax made it quite probable, it was taking 14 seconds and if the server was busy then 150 seconds!), changed to 60 on 20061018
var ajaxdecay = 2; //  1  	Determines the progressive slowdown in a Ajax.PeriodicalUpdater object refresh rate when the received response is the same as the last one. For example, if you use 2, after one of the refreshes produces the same result as the previous one, the object will wait twice as much time for the next refresh. If it repeats again, the object will wait four times as much, and so on. Leave it undefined or use 1 to avoid the slowdown.
var ajaxpath = 'http://www.vacilando.org/';
new Ajax.PeriodicalUpdater("how_many_stats_records", ajaxpath+"index.php?ajax=how_many_stats_records", {
 // initial number of seconds interval between calls
 //method: 'get',
 //insertion: Insertion.Top,
 frequency : ajaxperiod, 
 decay : ajaxdecay 
 });
new Ajax.PeriodicalUpdater("how_many_people_online", ajaxpath+"index.php?ajax=how_many_people_online", {
 // initial number of seconds interval between calls
 //method: 'get',
 //insertion: Insertion.Top,
 frequency : ajaxperiod, 
 decay : ajaxdecay 
 });



// Form field Limiter script - http://www.dynamicdrive.com/dynamicindex16/limitinput.htm
var ns6=document.getElementById&&!document.all
function restrictinput(maxlength,e,placeholder){
if (window.event&&event.srcElement.value.length>=maxlength)
return false
else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
var pressedkey=/[a-zA-Z0-9\.\,\/]/ //detect alphanumeric keys
if (pressedkey.test(String.fromCharCode(e.which)))
e.stopPropagation()
}
}
function countlimit(maxlength,e,placeholder){
var theform=eval(placeholder)
var lengthleft=maxlength-theform.value.length
var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
if (window.event||e.target&&e.target==eval(placeholder)){
if (lengthleft<0)
theform.value=theform.value.substring(0,maxlength)
placeholderobj.innerHTML='text length: '+theform.value.length+' (<b>'+lengthleft
}
}
function displaylimit(thename, theid, thelimit){
var theform=theid!=""? document.getElementById(theid) : thename
var limit_text='<span id="'+theform.toString()+'">'+'text length: '+theform.toString().length+' (<b>'+thelimit+'</span></b> characters remaining on your input limit)'
if (document.all||ns6)
document.write(limit_text)
if (document.all){
eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
}
else if (ns6){
document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true); 
document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true); 
}
}

