/* $Change: 1827608 $ $DateTime: 2007/04/09 09:12:55 $ $Revision: #14 $ */

/*===================================================================== 
	IDEMO PLAYER POPUPS
=====================================================================*/
// Popup window size 840x725, SWF content size 820x685
function iDemoPopup1(sURL)
{	sOptions = "width=840,height=725,location=no,screenX=10,left=10,screenY=10,top=10,directories=0,location=0,menubar=0,resizable=1,scrollbars=0,status=0,toolbar=0";
	var oWin = window.open(sURL, "iDemoPopup1", sOptions);
	oWin.focus();
}

/*===================================================================== 
	VIDEO PLAYER POPUPS
=====================================================================*/
// 360x285 including playbar; video is 360x240
function VideoPopup1(sURL)
{	sOptions = "width=360,height=285,location=no,screenX=10,left=10,screenY=10,top=10,directories=0,location=0,menubar=0,resizable=1,scrollbars=0,status=0,toolbar=0";
	var oWin = window.open(sURL, "VideoPopup1", sOptions);
	oWin.focus();
}

/*===================================================================== 
	X PLAYER POPUPS
=====================================================================*/
// 900x585
function x4Popup1(sURL)
{	sOptions = "width=900,height=585,location=no,screenX=10,left=10,screenY=10,top=10,directories=0,location=0,menubar=0,resizable=1,scrollbars=0,status=0,toolbar=0";
	var oWin = window.open(sURL, "x4Popup1", sOptions);
	oWin.focus();
}
// 900x585
function x5Popup1(sURL)
{	sOptions = "width=900,height=585,location=no,screenX=10,left=10,screenY=10,top=10,directories=0,location=0,menubar=0,resizable=1,scrollbars=0,status=0,toolbar=0";
	var oWin = window.open(sURL, "x5Popup1", sOptions);
	oWin.focus();
}

/*===================================================================== 
	BREEZE POPUPS
=====================================================================*/
// Use for all Breeze multimedia content
// Note: unlike other multimedia content, Breeze content will contain some space around it within the popup window
// 1014x616
function BreezePopup1(sURL)
{	var s = GetScreenSize();
	var w = "1014"; // Popup width to allow demos to display at original width
	var h = "616"; // Popup height to allow demos to display at original height
	if(s.width < w && s.height < h) // If client computer screen resolution is less than 1024 x 768
	{	w = s.width;				// Set popup to available width and height, ie, full screen
		h = s.height;
	}
	sOptions = "width=" + w + ",height=" + h + ",location=no,screenX=10,left=10,screenY=10,top=10,directories=0,location=0,menubar=0,resizable=1,scrollbars=0,status=0,toolbar=0";
	var oWin = window.open(sURL, 'BreezePopup1', sOptions);
	oWin.focus();
}

/*===================================================================== 
	CAMTASIA POPUPS
=====================================================================*/
// 640x497
function CamtasiaPopup1(sURL)
{	sOptions = "width=640,height=497,location=no,screenX=10,left=10,screenY=10,top=10,directories=0,location=0,menubar=0,resizable=1,scrollbars=0,status=0,toolbar=0";
	var oWin = window.open(sURL, "CamtasiaPopup1", sOptions);
	oWin.focus();
}
// 800x617
function CamtasiaPopup2(sURL)
{	sOptions = "width=800,height=617,location=no,screenX=10,left=10,screenY=10,top=10,directories=0,location=0,menubar=0,resizable=1,scrollbars=0,status=0,toolbar=0";
	var oWin = window.open(sURL, "CamtasiaPopup2", sOptions);
	oWin.focus();
}
// 800x655
function CamtasiaPopup3(sURL)
{	sOptions = "width=800,height=655,location=no,screenX=10,left=10,screenY=10,top=10,directories=0,location=0,menubar=0,resizable=1,scrollbars=0,status=0,toolbar=0";
	var oWin = window.open(sURL, "CamtasiaPopup3", sOptions);
	oWin.focus();
}


