/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

var containerId = '#content';
var tabsId = '#menu';

$(document).ready(function(){
    //VNC
    $('#cmdAminVNC').click(function() {
        popupFullScreen('http://www.zacas.org/zacas/noVNC/vnc.html');
        return false;
    });
	 //<-- End VNC	

    //Lista degli indirizzi IP dei server dei clienti
    $('#cmdAminViewIP').click(function() {
        $('#frmAminViewIP').load('zacas/utility/getip/listClientIP.html').dialog({modal: true});
        return false;
    });
	 //<--End Lista indirizzi IP    

	 //File Manager
	 var f = $('#elfinder').elfinder({
      url : 'zacas/elfinder/connectors/php/connector.php',
      lang : 'it',
    	docked : true
    });

	 $('#cmdAminFileManager_evtClose').hide();
	 $('#elfinder').elfinder('close');

    $('#cmdAminFileManager').click(function() {
        $('#elfinder').elfinder('open');
		  $('#elfinder').elfinder($(this).attr('rel'));
		  $('#cmdAminFileManager_evtClose').show();
        return false;
    });

    $('#cmdAminFileManager_evtClose').click(function() {
        $('#elfinder').elfinder('dock').elfinder('close');
		  $(this).hide();
        return false;
    });
	//<-- End File Manager	 

	//Tabs
   $('div.tabs').tabs({
        fx: {
            height: 'toggle', 
            opacity: 'toggle', 
            duration: 400
        }
    });
    $('div.tabs').bind('tabsselect', function(event, ui) {
        if(ui.index==4){
            $('#frmMail').resetForm();
        }
    });
	//End Tabs    

	 //Send E-mail from about page
    $('#cmdEmail').click(function() {
        //alert("sendContact=1" + "+email=" + $('#email').val() + "+subject=" + $('#subject').val() + "+message=" + $('#message').val());
        $.ajax({
            type: "post",
            url: "lib/libMail.php",
            dataType: "text",
            data: {
                'sendContact' : '1',
                'email' : $('#email').val(),
                'subject' : $('#subject').val(),
                'message' : $('#message').val()
            },
            success: function(msg){
                ShowMessage(msg);
                $('#frmMail').resetForm();
            },
            timeout: 5000,
            error: function(request,error) {
                ShowMessage("ERROR: " + error);
            }
        });
    });
	 //<-- End E-mail    

	 //Logout
    $('.logout').click(function() {
        $.ajax({
            type: "post",
            url: "index.php",
            dataType: "text",
            data: {
                'action' : 'logout'
            },
            success: function(msg){
              //  ShowMessage(msg);
            },
            timeout: 5000,
            error: function(request,error) {
                ShowMessage("ERROR: " + error);
            }
        });
    });
	 //<-- End Logout
});//<-- End ready function

function ShowMessage(msg){
    $('#showMessage').text(msg);
    $('#showMessage').showTopbarMessage({ background: "#093", close: 3500 });
    $('#showMessage').text('');
}

function popupFullScreen(url){
 params  = 'width='+screen.width;
 params += ', height='+screen.height;
 params += ', top=0, left=0'
 params += ', fullscreen=yes';

 newwin=window.open(url,'windowname4', params);
 if (window.focus) {newwin.focus()}
 return false;
}

