
/***
*
*	Funções alc propaganda
*	Desenvolvido por alc propaganda
*
****/

/***
*	:: Log para Debug ::
*	:: alc propaganda ::
*	:: 2007 ::
*
*	l(<Mensagem>,<true ou false para IE>);
*
*	Exibe um log para Debug.
*	ex:
*		l("testando");
*		l("testando",true);
***/
function l(x,consoleIE){
    consoleIE = typeof (consoleIE) == "undefined" ? false : consoleIE;
	if (window.loadFirebugConsole) window.loadFirebugConsole();
	if(window.console){
	    console.info(x);
	} else if (window._firebug) {
	    _firebug.info(x);
	}else if(consoleIE){
		if(!$("#dmDebug").is("div")){
			$("body").append("<div id=\"dmDebug\" style=\"width:"+($(window).width()-50+"px")+"; border:1px solid #000; position:absolute; bottom:0; left:0; height:150px; overflow:auto; filter:alpha(opacity=80); font-size:12px; padding:5px; font-family:Tahoma, Arial, Helvetica, sans-serif; background:#fff; z-index:99999;\"></div>");
		}
		$("#dmDebug").append("<p style=\"margin:0; border-bottom:1px dashed #000; color: #000; font-weight: bold;\">"+x+"</p>");
	}
}

