var d = document;
var ns = d.layers;
var app = navigator.appVersion;
var tresholdWidth = 1000;
var wideScreen = false;
var w;

//window.onload = function(){ AdjustWidth( true ); }
//window.onresize = function(){ AdjustWidth( true ); }

function AdjustWidth (loaded)
{
	if (d.getElementById && (app.indexOf("MSIE 5")==-1))
	{
		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) { 
				leftDiv = d.getElementById("leftcolumn");
				rightDiv = d.getElementById("rightcolumn");
				for( i=0 ; i<rightDiv.childNodes.length; i++ ) {
					rightDiv.childNodes[i].style.display = "none";
					leftDiv.appendChild(rightDiv.childNodes[i] );
				}
			}
			wideScreen = false;
		}
		else if (w > tresholdWidth && wideScreen == false) {
			
			c.setAttribute("style","width: 970px !important" );
			c.style.width = "970px";
			
			if (loaded) {
				leftDivList = d.getElementById("leftcolumn").getElementsByTagName("div");
				rightDiv = d.getElementById("rightcolumn");
				//alert("how many divs in leftcolumn: " + leftDivList.length);
				if (leftDivList.length > 0) {
					rightDiv.innerHTML = "";
					for (i=0; i<leftDivList.length; i++) {
						var name = leftDivList[i].getAttribute("className") + leftDivList[i].getAttribute("class");
						name = name.replace( "null", "");
						alert(name);
						if (name == "rightbox") {
							if (leftDivList[i].parentNode != rightDiv) {
								leftDivList[i].style.display = "";
								rightDiv.appendChild(leftDivList[i]);
								i--;
							}
							
						}
						
						
					}
					
				}
				else {
					rightDiv.firstChild.style.display = "block";
				}
				
				wideScreen = true;
			}
			
		}
	}
}

function AdjustWidthOld (loaded)
{
	if (d.getElementById && (app.indexOf("MSIE 5")==-1))
	{
		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("rightcolumn");
				
				for( i=0 ; i<rightDiv.childNodes.length; i++ ) {
					rightDiv.childNodes[i].style.display = "none";
					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("rightcolumn");
				alert("how many divs in content: " + divList.length);
				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", "");
						alert(name);
						if (name == "include-right") {
							if (divList[i].parentNode != rightDiv) {
								divList[i].style.display = "";
								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);
}