
function setPuntos(puntos){
$(".barra-cuenta .puntos").html(puntos + ' Puntos');
}
function TiendaDeseos(descri) {
	s=s_gi('s_account');
	s.linkTrackVars='prop16';
	s.prop16=descri;
	s.tl(this, 'o', 'Deseos:Producto agregado');
}
function addslashes(str) {
	str=str.replace(/\'/g,'\\\'');
	str=str.replace(/\"/g,'\\"');
	str=str.replace(/\\/g,'\\\\');
	str=str.replace(/\0/g,'\\0');
	return str;
}
function stripslashes(str) {
	str=str.replace(/\\'/g,'\'');
	str=str.replace(/\\"/g,'"');
	str=str.replace(/\\\\/g,'\\');
	str=str.replace(/\\0/g,'\0');
	return str;
}
function removeQuotes(x){
	if(x != null){
		x = x.replace(/['"]/g,'');
		return x;
	} else {
		return null;
	}
};

function getURLVar(urlVarName) {
	//divide the URL in half at the '?'
	var urlHalves = String(document.location).split('?');
	var urlVarValue = '';
	if(urlHalves[1]){
		//load all the name/value pairs into an array
		var urlVars = urlHalves[1].split('&');
		//loop over the list, and find the specified url variable
		for(i=0; i<=(urlVars.length); i++){
			if(urlVars[i]){
				//load the name/value pair into an array
				var urlVarPair = urlVars[i].split('=');
				if (urlVarPair[0] && urlVarPair[0] == urlVarName) {
					//I found a variable that matches, load it's value into the return variable
					urlVarValue = urlVarPair[1];
				}
			}
		}
	}
	return urlVarValue;   
}

function TiendaCompra(descri) {
	s=s_gi('s_account');
	s.linkTrackVars='prop16';
	s.events='scAdd';
	s.products='Complementos, Complementos+Bolson';
	s.prop16=descri;
	s.tl(this, 'o', 'Deseos:Producto agregado');
}
function toggle(selector, effect) {
	if ($(selector).css("display") == "none") {
		if(effect == "fade"){
			$(selector).fadeIn(300);
		} else {
			$(selector).slideDown(300);
		}
	} else {
		if(effect == "fade"){
			$(selector).fadeOut(300);
		} else {
			$(selector).slideUp(300);
		}
	}
	return false;
}
$(document).ready( function() {
	PEPS.rollover.init();
	MFG.rollover.init();
	
	$(".dummy").focus(function(){
		id = $(this).attr('id');
		id = id.replace("Dummy", "");
		$(this).hide();
		$("#"+id).show();
		$("#"+id).focus();
	});
	$(".real").blur(function(){
		if($(this).val() == ""){
			id = $(this).attr('id');
			
			$(this).hide();
			$("#"+id+"Dummy").show();
		}
	});
	$(".real").each(function(){
		if($(this).val() != ""){
			id = $(this).attr("id");
			$("#"+id+"Dummy").hide();
			$(this).show();
		}
	});
});

Array.prototype.remove = function(from, to) {
  var rest = this.slice((to || from) + 1 || this.length);
  this.length = from < 0 ? this.length + from : from;
  return this.push.apply(this, rest);
};

PEPS = {};
PEPS.rollover = {
	init : function() {
		this.preload();
		$(".ro").unbind();
		$(".ro").hover( function() {
			$(this).attr('src', PEPS.rollover.newimage($(this).attr('src')));
		}, function() {
			$(this).attr('src', PEPS.rollover.oldimage($(this).attr('src')));
		});
		
		$(".roclk").click( function() {
			$(".roclk").each(function (i) {
				$(this).attr('src', PEPS.rollover.oldimage($(this).attr('src')));
			});
			$(this).attr('src', PEPS.rollover.newimage($(this).attr('src')));
		});
		
	},
	
	preload : function() {
		$(window).bind(
				'load',
				function() {
					$('.ro').each(
							function(key, elm) {
								$('<img>').attr(
										'src',
										PEPS.rollover.newimage($(this).attr('src')));
							});
				});
	}, 

	newimage : function(src) {
		return src.substring(0, src.search(/(\.[a-z]+)$/)) + '_roll'
				+ src.match(/(\.[a-z]+)$/)[0];
	},

	oldimage : function(src) {
		return src.replace(/_roll\./, '.');
	}
};

MFG = {};
MFG.rollover = {
	init : function() {
		$(".ron").unbind();
		$(".ron").hover( function() {
			posY = MFG.rollover.positionY($(this));
			$(this).css('background-position', '0px '+(parseInt(posY)-21)+'px');
		}, function() {
			posY = MFG.rollover.positionY($(this));
			$(this).css('background-position', '0px '+(parseInt(posY)+21)+'px');
		});
	},
	positionY: function(elem){
		pos = elem.css('background-position');
		
		if (pos == 'undefined' || pos == null) {
			pos = elem.css("background-position-y");
			return pos;
		} else {
			pos = pos.split(" ");
			posY = pos[1].replace(/px,*\)*/g,"");
			return posY;
		}
	}
};

function formatCurrency(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
		num = "0";
	
	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 + ' €');
}