// JavaScript Document

$(function() {
    $.superbox();
});

$.superbox.settings = {
    boxId: "superbox",
    // Id attribute of the "superbox" element
    boxClasses: "",
    // Class of the "superbox" element
    overlayOpacity: .8,
    // Background opaqueness
    boxWidth: "696",
    // Default width of the box
    boxHeight: "478"
    // Default height of the box
    };

$(document).ready(function() {

    $("#features .featurepanel, #plans tr.hover, .contactinfo div div").hover(function() {

//Change the color of the table rows as the mouse hovers

        $(this).stop().animate({ 
            backgroundColor: "#e5e5e5"
        }, "fast");
    }, function() {

        $(this).stop().animate({
            backgroundColor: "#F0F0F0"
        }, "slow");
    });

//Make the heights of the feature panel and the individual testimonies equal

    $("#testimonials div div").equalHeights();

    $("#backgrounds img").hide(); //Hide backgrounds before being loaded

    $("#spanel").click(function() { //This whole block of the javascript is explained in the help file.
        return false;
    });
    
   var elements = new Array(
        $('#s1'),
        $('#s2'),
        $('#s3'),
        $('#s4')
    );
    
    var currentElement = 0;

    $("#s1").click(function() { 
        currentElement = 0;
        $(".slider").animate({
            right: "0px"
        }, 450, 'easeInCubic');        
        
        $("#s1").attr('src',"images/green_dot.png");
        $("#s2").attr('src',"images/gray_dot.png");
        $("#s3").attr('src',"images/gray_dot.png");
        $("#s4").attr('src',"images/gray_dot.png");

        
        $("#slider li").fadeOut("fast");
        $("#slider li.sp1").fadeIn("slow");
        $("#backgrounds img").fadeOut(950);
        return false;
    });

    $("#s2").click(function() {    	
        currentElement = 1;
        $(".slider").animate({
            right: "220px"
        }, 450, 'easeInCubic');
        
        $("#s1").attr('src',"images/gray_dot.png");
        $("#s2").attr('src',"images/green_dot.png");
        $("#s3").attr('src',"images/gray_dot.png");
        $("#s4").attr('src',"images/gray_dot.png");

        $("#slider li").fadeOut("fast");
        $("#slider li.sp2").fadeIn("slow");
        $("#backgrounds img").fadeOut("fast");
        $("#backgrounds #bg1").fadeIn(950);
        return false;
    });

    $("#s3").click(function() {         
        currentElement = 2;
        $(".slider").animate({
            right: "440px"
        }, 450, 'easeInCubic');
        
    $("#s1").attr('src',"images/gray_dot.png");
	$("#s2").attr('src',"images/gray_dot.png");
	$("#s3").attr('src',"images/green_dot.png");
	$("#s4").attr('src',"images/gray_dot.png");

        
        $("#slider li").fadeOut("fast");
        $("#slider li.sp3").fadeIn("slow");
        $("#backgrounds img").fadeOut("fast");
        $("#backgrounds #bg2").fadeIn(950);
        return false;
    });

    $("#s4").click(function() {     
        currentElement = 3;
        $(".slider").animate({
            right: "660px"
        }, 450, 'easeInCubic');
        
    $("#s1").attr('src',"images/gray_dot.png");
	$("#s2").attr('src',"images/gray_dot.png");
	$("#s3").attr('src',"images/gray_dot.png");
	$("#s4").attr('src',"images/green_dot.png");

        
        $("#slider li").fadeOut("fast");
        $("#slider li.sp4").fadeIn("slow");
        $("#backgrounds img").fadeOut("fast");
        $("#backgrounds #bg3").fadeIn(950);
        return false;
    });

    
    window.setInterval(function(){
        if (currentElement == 3) {
            elements[0].click();
        } else {
            elements[currentElement + 1].click();
        }
    }, 4000);
    
    $("#testimonials").cycle({ //Cycles the testimonials. Feel free to check the help file for more info. 
        timeout: 8000
    });

});
