<!-- Make timout div -->
function togglelayer( targetId ){
  if (document.getElementById){
        target = document.getElementById( targetId );
           if (target.style.display == "none"){
              target.style.display = "";
           } else {
              target.style.display = "none";
           }
     }
}

<!-- position popupwindows -->
function popuppos() {
	var x = 0;
	var y = 0;
	if (parseInt(navigator.appVersion)>3) {
		x = (screen.width - 800) / 2;
		y = (screen.height - 600) / 2;
	}
	return 'top='+ y + ',left='+ x;
}

<!-- post form with enter key down -->
function submit(form) {
	if (document.getElementById(form).onsubmit()) {
		document.getElementById(form).submit();
	}
}

function keydown(e, form) {
	e = e || window.event;
	if (e.keyCode == 13) {
		submit(form);
		return false;
	}
}

<!-- count input in textarea -->
function textcounter(field, countfield, maxlimit) { 
	if (field.value.length > maxlimit) // if too long...trim it! 
	field.value = field.value.substring(0, maxlimit); 
// otherwise, update 'characters left' counter 
	else 
	countfield.value = maxlimit - field.value.length; 
} 


function UpdateArea(url,container,loading,delaytime) {
	
	if(!loading) loading='ajax-loading';
	if(!delaytime) delaytime=0;
	
	container.removeClass(loading);
	container.empty();
	
	if(delaytime>0) {
		container.addClass(loading);	
	}
			
	setTimeout( function() { 
					 
		$.ajax({
			url: url,
			type: "GET",
			dataType: "html",
			error: function (xhr, desc, exceptionobj) {
				alert(xhr.responseText);
			},
			success : function (html) {
				container.removeClass(loading);
				container.html(html);	
			}	
		});			 
	}, delaytime);
}

