var agt = navigator.userAgent.toLowerCase();
var dom = (document.getElementById) ? true : false;
var ns5 = ((navigator.userAgent.indexOf("Gecko")>-1) && dom) ? true: false;
var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
var ns4 = (document.layers && !dom) ? true : false;
var ie4 = (document.all && !dom) ? true : false;
var nodyn = (!ns5 && !ns4 && !ie4 && !ie5) ? true : false;
var is_win  = ((agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1)) ? true : false;

// NS4 resize fix
var origWidth, origHeight;
if (ns4) {
	origWidth = window.innerWidth; origHeight = window.innerHeight;
	window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
}

function openGallery(filename, w, h) 
{
	w = (w+130);
	h = (h+55);

	var NS=document.all;

	if(!NS)
	{
		var leftPos = (self.screen.width - self.outerWidth) / 2;
		var topPos = (self.screen.height - self.outerHeight) / 2;
	}
	else
	{
		var leftPos = (self.screen.width-w) / 2;
		var topPos = (self.screen.height-h) / 2;
	}

	winopts = "toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=auto,copyhistory=1,resizable=0,width=" + w + ",height=" + h;
	winopts += ",screenY=" + topPos + "screenY,=" + leftPos + ",top=" + topPos + ",left=" + leftPos;
	window.open(filename,"gallery",winopts);
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function SearchProject()
{
	if(projectListID != undefined && projectListID != "")
	{
		var pList = document.getElementById(projectListID);
		if(pList != null)
		{
			if(pList.options.selectedIndex > 0)
			{
				location.href = "/projecten/" + pList.options[pList.options.selectedIndex].value + ".aspx";
				return false;
			}
		}
	}
	
	return false;
}

function DoSearch(inputField)
{
	if(inputField.value != "--- op trefwoord ---")
	{
		location.href = '/search.aspx?q=' + inputField.value; 
	}
}

function SearchFieldFocus(inputField)
{
	if(inputField.value == "--- op trefwoord ---")
	{
		inputField.value = "";
	}
}

function SearchFieldBlur(inputField)
{
	if(inputField.value == "")
	{
		inputField.value = "--- op trefwoord ---";
	}
}


function SetFontSize(type)
{
 setActiveStyleSheet(type);
}

function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}



// init function for IE browsers only
navigationInit = function()
{
	var projectnavElement = document.getElementById("projects");
	if(projectnavElement != null)
	{
		var sfEls = projectnavElement.getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++)
		{
			sfEls[i].onmouseover=function()
			{
				this.className=this.className.replace(new RegExp(" sfout\\b"), "");
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function()
			{
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
				this.className+=" sfout";
			}
		}
	}
}

// "attachEvent()" is a M$ DOM specific event method
if (window.attachEvent) window.attachEvent("onload", navigationInit);
