$(function() {
	// setup overlay	
	$("a.overlay").overlay({ 	 
		expose: { 
			color: '#333', 
			loadSpeed: 100, 
			opacity: .5
		},
		//top: '2.5%',
		closeOnClick: false
		//closeOnEsc: false
	});

		
});
function checkboxes(chkbx, form, fnc) {

        var f = document.getElementById(form);
        for(i=0; i<f.elements.length; i++) {
         	
               	var e = f.elements[i];
                if ( e.type != 'checkbox' ) continue;

                if ( e.id != chkbx ) 
                        e.checked = false;
                else {
			fnc();
                } // else
        } // for

} // function


function showHideForm(id) {
        var elem = $("#"+id);

        if ( elem.is(':visible') ) {
		elem.fadeOut('slow');
	}
        else {
		elem.fadeIn('slow');
	}
        
}

function doEscape(content) {
	
	content = content.replace('/\+/g', "&#43");
	content = content.replace('/\\/g', "&#92");
	//content = escape(content);
	return content;
}
/**
 * Performs an Ajax Call to the given URL (urlink)
 * 
 * urlink 	- The URL to send the request to
 * postData 	- Additional POST parameters that should be sent
 * infoElement	- DOM element that should contain the returned output
 * ajax		- Inform the backend that only the requested output is required and not the whole page
 * */
function doAjax(urlink, postData, infoElement, ajax, returnurl) {

	urlink += '&ajax='+ajax;
	
	$.ajax({
			type: "POST",
			url: urlink,
			data: postData,
			success: function(response) {
				if ( true == ajax ) {
					infoElement.html(response);
				} else {
					if ( response.indexOf('ERROR: ') != -1 ) {
						alert(response.substr(7));
					} else {
						alert(response);
						if ( undefined != returnurl ) window.location = returnurl;
					}
				}
			}
	});
}


