var OrangeShop = {};

// START: Tabs
var tabControl= Class.create({
	initialize: function (element,options){
		this.element = $(element);
		this.options = {
			activeTab: 0
		}
		Object.extend(this.options,options || {});
		this.tabHandles = this.element.getElementsBySelector('.tab-handles li');
		this.tabs = this.element.getElementsBySelector('.tab');
		this.selectedTab = this.options.activeTab
		this.tabHandles.each(function(node, n) {
			node.observe('click', function(event) {
				this.showTab(n);
				Event.stop(event);
				if($$('.replacement')){
					replaceHeaders();
				} 
				return false;
			}.bind(this))
			this.tabs[n].addClassName('displayNone');
		}.bind(this));
		this.showTab(this.options.activeTab);
	},
	showTab: function(tabIndex) {
		this.tabs[this.selectedTab].addClassName('displayNone');
		this.tabHandles[this.selectedTab].removeClassName("selected");
		this.tabs[tabIndex].removeClassName('displayNone');
		this.tabHandles[tabIndex].addClassName("selected");
		this.selectedTab = tabIndex;
	}
});

var tabRewardControl= Class.create({
	initialize: function (element,options){
		this.element = $(element);

		//alert(document.getElementById("reward_tabs_dolphin").innerHTML);
		this.options = {
			activeTab: 0
		}
		Object.extend(this.options,options || {});
		if(this.options.override)
		{
			this.tabHandles = this.element.getElementsBySelector(this.options.override);
		}
		else
		{
			this.tabHandles = this.element.getElementsBySelector('.reward_details_menu li');
		}

		this.tabs = this.element.getElementsBySelector('.tab');
		this.selectedTab = this.options.activeTab

		this.tabHandles.each(function(node, n) {
			node.observe('click', function(event) {
				this.showTab(n);
				//this.tabs[n].removeClassName('displayNone');
				Event.stop(event);
				return false;
			}.bind(this))
			//this.tabs[n].hide();
			//alert(this.tabs[n].className);
			this.tabs[n].addClassName('displayNone');
		}.bind(this));
		//this.tabs[this.options.activeTab].removeClassName('displayNone');
		//this.tabs[this.options.activeTab].addClassName('displayBlock');
		this.showTab(this.options.activeTab);

//		this.position
	},
	showTab: function(tabIndex) {
		//this.tabs[this.selectedTab].hide();
		this.tabs[this.selectedTab].addClassName('displayNone');
		this.tabHandles[this.selectedTab].removeClassName("selected");
		//this.tabs[tabIndex].show();
		this.tabs[tabIndex].removeClassName('displayNone');
		this.tabHandles[tabIndex].addClassName("selected");
		this.selectedTab = tabIndex;
	}
});
// END: Tabs


// START: Form Helpers (works on fieldsets only)
OrangeShop.formHelpers = Class.create({
	initialize: function (options){
		this.options = { };
		Object.extend(this.options,options || {});
		if (this.options.imageSrc) {

			$$('fieldset .help').each(function(h) {

				var formElement = h.up().getElementsBySelector('select', '.text', '.info')[0];
				if (formElement) {
					var helper = new Element('div').setStyle({position: 'absolute'}).setStyle(
						{ left: (formElement.positionedOffset().left + formElement.getWidth()) + 'px', top: '0' }
					);

					formElement.insert({ after: $(helper) })
					var img = new Element('img', {'src': this.options.imageSrc, 'className': this.options.imageClass}).observe(
						'click', function(event){
							if(this.current) this.current.hide();
							Effect.Appear(h, 'appear', {duration: .4})
							this.current = h;
						}.bindAsEventListener(this)
					);
					$(helper).insert({ bottom: img}).insert({ bottom: $(h)});

					h.setStyle({position: 'absolute', left: (img.positionedOffset().left + img.getWidth()) + 'px'}).hide();
				}
			}.bindAsEventListener(this));
		} else {
			$$(this.options.helpClass).each(function(h) {
				var formElement = h.up().getElementsBySelector('select', '.text')[0];;
				formElement.observe('focus', function(event){
					Effect.Appear(h, {duration: .4})
				}).observe('blur', function(event){
					h.hide();
				});
				h.setStyle({position: 'absolute', left: (formElement.positionedOffset().left + formElement.getWidth()) + 'px'}).hide();
			}.bindAsEventListener(this));
		}
		Event.observe(document.body, 'click', function(event) {
			if(this.current) {
				this.current.hide();
			}
		}.bind(this))
	}
});