/*===================================================================== 
	CAPTIVATE POPUPS
=====================================================================*/
// 790x545
function CaptivatePopup1(sURL)
{	sOptions = "width=790,height=545,location=no,screenX=10,left=10,screenY=10,top=10,directories=0,location=0,menubar=0,resizable=1,scrollbars=0,status=0,toolbar=0";
	var oWin = window.open(sURL, "CaptivatePopup1", sOptions);
	oWin.focus();
}
// 640x480
function CaptivatePopup2(sURL)
{	sOptions = "width=640,height=480,location=no,screenX=10,left=10,screenY=10,top=10,directories=0,location=0,menubar=0,resizable=1,scrollbars=0,status=0,toolbar=0";
	var oWin = window.open(sURL, "CaptivatePopup2", sOptions);
	oWin.focus();
}


/*===================================================================== 
	NON-STANDARD SIZE POPUP
=====================================================================*/
// Non-standard size, must pass width and height using a param object
// Usage: <a href="javascript:NonStandardPopup1({width:'687',height:'521',url:'http://digital.ni.com/express.nsf/bycode/excsy2'})">My link text</a>
function NonStandardPopup1(params)
{	sOptions = "width=" + params.width + ",height=" + params.height + ",screenX=10,left=10,screenY=10,top=10,directories=0,location=0,menubar=0,resizable=1,scrollbars=0,status=0,toolbar=0";
	var oWin = window.open(params.url,"NonStandardPop1", sOptions);
	oWin.focus();
}

/*===================================================================== 
	NEW WINDOW
=====================================================================*/
// Use to open a new browser window with toolbar, etc.
// Usage: <a href="javascript:NewWindowPopup1({width:800,height:600,url:'http://myurl.com/'})">Open new window</a>
function NewWindowPopup1(params)
{	sOptions = "width=" + params.width + ",height=" + params.height + ",screenX=10,left=10,screenY=10,top=10,directories=0,location=1,menubar=1,resizable=1,scrollbars=1,status=1,toolbar=1";
	var oWin = window.open(params.url,"NewWindowPopup1", sOptions);
	oWin.focus();
}


/*===================================================================== 
	OTHER FLASH POPUPS
=====================================================================*/
// Use for Flash presentations
// 794x530
function EventManagerFlash1(sURL)
{	sOptions = "width=794,height=530,location=no,screenX=10,left=10,screenY=10,top=10,directories=0,location=0,menubar=0,resizable=1,scrollbars=0,status=0,toolbar=0";
	var oWin = window.open(sURL, "FlashPopupWindow", sOptions);
	oWin.focus();
}

// Use for Flash demos that play multiple SWFs from a playlist
// 640x537
function FlashPlaylist1(sURL)
{	sOptions = "width=640,height=537,location=no,screenX=10,left=10,screenY=10,top=10,directories=0,location=0,menubar=0,resizable=1,scrollbars=0,status=0,toolbar=0";
	var oWin = window.open(sURL, "FlashPlaylistWindow", sOptions);
	oWin.focus();
}


/*===================================================================== 
	WINDOWS MEDIA POPUPS
=====================================================================*/
// use for 480x360 Windows Media Files 
function WindowsMediaPopup1(sURL)
{	if(window.oWin){window.oWin.close();} // Close if popup window is already open from a previous video
	var iWidth = 480;
	var iHeight = 360 + 45 + 20; // add 45 pixels for the playbar and 20 for the status bar
	var sOptions = "width="+iWidth+",height="+iHeight+",location=no,screenX=100,left=100,screenY=100,top=100,directories=0,location=0,menubar=0,resizable=1,scrollbars=0,status=0,toolbar=0";
	window.oWin = window.open("", "", sOptions);
	
	var sHTML = '<html><head><title>National Instruments</title></head>';
	sHTML += '\n<body style="margin:0;padding:0;">\n';
	sHTML += '<script type="text/javascript" src="/javascript/multimedia/popups.js"><\/script>';
	sHTML += '<script type="text/javascript">';
	sHTML += "window.onload = function(){WriteWindowsMediaPlayer10(" + iWidth + "," + iHeight + ",'" + sURL + "')}";
	sHTML += '</script>';
	sHTML += '</body>';
	sHTML += '</html>';
	
	oWin.document.open();
	oWin.document.write(sHTML);
	oWin.document.close();
	oWin.focus();
}