////////////////////////
// Validação Genérica //
////////////////////////
////////////////////////
validar = {
	autor: "alc propaganda - 2008",
	versao: "2.25.7.2008",
	
	// Variáveis
	obj: null,
	nome: null,
	valor: null,
	valido: true,
	msg: null,
	campos: new Object(),
	timeout: null,
	
	// Inicialização
	init: function(){
		$(".validar").each(function(){
			
			var regras = $(this).attr("title");
			var obj = $(this);
			
			if(typeof(regras) != "undefined"){
				if(regras.indexOf("{") > 0){

					// Gera as regras
					var opcoes = new Object();
					regras = regras.substring(regras.indexOf("{"),regras.length).replace("{","").replace("}","").split(",");
					
					$.each(regras,function(i,val){
						var nome = val.split(":")[0];
						var valor = eval(val.split(":")[1].replace("(doispontos)",":"));
						opcoes[nome] = valor;
					});
					
					// Cria uma biblioteca com os campos e as regras
					validar.campos[$(this).attr("id")] = opcoes;

					// Eventos
					var validacaoBlur = function(){
						validar.obj = $(this);
						validar.valor = $(this).val();
						validar.valido = true;
						validar.verifica();
					}
					$(this).not(".calendario").unbind('blur',validacaoBlur).blur(validacaoBlur);
					
					// Máscaras
					if($(this).attr("title").indexOf("mascara") != -1){
						switch(opcoes.mascara){
							case "R$": $(this).maskMoney({symbol:"R$",decimal:",",thousands:"."}); break;
							default: $(this).mask(opcoes.mascara); break;
						}
					}
				}
			}
			
			var titulo = $(this).attr("title");
			$(this).attr("title",titulo.split("{")[0]);

		});
		
		if($(".validar").length > 0){
			$("form").unbind('submit',validar.form).submit(validar.form);
		}
	},
	
	form: function(form){
		var valido = true;
		obj = typeof(form) == "string" ? $(form) : this;
				
		$(".validar",obj).each(function(){
			if(valido){
				validar.obj = $(this);
				validar.valor = $(this).val();
				validar.valido = true;
				validar.verifica();
				valido = validar.valido;
				if(!validar.valido) $(validar.obj).focus();
			}
		});
		
		return valido;
	},
	
	// Função que faz as verificações
	verifica: function(){

		var id = $(validar.obj).attr("id");

		$.each(validar.campos[id],function(funcao,val){
			if(validar.valido && funcao != "mascara") validar[funcao](val);
		});

		if(!validar.valido){
			$(validar.obj).removeClass("form_ok").addClass("form_erro");
			validar.nome = $(validar.obj).attr("title");
			validar.exibeMsg();
		}else{
			$(validar.obj).removeClass("form_erro").addClass("form_ok");
		}

	},
	
	// Exibir mensagem
	exibeMsg: function(){

		var msg = "O campo <strong>\""+validar.nome+"\"</strong> "+validar.msg // Mensagem

		// Gera Box da mensagem
		var posicaoBox = function(){
			$(".boxMsg").css($(validar.obj).offset());// alterar *********************************************************
			$(".boxMsg").css({
				opacity: "0.9",
				top: parseInt($(".boxMsg").css("top")) - parseInt($(".boxMsg").height()) - 22,
				left: parseInt($(".boxMsg").css("left")) - 1
			});
			/*setTimeout(function(){
				if($(".boxMsg").is("div")) posicaoBox();
			},100);*/
		}
		$(".boxMsg").remove();
		$("body").prepend("<div class=\"boxMsg hide\">"+msg+"</div>");
		$(".boxMsg").css($(validar.obj).offset());// alterar *********************************************************
			$(".boxMsg")
				.stop()
				.css({
					opacity: "0.9",
					top: parseInt($(".boxMsg").css("top")) - parseInt($(".boxMsg").height()) - 22,
					left: parseInt($(".boxMsg").css("left")) - 1
				})
				.fadeIn("fast", function(){
					clearTimeout(validar.timeout);
					validar.timeout = setTimeout(function(){ validar.escondeMsg(); },5000);
					posicaoBox();
				})
				.click(validar.escondeMsg);
	},
	
	escondeMsg: function(){
		clearTimeout(validar.timeout);
		if($(".boxMsg").length > 0) $(".boxMsg").fadeOut("fast",function(){ $(".boxMsg").remove(); });
	},
	
	verificaCampos: function(objs){
		validar.valido = true;
		$(objs).filter(".validar").not("[disabled]").each(function(){
			if(validar.valido){
				validar.obj = $(this);
				validar.valor = $(this).val();
				validar.valido = true;
				validar.verifica();
				if(!validar.valido) $(validar.obj).focus();
			}
		});
		return validar.valido;
	},
	
	// Quantidade mínima de caracteres
	min: function(regra){
		if(validar.valor.length < regra){
			validar.valido = false;
			validar.msg = "deve ser preenchido com no mínimo <strong>"+regra+"</strong> caracteres.";
		}
	},
	
	// Quantidade máxima de caracteres
	max: function(regra){
		if(validar.valor.length > regra){
			validar.valido = false;
			validar.msg = "deve ser preenchido com no máximo <strong>"+regra+"</strong> caracteres.";
		}
	},
	
	// Igual a campo ou string
	igualA: function(regra){
		var valor = regra.indexOf("#") == -1 ? regra : $(regra).val();
		if(validar.valor != valor){
			validar.valido = false;
			validar.msg = "não foi preenchido corretamente.";
		}
	},
	
	// Diferente de campo ou string
	diferenteDe: function(regra){
		var valor = regra.indexOf("#") == -1 ? regra : $(regra).val();
		if(validar.valor == valor){
			validar.valido = false;
			validar.msg = "não foi preenchido corretamente.";
		}
	},
	
	// Definições de tipos
	tipo: function(regra){
		switch(regra){
			
			// Numérico inteiro
			case "inteiro": case "int":
				var expressao = /^\d+$/;
				if(!expressao.test(validar.valor)){
					validar.valido = false;
					validar.msg = "deve ser preenchido com um <strong>número inteiro</strong>!";
				}
			break;
			
			// E-mail
			case "email": case "e-mail":
				var expressao = /^[a-zA-Z0-9]{1}([\._a-zA-Z0-9-]+)(\.[_a-zA-Z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+){1,3}$/;
				if(!expressao.test(validar.valor)){
					validar.valido = false;
					validar.msg = "não é um <strong>e-mail válido</strong>!";
				}
			break;
			
			// Data tipo dd/mm/aaaa
			case "data":
				var expressao = /^((0?[1-9]|[12]\d)\/(0?[1-9]|1[0-2])|30\/(0?[13-9]|1[0-2])|31\/(0?[13578]|1[02]))\/(19|20)\d{2}$/;
				if(!expressao.test(validar.valor)){
					validar.valido = false;
					validar.msg = "não é uma data válida, utilize o formato <strong>dd/mm/aaaa</strong>!";
				}
			break;
			
			// CPF                                                                                                                                                    
			case "cpf": case "CPF":
				var cpf = validar.valor.replace(/[^0-9]/g, "");
				if (cpf.length >= 11) {
					if (cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999") {
						validar.valido = false;
					} else {
						var a = [];
						var b = new Number;
						var c = 11;
						for (i = 0; i < 11; i++) {
							a[i] = cpf.charAt(i);
							if (i < 9) b += (a[i] * --c);
						}
						if ((x = b % 11) < 2) { a[9] = 0; } else { a[9] = 11 - x; }
						b = 0;
						c = 11;
						for (y = 0; y < 10; y++) b += (a[y] * c--);
						if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11 - x; }
						validar.valido = ((cpf.charAt(9) == a[9]) && (cpf.charAt(10) == a[10]));
					}
				} else {
					validar.valido = false;
				}
				validar.msg = "é um número de CPF invalido!";
				break;

			// CNPJ                                                                                                                                                    
			case "cnpj": case "CNPJ":
				var cnpj = validar.valor.replace(/[^0-9]/g, "");
				if (cnpj.length >= 14) {
					var a = [];
					var b = new Number;
					var c = [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];
					for (i = 0; i < 12; i++) {
						a[i] = cnpj.charAt(i);
						b += a[i] * c[i + 1];
					}
					if ((x = b % 11) < 2) { a[12] = 0 } else { a[12] = 11 - x }
					b = 0;
					for (y = 0; y < 13; y++) {
						b += (a[y] * c[y]);
					}
					if ((x = b % 11) < 2) { a[13] = 0; } else { a[13] = 11 - x; }
					validar.valido = ((cnpj.charAt(12) == a[12]) && (cnpj.charAt(13) == a[13]));
				} else {
					validar.valido = false;
				}
				validar.msg = "é um número de CNPJ inválido!";
				break;
			
			// Obrigatorio
			case "obrigatório":
				if(validar.valor.length == 0){
					validar.valido = false;
					validar.msg = "é obrigatório o preenchimento!";
				}
			break;
		}
	}
}
/***
*	:: Exibe div de bloqueio ::
*	:: alc propaganda - alc propaganda ::
*	:: 2007 ::
*
*	Função que abre uma div cobrindo toda a tela bloqueando o site, com função de callback.
*	ex:
*		bloqueia({ speed: "slow", bgcolor: "#000" });
*		bloqueia({ speed: "slow", evento: "fim" });
*
*	OBS: Nescessário plugin Dimension.
***/
function bloqueia(options,callback){
	var defaults = {
		autor: "alc propaganda",
		versao: 2.1,
		id: "bloqueio",
		evento: "inicio",
		bgColor: "#000",
		opacity: "0.5",
		speed: "normal",
		zIndex: "100",
		cursor: "default",
		animate: true
	}
	options = $.fn.extend({}, defaults, options);

	if ((options.id == "" || options.id == "bloqueio") && !$("#bloqueio").is("div")) $("body").append("<div id=\"bloqueio\" style=\"display:none\"></div>");

	var altura = $(document).height() > $(window).height() ? $(document).height() : $(window).height();

	if (options.evento == "inicio") {
		if ($.browser.msie && $.browser.version == "6.0") $("select:visible").addClass("hiddenForDmBlock").css("visibility", "hidden");
		$("#" + options.id).css({
			background: options.bgColor,
			cursor: options.cursor,
			height: altura,
			left: "0",
			opacity: options.opacity,
			position: "absolute",
			top: "0",
			width: "100%",
			zIndex: options.zIndex
		});
		if (options.animate) {
			$("#" + options.id).fadeIn(options.speed, function() { if (typeof (callback) != "undefined") { callback(); } });
		} else {
			$("#" + options.id).css("display", "block");
			if (typeof (callback) != "undefined") { callback(); }
		}
		carregandoResize = function() {
			altura = $(document).height() > $(window).height() ? $(document).height() : $(window).height();
			$("#" + options.id).css({ height: altura });
		}
		$(window).bind('resize', carregandoResize);
	} else {
		$("select.hiddenForDmBlock").css("visibility", "visible");
		$(window).unbind('resize', carregandoResize);
		if (options.animate) {
			$("#" + options.id).fadeOut(options.speed, function() { if (typeof (callback) == "function") { callback(); } });
		} else {
			$("#" + options.id).css("display", "none");
			if (typeof (callback) == "function") { callback(); }
		}
	}
}

