function select_all(node) {
         $('.'+node).each(function() {
                  this.checked=true
         });
}

function deselect_all(node) {
         $('.'+node).each(function() {
                  this.checked=false
         });
}

function openDialog(title,node,x,y) {

         $("#"+node).show();                          
         $("#"+node).dialog({
                  modal: true,
                  height: y,
                  title: title,
                  width: x
         });
    
}

function processCheckboxes(classname,msg) {
    var checkboxes=new Array();
    if ($('input.'+classname+':checked').length>0) {
    
        $('input.'+classname+':checked').each(function() {
            checkboxes.push($(this).val());
        });
        return checkboxes; 
    }  
    else {
        alert(msg);
        return false;   
    }
    
}


function closeDialog(node) {
         $("#"+node).dialog("close");
         $("#"+node).hide();
}

function openDialogTinyMCE(title,node,x,y,tinymcenodes) {
         
         $("#"+node).show();                          
         $("#"+node).dialog({
                  modal: true,
                  height: y,
                  title: title,
                  width: x,
                  open : function () {
                           tmnodes=tinymcenodes.split(",");
                           $.each(tmnodes, function(i,n) {
                                    tinyMCE.execCommand('mceAddControl', false,n);
                           });
                  },
                  close: function () {
                           tmnodes=tinymcenodes.split(",");
                           $.each(tmnodes, function(i,n) {
                                    tinyMCE.execCommand('mceRemoveControl', false,n);
                           });
                  }
         });  
    
}

// Have a generic title, width and height,variables to send
function jQueryAlert(title,msg,x,y) {
         // node 
         $("#alert").html(msg);
         $("#alert").show();
         $("#alert").dialog({
                  width: x,
                  height: y,
                  title: title,
                  buttons: {
                           "OK": function() {
                                    closeDialog('alert');
                                    return true; 
                           },
                           "Cancel": function () {
                                    closeDialog('alert');
                                    return false;
                           }
                  }
         });
}


function ajax(script,node,querystring) {

    $.ajax({
        type: "POST",
        url: script,
        async: false,
        data: querystring,
        success: function(msg) {

                  $("#"+node).html(msg);
        }
    });


}

function scrollTo(node) {
         var targetOffset = $('#'+node).offset().top;
         $('html,body').animate({scrollTop: targetOffset},500);
}

function ajaxtabs(script,node,querystring,tabnode) {

    $.ajax({
        type: "POST",
        url: script,
        async: false,
        data: querystring,
        success: function(msg) {

                  $("#"+node).html(msg);
                  $("#"+tabnode).tabs();
                  
        }
    });


}

function ajax_bgcolor(script,node,querystring) {

    $.ajax({
        type: "POST",
        url: script,
        async: false,
        data: querystring,
        success: function(color) {
                  $('#'+node).css({
                           'background-color' : color
                  })
        }
    });


}