var ajaxRequest = null;
var messageTimer = false;
var messageTime = 2000;
var currentDialog = false;
var serverAddress = "iaxcalls.voipgate.com";
$(function(){	
	
	$('.ui-state-default').live('mouseover', function(){ $(this).addClass('ui-state-hover'); })
						  .live('mouseout',  function(){ $(this).removeClass('ui-state-hover'); });

	
	$('.phoneNumber').live('click',function(){
		toPhoneNumberBox($(this).find('.value').text());
		return false;
	});
	
	$('.sms').live('click',function(){
		toSmsBox($(this).find('.value').text());
		return false;
	});
				
});

function toPhoneNumberBox(value){
	$("#dialpad #phoneNumber").val(value);
	jQuery('.ui-tabs#rightPanel').tabs( 'select' , 'dialpad');
	jQuery(currentDialog).dialog('close');
}


function toSmsBox(value){	
	$("#sms input.number").val(value);
	jQuery('.ui-tabs#rightPanel').tabs( 'select','sms');
	jQuery(currentDialog).dialog('close');
}

function closeMainMenus(){
	$('.mainMenu').removeClass('opened').find('ul').slideUp(300)
				  .find('.active').removeClass('active');
}

function displayMessage(msg){
	$('#message').html(msg).dialog({
		modal: true,
		draggable: false,
		resizable: false,
		buttons: {
			Ok: function() {
				$(this).dialog('close');
			}
		}
	});	
	
}