/***
*	:: Função de Ajax ::
*	:: alc propaganda ::
*	:: 2008 ::
*
*	Função que executa um ajax.
*	Opções:
*		arquivo:<string>
*			Qual arquivo será chamado com ou sem extenção, a extenção padrão é .php.
*		acao:<string>
*			Envia uma variável GET com nome padrão de "acao".
*		querystring:<string>
*			Envia dados obrigatoriamente via querystring, ex.: "id=1&produto=teste"
*		dados:<string ou objeto>
*			Envia dados via get ou post, dependendo do método de envio, ex.: "id=1&produto=teste" ou {id:1,produto:"teste"}.
*		carregando:<inteiro>
*			Tipo de carregando, padrão: 1.
*		aoIniciar:<função>
*			Executa função ao iniciar a requisição ajax.
*		aoConcluir:<função>
*			Executa função ao concluir a requisição ajax.
*		formulario:<seletor css>
*			Recupera os dados dos campos de um formulário e envia.
*		retornarEm:<seletor css>
*			Retorna dados para um determinado objeto.
*		metodo:<string>
*			Método de envio dos dados, get ou post, padrão: "GET".
*		caminho:<string>
*			Caminho que será chamado o arquivo, padrão: "inc/ajax/".
*
*	ex:
*		ajax({
*			arquivo: "produtos.php",
*			acao: "listarProdutos",
*			aoConcluir: function(retorno){
*				if(retorno != "erro"){
*					$("#tabela").html(retorno);
*				}
*			}
*		});
***/

