﻿// JScript File

function setCaret(field){
	if (field.createTextRange) {
		var r = field.createTextRange();
		r.moveStart('character', field.value.length);
		r.collapse();
		r.select();
	}
}

function browserHeight() {
  if(typeof(window.innerHeight) == 'number'){
    //Non-IE
    return window.innerHeight;
  } else if(window.document.documentElement && window.document.documentElement.clientHeight){
    //IE 6+ in 'standards compliant mode'
    return window.document.documentElement.clientHeight;
  } else if( window.document.body && window.document.body.clientHeight){
    //IE 4 compatible
    return window.document.body.clientHeight;
  }
}

function browserWidth() {
  if(typeof(window.innerWidth) == 'number'){
    //Non-IE
    return window.innerWidth;
  } else if(window.document.documentElement && window.document.documentElement.clientWidth){
    //IE 6+ in 'standards compliant mode'
    return window.document.documentElement.clientWidth;
  } else if( window.document.body && window.document.body.clientWidth){
    //IE 4 compatible
    return window.document.body.clientWidth;
  }
}

var popup = null;

function CreateWnd (file, title, width, height, resize, showbrowserbars)
{
	var doCenter = false;
	if((popup == null) || popup.closed)
	{
		if(!(navigator.appName=="Netscape")){width+=18;}
		attribs = "";
		if(resize) size = "yes"; else size = "no";
		for(var item in window)
			{ if(item == "screen") { doCenter = true; break; } }
		if(doCenter)
		{	
			if(width > screen.availWidth){width=screen.availWidth}
			if(height > (screen.availHeight - 38)){height=screen.availHeight - 38}
			if(screen.availWidth <= width || screen.availHeight <= height) size = "yes";
			WndTop  = ((screen.availHeight - 38) - height) / 2;
			WndLeft = (screen.availWidth  - width)  / 2;
			attribs = "width=" + width + ",height=" + height + ",resizable=" + size + ",scrollbars=" + size + "," + 
			"status=" + showbrowserbars + ",toolbar=" + showbrowserbars + ",directories=" + showbrowserbars + ",menubar=" + showbrowserbars + ",location=" + showbrowserbars + ",top=" + WndTop + ",left=" + WndLeft;
		}
		else
		{
			if(navigator.appName=="Netscape" && navigator.javaEnabled())
			{	
				var toolkit = java.awt.Toolkit.getDefaultToolkit();
				var screen_size = toolkit.getScreenSize();
				if(screen_size.width <= width || screen_size.height <= height) size = "yes";
				WndTop  = (screen_size.height - height) / 2;
				WndLeft = (screen_size.width  - width)  / 2;
				attribs = "width=" + width + ",height=" + height + ",resizable=" + size + ",scrollbars=" + size + "," + "status=" + showbrowserbars + ",toolbar=" + showbrowserbars + ",directories=" + showbrowserbars + ",menubar=" + showbrowserbars + ",location=" + showbrowserbars + ",top=" + WndTop + ",left=" + WndLeft;
			}
			else
			{
				size = "yes";
				attribs = "width=" + width + ",height=" + height + ",resizable=" + size + ",scrollbars=" + size + "," + "status=no,toolbar=no,directories=no,menubar=no,location=no";
			}
		}
		if(!(file.indexOf('photoviewer')<0)){
			popup = open(file, 'VectaPhoto', attribs);
		}
		else{
			popup = open(file, 'VectaPopUp', attribs);
		}
	}
	else
	{
		DestroyWnd();
		CreateWnd(file, title, width, height, resize, showbrowserbars);
	}
}

function DestroyWnd ()
{
	if(popup != null)
	{
		popup.close();
		popup = null;
	}
}