// Use for 320 x 240 Windows Media files
function WindowsMediaPopup2(sURL)
{	if(window.oWin){window.oWin.close();} // Close if popup window is already open from a previous video
	var iWidth = 320;
	var iHeight = 240 + 45 + 20; // add 45 pixels for the playbar and 20 for the status bar
	var sOptions = "width="+iWidth+",height="+iHeight+",location=no,screenX=100,left=100,screenY=100,top=100,directories=0,location=0,menubar=0,resizable=1,scrollbars=0,status=0,toolbar=0";
	window.oWin = window.open("", "", sOptions);
	
	var sHTML = '<html><head><title>National Instruments</title></head>';
	sHTML += '\n<body style="margin:0;padding:0;">\n';
	sHTML += '<script type="text/javascript" src="/javascript/multimedia/popups.js"><\/script>';
	sHTML += '<script type="text/javascript">';
	sHTML += "window.onload = function(){WriteWindowsMediaPlayer10(" + iWidth + "," + iHeight + ",'" + sURL + "')}";
	sHTML += '</script>';
	sHTML += '</body>';
	sHTML += '</html>';
	
	oWin.document.open();
	oWin.document.write(sHTML);
	oWin.document.close();
	oWin.focus();
}


/*===================================================================== 
	HELPER FUNCTIONS
=====================================================================*/
// Helper function to return screen resolution
// Returns an object with width and height properties
function GetScreenSize()
{	return {width:screen.availWidth,height:screen.availHeight};
}
// Helper function to fix the activate activex control issue
// This function writes out the HTML code, which is Microsoft's workaround strategy
function WriteWindowsMediaPlayer10(iWidth,iHeight,sURL)
{	document.open();
	var sHTML = '<html><head><title>National Instruments</title>';
	sHTML += '</head>';
	sHTML += '<body style="margin:0;padding:0;background:#000000;">';
	sHTML += '<object classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="'+iWidth+'" height="'+iHeight+'">';
	sHTML += '<param name="uiMode" value="full">';
	sHTML += '<param name="autoStart" value="true">';
	sHTML += '<param name="URL" value="'+sURL+'">';
	sHTML += '<embed type="application/x-mplayer2" ';
	sHTML += 'src="'+sURL+'" ';
	sHTML += 'width="'+iWidth+'" ';
	sHTML += 'height="'+iHeight+'" ';
	sHTML += 'status="true" ';
	sHTML += '>';
	sHTML += '</embed>';
	sHTML += '</object>';
	sHTML += '</body>';
	sHTML += '</html>';
	document.write(sHTML);
	document.close();
}
// OBSOLETE: AddScrollbarWrapper(sURL) is no longer needed; since we now allow users to resize windows,
// we do not need to add scrollbars to the popups by wrapping the page loaded in an iframe.
// Helper function to wrap demos in iframe
// in order to add auto scrollbars inside popup windows.
// Adding scrollbars to the popup windows themselves would always leave a vertical scrollbar in IE, even if not needed
// so the work around is to add the scrollbars to an iframe wrapper around the content
function AddScrollbarWrapper(sURL)
{	var sHTML = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
	sHTML += '<html xmlns="http://www.w3.org/1999/xhtml" style="height:100%">';
	sHTML += '<head>';
	sHTML += '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />';
	sHTML += '<title>National Instruments</title>';
	sHTML += '</head>';
	sHTML += '<body style="margin:0;height:100%;padding:0px;">';
	sHTML += '<iframe style="margin:0;height:100%;width:100%;" scrolling="auto" frameborder="no" src="' + sURL + '"></iframe>';
	sHTML += '</body>';
	sHTML += '</html>';
	return sHTML;
}