function ajax(opcoes){
	
	// Valores padrão das opções e variáveis
	opcoes = $.extend({}, {
		arquivo: "",
		acao: "",
		querystring: "",
		dados: "",
		carregando: 1,
		aoIniciar: "",
		aoConcluir: "",
		aoFalhar: "",
		formulario: "",
		retornarEm: "",
		metodo: "get",
		tipoDados: "html",
		erro: false,
		caminho: "inc/ajax/",
		mostraErros: function(){ if(opcoes.erro != false) alert("Um erro ocorreu!\n\nPor favor, contate o administrador deste sistema e informe o seguinte erro:\n\n\"" + opcoes.erro + "\""); }
	}, opcoes);
	var er,dados;
	
	// Verificação de erros
	if(opcoes.arquivo == "") opcoes.erro = "Não foi informado o arquivo para ser carregado.";
	
	if(!opcoes.erro){
		// Caminho do arquivo
		er = /(\.php|\.asp|\.aspx|\.htm|\.html|\.js|\.jsp)/;
		opcoes.arquivo = !er.test(opcoes.arquivo) ? opcoes.arquivo += ".php" : opcoes.arquivo;
		
		// Ação
		opcoes.arquivo = opcoes.acao != "" ? opcoes.arquivo + "?acao=" + opcoes.acao : opcoes.arquivo;
		
		// Get
		opcoes.arquivo = opcoes.querystring != "" ? opcoes.arquivo.indexOf("?") != -1 ? opcoes.arquivo + "&" + opcoes.querystring : opcoes.arquivo + "?" + opcoes.querystring : opcoes.arquivo;
		
		// Dados
		dados = opcoes.formulario != "" ? $(opcoes.formulario).is("form") ? $(opcoes.formulario).serialize() : "" : "";
		dados = opcoes.dados != "" ? $.merge(opcoes.dados,dados) : dados;

		// Método get ou post
		opcoes.metodo = opcoes.formulario != "" ? $(opcoes.formulario).is("form") ? typeof($(opcoes.formulario).attr("method")) != "undefined" ? $(opcoes.formulario).attr("method") : opcoes.metodo : opcoes.metodo : opcoes.metodo;

		// Carregando
		var ajaxCarregando = function(acao){
			
			if(acao == "inicio"){
				// Carregando - Início
				switch(opcoes.carregando){
					case 1:
						bloqueia({
							bgColor:"url(imagens/carregando.gif) no-repeat center",
							cursor:"wait",
							animate:false
						});
					case 2:
					break;
				}
			}else{
				// Carregando - Fim
				switch(opcoes.carregando){
					case 1:
						bloqueia({
							evento:"fim",
							animate:false
						});
					case 2:
					break;
				}
			}
		}
		ajaxCarregando("inicio");
		
		// Executa o ajax
		var debugErros = true;
		$.ajax({
			url: opcoes.caminho + opcoes.arquivo,
			type: opcoes.metodo,
			data: dados,
			dataType: opcoes.tipoDados,
			beforeSend: function(){ if(typeof(opcoes.aoIniciar) == "function") opcoes.aoIniciar(); },
			success: function(retorno){
				if(typeof(retorno) != "undefined") if($.trim(String(retorno)) == "nao_logado") window.location = "default.php";
				if(opcoes.retornarEm != "") $(opcoes.retornarEm).html(retorno); // Retornar em
				ajaxCarregando("fim"); // Carregando
				if(typeof(opcoes.aoConcluir) == "function") opcoes.aoConcluir(retorno); // Ao concluir
			},
			error: function(XMLHttpRequest){
				if(opcoes.aoFalhar != "") opcoes.aoFalhar(XMLHttpRequest); // Ao falhar
				if(debugErros){
					try{
						var regExp	= new RegExp('(<body)(.|\n|\f|\r|\t|\v|\s| )*', 'gim');
						var texto	= XMLHttpRequest.responseText;
						texto		= texto.match(regExp)[0];
						regExp		= new RegExp('(.|\n|\f|\r|\t|\v|\s| )*(\/body>)', 'gim');
						texto		= texto.match(regExp)[0];
						texto		= texto.replace(/<(\/)?body(.)*>/g,"").replace(/(<(\/)?script[^>]*>)/g,"<!--$1-->");
						var div		= $('<div title="Clique para fechar">');
						bloqueia();
						$(div)
							.css({
								border:"1px solid #000",
								position:"absolute",
								top:"100px",
								left:"50%",
								height:"500px",
								width:"770px",
								margin:"0 0 0 -392px",
								padding:"10px",
								background:"#fff url(imagens/erro-ajax-bg.jpg) no-repeat center",
								cursor:"pointer",
								zIndex:"999999",
								display:"none"
							})
							.html(texto)
							.prepend('<a href="javascript:void(0);" title="Fechar" style="float:right;">X Fechar</a>')
							.click(function(){
								$(this).fadeOut('fast');
								bloqueia({evento:"fim"});
							});
						$("body").append(div);
						$("*",div).css("position","static");
						$(div).fadeIn('fast');
					}catch(e){
						opcoes.erro = "Erro ao acessar o arquivo remoto.";
						opcoes.mostraErros();
						ajaxCarregando("fim"); // Carregando
					}
				}else{
					opcoes.erro = "Erro ao acessar o arquivo remoto.";
					opcoes.mostraErros();
					ajaxCarregando("fim"); // Carregando
				}
			}
		});
	}

	// Exibe mensagem de erro caso ocorra
	opcoes.mostraErros();
}
	
	
function atualizaQtd(qtd, acao) {
		ajax({ 
			 arquivo: 'carrinho.php', 
			 querystring: 'qtd='+qtd+'&acao='+acao,
			 aoConcluir: function(retorno){ 
				if(retorno != 'erro'){ 
					$('#retornoJS').html(retorno); 
				}else{
				 alert("Ocorreu um erro!");	
				}
			}
		});
}

