/*DOM*/
$(document).ready(function() {
	
//featurify
//Se pasó al header
//featurify end
	
//Popeye
$('#ppy1').popeye();
//Popeye end
	
//ScrollTo
function scroll(direction) {

    var scroll, i,
            positions = [],
            here = $(window).scrollTop(),
            collection = $('.listing_ad');

    collection.each(function() {
        positions.push(parseInt($(this).offset()['top'],10));
    });

    for(i = 0; i < positions.length; i++) {
        if (direction == 'next' && positions[i] > here) { scroll = collection.get(i); break; }
        if (direction == 'prev' && i > 0 && positions[i] >= here) { scroll = collection.get(i-1); break; }
    }

    if (scroll) {
        $.scrollTo(scroll, {
            duration: 750
        });
    }

    return false;
}

$("#next,#prev").click(function() {
    return scroll($(this).attr('id'));
});

$(".scrolltoanchor").click(function() {
    $.scrollTo($($(this).attr("href")), {
        duration: 750
    });
    return false;
});

//scrollto end

//exposé
$("#login_click").click(function() {
	$("#login_container").expose("#666");
});
//exposé end

//tooltip
//$(".listing_results_logo a").tooltip({ effect: 'slide'});
//$(".items img[title]").tooltip({effect: 'slide'});

$(".user_menu img[title]").tooltip({
	effect: 'slide',
	opacity: 0.9,
	offset: [0, 0]
});

$("#listing_social img[title]").tooltip({
	effect: 'slide',
	opacity: 0.9,
	offset: [0, 0],
	predelay: 500,
	delay: 1000
});

$(".corporativo_title").tooltip({
	effect: 'slide',
	opacity: 0.9,
	offset: [0, 0],
	predelay: 500,
	delay: 1000
});

$(".items img[title]").tooltip({
	effect: 'slide',
	opacity: 0.9,
	position: "bottom right"
});
$("#compare_container img[title]").tooltip({
	effect: 'slide',
	opacity: 0.9,
	position: "bottom center"
});
//tooltip end

//lightbox
	
//imágenes
$("a.image_group").fancybox( {
	"hideOnContentClick" : false
});

//videos

$("a#video").fancybox({
hideOnContentClick : false,
frameWidth: 490,
frameHeight: 395
});

//popups

$("a.pop_up").fancybox({
'hideOnContentClick': true
});

$("a.pop_up2").fancybox({
	'hideOnContentClick': true,
	frameWidth: 900,
	frameHeight: 450
});

$("a.pop_up3").fancybox({
	'hideOnContentClick': true,
	frameWidth: 640,
	frameHeight: 360
});

$("a.pop_up4").fancybox({
	'hideOnContentClick': true,
	frameWidth: 670,
	frameHeight: 510
});

//lightbox end

//page flip

$("#pageflip").hover(function() { // On hover...

		$("#pageflip img , .msg_block").stop()

		.animate( { // Animate and expand the image and the
					// msg_block (Width + height)

					width : '307px',

					height : '319px'

				}, 500);

	}, function() {

		$("#pageflip img").stop() // On hover out, go back to
									// original size 50x52

				.animate( {

					width : '50px',

					height : '52px'

				}, 220);

		$(".msg_block").stop() // On hover out, go back to original
								// size 50x50

				.animate( {

					width : '50px',

					height : '50px'

				}, 200); // Note this one retracts a bit faster
							// (to prevent glitching in IE)

});

//page-flip end
});
/*DOM end*/

