	$(document).ready(function() {
		// buttons
		$("input:submit").button();					   
		$("input:submit", ".preview").button();					   
		$("a", ".tac").button();
       // header ref search
		 $("input:radio[name=group1]").click
                (
                    function()
                    {
                        $("#ref_form").attr("action",$(this).val());
                    }
                ); 
		//dialog message reg7.php/salereg6.php
		$(function() {
		$("#dialog-message").dialog("destroy");
	
		$("#dialog-message").dialog({
            width: 450,
			modal: true,
			buttons: {
				Ok: function() {
					$(this).dialog(window.location = "/owners.php");
				}
			}
		});
		});			
		//dialog message regreview.php/salereg5.php
		$(function(){
        // jQuery UI Dialog    

        $('#dialogsub').dialog({
            autoOpen: false,
            width: 450,
            modal: true,
            resizable: false,
            buttons: {
                "Submit Advert": function() {
                    document.testconfirmJQ.submit();
                },
                "Cancel": function() {
                    $(this).dialog("close");
                }
            }
        });
		$('form#testconfirmJQ').submit(function(){
                    $('#dialogsub').dialog('open');
                    return false;
                });
		});

		//images scripts
			$(function() {
		$("#contentLeft ul").sortable({ opacity: 0.4, cursor: 'move', update: function() {
			var order = $(this).sortable("serialize") + '&action=updateRecordsListings'; 
			$.post("/updaterentalimagesDB.php", order, function(theResponse){
				$("#contentRight").html(theResponse);
			}); 															 
		}								  
		});
	});

});	
        // jQuery UI Dialog    
jQuery('.delete').live('click',function(){
	jQuery(this).addClass("selected");
	jQuery('#dialog').dialog('open');
		
	return false;
});
        
jQuery(function(){
        jQuery('#dialog').dialog({
            autoOpen: false,
            width: 400,
            modal: true,
            resizable: false,
            buttons: {
                "Delete Image": function() {
					var parent = jQuery(".delete.selected").parent().parent().parent();
					var iframeId = document.getElementById("upload_target1");
					jQuery('<img style = "align : center; position:absolute;top:0;" id = "loading" src = "/photos/loading.gif" ></img>').insertAfter(parent.children("form"));
					
					var eventHandler = function()  {
						var iframeId = document.getElementById("upload_target1");
						if (iframeId.detachEvent)
							iframeId.detachEvent("onload", eventHandler);
						else
							iframeId.removeEventListener("load", eventHandler, false);

						if (iframeId.contentDocument) {
                    		content = iframeId.contentDocument.body.innerHTML;
                		} else if (iframeId.contentWindow) {
                    		content = iframeId.contentWindow.document.body.innerHTML;
                		} else if (iframeId.document) {
                    		content = iframeId.document.body.innerHTML;
                		}
				
						parent.children("div").remove();
						parent.children("img").remove();
						parent.removeClass("selected");
						jQuery("#loading").remove();
						
					}
					
				jQuery("#upload_target1").contents().empty();
				var parent = jQuery(".delete.selected").parent().parent().parent(); 

				if (iframeId.addEventListener)
					iframeId.addEventListener("load", eventHandler, true);
				if (iframeId.attachEvent)
					iframeId.attachEvent("onload", eventHandler);
				
				parent.children("div").children().submit();
				jQuery("#dialog").dialog("close");
							
                },

                "Cancel": function() {
                    jQuery(this).dialog("close");
                }
            }
        });
		});
              

jQuery("input[type = 'submit']").live('click',function() {
	jQuery(this).parent().parent().addClass("selectedLi");
	var parent = jQuery(".selectedLi");
	var iframeId = document.getElementById("upload_target");
	jQuery('<img style = "align : center; position:absolute;top:0;" id = "loading" src = "/images/loading.gif" ></img>').insertAfter(parent.children("form"));
	
	var eventHandler = function()  {

	if (iframeId.detachEvent)
		iframeId.detachEvent("onload", eventHandler);
	else
		iframeId.removeEventListener("load", eventHandler, false);
				
	var result = jQuery("#upload_target").contents().find("#result");
	var id = result.attr("idres");
	var filename = result.attr("filename");
	var parent = jQuery(".selectedLi");
	jQuery("#upload_target").empty();
	parent.children("div").remove();
	parent.children("img").remove();
	var html = '';
	html = '<img src="/rentalproperties/'+prop+'/'+filename+'" id="'+id+'" class="thumb" border="1">'+
		'<div style="position:relative; margin:-5px 200px 0px 0px;">'+
		'<form target = "upload_target1" action="/deleterentalimage.php" method="post" name="delete" id="confirmJQ">'+
		'<input name="uniqID" type="hidden" value="'+parent.children("form").children("input[name = 'uniqID']").val() +'"/>'+
		'<input name="propID" type="hidden" value="'+parent.children("form").children("input[name = 'propID']").val() +'"/>'+
		'<input name="Delete" class = "delete"  id = "delete" type="image" src="/images/bin.gif"/>'+
		'</form>'+
		'</div>';
				
	parent.append(html);
	var html = '';

	jQuery(".selectedLi").removeClass("selectedLi");
	jQuery("#loading").remove();
	
	}
				jQuery("#upload_target").empty();
				if (iframeId.addEventListener)
					iframeId.addEventListener("load", eventHandler, true);
				if (iframeId.attachEvent)
					iframeId.attachEvent("onload", eventHandler);
			
			})
	$(function(){
		//all hover and click logic for buttons
		$(".fg-button:not(.ui-state-disabled)")
		.hover(
			function(){ 
				$(this).addClass("ui-state-hover"); 
			},
			function(){ 
				$(this).removeClass("ui-state-hover"); 
			}
		)
		.mousedown(function(){
				$(this).parents('.fg-buttonset-single:first').find(".fg-button.ui-state-active").removeClass("ui-state-active");
				if( $(this).is('.ui-state-active.fg-button-toggleable, .fg-buttonset-multi .ui-state-active') ){ $(this).removeClass("ui-state-active"); }
				else { $(this).addClass("ui-state-active"); }	
		})
		.mouseup(function(){
			if(! $(this).is('.fg-button-toggleable, .fg-buttonset-single .fg-button,  .fg-buttonset-multi .fg-button') ){
				$(this).removeClass("ui-state-active");
			}
		});
	});


$.fx.speeds._default = 1000;
	$(function() {
		$('#dialog-help').dialog({
			autoOpen: false,
            width: 450,
			show: 'blind',
			hide: 'blind',
			buttons: {
				Ok: function() {
					$(this).dialog('close');
				}
			}

		});
		
		$('#opener').click(function() {
			$('#dialog-help').dialog('open');
			return false;
		});
	

			
			
			
			
			
			
			
			
			
			
	});
	
<!--popup window
function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, 'width=440,height=300,scrollbars=yes');
return false;
}
//-->

