/* ==================================================== */
/* ==================================================== */
/*
	browserchecks
	
		IS_MOZ
		IS_IE
		IS_SAFARI
		
		IS_OPERA
		
		IS_WIN
			VERSION_IS
		IS_MAC
			IS_OSX
*/
/* ==================================================== */

if(navigator)
{
	user = navigator;
	IS_MOZ = (user.appName.toLowerCase().indexOf("netscape") != -1);
	IS_IE = (user.appName.toLowerCase().indexOf("internet") != -1);
	IS_SAFARI = (user.userAgent.toLowerCase().indexOf("safari") != -1);
	
	IS_OPERA = (user.appName.toLowerCase() == "opera");
	
	if(user.userAgent.indexOf("Opera")>-1)
	{
		IS_IE = false;
		IS_OPERA = true;
	}
	// browser version
	if (user.appVersion)
	{  // don't try to parseInt a string (NA = "")
		VERSION_IS = parseInt(user.appVersion);
		if (IS_IE)
		{  
			VERSION_IS = parseFloat(user.userAgent.split("MSIE")[1].split(";")[0]);
		}
	}
	if (user.userAgent && user.appVersion)
	{
		agt = user.userAgent.toLowerCase();  
		IS_WIN = ((agt.indexOf("win") != -1) || (agt.indexOf("16bit") != -1));
		IS_MAC = (agt.indexOf("mac") != -1);
		
		IS_OSX = IS_MAC && (agt.indexOf("os x") != -1);
	}
}	

/* ==================================================== */
/* ==================================================== */
/* Flash check											*/
/* ==================================================== */

HAS_FLASH6 = false;

if (IS_IE && IS_WIN) {
	document.write("<scri"+"pt type=\"text/vbscript\">\n");
	document.write("	on error resume next\n");
	document.write("	HAS_FLASH6 = (IsObject(CreateObject(\"ShockwaveFlash.ShockwaveFlash.6\")))\n");
	document.write("</scri"+"pt>\n");
}
else
{
	if (user.mimeTypes && user.mimeTypes["application/x-shockwave-flash"] && user.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {
		if (user.plugins && user.plugins["Shockwave Flash"]){
			descr = user.plugins["Shockwave Flash"].description
		 	if(parseInt(descr.substr((descr.indexOf('Flash ')+6),1))>=6){
				HAS_FLASH6=true;
			}
		}
	}
}

function writeRecensieViewer(imgSrc,title,x,y,s)
{
	var swfSrc = "swf/recensie_viewer.swf";
	var flashVars = "";
	flashVars += "imgSrc="+imgSrc;
	flashVars += "&recensieTitle="+title;
	flashVars += "&startX="+x;
	flashVars += "&startY="+y;
	flashVars += "&startScale="+s;

	width = "100%";
	height = "100%";
	
	var HTML = ""
	if(HAS_FLASH6)
	{
		HTML += "<object id=\"swfPlayer\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" width=\""+width+"\" height=\""+height+"\" >\n";
		HTML += "<param name=\"movie\" value=\""+swfSrc+"\">\n";
		HTML += "<param name=\"flashvars\" value=\""+flashVars+"\">\n";
		HTML += "<param name=\"quality\" value=\"high\">\n";
		HTML += "<param name=\"menu\" value=\"false\">\n";
		HTML += "<param name=\"scale\" value=\"noscale\">\n";
		HTML += "<param name=\"wmode\" value=\"transparent\">\n";
		HTML += "<embed src=\""+swfSrc+"\" width=\""+width+"\" height=\""+height+"\" flashvars=\""+flashVars+"\" quality=\"best\" menu=\"false\" wmode=\"transparent\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\"></embed>";
		HTML += "</object>\n";
	}
	else
	{
		HTML += "Geen Macromedia Flash Player gedetecteerd!\n";
	}
	document.write(HTML);
}

//--------------------------------------------

var windowTargetSizeList = {
	recensie:{w:700,h:400,attr:"location=no,status=yes,menubar=no,scrollbars=no,resizable=yes"}
}

var windowList = {}

function openInNewWindow(aObj,w,h,attr,x,y)
{

	var url;
	var targetName;
	
	if(typeof(aObj)=="string")
	{
		url = aObj;
		targetName = "_blank";
	}
	else
	{
		url = aObj.href;
		targetName =  aObj.target;
	}
	
	if(windowTargetSizeList[targetName])
	{
		w = (w)?w:windowTargetSizeList[targetName].w;
		h = (h)?h:windowTargetSizeList[targetName].h;
		attr = (attr)?attr:windowTargetSizeList[targetName].attr;
	}
	
	w += (IS_SAFARI)?-2:((IS_MAC && IS_IE)?-16:0);
	h += (IS_SAFARI)?15:((IS_MAC && IS_IE)?-16:0);
	
 	x=x?x:(screen.availWidth-w)/2;
 	y=y?y:(screen.availHeight-h)/2;
		
 	if(windowList[targetName])
 	{
 		aWindow = windowList[targetName];
 		if(!aWindow.closed)
 		{ 
			aWindow.focus();
			return false;
 		}
 	};
 	windowList[targetName] = window.open(url,targetName,"width="+w+",height="+h+",left="+x+",top="+y+","+(attr ? attr : "location=no,status=yes,menubar=no,scrollbars=yes,resizable=no"))
	
 	return false;
}



function highlite(menuElm)
{
	if(!menuElm.defaultClassName) menuElm.defaultClassName = menuElm.className;
	menuElm.className = menuElm.defaultClassName+" over";
	menuElm.onmouseout = function()
	{
		this.className = this.defaultClassName;
	} 
	menuElm.onmousedown = function()
	{
		this.parentNode.className=this.parentNode.className
		fC = this.getElementsByTagName("div")[0];
		if(fC.defaultClassName)
		{
			fC.className=fC.defaultClassName;
			fC.defaultClassName=null;
			this.className = this.defaultClassName+" over";
			this.onmouseover = function()
			{
				highlite(this);
			}
			this.onmouseout = function()
			{
				this.className = this.defaultClassName;
			} 
		}
		else
		{
			fC.defaultClassName=fC.className;
			fC.className+=" show";
			this.className = this.defaultClassName+" over";
			this.onmouseover=null;
			this.onmouseout=null;
		}
		
	}
}

window.onload = function()
{
	mainNavElm = document.getElementById("mainNav");
	if(mainNavElm)
	{
		aList = mainNavElm.getElementsByTagName("a");
		for(var i=0;i<aList.length;i++)
		{
			aElm = aList[i];
			
			imgElm = aElm.getElementsByTagName("img")[0];
			
			liElm = aElm.parentNode;
			liElm.aElm = aElm;
			
			liElm.imgElm = imgElm;
			liElm.imgNormal =  new Image();
			liElm.imgHover = new Image();
			liElm.imgNormal.src = imgElm.src;
			liElm.imgHover.src = imgElm.src.replace("_normal","_hover");
			
			liElm.style.cursor = "pointer"
			
			liElm.onmouseover=function()
			{
				if(this.className!="active")
				{
					this.imgElm.src = this.imgHover.src;
					this.onmouseout = function()
					{
						this.imgElm.src = this.imgNormal.src;
					}
				}
				this.onclick=function()
				{
					document.location.href = this.aElm.href;
					return false;
				}
			}
		}
	}
}
