﻿$(window).resize(function(){
    var bodyheight = $(document).height();
    $("#blankOverlay").css("height", bodyheight);
    var bodywidth = $(document).width();
    $("#blankOverlay").css("width", bodywidth);
    
});

$(document).ready(function(){
    var bodyheight = $(document).height();
    $("#blankOverlay").css("height", bodyheight);
    var bodywidth = $(document).width();
    $("#blankOverlay").css("width", bodywidth);
    
    $("#blankOverlay").fadeTo("normal", 0.0, function(){
        $("#blankOverlay").hide()
    });
    $("#supportTrainingContent").fadeTo("normal", 0.0, function(){
        $("#supportTrainingContent").hide()
    });
    
    
    $("#supportTraining").click(function(){
    
        var mycompare = $("#blankOverlay").css("display");
        if (mycompare != "none") {
            $("#blankOverlay").fadeTo("normal", 0.0, function(){
                $("#blankOverlay").hide()
            });
            $("#supportTrainingContent").fadeTo("normal", 0.0, function(){
                $("#supportTrainingContent").hide()
            });
        }
        else {
            $("#blankOverlay").show();
            $("#blankOverlay").fadeTo("normal", 0.75);
            $("#supportTrainingContent").show();
            $("#supportTrainingContent").fadeTo("normal", 1.0);
        }
    });
    
    
    $("#supportTrainingClose").click(function(){
        $("#blankOverlay").fadeTo("normal", 0.0, function(){
            $("#blankOverlay").hide()
        });
        $("#supportTrainingContent").fadeTo("normal", 0.0, function(){
            $("#supportTrainingContent").hide()
        });
    });
    
    
    
    $("#exploreSageClose").click(function(){
    
        $("#exploreSage").animate({
            height: 0,
            marginTop: 0
        }, 400);
    });
    
    $("#exploreSageGo").click(function(){
        var testforflash = $("#flashObject").height();
        var FFversion = 0;
        if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)) { //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
            var ffversion = new Number(RegExp.$1) // capture x.x portion and store as a number
            if (ffversion >= 3) 
				{
                FFversion = 3;
				}
            else {
                if (ffversion >= 2) 
				{
				FFversion = 2;
				}
                else {
                    if (ffversion >= 1) 
					{
					FFversion = 1;
					}       
        		}
			}
		}
		else {
            FFversion = -1;
        }
		
        var mycompare = $("#exploreSage").height();
        var mytopmargin = 0;
        
        if (FFversion != 3) 

		{
            if (testforflash >= 265) 
			{
                if (mycompare != 0) 
				{
                    $("#exploreSage").animate(
					{
                        height: 0,
                        marginTop: 0
                    }, 400);
                }
                else {
                    $("#exploreSage").animate(
					{
                        height: 265,
                        marginTop: -265
                    }, 600);
                    
                }
            }
            
            if (testforflash < 265) 
			{
                mytopmargin = mytopmargin - testforflash;               
                if (mycompare != 0) 
				{
                    $("#exploreSage").animate(
					{
                        height: 0,
                        marginTop: 0
                    }, 400);
                    
                }
                else {
                    $("#exploreSage").animate(
					{
                        height: 265,
                        marginTop: mytopmargin
                    }, 600);
                    
                }
            }
            
        }
        
        if (FFversion == 3)
		{		
            if (mycompare != 0) 
			{
                $("#exploreSage").animate(
				{
                    height: 0
                }, 400);
            }
            
            else {
                $("#exploreSage").animate(
				{
                    height: 265
                }, 600);               
            }
        }
		});
		});



/*
 This overrides the setIFrameSize function in Immediacy.Plugins / EmbedSite.EmbedSite.js
 which doesn't work in Firefox (and Chrome?) as FF reports 0 for contentDocument.body.offsetHeight,
 using contentDocument.documentElement.scrollHeight instead.
*/
function setIFrameSize(frameid){
	var frame=document.getElementById(frameid)
	if (frame && !window.opera)
	{
	    if (frame.contentDocument && frame.contentDocument.body.offsetHeight) //ns6 syntax
			frame.height = frame.contentDocument.body.offsetHeight+immFFextraHeight;
		else if (frame.Document && frame.Document.body.scrollHeight) //ie5+ syntax
			frame.height = frame.Document.body.scrollHeight;
	    else if (frame.contentDocument && frame.contentDocument.documentElement && frame.contentDocument.documentElement.scrollHeight)
			frame.height = frame.contentDocument.documentElement.scrollHeight;
	}
}

