/**
 * @author arwin_galinato
 */

 $(function(){
 	var interval_time = 14000;
	var item_count;
	var item_interval;
	var old_item = 0;
	var current_item = 0;
	
	function item_rotate() {
	    current_item = (old_item + 1) % item_count;
	    $("div.slideshow-item:eq(" + old_item + ")").fadeOut("slow", function() {
	        $("div.slideshow-item:eq(" + current_item + ")").fadeIn("slow");
	    });
	    old_item = current_item;
	}
	
	$("a[rel]").overlay({ 
	    expose: 'darkred', 
	    effect: 'apple', 
	
	    onBeforeLoad: function() { 
	
	        // grab wrapper element inside content 
	        var wrap = this.getContent().find("div.wrap"); 
	
	        // load only for the first time it is opened 
	        
	            wrap.load(this.getTrigger().attr("href")); 
	       
	    } 
	
	});
	
	
	var triggers = $("button.modalInput").overlay({
 
    // some expose tweaks suitable for modal dialogs
    expose: {
        color: '#333',
        loadSpeed: 200,
        opacity: 0.9
    },
 
    closeOnClick: false
});
 
 
var buttons = $("#yesno button").click(function(e) {
    
    // get user input
    var yes = buttons.index(this) === 0;
 
    // do something with the answer
    //triggers.eq(0).html("You clicked " + (yes ? "yes" : "no"));
	//alert(yes ? "yes" : "no");
	
	if(buttons.index(this)===0){
		window.location.replace('http://miaisabellarealitytv.com/index.php/gallery');
	} else {
		window.location.replace('http://miaisabellarealitytv.com');
	}
});
	
	
	$("div.scrollable").scrollable({size:4});
	
	
	item_count = $("div.slideshow-item").size();

    $("div.slideshow-item").each(function(i) {
        $(this).hide();
    });

    $("div.slideshow-item:eq(" + current_item + ")").fadeIn("slow");

    item_interval = setInterval(item_rotate, interval_time); // time in milliseconds
    $('#slideshow-container').hover(function() {
        clearInterval(item_interval);
    }, function() {
        item_interval = setInterval(item_rotate, interval_time); //time in milliseconds
        item_rotate();
    });

});
