// JScript source code
// Goes on the Server Proyect

var printCard;
var newWindow;

    
//contains calls to silverlight.js, example below loads Page.xaml
function createSilverlight()
{
    var windowHeight = getWindowHeight()-25;
    var windowWidth = getWindowWidth()-20;
	Silverlight.createObjectEx({
		source: "Page.xaml",
		parentElement: document.getElementById("SilverlightControlHost"),
		id: "SilverlightControl",
		properties: {
			width: "100%",
			height: "100%",
			version: "1.1",
			enableHtmlAccess: "true"
		},
		events: { onLoad: OnLoaded },
		//Each parameter is separated by a pipe (|) 1.sharepoint site URL 2.Width 3.Height				
		initParams: "parameters=http://www.officezealot.com/SilverlightViewer/|"+windowWidth+"|"+windowHeight+"|"		
	});
	   
	// Give the keyboard focus to the Silverlight control by default
    document.body.onload = function() {
      var silverlightControl = document.getElementById('SilverlightControl');
      if (silverlightControl)
      {
        silverlightControl.focus();
      }
    }     
    
}

function OnLoaded(sender, args)
{
   if(sender.id == 'SilverlightControl')
    {
        sender.Content.magic.OpenWindow = onOpenWindow;
    }    
}

function onOpenWindow(sender, args)
{        
    newWindow = window.open(args.Text); 
}

function getWindowHeight()
{
    var windowHeight = 0;
    if (typeof(window.innerHeight) == 'number')
    {
        windowHeight = window.innerHeight;
    }
    else
    {
        if (document.documentElement && document.documentElement.clientHeight)
        {
            windowHeight = document.documentElement.clientHeight;
        }
        else
        {
            if (document.body && document.body.clientHeight)
            {
                windowHeight = document.body.clientHeight;
            }
        }
    }
    return windowHeight;
}

function getWindowWidth()
{
    var windowWidth = 0;
    if (typeof(window.innerWidth) == 'number')
    {
        windowWidth = window.innerWidth;
    }
    else
    {
        if (document.documentElement && document.documentElement.clientWidth)
        {
            windowWidth = document.documentElement.clientWidth;
        }
        else
        {
            if (document.body && document.body.clientWidth)
            {
                windowWidth = document.body.clientWidth;
            }
        }
    }
    return windowWidth;
}


	

