function engine_class(){

  this.getEl = function( elId ){
    return document.getElementById(elId);
  }

  this.custom_submit = function(form_id){
    //alert(field_names+' -- '+form_id);
    var frm = this.getEl(form_id);
    if(frm != undefined){
      frm.submit();
    }
  }

  this.real_togle_element = function (el){

    //if($(el).style.display=="inline"){
    var el = this.getEl(el);
    if(el == null || !el || el == 'undefined'){
      return;
    }
    if(el.style.display=="inline" || el.style.display=="" || el.style.display=="undefined"){
      this.togle_element(el,false);
      return false;
    }else{
      this.togle_element(el,true);
      return true;
    }
  }
  this.togle_element = function(el,bFlag){
    //better name for this function is switch_element
    if(el != null){
      try{
        //alert(el);
        if(bFlag){
          el.style.display="inline";
        }else{
          el.style.display="none";
        }
      }catch(err){/*alert("Error toggling element: "+el);*/}
    }
  }

  this.swComm = function(commID,fromPrefix){

    var comDate = this.getEl("comm_date_id_"+commID);
    var comBody = this.getEl("comm_body_id_"+commID);

    //alert("comm_date_id_"+commID);

    if(comBody == null || !comBody || comBody == 'undefined' || comDate == null || !comDate || comDate == 'undefined'){
      //alert("comm_date_id_"+commID);
      return;
    }
    this.real_togle_element("comm_date_id_"+commID);
    this.real_togle_element("comm_body_id_"+commID);
    this.switchCntrlImg(commID,fromPrefix);
  }

  this.switchCntrlImg = function(commID,fromPrefix){
    var el = this.getEl("comm_cntrl_img_"+commID);
    if(el == null || !el || el == 'undefined'){
      return;
    }

    if(fromPrefix == null || !fromPrefix || fromPrefix == 'undefined'){
      fromPrefix = "";
    }
    if(el.src.indexOf("open.gif")!= -1){
      el.src = fromPrefix+"img/1/close.gif";
    }else{
      el.src = fromPrefix+"img/1/open.gif";
    }
  }

  this.getClientWidth = function(){
    return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
  }
  this.getClientHeight = function(){
    return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
  }
  /*	this.getOffsetTop =function(aID){
	  var target = this.getEl(aID);
	  var y = target.offsetTop;
	  var parent = target;
	  while (parent.offsetParent)
	  {
	    parent = parent.offsetParent;
	    y += parent.offsetTop ;
	  }
	return y;
	}

	this.getOffsetLeft = function(aID){
	  var target = this.getEl(aID);
	  var x = target.offsetLeft;
	  var parent = target;
	  while (parent.offsetParent)
	  {
	    parent = parent.offsetParent;
	    x += parent.offsetLeft ;
	  }
	return x;
	}*/

  this.toggleCheckbox = function(cbID){
    var el = this.getEl(cbID);
    if(el == null || !el || el == 'undefined'){
      return;
    }else{
      el.checked = !el.checked;
    }
  }




  this.toggleTwo = function(el1,el2){
    //same toggler, but not setting inline value
    var e1 = this.getEl(el1);
    var e2 = this.getEl(el2);

    if(e1.style.display == 'none'){
      e1.style.display = '';
      e2.style.display = 'none';
    }else{
      e2.style.display = '';
      e1.style.display = 'none';
    }
  }
  this.toggleOne = function(el){
    //same toggler, but not setting inline value
    var e = this.getEl(el);
    if(e.style.display == 'none'){
      e.style.display = '';
    }else{
      e.style.display = 'none';
    }
  }

  this.toggleSrc = function(el,newSrc){
    var e = this.getEl(el);
    e.src = newSrc;
  }


  //**********COOCKIES management
  this.setCookie = function(name, value, exprs, path, domain, secure) {
    var expires = exprs;
    if(!expires){
      expires = new Date();
//      expires.setTime(expires.getTime() + 31536000000);//year
      expires.setTime(expires.getTime() + 365*24*60*60*1000 );  //year
    }
    if( expires != -1 ){
      engine.deletecookie( name );
    }else{
      expires = "";
    }


    var curCookie = name + "=" + escape(value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
    document.cookie = curCookie;
  }

  this.getCookie = function(c_name){
    if (document.cookie.length>0)
    {
      c_start=document.cookie.indexOf(c_name + "=");
      if (c_start!=-1)
      {
        c_start=c_start + c_name.length+1;
        c_end=document.cookie.indexOf(";",c_start);
        if (c_end==-1) c_end=document.cookie.length;
        return unescape(document.cookie.substring(c_start,c_end));
      }
    }
    return "";
  }

  /*function getCookie(name) {
        var prefix = name + "="
        var cookieStartIndex = document.cookie.indexOf(prefix)
        if (cookieStartIndex == -1)
                return null
        var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
        if (cookieEndIndex == -1)
                cookieEndIndex = document.cookie.length
        return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
			}*/

  this.deletecookie = function( cname ){
    var cookie_date = new Date ( );  // current date & time
    cookie_date.setTime( cookie_date.getTime() - 1 );
    //document.cookie = cname += "=; expires=" + cookie_date.toGMTString();
    this.setCookie(cname,'',-1);
  }/**/

  //**********EO COOCKIES management




//**********EO Coordinates management

}

var engine = new engine_class();


