var d = document;
var ns = d.layers;
var app = navigator.appVersion;
var tresholdWidth = 1000;
var wideScreen = false;

window.onload = function(){ AdjustWidth( true ); }
window.onresize = function(){ AdjustWidth( true ); }



function AdjustWidth( loaded )
{
	if( d.getElementById && (app.indexOf("MSIE 5")==-1) )
	{
		var w = document.body.clientWidth;
		var c = d.getElementById( "container" );
		if( w < tresholdWidth )
		{
			c.setAttribute("style","width: 780px !important" );
			c.style.width = "780 px";
			if( loaded )
			{ 
				contentDiv = d.getElementById("content");
				rightDiv = d.getElementById("right");
				
				for( i=0 ; i<rightDiv.childNodes.length; i++ )
				{
					contentDiv.appendChild( rightDiv.childNodes[i] );
				}
			}
			wideScreen = false;
		}
		else if( w > tresholdWidth && wideScreen == false )
		{
			c.setAttribute("style","width: 970px !important" );
			c.style.width = "970px";
			if( loaded )
			{
				divList = d.getElementById("content").getElementsByTagName("div");
				rightDiv = d.getElementById("right");
				
				if( divList.length > 0 )
				{
					rightDiv.innerHTML = "";
					for( i=0; i<divList.length; i++ )
					{
						var name = divList[i].getAttribute("className") + divList[i].getAttribute("class");
						name = name.replace( "null", "" );
						if( name == "include-dynamic" || name == "include-right" )
						{
							if( divList[i].parentNode != rightDiv )
							{
								rightDiv.appendChild( divList[i]);
								i--;
							}
						}
					}
				}
				else
				{
					rightDiv.firstChild.style.display = "block";
				}
				wideScreen = true;
			}
		}
	}
}


if( d.layers )
{
	var url = location.href.split("/");
	var filename = url[ url.length-1 ];
	if( filename.indexOf("ns4_") == -1)
	{
		if( filename != "" )
		{
			newhref = "ns4_" + filename;
		}
		else
		{
			newhref = "ns4_index.html";
		}
		location.replace( newhref );
	}
}

// slideshow
function gotoshow()
{
	if (newwindow)
	{
		window.open(slidelinks[whichlink]);
	}
	else
	{
		window.location=slidelinks[whichlink];
	}
}

function slide_init1()
{
	for (i=0;i<slideimages.length;i++)
	{
		imageholder[i]=new Image();
		imageholder[i].src=slideimages[i];
	}
}

function slideit()
{
	if (!d.images) return;
	if (ie) d.images.slide.filters[0].apply();
	d.images.slide.src=imageholder[whichimage].src;
	if (ie) d.images.slide.filters[0].play();
	whichlink=whichimage;
	whichimage=(whichimage<slideimages.length-1)? whichimage+1 : 0;
	setTimeout("slideit()",slidespeed+blenddelay);
}

function flash_me(flash_file,my_width,my_height,my_url,alt_img)
{
	var flashinstalled = 0;
	var flashversion = 0;
	MSDetect = "false";
	if (navigator.plugins && navigator.plugins.length)
	{
		x = navigator.plugins["Shockwave Flash"];
		if (x)
		{
			flashinstalled = 2;
			if (x.description)
			{
				y = x.description;
				flashversion = y.charAt(y.indexOf('.')-1);
			}
		}
		else
			flashinstalled = 1;
		if (navigator.plugins["Shockwave Flash 2.0"])
		{
			flashinstalled = 2;
			flashversion = 2;
		}
	}
	else if (navigator.mimeTypes && navigator.mimeTypes.length)
	{
		x = navigator.mimeTypes['application/x-shockwave-flash'];
		if (x && x.enabledPlugin)
			flashinstalled = 2;
		else
			flashinstalled = 1;
	}
	else
	{
		MSDetect = "true";
	}
	if (MSDetect == "true") 
	{
	document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+my_width+'" height="'+my_height+'" id="fma">');
	document.writeln('  <param name="movie" value="../doc/'+flash_file+'" />');
	document.writeln(' <param name="quality" value="high" />');
	document.writeln(' <param name="FlashVars" value="clickTag=/software/mx2004/index.html&amp;clickTarget=_self&amp;getURLOK=false" />');
	document.writeln(' <embed flashvars="clickTag=/software/mx2004/index.html&amp;clickTarget=_self&amp;getURLOK=true" src="../doc/'+flash_file+'" width="'+my_width+'" height="'+my_height+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="fma"></embed>');
	document.writeln('</object>');
	}
	else
	{
	document.writeln('<img src="../img/'+alt_img+'" />');
	}
}
