function setShowHideFilters(){
	//this sets up the shows hide of the 2nd row of options
	$$('#show-2nd-row a').each(function(elm){
		elm.observe('click',function(event){
			var optionRow = $('options-row-2');
			if(optionRow.visible()){
				this.innerHTML = "Show More Options";
				optionRow.hide();
			}else{
				this.innerHTML = "Hide More Options";
				optionRow.show();
			}
			event.stop();
		});
	})
}

function setPlusMinusTTip(){
	//this fixes the ttip hovers on this page,
	//they now need to show plus minus
	$$('.ttipPlusSymbol').each(function (elm){elm.observe('mouseout',function(event){elm.src="/images/whatIsXM/plans-pricing/plus-symbol.gif";});});
	$$('.ttipPlusSymbol').each(function (elm){elm.observe('mouseover',function(event){elm.src="/images/whatIsXM/plans-pricing/minus-symbol.gif";});});
}


function applyFilters(viewAll) {
	if (viewAll && document.getElementById("filter-view-all").checked) {
		document.getElementById("filter-select-sirius").checked = false;
		document.getElementById("filter-includes-xmro").checked = false;
		document.getElementById("filter-family-friendly").checked = false;
	} else if (!viewAll) {
		document.getElementById("filter-view-all").checked = false;
	}
	document.getElementById("filterform").submit();
}

function tierHieghtFixFor3rdColumn(){
	//fixing tier height to vertical center 3 column.
	var loopt = 0;
	$$('.pricingTier').each(function(elm){
		loopt++;
		
		elm = $(elm);
		//alert("loop= " + loopt + "\nelm.id= " + elm.id);
		//get height of whole tier
		var h = elm.getHeight();
		
		//get the span for the of the bullets (3rd colum)
		var fixHeight = elm.descendants().grep(new Selector(".fixHeight"))[0]
		if(typeof fixHeight != "undefined"){
			//alert("fixHeight= " + fixHeight + "\nid= " + fixHeight.id);
			//fixHeight = $(fixHeight);	
			
			//get height of 3rd column
			var colHeight = fixHeight.getHeight();
			//alert(fixHeight.id + " colHeight= " + colHeight);
			//top and bottom images on 3rd column are 18px *2 = 36px;
			if(h > colHeight + 36){
			
				var diff = (h - colHeight - 36);
				var medDif = Math.ceil(diff/2)-2;
				
				var newmargin = medDif+'px 0 '+ medDif+'px 0'			
				fixHeight.setStyle({
			 	 	margin: newmargin
				});	
			}
		}
	})
}

function getElementsByClassName(strClassName, strTagName){
	var arrElements = (strTagName == "*" && document.all)? document.all : document.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];
		if(oRegExp.test(oElement.className)){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}

function hideOrShowElements(className, tag, hideOrShow) {
	var elements = getElementsByClassName(className, tag);
	for (var i=0; i<elements.length; i++) {
		elements[i].style.display = hideOrShow;
	}
}

//popup function for compare window.
var xmRadioPlayerWindow = "";
function poptastic(url) {
	if (!xmRadioPlayerWindow.closed && xmRadioPlayerWindow.location) {
		xmRadioPlayerWindow.location.href = url;
	}
	else {
		var winHeight = screen.height - 300;
		//if(winHeight > 1000)winHeight = 1000;
		
		xmRadioPlayerWindow = window.open(url,'windowName', 'toolbar=0, location=0, directories=0, scrollbars=1, menuBar=0, resizable=1, width=808, height='+winHeight+', left=50, top=50');
		
		if (!xmRadioPlayerWindow.opener) xmRadioPlayerWindow.opener = self;
	}
	if (window.focus) {xmRadioPlayerWindow.focus()}
	return false;
}

	<!-- tierFilters.vm included -->


  
  
   