/*
 * Info overlay
 * Shows an info icon which shows mini relative-positioned overlay when clicked
 * @param titleClass - the class that relates to the text which should have the icon image added.
 * @param icon - the image URL for the icon
 *
 * @info requires a div or span with class="help" following the titleClass element
 */
OrangeShop.infoOverlay = Class.create({
	initialize: function (titleClass, icon, options){
		$$(titleClass).each( function(el) {
			el.next('.help').hide();

			var image = new Element('img', {
				src: icon,
				alt: 'click for more information',
				style: 'vertical-align:middle; margin-left:10px;'
			});
			if (options && options.insertAfter) { el.insert({ after: image }); }
			else { el.insert({ bottom: image }); }

			image.observe('click', function(evt) {
				var clickedElement = evt.element();
				var content = (options && options.insertAfter) ?
					'<div class="infoTooltipContainer"><div class="infoTooltip">' + clickedElement.previous(titleClass).next('.help').innerHTML + '</div></div>' :
					'<div class="infoTooltipContainer"><div class="infoTooltip">' + clickedElement.up(titleClass).next('.help').innerHTML + '</div></div>';
				var offset = clickedElement.cumulativeOffset();
				var dimensions = clickedElement.getDimensions();

				var tooltip = new Control.Modal(false, {
					contents: content,
					overlayCloseOnClick: true,
					position:'relative',
					offsetLeft: (offset['left'] + dimensions['width']),
					offsetTop: (offset['top'] + dimensions['height']),
					containerClassName: 'modalTooltip',
					opacity: 0
				});
				tooltip.open();
			});
		});
	}
});

