function toggleRow(rowElement) {
	if (rowElement.className=='offer' || rowElement.className=='offer-on first') {
		rowElement.className = 'offer-on';
	} else {
		rowElement.className = 'offer';
	}
}

function zoom(imageUrl) {
	$('zoomDiv').innerHTML = '<img src="'+imageUrl+'" onclick="Element.hide(\'zoomDiv\')"/>';
	Element.show('zoomDiv');
}

zlioGetCurrencyString = function (currency) {
	switch(currency) {
		case "EUR":
			return "&#8364;";
		case "USD":
			return "&#36;";
	}
}

function strtrim() {
    return this.replace(/^\s+/,'').replace(/\s+$/,'');
}
String.prototype.trim = strtrim;


/** Author : David Levy **/
var ZPriceFormatter = Class.create();
ZPriceFormatter.prototype = {
  initialize: function(currency) {
    this.currency = currency;
  },

    format: function(num) {
      switch(this.currency) {
        case 'USD': // US dollar
        case 'CAD': // Canadian dollar
        case 'GBP': // Great Britain Pound
            return this.__formatEnglish(num);
        case 'EUR': // Euro
            return this.__formatNonEnglish(num);    
      }
    },
    
  __formatEnglish:function(num0) {
    var num = num.toString().replace(/\$|\,/g,'');
    if(isNaN(num))
      return num0;

    sign = (num == (num = Math.abs(num)));
    num = Math.floor(num*100+0.50000000001);
    cents = num%100;
    num = Math.floor(num/100).toString();
    if(cents<10)
    cents = "0" + cents;
    for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
    num = num.substring(0,num.length-(4*i+3))+','+
    num.substring(num.length-(4*i+3));
    return (((sign)?'':'-') + this.getCurrrencySymbol() + num + '.' + cents);
  },
  __formatNonEnglish:function(num0) {
    var num = num0.toString().replace(/\$|\,/g,'');
    if(isNaN(num))
      return num0;
      
    sign = (num == (num = Math.abs(num)));
    num = Math.floor(num*100+0.50000000001);
    cents = num%100;
    num = Math.floor(num/100).toString();
    if(cents<10)
    cents = "0" + cents;
    for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
    num = num.substring(0,num.length-(4*i+3))+' '+
    num.substring(num.length-(4*i+3));
    return (((sign)?'':'-') + num + ',' + cents + this.getCurrrencySymbol());
  },
  getCurrrencySymbol:function() {
  	switch(this.currency) {
  		case "EUR":
  			return " &#8364;";
  		case "USD":
  		case 'CAD':
  			return "&#36;";
  		case "GBP":
  			return "&#163;";
  		case "YEN":
  		  return "&#165;";
  	}  
  }
}
