/**
 * @author shrestha
 * For compare button and compare checkboxes
 */

PHILIPS.namespace('PHILIPS.ui'); 

PHILIPS.ui.compare = new Class({
    Implements: [Options, Events],
    options: {
		CLASSES: {
			topLevelButton: "product_list",
			active: "active",
			inactive: "inactive",
			compareCheckboxes: "compare_button input",
			checkboxes: 'checkbox'
		},
		IDS: {
			topLevelButton: "product_list",
			compareButton: "compare_submit",
			compareEntries: "entryids",
			compareForm: "compare_form",
			compareSubmit: "compare_trigger"
		},
		SELECTORS: {
			
		}
    },
	compareBoxes: [],
	compareButton:'',
	cbs: [],
	
    initialize: function(options) {
		
        this.setOptions(options);
		
		this._findElements();
		
		this._attachListeners();
		
    },
	
		//----------------------------------------------------------------------
		// PROPERTIES
		//----------------------------------------------------------------------
		
	
	
		//----------------------------------------------------------------------
		// PRIVATE METHODS
		//----------------------------------------------------------------------
		
	_attachListeners: function() {
		this.compareButton.addEvent('click', this._addButton.bindWithEvent(this));
		
	},
		
	_findElements: function() {
		this.compareButton = $(this.options.IDS.compareButton);
		this.compareBoxes = $$('.' + this.options.CLASSES.compareCheckboxes);

	},
	_addButton: function(e) {
		this._updateCompareItems();
		
		//$(this.options.IDS.compareForm).submit();
		e.preventDefault();
		
		return false;
	},
	_updateCompareItems: function(){
		var valueString = '';
		
		for(i=0; i<this.compareBoxes.length; i++){
			if(this.compareBoxes[i].checked){
				valueString +=this.compareBoxes[i].get('value') + '|';
			}
			
			if(valueString.length > 1){
				//removing the last |
				//valueString = valueString.slice(0, valueString.length-1);
			}
			$(this.options.IDS.compareEntries).set('value', valueString);
					
		}
	},
	
		//----------------------------------------------------------------------
		// EVENT HANDLERS
		//----------------------------------------------------------------------
	setupButtons: function(e,el){
		
		
		
	},
		//----------------------------------------------------------------------
		// GETTER SETTERS
		//----------------------------------------------------------------------
	setSomeVariable: function() {
	
	},
	getSomeVariable: function() {
	
	}
	
});