OrangeShop.toggleOnSelect = Class.create({
	initialize: function (optionClass,togglingClass){
		this.togglingElements = $$(togglingClass);
		this.optionElement = $$(optionClass)[0];
		this.validationAdded = 0;
		this.hide();
		this.addHandlerToOption();
		this.checkSelectStatus();
	},
	hide: function(){
		this.togglingElements.invoke('hide');
	},
	addHandlerToOption: function() {
		this.optionElement.up('select').observe('change', function(event){
			this.checkSelectStatus();
		}.bindAsEventListener(this));
	},
	checkSelectStatus: function() {
		if(this.optionElement.selected) {
			this.togglingElements.invoke('show');
			this.togglingElements.each(function(e){
				try {
					e.select('.maybeRequired').invoke('addClassName','required');
					if (!this.validationAdded)
					{
						attachValidation(e.down('input', 0).id, e.up('form').name);
						this.validationAdded = 1;
					}
				} catch(e) {};
				try {
					e.select('.requiredLabel').each(function(reqLabel){
						// add a mandatory asterisk element if the label doesn't already contain one
						if(!reqLabel.down('span.mandatory'))
							reqLabel.insert(new Element('span', {'class': 'mandatory'}).update("*"), 'bottom');
					});
				} catch(e) {};
			})
		} else {
			this.togglingElements.invoke('hide');
			this.togglingElements.each(function(e){
				e.select('.maybeRequired').invoke('removeClassName','required');
				try {
					attachValidation(e.down('input', 0).id, e.up('form').name);
				} catch(e) {};
			})
		}
	}
});
/**
* Shows or hides one or more page elements depending on the class name of the currently selected option.
* Includes custom addition/removal of required classes, depending on visible state.
* @param selectId The id of the select element to be examined.
* @param matchValue The class name assigned to options that will trigger the display of the hidden element(s).
* @param togglingClass The class assigned to elements that will be hidden or shown.
*/
OrangeShop.toggleOnSelectClassName = Class.create({
	initialize: function (selectId,matchValue,togglingClass){
		this.togglingElements = $$(togglingClass);
		this.selectElement = $(selectId);
		this.matchValue = matchValue;
		this.checkDisplayAndValidate();
		this.addHandlerToSelect();
		this.validationAdded = 0;
	},
	checkDisplayAndValidate: function() {
		if (this.selectElement != null) {
			if (Element.hasClassName(this.selectElement.options[this.selectElement.options.selectedIndex],this.matchValue)) {
				this.togglingElements.invoke('show');
				this.togglingElements.each(function(e){
					e.select('.maybeRequired').invoke('addClassName','required');
					e.select('.select-notfirst-maybe').invoke('addClassName','select-notfirst');
					try {
						if (!this.validationAdded)
						{
							attachValidation(e.down('select', 0).id, e.up('form').name);
							this.validationAdded = 1;
						}
					} catch(e) {};
				}.bind(this))
			} else {
				this.togglingElements.invoke('hide');
				this.togglingElements.each(function(e){
					e.select('.maybeRequired').invoke('removeClassName','required');
					e.select('.select-notfirst-maybe').invoke('removeClassName','select-notfirst');
					try {
						attachValidation(e.down('select', 0).id, e.up('form').name);
					} catch(e) {};
				})
			}
		}
	},
	addHandlerToSelect: function() {
		if (this.selectElement != null) {
			this.selectElement.observe('change', function(event)
			{
				this.checkDisplayAndValidate();
			}.bindAsEventListener(this));
		}
	}
});
OrangeShop.toggleByRadioButtons = Class.create({
	initialize: function (radioName, togglingElement, onValue, options){
		this.togglingElement = togglingElement;
		this.radioElements = $$('input[name=' + radioName + ']');
		this.onValue = onValue;

		this.options = Object.extend({
			onToggle: Prototype.emptyFunction
		}, options || {});

		this.toggleState = "hidden";
		this.toggle();
		this.addHandlerToRadios();
	},
	toggle: function(){
		this.radioElements.each(function(r){
			if (r.checked) {
				// if we're dealing with an array of 'on' values, iterate over its elements
				if (this.onValue instanceof Array) {
					this.matchFound = false;
					this.onValue.each(function(v) {
						if(this.matchFound == false) {
							this.toggleElement(r.value, v);
						}
					}.bind(this));
				} else {
					this.toggleElement(r.value, this.onValue);
				}
			}
		}.bind(this));
		if (this.options.onToggle) this.notify('onToggle', this.toggleState);
	},
	addHandlerToRadios: function() {
		this.radioElements.invoke('observe', 'click', this.toggle.bind(this));
	},
	toggleElement: function(radioValue, onValue){
		if (radioValue == onValue) {
			this.matchFound = true;
			this.togglingElement.show();
			this.toggleState = "visible";
		} else {
			this.togglingElement.hide();
			this.toggleState = "hidden";
		}
	},
	notify: function(event_name){
		try{
			if(this.options[event_name])
				return [this.options[event_name].bindAsEventListener(this).apply(this.options[event_name],$A(arguments).slice(1))];
		}catch(e){
			if(e != $break) {
				throw e;
	}
			else
				return false;
		}
	}
});

