$(document).ready(function() {

    aboutOut = false;
    productsOut = false;
    contactOut = false;

	//stick the footer at the bottom of the page if we're on an iPad/iPhone due to viewport/page bugs in mobile webkit
	if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod')
	{
	     $("#footer").css("position", "static");
	};

    $("#about").hover(function() {
        $("#about-links").fadeIn("fast");
        $("#about-links").animate({ "height": "68px" }, { queue: false, duration: "fast" });
        $("#about-links .link-holder").animate({ "left": "0px" }, { queue: false, duration: "fast" });
        aboutOut = true;
    }, function() {
        $("#about-links").animate({ "height": "0px" }, { queue: false, duration: "fast" });
        $("#about-links .link-holder").animate({ "left": "-30px" }, { queue: false, duration: "fast" });
        $("#about-links").fadeOut("fast");
    });
    
    $("#products").hover(function() {
        $("#products-links").fadeIn("fast");
        $("#products-links").animate({ "height": "92px" }, { queue: false, duration: "fast" });
        $("#products-links .link-holder").animate({ "left": "0px" }, { queue: false, duration: "fast" });
    }, function() {
        $("#products-links").animate({ "height": "0px" }, { queue: false, duration: "fast" });
        $("#products-links .link-holder").animate({ "left": "-30px" }, "fast");
        $("#products-links").fadeOut("fast");
    });
    
    $("#contact").hover(function() {
        $("#contact-links").fadeIn("fast");
        $("#contact-links").animate({ "height": "92px" }, { queue: false, duration: "fast" });
        $("#contact-links .link-holder").animate({ "left": "0px" }, { queue: false, duration: "fast" });
    }, function() {
        $("#contact-links").animate({ "height": "0px" }, { queue: false, duration: "fast" });
        $("#contact-links .link-holder").animate({ "left": "-30px" }, { queue: false, duration: "fast" });
        $("#contact-links").fadeOut("fast");
    });
    
    if( typeof( window.innerWidth ) == 'number' ) {
        //Non-IE
        myWidth = window.innerWidth/2 - 262;
        myHeight = window.innerHeight/2 - 177;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth/2 - 262;
        myHeight = document.documentElement.clientHeight/2 - 177;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        myWidth = document.body.clientWidth/2 - 262;
        myHeight = document.body.clientHeight/2 - 177;
    }
    
    
    $("#gpssoon").css("left", myWidth+"px");
    $("#gpssoon").css("top", myHeight+"px");
    $("#accesssoon").css("left", myWidth+"px");
    $("#accesssoon").css("top", myHeight+"px");
    
    setTimeout(openFB, 2000);
    
});

function openFB() {
	$("#facebook-like").slideDown("fast");
	setTimeout(closeFB, 3000);
}

function closeFB() {
	$("#facebook-like").slideUp("fast");
}

function displayGPS() {
    if ($("#gpssoon").css("display") == "none") {
        $("#gpssoon").fadeIn("fast");
    }
    else {
        $("#gpssoon").fadeOut("fast");
    }
    
    if ($("#accesssoon").css("display") != "none") {
        $("#accesssoon").fadeOut("fast");
    }
}

function displayAccess() {
    //If GPS is out
    if ($("#gpssoon").css("display") != "none") {
        $("#gpssoon").fadeOut("fast");
    }
    
    if ($("#accesssoon").css("display") == "none") {
        $("#accesssoon").fadeIn("fast");
    }
    else {
        $("#accesssoon").fadeOut("fast");
    }
}

function closeBox() {
    $("#gpssoon").fadeOut("fast");
    $("#accesssoon").fadeOut("fast");
}

