

$(document).ready(function(){

// + KEYBOARD OPERATIONS

shortcut.add("Up",function() {
	obj=$("input:focus").prev().prev();
	if ($(obj).focus()) $(obj).select();
	return false;
});
shortcut.add("Down",function() {
	obj=$("input:focus").next().next();
	if ($(obj).focus()) $(obj).select();
	return false;
});

shortcut.add("Ctrl+Up",function() {
	obj=$("input:focus").prev().prev();
	if ($(obj).focus()) $(obj).select();
	return false;
});
shortcut.add("Ctrl+Down",function() {
	obj=$("input:focus").next().next();
	if ($(obj).focus()) $(obj).select();
	return false;
});
shortcut.add("Ctrl+Right",function() {
	obj=$("input:focus").next();
	if ($(obj).focus()) $(obj).select();
	return false;
});
shortcut.add("Ctrl+Left",function() {
	obj=$("input:focus").prev();
	if ($(obj).focus()) $(obj).select();
	return false;
});

// - KEYBOARD OPERATIONS


// $("#price input").focus(function() {
	// if((($(this).next().next().attr('id')==null) || ($(this).next().next().attr('id'))=="") /* && ((($(this).prev().attr('value'))!="") || (($(this).prev().prev().attr('value'))!="")) */ ) {

		// if((($(this).attr('id'))%2)==0) {
			// $('<input id="'+ (parseInt($(this).attr('id'))+1) +'" name="arr1[]" value="" /><input id="'+ (parseInt($(this).attr('id'))+2) +'" name="arr2[]" value="" /><input type="button" value="x" class="buttonx" id="del'+ (parseInt($(this).attr('id'))+2) +'" />').appendTo('#price');
		// } else {
			// $('<input id="'+ (parseInt($(this).attr('id'))+2) +'" name="arr1[]" value="" /><input id="'+ (parseInt($(this).attr('id'))+3) +'" name="arr2[]" value="" /><input type="button" value="x" class="buttonx" id="del'+ (parseInt($(this).attr('id'))+3) +'" />').appendTo('#price');			
		// }
	// }
// });


$("#addrow").click(function() {
	$('<input id="" name="addproperty[]" value="" /><input id="" name="addprice[]" value="" />').appendTo('#price');			
});


// + LOGIN BOX

	$("a.signin").click(function(){
		$("#loginbox").slideToggle("slow");
		
	});
	
// - LOGIN BOX
	

	$("span.addpost_trigger").click(function(){
		$("#addpost").slideToggle("slow");
	});
	
	$("#usamap").mouseover(function () {
	
		$("#usamapimage").stop();
		$("#usamap").stop();
		$("#usamap").animate({
			opacity: 0.75,
			width: '909px',
			left: '-73px',
			top: '-175px',
			height: '593px'
		}, 500);
		$(".table-property").css("position","relative");
		$(".table-property").stop();
		$(".table-property").animate({
			top: '-175px'
		}, 500);
/*		setTimeout(function(){
			$("#usamapdiv").attr("usemap", "#all");
		}, 600); */
	})
	
	
	
	.mouseout(function() {
		$("#usamapimage").stop();
		$("#usamap").stop();
		$("#usamap").animate({
			opacity: 1,
			width: '405px',
			left: '0px',
			top: '0px',
			height: '264px'
		}, 500);
		$(".table-property").stop();
		$(".table-property").animate({
			top: '0px'
		}, 500);
/*		setTimeout(function(){
			$("#usamapdiv").attr("usemap", "#");
		}, 600); */
	});
	
function over(image) {
    $("#allimg").attr("src", "http://serv7zu3o1qm.sn.sourcedns.com/~royston/usamap/ch/" + image + ".gif");
}
function overoff() {
    $("#allimg").attr("src", "http://serv7zu3o1qm.sn.sourcedns.com/~royston/usamap/blank.gif");
}
function clck(image) {
    $("#allimg2").attr("src", "http://serv7zu3o1qm.sn.sourcedns.com/~royston/usamap/ch/" + image + ".gif");
}
function clckoff() {
    $("#allimg2").attr("src", "http://serv7zu3o1qm.sn.sourcedns.com/~royston/usamap/blank.gif");
}

$("#all area").hover(
    function () {
		if ($(this).attr("id")=="") {
			overoff();
		} else
        over($(this).attr("id"));
    },
    function () {
        overoff();
    });

$("#all area").click(
    function () {
		if ($(this).hasClass("selected")) {
			clck("blank");
			$('div#price').load('state/al.html');
			$('div#price2').load('state/al.html');
			$(this).removeClass("selected");
		} else {
			$("#all area.selected").removeClass("selected");
			clck($(this).attr("id"));
			$('div#price').load('state/'+$(this).attr("id")+'.html');
			$('div#price2').load('state/'+$(this).attr("id")+'.html');
			$('table.table-property').css('position','relative');
			$('table.table-property').css('top','-175px');
			$(this).addClass("selected");
		}
	}
);

$("button.buttonx").click( function() {
	$("<input type='hidden' name='delete[" + ($(this).attr('id')).slice(3) + "]' value='1'>").appendTo("#formprice");	
	$("input#property"+(($(this).attr('id')).slice(3))).attr('class','deleted');
	$("input#price"+(($(this).attr('id')).slice(3))).attr('class','deleted');
});

$("#content-wrapper2 #address .inp").focus(function() {
        $("#content-wrapper2 #address .but").css('display','block');
});
$("#content-wrapper2 #address .inp").blur(function() {
        setTimeout(function() {
	    $("#content-wrapper2 #address .but").css('display','none');
	}, 1000)
});

	
	
	
	
	$("div.overout").mouseover(function(){
      $("p:first",this).text("mouse over");
      $("p:last",this).text(++i);
    }).mouseout(function(){
      $("p:first",this).text("mouse out");
    });
	


$(".editbtn").click(function(){
element=document.getElementById("e"+(($(this).attr('id')).substr(7,6)));
oldid=element.id;
    if ( element.nodeName.toLowerCase() == 'div'
         && ( element.className.indexOf( 'editable' ) != -1 ) )
        replaceDiv( element );
$("#f"+element.id+" .ee").css('display','block');
});


/*
$("#formprice input:last").live('change',function() {
	$("#formprice input:last[type='text']").after('<input value="" name="addproperty[]" id=""><input value="" name="addprice[]" id="">');
});

$("#formprice input:last").prev().live('change',function() {
	$("#formprice input:last").after('<input value="" name="addproperty[]" id=""><input value="" name="addprice[]" id="">');
});



$("#formprice input").live('click' ,function() {
	alert($("#formprice input:last[type='text']").attr('id'));
});
*/


$(function() {
  $("#date_input").date_input();
});















});




//+ GALLERY
var from,to;
var currentid;
$(document).ready(function() {
$(".notice-ok").fadeOut(1);
});

$(function() {
	$(".draggable").draggable({
		drag: function(event, ui) {
			from=$(this).find('span').html();
		}
	
}	);

	$(".droppable").droppable({
		drop: function(event, ui) {
			to=$(this).find('span').html();
			document.location=("?from="+from+"&to="+to);
		}
	});

});
function Change(id,value,f)
	{
  document.getElementById('ok1').style.visibility='visible';
    currentid=id;
    http_request = false;

    if (window.XMLHttpRequest) { // Mozilla, Safari,...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text');
        }
    } else if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
            http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }
    if (!http_request) {alert('Could not complete request! :(');return false;
    }
    http_request.open('GET', 'inc/change.php?id='+id+'&value='+escape(value)+'&f='+f, true);
    http_request.send(null);

  $(".notice-ok").html('Saved').hide().fadeIn(500);
  setTimeout(function(){ $('.notice-ok').fadeOut(500); }, 1000);
}
//- GALLERY