OrangeShop.toggleByLink = Class.create({
	initialize: function (triggerElement,togglingElement, options){
		this.triggerElement = triggerElement;
		this.togglingElement = togglingElement;
		this.originalText = this.triggerElement.innerHTML;
		this.options = options;
		if (this.options.startState == false)
			{this.toggle()} else {this.doAfterShow()}
		this.addHandlerToTrigger();
	},
	toggle: function(){
		this.togglingElement.toggle();
		if (this.togglingElement.visible())
			{this.doAfterShow()} else {this.doAfterHide()}
	},
	doAfterShow: function(){
		if (this.options.toggledText) this.triggerElement.innerHTML = this.options.toggledText;
		if (this.options.toggledClass) this.triggerElement.addClassName(this.options.toggledClass);
		replaceHeaders();
		try {
			this.togglingElement.down('input',0).focus();
		} catch(e) { }
	},
	doAfterHide: function(){
		if (this.options.toggledText) this.triggerElement.innerHTML = this.originalText;
		if (this.options.toggledClass)this.triggerElement.removeClassName(this.options.toggledClass);
	},
	addHandlerToTrigger: function() {
		this.triggerElement.observe('click', function(e){
			Event.stop(e);
			this.toggle();
		}.bindAsEventListener(this))
	}
});

OrangeShop.popup = Class.create ({
	initialize: function(elements, options) {
		this.options = Object.extend({
			width:500,
			height:600,
			scrollbars:'yes',
			menubar:'yes',
			resizeable:'yes'
		}, options || {});
		this.elements = $$(elements);
		if (Prototype.Browser.IE) {
			this.options.width = (this.options.width*1) + 20;
			this.options.height = (this.options.height*1) + 20;
		}
		this.setupObservers();
	},
	setupObservers: function() {
		this.elements.each(function(e) {
			e.observe('click', function(f) {
				Event.stop(f);
				var dims = 'width='+ this.options.width +
					',height=' + this.options.height +
					',scrollbars=' + this.options.scrollbars +
					',menubar=' + this.options.menubar +
					',resizable=' + this.options.resizable;
				var theWindow = window.open(f.element().href, '_blank', dims);
				theWindow.focus();
			}.bind(this));
		}.bind(this));
	}
});
OrangeShop.makePrintLink = Class.create ({
	initialize: function (element, options){
		this.element = $(element);
		this.options = Object.extend({
			// options go here
		}, options || {});
		if (this.options.printSelf)
			this.printSelf()
		else
			this.printTarget()
	},
	printSelf: function(){
		// Added try catch block to allow for pages that contain
		// makePrintLink call in header for an optional element.
		try {
	 		Event.observe(this.element, 'click', function(event){
				Event.stop(event);
				window.print();
			});
		} catch(e) { }
	},
	printTarget: function(){
 		new OrangeShop.popup(this.element, { width:'640', height:'480' });
	}
});

var ajaxModal = Class.create({
	initialize: function (url, options){
		this.options = Object.extend({}, options || {});
		this.modalHeader = '<div class="modal"><div class="modal-title-bar" onclick="Control.Modal.close(); return false;"><p><a class="close" onclick="Control.Modal.close(); return false;" href="#">close</a></p></div><div id="modal-window">';
		this.modalFooter = '</div></div>';

		var ajax = new Ajax.Request(url,{
			method: 'get',
			onSuccess: function(request){

				// KM: Hash code added so that page loads with #idname anchor as focus if it's supplied.
				if (url.indexOf('#') != -1){
					var hash = url.split('#').last().split('?').first();
					request.responseText = request.responseText + '<script type="text/javascript">location.href = "#' + hash + '";</script>';
				}

				// Concatenate contents
				var modalContent = (this.options.closeHeader && this.options.closeHeader == true) ?
					this.modalHeader + request.responseText + this.modalFooter :
					request.responseText;

				new openModalWithContent(modalContent,options);
			}.bind(this),
			onComplete: replaceHeaders
		});
	}
});

