// JavaScript Document

/*
all_locations_chk
location_table input
*/

jQuery.fn.exists = function(){return jQuery(this).length>0;}

function MOON() {
	var version = '1.0';
	return version;
}

MOON.general = {
	initCalendarTooltips:function() {
		$(".tip").tooltip({
			delay: 0, 
			showURL: false, 
			bodyHandler: function() { 
				return ($(this).attr('rel') != '')?$(this).attr('rel'):'No Info';
			}
		});	
	},
	
	initVideoTourLink:function(){
		$('.virtual_tour').click( function(){
			if($('.video_property_section').css('display') == "block") {
				$('.video_property_section').css('display','none');
				$('.virtual_tour_bottom_link .operative-word').html('Show');
			} else {
				$('.video_property_section').css('display','block');
				$('.virtual_tour_bottom_link .operative-word').html('Hide');
			}
			
			if($(this).hasClass("top_link")) {
				return true;
			} else {
				return false;
			}			
		});
	},
	
	initInputFocusHide:function() {
		$("input[name=exp_date_month]").focus( function (){
				if($(this).attr('value') == 'mm')
					$(this).attr('value','');
		});
		
		$("input[name=exp_date_year]").focus( function (){
				if($(this).attr('value') == 'yy')
					$(this).attr('value','');
		});
	}
};

MOON.editor = {
	initEditors:function(){		
		if(window.CKEDITOR){
			$('.editor').ckeditor();
		}		
	}	
}

MOON.search = {
	
	start:function() {
		MOON.search.initSearchForm();
		MOON.editor.initEditors();
	},
	
	initSearchForm:function() {
		$('#all_locations_chk').change(function() {
			$('.location_table input[@type=checkbox]:checked').attr('checked',!this.checked); 
		});
	}
};

$(document).ready(function(){
	MOON.search.start();
	MOON.general.initCalendarTooltips();
	MOON.general.initInputFocusHide();	
});

