function engine_class(){
	
	this.custom_submit = function(field_names,form_id){
		//alert(field_names+' -- '+form_id);
		var frm = document.getElementById(form_id);
		if(frm != undefined){
			frm.submit();
		}
	}
	
	this.real_togle_element = function (el){
		
			//if($(el).style.display=="inline"){
			var el = document.getElementById(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 = document.getElementById("comm_date_id_"+commID);
			var comBody = document.getElementById("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 = document.getElementById("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 = document.getElementById(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 = document.getElementById(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 = document.getElementById(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 = document.getElementById(el1);
		var e2 = document.getElementById(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 = document.getElementById(el);
		if(e.style.display == 'none'){
			e.style.display = '';
		}else{						
			e.style.display = 'none';						
		}					
	}
	
	this.toggleSrc = function(el,newSrc){
		var e = document.getElementById(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			 		
				}
					
				 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();
			}/**/
			
//**********EO COOCKIES management	
	
}

var engine = new engine_class();