var openModalWithContent = Class.create({
	initialize: function(modalContent, options) {
		// Determine modal settings
		if (options && options.message) {
			var modalHeader = '<div class="modal ' + (modalContent.include('incompatibleMessage') ? 'incompatibleMessage' : 'message') + '"><div class="modal-title-bar" onclick="Control.Modal.close(); return false;"><p><a class="close" onclick="Control.Modal.close(); return false;" href="#">close</a></p></div><div id="modal-window">';
			var modalFooter = '</div></div>';
			modalContent = modalHeader + ((modalContent.include('incompatibleMessage')) ? modalContent : ('<p><strong>'+modalContent+'</strong></p>')) + modalFooter;
		}
		else if (options && options.messageWithClass && options.className) {
			var modalHeader = '<div class="modal ' + options.className + '"><div class="modal-title-bar" onclick="Control.Modal.close(); return false;"><p><a class="close" onclick="Control.Modal.close(); return false;" href="#">close</a></p></div><div id="modal-window">';
			var modalFooter = '</div></div>';
			modalContent = modalHeader + modalContent + modalFooter;
		}
		if (options) {
			if(options.width != undefined){
				var modalHeader = '<div class="modal" style="width:'+options.width+'"><div id="modal-window">';
				var modalFooter = '</div></div>';
				modalContent = modalHeader +  modalContent + modalFooter;
			}
		}

		var modalOptions = {
			overlayCloseOnClick: (options && options.message && !(modalContent.include('incompatibleMessage'))),
			containerClassName: ((options && options.containerClassName) ? options.containerClassName : ''),
			contents:modalContent
		};

		// Open the modal to fill with
		if (Control.Modal.current) {
			m = Control.Modal.current;
			m.update(modalContent);
		} else {
			m = new Control.Modal(false, modalOptions);
		}
		m.open();
		replaceHeaders();
	}
});

var linksToModal = Class.create({
	initialize: function (links, options){
		$$(links).invoke('observe', 'click', function(evt) {
			Event.stop(evt);
			// If the a tag is around an image that will trigger instead of a tag - this should catch that.
			var element = evt.element();
			if (element.tagName == 'IMG') { element = element.up('a'); }

			var href = element.href;
			if (href.indexOf('?') > -1) {
				new ajaxModal(href + '&ajax=yes', options);
			} else {
				if (href.indexOf('#') > -1) {
					var hash = href.split('#').last();
					var hrefstart = href.split('#').first();
					new ajaxModal(hrefstart + '?ajax=yes' + '#' + hash, options);
				} else {
					new ajaxModal(href + '?ajax=yes', options);
				}
			}
		});
	}
});

function $FR(frm, name) {
	return $F($(frm).getInputs('radio', name).find(function(obj) {
		return obj.checked
	}));
}
/**
* This method is essentially the same as $FR, but will return an empty string if the radio group has nothing selected
*/
function getRadioValue(frm, name) {
	var currValue = "";
	formData = $(frm).serialize(true);
	return (formData[name]) ? (formData[name]) : '';
}

function horizontalWrap(element, childSelector) {
	var wrapper = new Element('div');
	element.setStyle({overflow: 'hidden'}).insert({top: wrapper});
	childElements = element.getElementsBySelector(childSelector);
	var w = 0;
	childElements.each(function(e){
		w += e.getWidth();
		wrapper.insert({bottom: e});
	});
	wrapper.setStyle({width: w + 'px'});
}

/* Extended Form.serializeElements in prototype.js to ignore input type = image  */
Form.serializeElements = function(elements, options) {
    if (typeof options != 'object') options = { hash: !!options };
    else if (options.hash === undefined) options.hash = true;
    var key, value, submitted = false, submit = options.submit;

    var data = elements.inject({ }, function(result, element) {
      if (!element.disabled && element.name) {
        key = element.name; value = $(element).getValue();
        if (value != null && ((element.type != 'image' && element.type != 'submit') || (!submitted &&
            submit !== false && (!submit || key == submit) && (submitted = true)))) {
          if (key in result) {
            // a key is already present; construct an array of values
            if (!Object.isArray(result[key])) result[key] = [result[key]];
            result[key].push(value);
          }
          else result[key] = value;
        }
      }
      return result;
    });

    return options.hash ? data : Object.toQueryString(data);
  }

