/*
 * copyright 2011, QP Image Builders, LLC
 */
$(function() {

	var raiz = $("meta[name=raiz]").attr("content");

	if ($(".show-n-tell").length > 0) {
		var show_n_tell_root = $(".show-n-tell").scrollable( {
			circular : true,
			speed : 2000
		});
		$(".show-n-tell").each(function(i) {
			$(this).autoscroll(8000 + (2000 * Math.random()));
			$(this).scrollable().onSeek(function() {
				if (this.getIndex() == this.getItems().length - 4) {
					this.seekTo(0, 0);
					return;
				}
				//this.getItems().eq(this.getIndex() + 4*Math.random()).mouseover();
					//this.play();
				});
			$(this).scrollable().onBeforeSeek(function() {
				//this.getItems().eq(this.getIndex()).next().mouseout();
					//this.play();
				});
		});
		$(".prtfl-div").hover(function(event) {
			event.preventDefault();
			$(this).children().first().hide();
		}, function(event) {
			event.preventDefault();
			$(this).children().first().show();
		});
	}

	$("#wrapper div[rel]").overlay( {
		mask : '#fff',
		effect : 'apple',
		onBeforeLoad : function() {
			$(".show-n-tell").each(function() {
				$(this).scrollable().stop();
			});
		},
		onLoad : function() {
			$(".show-n-tell").each(function() {
				$(this).scrollable().stop();
			});
		},
		onClose : function() {
			$(".show-n-tell").each(function() {
				$(this).scrollable().play();
			});
		}
	});

	$("#wrapper li[rel]").overlay( {
		mask : '#fff',
		effect : 'apple',
		onBeforeLoad : function() {
			$(".show-n-tell").each(function() {
				$(this).scrollable().stop();
			});
			dv = this.getOverlay().attr("id").split("-overlay", 1);
			window.console.info(dv[0]);
			trg = "#" + this.getOverlay().attr("id") + "-text";
			window.console.info(trg);
			$(trg).html($("#" + dv[0]).html());
		},
		onLoad : function() {
			$(".show-n-tell").each(function() {
				$(this).scrollable().stop();
			});
		},
		onClose : function() {
			$(".show-n-tell").each(function() {
				$(this).scrollable().play();
			});
		}
	});

	$(".correoa").attr(
			"href",
			function() {
				return "ma" + "i" + "lt" + "o:" + $(this).attr("id") + "@qpim" + "agebu"
						+ "ilders.com";
			});

	$("#details-button").click(function() {
		$("#services-carrusel-play").click();
	});
});
