function getNewUrl(path, minus) {
	
	path = path.split('/');
  var page = parseInt(path[path.length-1]);
	path[path.length-1] = minus ? page - 1 : page + 1;
		
	return path.join('/');
}

var more_rules = ['contacts', 'albums', 'fans', 'videos', 'tickets'].fold( {}, function(result, value) {

  result['#'+value+'_more'] = function(el) {
		
		// Change ajax url.
		el.href = el.href.split("#")[1];
		
	  $(value+'_more').onclick = function () {
			var v = new Ajax.Updater(value, this.href, { evalScripts: true });
			$(value+'_less').href = getNewUrl(this.href,true);
			el.href = getNewUrl(this.href,false);
			return false;
	  };

		$(value+'_more').onmousedown = preventFocus;		
	};

  result['#'+value+'_less'] = function(el) {
		$(value+'_less').onclick = function () {
			var v = new Ajax.Updater(value, this.href, { evalScripts: true });
			$(value+'_more').href = getNewUrl(this.href,false);
			el.href = getNewUrl(this.href,true);
			return false;
	  };

	  $(value+'_less').onmousedown = preventFocus;
	};

	return result;
});

Behaviour.register(more_rules);

var wizard_rules = {

	'#wizard a.close' : function (el) {
	  el.onclick = function () {
		  if ($('wizard_check').checked) {
	  		var opt = {
		 		  method: 'get',
	 			  parameters: 'show=never',
			    evalScripts: false
		    };
		    new Ajax.Updater('ajaxDump', urlAjax.user+'home/wizard/', opt);
			}
  	  Cookie.create('wizard', 'hide');
		  banners._show();
		  dialog.close();
		  return false;
		};
	}
	
};

Behaviour.register(wizard_rules);

var home = {
	
	translate: {
	  fr_CA: {
		  email_confirm: "Une confirmation a été envoyée à votre courriel<br />Consultez vos courriels et cliquez sur le lien pour activer votre inscription"
		},
	 
	  en_CA: {
		  email_confirm: "A confirmation has been sent<br />Go look your emails and click on the link to complete"
		}
	},
	
	sendConfirmation : function () {
 	  var opt = {
			method: 'post',
			onComplete: this.sendSuccess
		};
	  new Ajax.Request(urlAjax.user + 'home/confirm/', opt);
	},
	
	sendSuccess : function (t) {
	 
 	 	flash.success(eval('home.translate.' + lang + '.email_confirm'));
	}
};

var home_rules = {
	'#validate_email' : function (el) {
 	  el.onclick = function() {
			home.sendConfirmation();
			return false;
		}
	}



};

Behaviour.register(home_rules);
