
		function confirmDialog(text, okurl, failurl)
		{
			var x = confirm(text);
			
			if(x)
			{
				$.getJSON(okurl,
				        function(data){
				        	if(data.status == "ok")
				        	{
				        		alert("Delete operation successful");
				        		location.reload();
				        	}
				        	else
				        		alert("Delete operation failed");
				        });
			}
			else if (failurl)
				window.location = failurl;
			return;
		}

        function disableKeyPress(e)
        {
            /* var key;
             if(window.event)
                  key = window.event.keyCode; //IE
             else
                  key = e.which; //firefox

             return (key != 13);*/
        }

        function isJson(data)
        {
        	data = data.replace(/^\s+|\s+$/g, '');

                if(data.search(/^{/) != -1)
                    return true;
                return false;
        }

        function boxyConfirm(msg, url)
        {
        	Boxy.confirm(msg , function() { window.location = url }, {title: "Confirmation required"}); return false;
        }

        function toJson(html)
        {
                data = html.replace(/^\s+|\s+$/g, '');
                return eval("(" + data +")");
        }
        
        function populateProgressBar()
        {
        	$.get(ROOT_URL + "ajax/fetch_progress.php", function (data, textStatus)
                {
                       data = eval(data);
                       if(data != "")
                       {
                    	        if(data.part < data.parts)
                    	        {
	                       	        percent = (data.part/data.parts)*100
					$("#progessbar").html(data.action_plural + " " + data.part + " of " + data.action_plural + "(" + percent + "%)");
					setTimeout("populateProgressBar()", 1000);
                    	        }
                       }
                });
        }

        function populateNotices()
        {
                $.getJSON(ROOT_URL + "ajax/fetch_usernotices.php", function (data, textStatus)
                {
                        refresh = false;
                        item_num = false;
                        current_notices = $("#usernotice_list").html();
                        new_notices = "";

			   if(data != null)
			{
                        $.each(data, function(i,item)
                        {
                                item_num = i + 1;
                                if(item.refresh)
                                {
                                        refresh = true;
                                        $(document).ready(function()
                                        {
                                                window.location = item.refresh;
                                        });
                                        return;
                                }
                                else
                                {
                                        new_notices = new_notices + "<div id='usernotice" + item_num + "' class='" + item.level + "'>" + item_num + ". " + item.message + "</div>";
                                }
                        });
			}

                        if(new_notices != current_notices)
                        {
                        	$("#usernotices").fadeIn(1200);
                                $("#usernotice_list").html(new_notices);
			}

                        if(!refresh && item_num)
                        {
                                if(item_num == 1)
                                        $("#usernotice_summary").html("You have one notice:");
                                else
                                        $("#usernotice_summary").html("You have " + item_num + " notices:");
                        }

                });
        }


        function pageOnLoad()
        {
                if(window.loadGoogleMap)
                        loadGoogleMap();
        }

        function pageOnUnLoad()
        {
                if(window.GUnload)
                        GUnload();
        }