function tierFiltersClass() {

     	 								var _allFilters = new Array('filter-Option_One','filter-Option_Two','filter-Option_Three');
	
	//alert("added "+_allFilters.length+" filters");
	
	//this model keeps track of current checkboxes checked.
		var _activeFilters = new Array();
		for (i = 0; i < _allFilters.length; i++) {
			_activeFilters[i] = false;
		}
	
	//an array which holds tier key & filters for each tier
	var _allTiers = new Array();
	
	
	this.switchFilter = function(num){
		//alert("in switchFilter("+num+")");
		if(_activeFilters[num]){
			_activeFilters[num] = false;
		}else{
			_activeFilters[num] = true;		
		}
	//	this.alertCurrentState();
		this.updateView();
	}
	
	this.pushTier = function (tierFilters){
		//tierFilters is an object
		_allTiers.push(tierFilters);
	}
	
	this.alertCurrentState = function(){
		var message= "";
		message += " \n _allfilters = " +  _allFilters.inspect();
		message += " \n _activeFilters = " +  _activeFilters.inspect();
		message += " \n _allTiers = " +  _allTiers.inspect();
		alert(message);
	}
	
	this.updateView = function (){
	//	alert("in updateView()");
		//is one filter is true?
		var allFiltersOff = true;
		for(i =0; i <_activeFilters.length ; i++){
			if(_activeFilters[i]) allFiltersOff = false;
		}
		
		//if no	
		if(allFiltersOff){
		//	alert("all filters off, showing all results");
			this.showAll();
			this.checkNone();
		}else{
			//make sure second row of filters is showing if necessary
			if( (_activeFilters[3]) || (_activeFilters[4]) || (_activeFilters[5]) ){
				//	alert("showing second row");
					$$('#show-2nd-row a').each(function(elm){
						var optionRow = $('options-row-2');
						elm.innerHTML = "Hide More Options";
						optionRow.show();
					});
			}			
			this.filterThroughAndHide();		
		}
		
		this.updateUrl();
	}
	
	this.showAll = function(){
		//alert("in showAll");
		var _activeFilters = new Array();
		for (i = 0; i < _allFilters.length; i++) {
			_activeFilters[i] = false;
		}
		for(i =0; i <_activeFilters.length ; i++){
		//	alert("activeFilters["+i+"]: "+_activeFilters[i]+", _allFilters["+i+"]: "+_allFilters[i]);
			document.getElementById(_allFilters[i]).checked = false;
		}
		for(j =0; j <_allTiers.length ; j++){
			$(_allTiers[j].id).show();
			_allTiers[j].vis = true;
		}
	}
	
	this.filterThroughAndHide= function(){
	//	alert("in filterThroughAndHide");
		var currentFilters = new Array();
		//go through each _checkboxModel and only take filters which are active;
		for(i =0; i <_activeFilters.length ; i++){
			//alert("activeFilters["+i+"]: "+_activeFilters[i]+", _allFilters["+i+"]: "+_allFilters[i]);
			if(_activeFilters[i]){
				currentFilters.push(_allFilters[i]);
				document.getElementById(_allFilters[i]).checked = true;		 		
			}else{
				document.getElementById(_allFilters[i]).checked = false;
			}
		}
		//alert("current filters: " +currentFilters);
		
		// for each tier object
		for(i =0; i <_allTiers.length ; i++){
			var thisTierFilters = _allTiers[i].filters;
			var thisLoopCF = currentFilters;
			for(z=0 ; z <thisTierFilters.length ; z++){
				//see - http://prototypejs.org/api/array/without
				thisLoopCF = thisLoopCF.without(thisTierFilters[z]);
			}
			
			if( thisLoopCF.length == 0){
				// current tier has necessary filters
				$(_allTiers[i].id).show();
				_allTiers[i].vis = true;
			}else{
				$(_allTiers[i].id).hide();
				_allTiers[i].vis = false;
			}
		}
		
		this.checkNone();
	}
	
	
	this.checkNone = function(){
		var visSatTiers = 0;
		var visOnlineTiers = 0;
		for(var idx=0;idx<_allTiers.length;idx++){
			if(_allTiers[idx].vis && !(_allTiers[idx].online)) visSatTiers++;
			if(_allTiers[idx].vis && _allTiers[idx].online) visOnlineTiers++;
		}
		document.getElementById('noSatTiersDiv').style.display = (visSatTiers == 0) ? "block" : "none";
		document.getElementById('noOnlineTiersDiv').style.display = (visOnlineTiers == 0) ? "block" : "none";
	}

	this.updateUrl = function(){
		var winUrl =  location.href
		var baseUrl = winUrl.split('#')[0];
		baseUrl += '#'
		for(i =0; i <_activeFilters.length ; i++){
			if(_activeFilters[i]){ baseUrl += _allFilters[i]+'=true&'}		 		
		}
		//baseUrl = baseUrl.slice(0, -1)
		location.href=baseUrl;
	}
	
	this.readUrl = function(){	
		var winUrl =  location.href;
		var splitedWinUrl =  winUrl.split('#');
		if(splitedWinUrl.length > 1){
			var urlVars =  splitedWinUrl[1].split('&');
			for(i = 0; i < urlVars.length; i++){
				var filterPair = urlVars[i].split('=');
				if((filterPair[1] == 'true') || filterPair[1] == 'true&' ){
					var indexOfFilter = _allFilters.indexOf(filterPair[0])
					_activeFilters[indexOfFilter] = true;
				}
			}
		}
		this.updateView();
	}
}
var tierFilterObject = new tierFiltersClass();
//tierFilterObject.alertCurrentState();