function menu_produto(qtd, acao) {
		ajax({ 
			 arquivo: 'carrinho.php', 
			 querystring: 'qtd='+qtd+'&acao='+acao,
			 aoConcluir: function(retorno){ 
				if(retorno != 'erro'){ 
					$('#retornoJS').html(retorno); 
				}else{
				 alert("Ocorreu um erro!");	
				}
			}
		});
}


/***
	*	:: Tira bordas do Flash no IE ::
	*	:: 2008 ::
	*
	*	Retira as bordas pontilhadas do flash no Internet Explorer
	*	Ex.: 	$("#flash").addFlash({
	*				src: "swf/banner2.swf",
	*				width: 584,
	*				height: 201,
	*				title: "alc propaganda"
	*			});
	***/
	$.extend({
		addFlash: {
			version: 1.2,
			defaults: {
				src: "",
				width: 100,
				height: 50,
				title: "",
				quality: "high",
				menu: "false",
				wmode: "transparent"
			}
		}
	});
	$.fn.extend({
		addFlash: function(options){
			options = $.extend({}, $.addFlash.defaults, options);
			return this.each(function(){
				if(options.src != ""){
					var flash = '<object type="application/x-shockwave-flash" data="'+options.src+'?clicktag=./" width="'+options.width+'" height="'+options.height+'" tabindex="0" title="'+options.title+'">'
					flash += '<param name="movie" value="'+options.src+'?clicktag=./" />'
					flash += '<param name="quality" value="'+options.quality+'" />'
					flash += '<param name="menu" value="'+options.allowFullScreen+'" />'
					flash += '<param name="wmode" value="'+options.wmode+'" />'
					flash += '<p>Para visualizar este conteúdo corretamente, é necessário ter o <a title="Clique para instalar o flash player" href="http://www.macromedia.com/shockwave/download/alternates/" rel="nofollow">Flash Player</a> instalado.</p>'
					flash += '</object>'
					$(this).html(flash);
				}
			});
		}
	});


	