function embedFlash(url,height,width, language) {
    document.write('<!--[if IE]>');
	document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
	document.write('		codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"');
	document.write('		width="' + width + '" height="' + height + '"');
	document.write('		id="flash"');
	document.write('		viewastext>');
	document.write('	<PARAM name="movie" value="' + url + '?language=' + language + '">');
	document.write('	<PARAM name="quality" value="high">');
    document.write('   <PARAM name="salign" VALUE="tr">');
	document.write('	<PARAM name="bgcolor" value="#FFFFFF">');
	document.write('	<PARAM name="wmode" value="transparent">');
	document.write('	<PARAM name="scale" value="exactfit">');
	document.write('</OBJECT>');
	document.write('<![endif]-->');
	document.write('<![if !IE]>');
	document.write('<EMBED src="' + url + '?language=' + language + '" ');
	document.write('		quality="high"');
	document.write('		bgcolor="#FFFFFF"');
	document.write('		width="' + width + '" ');
	document.write('		height="' + height + '"');
	document.write('		type="application/x-shockwave-flash"');
	document.write('		pluginspage="http://www.macromedia.com/go/getflashplayer"');
	document.write('		salign="lt"');
	document.write('		wmode="transparent"');
	document.write('		scale="exactfit"');
	document.write('		id="flash">');
	document.write('</EMBED>');
	document.write('<![endif]>');
}

function openMicrosite(theURL, winName, theWidth, theHeight, IsResizeable){
	if(!(theURL)){theURL = 'http://www.steelcase.com/files/flash/na/think/default.html?mainWindowSet'}
	if(!(winName)){winName = 'microSiteWindow'}
	if(!(theWidth))
	{
	    if (screen.width>=1024)
	    {
	        theWidth = '912';
	    }
	    else
	    {
	        theWidth = '779';
	    }
	}
	if(!(theHeight))
	{
	    if (screen.width>=1024)
	    {
	        theHeight = '672';
	    }
	    else
	    {
	        theHeight = '539';
	    }
	}
	if(!(IsResizeable)){IsResizeable = 'no'}
	var features = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable='+IsResizeable+',width='+theWidth+',height='+theHeight+';'
	window.open(theURL,winName,features);
}

function embedIdropv2(Background, Package, Height, Width, NotInstalledImage) {
    document.write('<object name="idrop" classid="clsid:21E0CB95-1198-4945-A3D2-4BF804295F78" width="' + Width + '" height="' + Height + '" VIEWASTEXT>');
    document.write('				<param name="background" value="' + Background + '"/>');
    document.write('				<param name="proxyrect" value="0,0,' + Width + ',' + Height + '"/>');
    document.write('				<param name="griprect" value="0,0,' + Width + ',' + Height + '"/>');
    document.write('				<param name="package" value="' + Package +'"/>');
    document.write('				<param name="validate" value="1"/>');
    document.write('				<img src="' + NotInstalledImage + '" />');
    document.write('</object>');
}

function embedAppdbIdrop(Image, Drawing, Height, Width, NotInstalledImage, Path) {
    document.write('<object name="idrop" classid="clsid:21E0CB95-1198-4945-A3D2-4BF804295F78" width="' + Width + '" height="' + Height + '" VIEWASTEXT>');
    document.write('				<param name="background" value="' + Image + '"/>');
    document.write('				<param name="proxyrect" value="0,0,' + Width + ',' + Height + '"/>');
    document.write('				<param name="griprect" value="0,0,' + Width + ',' + Height + '"/>');
    document.write('				<param name="package" value="' + Path + '?f=18310&adbstreamfileid=idrop&tu=' + Image + '&du=' + Drawing +'"/>');
    document.write('				<param name="validate" value="1"/>');
    document.write('				<img src="' + NotInstalledImage + '" />');
    document.write('</object>');
}

//Note:  The following two functions are used for previewing PDFs on this page -- brochures_knowledge.aspx?f=26078
//Original Author Acknowledgement: http://javascript.internet.com/navigation/link-previewer.html
function showPreview(url, border, width, height, desc, elementId)
{
  border = typeof(border) == "undefined" ? 0 : border;
  width = typeof(width) == "undefined" ? 100 : width;
  height = typeof(height) == "undefined" ? 100 : height;
  desc = typeof(desc) == "undefined" ? "" : desc;
  document.getElementById(elementId).innerHTML = '<img src="' + url + '" border="' + border + '" width="' + width + '" height="' + height + '"/><br>' + desc;
}

function clearPreview(elementId)
{
  document.getElementById(elementId).innerHTML = "";
}