/**
* This class is designed to 'disable'/'undisable' image submits in forms with required fields.
*
* Required arguments:
* Forms, with class applied e.g. $$('form.withRequiredElements)
* the required class added to required elements within the forms e.g. '.requiredElement'
* the image to replace the input image with e.g. '/shop/library/images/general/btn_buy_now_off.gif'
*
* Optional arguments:
* onSubmitAllowed: Takes a function that is called once the form has the required elements picked.
*
* N.B. This class currently only works with select (single, not multiple), and radio buttons, the
* check applied is not null for radios, and not '' for selects.
*/
var formWithRequiredElements = Class.create({

	initialize: function(forms, requiredClass, replaceImage, options) {
		this.forms = forms;
		this.requiredClass = requiredClass;
		this.replaceImage = replaceImage;

		this.options = Object.extend({
			onSubmitAllowed: Prototype.emptyFunction
		}, options || {});

		this.attachToggleHandlerToInputs();
		this.toggleSubmitButtons();
	},

	getRequiredInput: function(form) {
		// Check that each of the required elements has had a value selected.
		var requiredElements = form.select(this.requiredClass);
		return requiredElements;
	},

	getSubmitAllowed: function(form) {
		// This class checks the values of each element and returns whether the elements are correctly filled.
		var submitAllowed = false;

		var elems = this.getRequiredInput(form);
		var requiredInputs = new Object();

		elems.each(function(e) { requiredInputs[e.name] = false });
		elems.each(function(e) {
			if (e.type == 'radio') {
				if (getRadioValue(form, e.name) != '') requiredInputs[e.name] = true;
			}
			else if (e.type == 'select-one') {
				if (e.getValue() != '') requiredInputs[e.name] = true;
			}
		});

		if ((Object.values(requiredInputs)).indexOf(false) == -1) {
			submitAllowed = true;
			this.notify('onSubmitAllowed');
		}

		return submitAllowed;
	},

	toggleSubmitButtons: function() {
		this.forms.each( function (f) {
			if (this.getSubmitAllowed(f)) {
				// Allowed to submit - 'undisable' the form
				f.down('input[type=image]').show();
				if (f.down('img[class=tempDisabled]')) {
					f.down('img[class=tempDisabled]').hide();
				}
			} else {
				// Not allowed to submit - 'disable' the form
				f.down('input[type=image]').hide();
				if (f.down('img[class=tempDisabled]')) {
					f.down('img[class=tempDisabled]').show();
				} else {
					var image = new Element('img', { 'class':'tempDisabled', 'src':this.replaceImage} );
					f.down('input[type=image]').insert({ after:$(image) });
				}
			}
		}.bind(this));
	},

	attachToggleHandlerToInputs: function() {
		this.forms.each( function (i) {
			var elems = this.getRequiredInput(i);
			elems.each(function(e) {
				if (e.type == 'radio') {
					e.observe('click', this.toggleSubmitButtons.bind(this));
				} else if (e.type == 'select-one') {
					e.observe('change', this.toggleSubmitButtons.bind(this));
				}
			}.bind(this));
		}.bind(this));
	},

	notify: function(event_name){
		try{
			if(this.options[event_name])
				return [this.options[event_name].bindAsEventListener(this).apply(this.options[event_name],$A(arguments).slice(1))];
		}catch(e){
			if(e != $break) {
				throw e;
			}
			else
				return false;
		}
	}
});


OrangeShop.intersection = Class.create(
{
	bringIntoView: function(elm)
	{
		var e=elm.substring(1,elm.length);

		if (document.getElementById(e)) document.getElementById(e).scrollTo();
	}
});