//////////////////
// ScrollPages //
////////////////
$.extend({
	scrollPages: {
		defaults: {
			elementSize: 50,
			elements: 3,
			speed: "slow",
			direction: "up"
		}
	}
});
$.fn.extend({
	scrollPages: function(options){
		options = $.extend({}, $.scrollPages.defaults, options);
		return this.each(function(){
			
			// Definições de variáveis
			var total = $(".scrollMask li",this).length;
			var mask = options.elementSize * options.elements;
			var area = options.elementSize * total;
			var animation = false;
			var obj = this;
			var dimension = options.direction == "left" ? "width" : "height";
			var side = new Array();
			side[0] = options.direction;
			side[1] = options.direction == "up" ? "down" : "right";
			
			$(".scrollButtom",this).css("visibility","visible");
			if(options.elements >= total){
				$(".scrollButtom",this).css("visibility","visible");
				mask = area;
			}else{
				$(".scrollButtom[rel*='"+options.direction+"']",obj).css("visibility","hidden");
			}
			
			// Aplicação de estilos
			$(".scrollMask",this).css({"width": mask + "px", overflow: "hidden"}); // Máscara
			$(".scrollMask ul",this).css({"width": area + "px", marginTop: 0}); // UL
			$(".scrollMask li",this).css({"width": options.elementSize + "px", display: "block"}); // LI

			// Função que executa a rolagem
			var rolagem = function(direction){

				// Variáveis
				var margem = -parseInt($(".scrollMask ul",obj).css("margin-"+(options.direction == "up" ? "top" : "left")));

				var intervalo = direction == side[1]
					? ( margem + ( mask * 2 ) ) < area
						? mask
						: area - (margem + mask)
					: ( margem - mask ) < 0
						? margem
						: mask
				;
				direction = direction == side[1]
					? -margem - intervalo
					: -margem + intervalo
				;
				
				$(".scrollButtom",obj).css("visibility","visible");
				var rel = -direction == 0 ? side[0] : (-direction + mask) == area ? side[1] : null;
				if(rel != null) $(".scrollButtom[rel*='"+rel+"']",obj).css("visibility","hidden");
				
				// Animação
				animation = true;
				if(options.direction == "up"){
					$(".scrollMask ul",obj).animate({marginTop: direction + "px"},options.speed,function(){ animation = false; });
				}else{
					$(".scrollMask ul",obj).animate({marginLeft: direction + "px"},options.speed,function(){ animation = false; });
				}
			}
			
			// Aplicação de eventos
			$(".scrollButtom",this).unbind("click").click(function(){
				if(!animation){
					var direction = $(this).attr("rel");
					rolagem(direction);
				}
			});
		});
	}
});

///////////////////////////////////////////////////////////
// Ações												//
/////////////////////////////////////////////////////////
jQuery(function($) {
	validar.init();
});




///////////////////////////////////////////////////////////
// Carrosseu											//
/////////////////////////////////////////////////////////
function mycarousel_initCallback(carousel)
{	

	 // Disable autoscrolling if the user clicks the prev or next button.
	carousel.buttonNext.bind('click', function() {
		carousel.startAuto();
	});
	carousel.buttonPrev.bind('click', function() {
		carousel.startAuto();
	});


	// Pause autoscrolling if the user moves with the cursor over the clip.
	carousel.clip.hover(function() {
		carousel.stopAuto();
	}, function() {
		carousel.startAuto();
	});
};
