/**/

jQuery.noConflict();

(function($) {
	
	$(document).ready(function(){
		
		$(".cancel_btn").click(function(){
			if(confirm('Are you sure Sure?')){
				var redirect = $(this).attr("target");
				window.location = redirect;
			}else{
				return false;
			}
		});
		
		
		/* - Toggle Input Disabled/Enabled - */
		function toggleEnable( elem ){
			if($(elem).arr("disabled")){
				$(elem).removeAttr("disabled");
			}else{
				$(elem).attr("disabled","disabled");
			}
			return $(elem);
		}
		
		/* - Label Click's Focus Assoc. Input - */
		$("label").click(function(){
			var trgt = $(this).attr("for");
			$("#"+trgt+" :radio").check();
			$("#"+trgt+" :text").click();
		});
		
		/* - Generic Handle/Drawer Handler - */
		$(".handle").change(function(){
			var trgt = $(this).attr("target");
			$("#"+trgt).toggle();
			$("#"+trgt).children("input :first").focus();
		});
		
		$("#AddListingForm").keypress(function(event){
			if ( event.which == 13 ) {
				$("#Us720Next").trigger("click");
			}
		});
		
		$("input.numeric").after('<span class="filter_msg"> Numbers Only </span>');
		$("input.numeric").keypress(function(event){
			//alert( event.which );
			var elem = $(this).next(".filter_msg");
			if ( 
				event.which != 63233 && //	Down Arrow
				event.which != 63232 && //	Up Arrow
				event.which != 63235 && //	Right Arrow
				event.which != 63234 && //	Left Arrow
				event.which != 63272 && //	Delete
				event.which != 46 && //		.
				event.which != 13 && //		Enter
				event.which != 8  && //		Backspace
				event.which != 9 && //		Tab
				event.which != 0 && //		
				(event.which < 48 || event.which > 57) 
			) {
				$(elem).show();
				$(elem).fadeOut(200);
  					return false;
  				}
		});			
		
		/* - Keyboard Bindings - */
		$("input").keypress(function(e){
			if (e.which == 13 ) {
				$("Us720Submit").val("next");
				$("addListingForm").submit();
				//$("Us720Next").click();
				//return true;
			}
		});
		
		/* - Form Input AutoFocus + Error Row Styling - */
		if ($(".error_message").length >= 1) {
			$(".error_message").parent().addClass("error_row");
			$(".error_row :first").parent().find("input").focus();
		} else {
			$("input:text:first").focus();
		}
		
		/**/
		$("#ListingLisitngPaymentOption").click(function(){
			//alert(   $(this).val() );
		});
		
		/*add stars to required fields*/
		$(".input.required > label").append("<span class=\"star\">*</span>");
		
		
		/**//*
		$.fn.createDialog.defaults = {
			progress: true,
			center: true,
			opacity: 0.9,
			bg: '#000'
		}
		/**//*
		$("#jDialogOverlay").click(function(){
			$.closeDialog();
		});
		/**//*
		$("#email_listing_link").createDialog({
			addr: "/us720/listings/send_listing/",
			bg: "#000000"
	      });
		/**/
	});	
})(jQuery);