﻿var $j = jQuery.noConflict();

var windowWidth = 0, windowHeight=0;
var BoxWidth = 400;
var Boxheight = 500;
var boxPositionTop;
var boxPostionLeft;

$j(function(){ 
	setTimeout(showPage, 1500); //delays page load until all objects are ready	
	SetBGSize();	//Set Bottom half background height
    setGoogleMap();             
	
	//These 2 lines of code are for the photogallery
	if(document.getElementById("photoGallery"))
		$j(".PhotoHolder a").lightBox();
	
    /*if(document.getElementById('GiftForm'))
    {
    	document.getElementById('GiftForm').onclick = openbox;
    }
	if (document.getElementById('SalmonBosco')) {
        $j('#SalmonBosco').click(function () {

            openbox("SalmonBosco");
        });
    }
    if (document.getElementById('Cappelinni')) {
        $j('#Cappelinni').click(function () {

            openbox("Cappelinni");
        });
    }*/	
	
	//If we are on teh recipe page, load button click event
	if (document.getElementById('Manicotti')) {
        $j('#Manicotti').click(function () {
            openbox("Manicotti");
        });
    }
	
});
function showPage()
{
	
	var bodydisplay = document.getElementById("SiteContainer");    
    bodydisplay.removeClass = "Hidepage";
    bodydisplay.className = "DisplayPage";
}

function SetBGSize()
{
	if(document.getElementById('HomePageContentContainer')){
		var ContentHeight = document.getElementById('HomePageContentContainer').offsetHeight;
	}
	else{
		var ContentHeight = document.getElementById('ContentContainer').offsetHeight;		
	}
	ContentHeight+= 220;
	document.getElementById('BottomBackground').style.height = ContentHeight +"px";
	
	
}
function popUp(URL) 
{
    var newWindow = window.open(URL, "", "toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=800,height=600,left = 375,top = 212");    
}

function setGoogleMap()
{
    if(document.getElementById("GoogleMap"))
    {
        var map = new GMap2(document.getElementById("GoogleMap"));
        map.setCenter(new GLatLng(26.196147, -81.812785), 17);  
        var point = new GLatLng(26.196147, -81.812785)
        map.addOverlay(new GMarker(point));
        map.openInfoWindow(map.getCenter(),document.createTextNode("MireMare Ristorante"));
        map.setUIToDefault();
        window.onunload = unLoad;
    }
}
function unLoad()
{
    GUnload();
}

//Open the lightbox


function openbox(recipe) {

   // document.getElementById('recipeBox').src = "recipes/" + recipe + ".php";
   var iframe = document.getElementById('recipeBox');
   iframe.setAttribute("src", "recipes/" + recipe + ".php");


   FindWindowSize();
    var filterHeight = windowHeight + 500;
    $j('#filter').css("opacity", "0.6");
    $j('#filter').css("filter", "alpha(opacity = 60)");
    $j('#filter').css("height", filterHeight);
    
	boxPositionLeft = (windowWidth - BoxWidth) / 2;
	boxPositionTop = (windowHeight - Boxheight) / 2;
	
	$j("#filter").css("display", "block");
	$j("#box").css("left", boxPositionLeft);
	$j("#box").css("top", boxPositionTop);
	$j("#box").fadeIn(500);
}

// Close the lightbox
function closebox()
{
	
	$j("#box").fadeOut(500);
	$j("#filter").fadeOut(500);
   //document.getElementById('filter').style.display='none';
}

function FindWindowSize() {
    
    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        windowWidth = window.innerWidth;
        windowHeight = window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }
  
}




