function loadFormToPopupDiv(urlform, x)
{
    var popupDiv = jQuery("#MainPopupDiv");

    //Get the screen height and width  
    var maskW = jQuery(document).width();
    var maskH = jQuery(document).height();

    //Set height and width to mask to fill up the whole screen  
    jQuery("#MainPopupMask").css({ "width": maskW, "height": maskH });
    // Show mask with opacity
    jQuery("#MainPopupMask").fadeTo(200, 0.3);  


    var popupX = (maskW - x) / 2;
    var popupY = 50;
    
    popupDiv.css("left", popupX);
    popupDiv.css("top", popupY);
    
    jQuery("#MainPopupContent").html("<img src='/images/loading.gif' alt='loading'/>");
    
    popupDiv.show();
    loadForm(urlform)
}
function closeForm()
{
    jQuery("#MainPopupContent").html('');
    jQuery("#MainPopupMask").css({ "width":0, "height": 0 });
    //jQuery("#MainPopupDiv").css({ "width":0, "height": 0 });
    jQuery("#MainPopupDiv").hide();
}
function loadForm(urlform)
{
    jQuery.ajax({
        url: urlform,
        type: "GET",
        dataType: "html",
        success: function(data) 
              {
                  jQuery('#MainPopupContent').html(data); 
              },
        //beforeSend:function() 
        //    {
        //        jQuery('#GroupSelectSub').html('<div>...</div>'); 
        //    },
        error: function() 
            {
            jQuery('#MainPopupContent').html('<div>ERROR</div>'); 
            }
     })
}
function submitForm(urlform)
{
    jQuery.ajax({
        url: urlform,
        type: "POST",
        data: (jQuery('#requestForm').serialize()),
        dataType: "html",
        success: function(data) 
              {
                  jQuery('#MainPopupContent').html(data); 
              },
        //beforeSend:function() 
        //    {
        //        jQuery('#GroupSelectSub').html('<div>...</div>'); 
        //    },
        error: function() 
            {
            jQuery('#MainPopupContent').html('<div>ERROR</div>'); 
            }
     })
}
function clearDefaultText(txtbox, emptyValue)
{
    if (txtbox.value == emptyValue)
    {
        txtbox.value = '';
            //txtbox.value.focus();
    }
}

function restoreDefaultText(txtbox, emptyValue)
{
    if (txtbox.value == '')
    {
    	txtbox.value = emptyValue;
    }
}

function clearFilterInput(txtbox_id, url)
{
    if ( $('#' + txtbox_id).val().length == 0 )
    {
        $('#' + txtbox_id).css('background', url);
            //txtbox.value.focus();
    }
}

function restoreFilterInput(txtbox_id, url)
{//alert($('#' + txtbox_id).val().length);
    if ( $('#' + txtbox_id).val().length == 0 )
    {
    	//$('#' + txtbox_id).removeclass('filter_input_empty');
        $('#' + txtbox_id).css('background', url);
            //txtbox.value.focus();
    }
}

