        jQuery.noConflict();

        jQuery(document).ready(function() {

            jQuery('#notes').dialog({
                autoOpen: false,
                close: function (event,ui) {
                    jQuery('#notes').empty();
                    jQuery('#notes').dialog('option','buttons',{});
                 },
                position: 'top'
            });
        });

function flash_title(msg) {
	window.focus();
    var oldTitle = document.title;
    var timeoutId = setInterval(function() {
        document.title = document.title == msg ? ' ' : msg;
    }, 1000);
    window.onmousemove = function() {
        clearInterval(timeoutId);
        document.title = oldTitle;
        window.onmousemove = null;
    };
}
function getHelp(id) {
	jQuery.get('/helpPopup.php', {helpId: id},
			function(data) {
				jQuery('#notes').html(data);
				jQuery('#notes').dialog('option','title','MafiaReturns Help');
				jQuery('#notes').dialog('open');
			}
		);
}

function do_petty() {
	flash_title("Petty time!!!");
	jQuery.get('/profit/pettycrime.php', {ajax:'1'},
		function(data) {
			jQuery('#notes').html(data);
			jQuery('#notes').dialog('option','title','Petty Crime');
			jQuery('#notes').dialog('open');
			jQuery('textarea:first').focus();
			
			jQuery('#pettyform').submit(function() { 
				jQuery('#pettymsg').hide();

			selection = document.getElementById('pettyform').ptype;

			type = '';
			for (i=0; i<selection.length; i++)
				if (selection[i].checked == true)
						type = selection[i].value;

			jQuery.post('/profit/dopetty.php', 
				{
					ajax: true,
					ptype: type,
					submit: 'Do petty!'
				}, function (data) {
					jQuery('#pettymsg').html(data).fadeIn(3000);

					if (data.substr(0,7) == 'Success') {
						jQuery('#notes').dialog('close');
						jQuery.getScript('/js/timers.php');
					}
//					else {
//						alert(data);
//					}

				}, 'html'
			);
				return false; 
			});
		}
		,'html'
	);
}
function do_felony() {
    flash_title("Felony time!!!");
//document.title = 'Clicked';
    jQuery.get('/profit/felony.php',{ajax: true},
        function(data) {
//            alert(data);
			jQuery('#notes').html(data);
            jQuery('#notes').dialog('option','title','Felony');
            jQuery('#notes').dialog('open');
    	},'html'
    );
//document.title = 'End Of Function';
}
function show_airport() {
    jQuery.get('/manage/airport.php', {ajax:true},
        function(data) {
            jQuery('#notes').html(data);
            jQuery('#notes').dialog('option','title','Airport');
            jQuery('#notes').dialog('open');
            jQuery('#airportform').submit(function() {
				selection = document.getElementById('airportform').to;
				type = '';
				for (i=0; i<selection.length; i++)
					if (selection[i].checked == true)
						type = selection[i].value;
					jQuery.post('/manage/airport.php',
						{
							ajax: true,
							to: type,
							submit: 'Fly!'
						}, function (data) {
							if (data.substr(0,15) == 'You have landed') {
								loc = '<img src="/images/city_' + type;
								loc = loc + '.jpg" alt="'+data.substr(19,(data.length - 1))
+'" onClick="show_airport();" />';
								document.getElementById('loc').innerHTML=loc;
								jQuery('#notes').dialog('close');
								jQuery.getScript('/js/timers.php');
							}
						}, 'html'
					);
					return false;
            });
        }
        ,'html'
    );
}

function jail_time(){
	var timeoutid = setInterval(function(){
				jQuery('#msg').load('/js/jail.php',{},
				function(responseText, textStatus, Object){
					document.getElementById('msg').innerHTML = responseText;
					//jQuery('#msg').html = responseText;
					if(document.getElementById('msg').innerHTML == 'Your sentence is up. You are free to go.'){
    				    clearInterval(timeoutid);
   					}
				});
			}, 5000);
}

/*
function jail_time(){

	var xmlHttpJailTime=GetXmlHttpObject()
if (xmlHttpJailTime==null)
 {
 alert ("Browser does not support HTTP Request");
 return;
 }
var timeout = setInterval(function{
var url="http://mafiareturns.com/js/jail.php";
xmlHttpJailTime.onreadystatechange = function(){ document.getElementById('msg').innerHTML = xmlHttpJailTime.responseText }; 
xmlHttpJailTime.open("GET",url,true)
xmlHttpJailTime.send(null)
}, 1000);
}
*/

function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