quickToggler = Class.create({
	initialize: function(toggleElement, initialState, toggleClass, options) {
		this.toggleElement = toggleElement;
		this.toggleClass = toggleClass;
		this.options = Object.extend({
			afterToggle: Prototype.emptyFunction
		}, options || {});
		this.toggle(initialState);
	},
	toggle: function(state) {
		if (state) {
			(this.toggleElement).removeClassName(this.toggleClass);
		} else {
			(this.toggleElement).addClassName(this.toggleClass);
		}
		if (this.options.afterToggle) this.notify('afterToggle', state);
	},
	notify: function(event_name){
		try{
			if(this.options[event_name])
				return [this.options[event_name].bindAsEventListener(this).apply(this.options[event_name],$A(arguments).slice(1))];
		}catch(e){
			if(e != $break) { throw e; }
			else return false;
		}
	}
});

document.observe("dom:loaded", function() {
	// This added for the content team to allow them to write in links that open as popups
	new OrangeShop.popup('a.content-popup-550x415', { width:'550', height:'415', menubar:'no' });
	new OrangeShop.popup('a.content-popup-590x620', { width:'590', height:'620',menubar:'no' });

	// Added for expanding LH external links navigation
	if ($('external-shop-menu')) {
    	new OrangeShop.toggleByLink($('external-shop-menu'), $('external-shop-menu').down('ul', 0), {
      		startState: false,
      		toggledClass: 'open'
  		});
    }
});

/**
*
*  Silder functionality to create dropdown
*
*/

Event.observe(window, 'load', function() {
	  if($('dropdown')){

		if($('filter-types')){
			$('filter-types').setStyle({
				display: 'none'
			})
	  	}

	  	Event.observe('dropdown', 'click', function() {

			if($('filter-types')){
				var button = $('drop_down_btn_up');
		  		var el = $('filter-types');
			}

			Effect.toggle(el, 'slide');

			if(button.className == "drop-down-down"){
				button.removeClassName('drop-down-down');
				button.addClassName('drop-down-up');
				showClearFilter($('clear-filter-submit'), false);

			}else if(button.className == "drop-down-up"){
				button.removeClassName('drop-down-up');
				button.addClassName('drop-down-down');
				showClearFilter($('clear-filter-submit'), true);
			}


		});
	  }
});

function showClearFilter(el, collapse){

	planFilters = $('plan-filter');
	planFiltersPrice = $$('input:checked[type="radio"][name="planCriteria"]').pluck('id');
	planFiltersPriceValue = $$('input:checked[type="radio"][name="planCriteria"]').pluck('value');
	planFiltersMin = $$('input:checked[type="radio"][name="minutes"]').pluck('id');
	planFiltersMinValue = $$('input:checked[type="radio"][name="planCriteria"]').pluck('value');
	planFiltersTxt = $$('input:checked[type="radio"][name="planCriteria"]').pluck('id');
	planFiltersTxtValue = $$('input:checked[type="radio"][name="texts"]').pluck('value');
	planFiltersBenefits = $$('input:checked[type="radio"][name="planType"]').pluck('id');
	planFiltersBenefitsValue = $$('input:checked[type="radio"][name="planType"]').pluck('vaue');

	if(collapse == true){
		$('clear-filter-submit').setStyle({
			display: 'none'
		});

	}else{
		if(planFiltersPriceValue=='0' && planFiltersMinValue=='0' && planFiltersTxtValue=='0' && planFiltersBenefitsValue=='0'){
			$('clear-filter-submit').setStyle({display:'none'});
		}else if(planFiltersPrice!='planCriteria_any' || planFiltersMin!='minutes_any' || planFiltersTxt!='texts_any' || planFiltersBenefits!='planType_any'){
		 	if(planFiltersPriceValue=='_NOFILTER_' && planFiltersMinValue=='_NOFILTER_' && planFiltersTxtValue=='_NOFILTER_' && planFiltersBenefits=='planType_any'){
		 		$('clear-filter-submit').setStyle({display:'none'});
		 	}else{
		 		$('clear-filter-submit').setStyle({display:'block'});
			}
		}else{
			$('clear-filter-submit').setStyle({display:'none'});
		}
	}

}
