var utils = {
	commaFormat: function(amount) {
		var delimiter = ","; // replace comma if desired
		//var a = amount.split('.',2)
	//	var d = a[1];
		var a = new Array();
		var d = new Array();
		a[0] = amount;
		var i = parseInt(a[0]);
		if(isNaN(i)) { return ''; }
		var minus = '';
		if(i < 0) { minus = '-'; }
		i = Math.abs(i);
		var n = new String(i);
		var a = [];
		while(n.length > 3) {
			var nn = n.substr(n.length-3);
			a.unshift(nn);
			n = n.substr(0,n.length-3);
		}
		if(n.length > 0) { a.unshift(n); }
		n = a.join(delimiter);
		if(d.length < 1) { amount = n; }
		else { amount = n + '.' + d; }
		amount = minus + amount;
		return amount;
	},
	stripChar: function(needle, heystack, pos) {
		var tmp = heystack.split(needle);
		return tmp[pos];
	},
	cleanString: function(cleaner, toClean) {
		
		var tmp = toClean.split(cleaner);
		tmp = tmp.join('');
		
		return tmp;
	},
	errorHandler: function(id, message) {
		$(id).innerHTML(message);
	},
	doubleSlider: function(slide, minKnob, maxKnob, s, e, sMin, sMax, minField, maxField) {
		var mySlideA = new Slider($(slide), $(minKnob), {
			start: s,
			end: e,
			knobheight: 17,
			onChange: function(pos){
				$(minField).value = '$' + utils.commaFormat(utils.sliderSteps(pos.minpos));
				$(maxField).value = '$' + utils.commaFormat(utils.sliderSteps(pos.maxpos));
				//$('maxPriceKnob').setHTML('min '+pos.minpos+' - max '+pos.maxpos);
			}
		}, $(maxKnob)).setMin(sMin).setMax(sMax);
	},
	sliderSteps: function(stepVal) {
		return (stepVal*32000);
	},
	getQuery: function(ji) {
		var hu = window.location.search.substring(1);
		var gy = hu.split("&");
		for (i=0;i<gy.length;i++) {
			var ft = gy[i].split("=");

			if (ft[0] == ji)  return ft[1];
		}
		return '';
	},
	isInteger: function(s) {
      var i;

      if (this.isEmpty(s))
      if (isInteger.arguments.length == 1) return 0;
      else return (isInteger.arguments[1] == true);

      for (i = 0; i < s.length; i++)
      {
         var c = s.charAt(i);

         if (!this.isDigit(c)) return false;
      }

      return true;		
	},
   isEmpty: function(s) {
      return ((s == null) || (s.length == 0))
   },

   isDigit: function (c) {
      return ((c >= "0") && (c <= "9"))
   },	
   activateToolTip: function(i) {
		var toolTips = new Tips($$(i), {
			offsets: {'x': -60, 'y': -55},
			initialize:function(){
				this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 500, wait: false}).set(0);
			},
			onShow: function(toolTip) {
				this.fx.start(1);
			},
			onHide: function(toolTip) {
				this.fx.start(0);
			}
		});
	}	
};
var show = {
	log: function(args) {
		if(!window.ie) {
			////console.log(args);
		} else {
			//alert(args);
		}
	}
};
