/**
 * toggler.js
 *
 * @version 1.0
 * @author Grady Kuhnline
 *
 * @requires prototype.js
 * @requires EventSelectors.js
 **/ 

var ToggleSiblings = Class.create({
			initialize: function(el) {
				this.c = {
					buttons: el.select('input.conect-button'),
					containers: el.select('fieldset.toggleSiblings-container')
				};                      
				this.c.buttons.each(
					function(button) {  
						this.onClick(null,button);
						button.observe('click', this.onClick.bindAsEventListener(this, button), false);
					 }.bind(this)
				 );
			},	        		   
	 	
			onClick: function(e, button) {  
				// get the id of element to show from the href
				//var href = button.href; 
				// strip unwanted url and # from the string
			    //var trunc = href.indexOf("#")+1;  		 
				//var id = href.substring(trunc);    														
				
				if (button.checked == true) 
				{
					var id = "villaName";
					button.parentNode.parentNode.className = "search-box small"; 					   								     				
				} 
				else
				{
					var id = "villaNormal";
					button.parentNode.parentNode.className = "search-box";					
				};
				
				//alert(button.name);
 			
				
				//alert(id);  //for debugging

				this.c.containers.each(function(el) {
					if (el.id == id )
						el.show();
					else
						el.hide();
				}); 								
				
				//Event.stop(e);
				}

			});
        // designate container which holds the elements to toggle           
		
		EventSelectors.register({
			'.search-box' : function(el) {
				new ToggleSiblings(el);
			}
		});                   
		
