// JavaScript Document

function common_ajax(surl,param,id){
	$.ajax({
		type: "POST",
		url: surl,
		data: param,
		cache: false,
		success: function(html){
			$("#"+id).html(html);
		}
	});
}

jQuery.fn.center = function (absolute) {
    return this.each(function () {
        var t = jQuery(this);

        t.css({
            position:    absolute ? 'absolute' : 'fixed', 
            left:        '50%', 
            top:        '50%', 
            zIndex:        '99'
        }).css({
            marginLeft:    '-' + (t.outerWidth() / 2) + 'px', 
            marginTop:    '-' + (t.outerHeight() / 2) + 'px'
        });

        if (absolute) {
            t.css({
                marginTop:    parseInt(t.css('marginTop'), 10) + jQuery(window).scrollTop(), 
                marginLeft:    parseInt(t.css('marginLeft'), 10) + jQuery(window).scrollLeft()
            });
        }
    });
};

$(document).ready(function()
{
    //-------------------------------------------------------
    /*shows the loading div every time we have an Ajax call*/
    $("#loading").center(true).bind("ajaxSend", function(){
   		$(this).show();
 	}).bind("ajaxComplete", function(){
   		$(this).hide();
 	});
 	//-------------------------------------------------------
})

function formsubmit(formname){
	$('#'+formname).submit(function() {
	  //alert('Handler for .submit() called.');
	  return false;
	});
}

function trim(s)
{
	var l=0; var r=s.length -1;
	while(l < s.length && s[l] == ' ')
	{	l++; }
	while(r > l && s[r] == ' ')
	{	r-=1;	}
	return s.substring(l, r+1);
}
