//DROPDOWN

// Copyright (C) 2005-2008 Ilya S. Lyubinskiy. All rights reserved.
// Technical support: http://www.php-development.ru/
//
// YOU MAY NOT
// (1) Remove or modify this copyright notice.
// (2) Re-distribute this code or any part of it.
//     Instead, you may link to the homepage of this code:
//     http://www.php-development.ru/javascripts/dropdown.php
//
// YOU MAY
// (1) Use this code on your website.
// (2) Use this code as part of another product.
//
// NO WARRANTY
// This code is provided "as is" without warranty of any kind.
// You expressly acknowledge and agree that use of this code is at your own risk.


// ***** Popup Control *********************************************************

// ***** at_show_aux *****

function at_show_aux(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child );

  var top  = (c["at_position"] == "y") ? p.offsetHeight+2 : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 0;

  for (; p; p = p.offsetParent)
  {
    top  += p.offsetTop;
    left += p.offsetLeft;
  }

  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}

// ***** at_show *****

function at_show()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  at_show_aux(p.id, c.id);
  clearTimeout(c["at_timeout"]);
}

// ***** at_hide -- Het rode getal is de tijd dat het duurt om het vorige menu te sluiten (best 0)*****

function at_hide()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.visibility = 'hidden'", 0);
}

// ***** at_click *****

function at_click()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  if (c.style.visibility != "visible") at_show_aux(p.id, c.id); else c.style.visibility = "hidden";
  return false;
}

// ***** at_attach *****

// PARAMETERS:
// parent   - id of the parent html element
// child    - id of the child  html element that should be droped down
// showtype - "click" = drop down child html element on mouse click
//            "hover" = drop down child html element on mouse over
// position - "x" = display the child html element to the right
//            "y" = display the child html element below
// cursor   - omit to use default cursor or specify CSS cursor name

function at_attach(parent, child, showtype, position, cursor)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);

  p["at_parent"]     = p.id;
  c["at_parent"]     = p.id;
  p["at_child"]      = c.id;
  c["at_child"]      = c.id;
  p["at_position"]   = position;
  c["at_position"]   = position;

  c.style.position   = "absolute";
  c.style.visibility = "hidden";

  if (cursor != undefined) p.style.cursor = cursor;

  switch (showtype)
  {
    case "click":
      p.onclick     = at_click;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show;
      c.onmouseout  = at_hide;
      break;
    case "hover":
      p.onmouseover = at_show;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show;
      c.onmouseout  = at_hide;
      break;
  }
}



//plan Mappy
function plan()
{
window.open("http://cms1.proximedia.com/Google/GoogleMap.asp?MapId=17739&Langue=NL&Options=100%25x100%25", "Plan", "toolbar=no, location=no, directories=no, status=yes, scrollbars=yes, resizable=yes, copyhistory=no, width=730, height=500, left=50, top=50");
}


/******************************************************************
	Toggle Object
		onclick="toggle('divToToggle');"
		onclick="showMore('divToToggle','standardImage.gif');"
******************************************************************/
//	toggle without image
function toggle(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}
//	toggle WITH image for example: plus and minus
var doit = true
function showMore(ob,pict) {
  if(doit) {
    document.getElementById(ob).style.height = '125'
    document.getElementById(pict).src = 'arrowl.gif'
    doit = false
  }
  else {
    document.getElementById(ob).style.height = '20'
    document.getElementById(pict).src = 'arrowd.gif'
    doit = true
  }
}
/******************************************************************
	Popup image with or without right mouse protection
	
		onclick="popImage('images/popupimage.jpg','Ur website name',true);"
		onclick="popImage('images/popupimage.jpg','Ur website name',false);"
******************************************************************/
var BrowserDetect = {
 init: function () {
  this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
  this.version = this.searchVersion(navigator.userAgent)
   || this.searchVersion(navigator.appVersion)
   || "an unknown version";
  this.OS = this.searchString(this.dataOS) || "an unknown OS";
 },
 searchString: function (data) {
  for (var i=0;i<data.length;i++) {
   var dataString = data[i].string;
   var dataProp = data[i].prop;
   this.versionSearchString = data[i].versionSearch || data[i].identity;
   if (dataString) {
    if (dataString.indexOf(data[i].subString) != -1)
     return data[i].identity;
   }
   else if (dataProp)
    return data[i].identity;
  }
 },
 searchVersion: function (dataString) {
  var index = dataString.indexOf(this.versionSearchString);
  if (index == -1) return;
  return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
 },
 dataBrowser: [
  {  string: navigator.userAgent,
   subString: "OmniWeb",
   versionSearch: "OmniWeb/",
   identity: "OmniWeb"
  },
  {
   string: navigator.vendor,
   subString: "Apple",
   identity: "Safari"
  },
  {
   prop: window.opera,
   identity: "Opera"
  },
  {
   string: navigator.vendor,
   subString: "iCab",
   identity: "iCab"
  },
  {
   string: navigator.vendor,
   subString: "KDE",
   identity: "Konqueror"
  },
  {
   string: navigator.userAgent,
   subString: "Firefox",
   identity: "Firefox"
  },
  {
   string: navigator.vendor,
   subString: "Camino",
   identity: "Camino"
  },
  {  // for newer Netscapes (6+)
   string: navigator.userAgent,
   subString: "Netscape",
   identity: "Netscape"
  },
  {
   string: navigator.userAgent,
   subString: "MSIE",
   identity: "Explorer",
   versionSearch: "MSIE"
  },
  {
   string: navigator.userAgent,
   subString: "Gecko",
   identity: "Mozilla",
   versionSearch: "rv"
  },
  {   // for older Netscapes (4-)
   string: navigator.userAgent,
   subString: "Mozilla",
   identity: "Netscape",
   versionSearch: "Mozilla"
  }
 ],
 dataOS : [
  {
   string: navigator.platform,
   subString: "Win",
   identity: "Windows"
  },
  {
   string: navigator.platform,
   subString: "Mac",
   identity: "Mac"
  },
  {
   string: navigator.platform,
   subString: "Linux",
   identity: "Linux"
  }
 ]
 
};
BrowserDetect.init();
function popImage(imageURL,imageTitle,rightMouse) {
	PositionX = 100;
	PositionY = 100;
	defaultWidth  = 500;
	defaultHeight = 500;
	var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
	var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
	var AutoClose = true;
	var RightMouse = (rightMouse == true)? true:false;
	
	if (parseInt(navigator.appVersion.charAt(0))>=4) {
		var isNN=(navigator.appName=="Netscape")?1:0;
		var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;
	}
	if (isNN){
		imgWin=window.open('about:blank','',optNN);
	}
	if (isIE){
		imgWin=window.open('about:blank','',optIE);
	}
	with (imgWin.document) {
		writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');
		writeln('<sc'+'ript>');
		writeln('var isNN,isIE,message="Deze functie werd gedeactiveerd!";');
		writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
		writeln('isNN=(navigator.appName=="Netscape")?1:0;');
		writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
		writeln('function reSizeToImage(){');
		writeln('if (isIE){');
		writeln('window.resizeTo(100,100);');
		writeln('width=100-(document.body.clientWidth-document.images[0].width);');
		writeln('height=100-(document.body.clientHeight-document.images[0].height);');
		if ( BrowserDetect.version == 7 ) {
			writeln('width=width+150;');
		}
		writeln('window.resizeTo(width,height);}');
		writeln('if (isNN){');       
		writeln('window.innerWidth=document.images["TheImage"].width;');
		writeln('window.innerHeight=document.images["TheImage"].height;}}');
		writeln('function doTitle(){document.title="'+imageTitle+'";}');
		writeln('function clickIE4(){if (event.button==2){alert(message);return false;}}');
		writeln('function clickNS4(e){if (document.layers||document.getElementById&&!document.all) {if (e.which==2||e.which==3) {alert(message);return false;}}}');
		writeln('if (document.layers){document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS4;}else if (document.all&&!document.getElementById){document.onmousedown=clickIE4;}');
		writeln('</sc'+'ript>');
		if (!AutoClose) 
			writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
		else 
			writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
		if(RightMouse)
			writeln('<sc'+'ript>document.oncontextmenu=new Function("alert(message);return false");</script>');
		writeln('<img name="TheImage" src='+imageURL+' style="display:block"></body></html>');
		close();
	}
}
/******************************************************************
	Macromedia functions
******************************************************************/
//	function who finds objects by ID...
function MM_findObj(n, d) 
{ 
  //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}
//	function who can show / hide layers on basis of ID...
//	onmouseover="showHideLayers('divID_1', '', 'hide', 'divID_2', '', 'show', 'divID_3', '', 'hide');"
//	onmouseout="showHideLayers('divID_1', '', 'show', 'divID_2', '', 'hide', 'divID_3', '', 'hide');"
function showHideLayers() 
{ 
  //v3.0
  var i,p,v,obj,args=showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}
//	swaps an image with a new one...
//	onmouseover="MM_swapImage('Name','','images/imagefile.gif',1)"
//	onmouseout="MM_swapImgRestore()"
function MM_swapImage() 
{ 
  //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//	restores original image after MM_swapImage()
//	see above
function MM_swapImgRestore() 
{ 
  //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
//	preloads images needed
//	<body onload="MM_preloadImages('images/fotos_on.jpg','images/zwemmen_on.jpg');">
function MM_preloadImages() 
{ //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//	Validates Forms...
//	onclick="MM_validateFormNL('naam','','R','tel','','R','e-mail','','RisEmail');return document.MM_returnValue"
function MM_validateForm(language) 
{
	//v4.0
	var language = (language !="") ? language : "NL";
	var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
	for (i=0; i<(args.length-2); i+=3) 
	{ 
		test=args[i+2]; 
		val=MM_findObj(args[i]);
		if (val) 
		{ 
			nm=val.name; 
			if ((val=val.value)!="") 
			{
				if (test.indexOf('isEmail')!=-1) 
				{ 
					p=val.indexOf('@');
					if (p<1 || p==(val.length-1)) 
					{
						switch(language)
						{
							case "NL":
								text = '- '+nm+' moet een e-mail adres bevatten.\n'
							break;
							case "FR":
								text = '- '+nm+' doit contenir une adresse e-mail.\n'
							break;
							case "FR":
								text = '- '+nm+' has to contain an e-mail address.\n'
							break;
						}
						errors+= text;
					}
				} 
				else if (test!='R') 
				{
					if (isNaN(val)) 
					{
						switch(language)
						{
							case "NL":
								text = '- '+nm+' moet een cijfer zijn.\n';
							break;
							case "FR":
								text = '- '+nm+' doit être un chiffre.\n';
							break;
							case "FR":
								text = '- '+nm+' must be a number.\n';
							break;
						}
						errors+= text;
					}
					if (test.indexOf('inRange') != -1) 
					{ 
						p=test.indexOf(':');
						min=test.substring(8,p);
						max=test.substring(p+1);
						if (val<min || max<val) 
						{
							switch(language)
							{
								case "NL":
									text = '- '+nm+' moet een cijfer zijn tussen '+min+' en '+max+'.\n';
								break;
								case "FR":
									text = '- '+nm+' doit être un chiffre entre '+min+' et '+max+'.\n';
								break;
								case "EN":
									text = '- '+nm+' must be a number between '+min+' and '+max+'.\n';
								break;
							}
							errors+= text;
						}
					}
				}
			} 
			else if (test.charAt(0) == 'R') 
			{
				switch(language)
				{
					case "NL":
						text = '- '+nm+' is vereist.\n';
					break;
					case "FR":
						text = '- '+nm+' est un champ obligatoire.\n';
					break;
					case "EN":
						text = '- '+nm+' is necessary.\n';
					break;
				}
				errors += text; 
			}
				
		} 
		
	}
	if (errors) 
	{
		switch(language)
		{
			case "NL":
				alerttext = 'Volgende fout(en) hebben zich voorgedaan:\n'+errors;
			break;
			case "FR":
				alerttext = 'La(es) faute(s) suivante(s) se sont produites:\n'+errors;
			break;
			case "EN":
				alerttext = 'The following error(s) have occurred:\n'+errors;
			break;
		}
		alert(alerttext);
	}
	document.MM_returnValue = (errors == '');
}
/******************************************************************
	Cookie functions
******************************************************************/
//	this function reads a cookie with the name as parameter
function getCookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ';', len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}
//	this function sets a cookie with name and value and some other parameters
function setCookie( name, value, expires, path, domain, secure ) {
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires ) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name+'='+escape( value ) +
		( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) + //expires.toGMTString()
		( ( path ) ? ';path=' + path : '' ) +
		( ( domain ) ? ';domain=' + domain : '' ) +
		( ( secure ) ? ';secure' : '' );
}
//	this function deletes the cookie with name, path and domain as parameters
function deleteCookie( name, path, domain ) {
	if ( getCookie( name ) ) document.cookie = name + '=' +
			( ( path ) ? ';path=' + path : '') +
			( ( domain ) ? ';domain=' + domain : '' ) +
			';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}
/******************************************************************
	Some Simple functions
******************************************************************/
//	redirects a user to an url
function gotoUrl(weblink)
{
	document.location.href = weblink;
}
//	displays a confirm before it redirects to url, makes use of gotoUrl for redirection...
//	onclick="disp_confirm('http://www.proximedia.be/Nuke_Russia','Are you sure you want to nuke Russia?');"
function disp_confirm(url,text)
{
	var text = (text !="") ? text:"Bent u zeker dat u deze actie wil uitvoeren?";
	var confirmkader=confirm(text)
	if (confirmkader==true)
	{
		gotoUrl(url);
	}
}
//	puts a certain value (waarde) in a certain field (veld) in a certain form (form)
//	onclick="plaknaarForm('contact','name','Kim Kennof');
function plaknaarForm(form,veld,waarde)
{
	if(waarde != "")
	{
		document.forms[form].elements[veld].value = waarde;
	}
}
//	creates a x char random string from letters & numbers
//	onclick="randomString(8);"
function randomString(length) 
{
	var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghikmnopqrstuvwxyz";
	var string_length = (length!="")? length: 8;
	var randomstring = '';
	for (var i=0; i<string_length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}
	alert("New random string = " + randomstring);
	//document.getElementById("new_pass").value = randomstring;
}
//	opens the default mappy window...
//	onclick="mappy('21248','nl','Mappy Popup Window');"
function mappy(client,lang,titel)
{
	var url = "http://www.proximedia.com"+client+";map.provider=Proximedia;&xml.state.wanted_lang="+lang;
	var vensternaam = titel.replace(/ /g,'');
	window.open(url,vensternaam,'toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,width=730,height=500,left=50,top=50');
}
//	this function dynamically removes all frames from flash embeds...
//	window.onload="ActivateFlash();"
function ActivateFlash() 
{ 
    var objects = document.getElementsByTagName("object"); 
    for (var i = 0; i < objects.length; i++) 
    { 
      objects[i].outerHTML = objects[i].outerHTML; 
    }
}
/******************************************************************
	Fader functions
******************************************************************/
//	Opacity changes
//	<a href="javascript:opacity('digicam', 100, 0, 500)">Hide</a>
function opacity(id, opacStart, opacEnd, millisec) 
{
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}
//change the opacity for different browsers
function changeOpac(opacity, id) 
{
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 
//	<a href="javascript:shiftOpacity('digicam2', 1000)">show/hide</a>
function shiftOpacity(id, millisec) 
{
    //if an element is invisible, make it visible, else make it ivisible
    if(document.getElementById(id).style.opacity == 0) {
        opacity(id, 0, 100, millisec);
    } else {
        opacity(id, 100, 0, millisec);
    }
} 
/*
	DIV with ID
	IMG with ID
	---------------
	<div style="background-image: url(media/texts/photos_about/02aft.jpg); background-repeat: no-repeat; width: 200px; height: 150px;" id="blenddiv">
		<img src="media/texts/photos_about/02aft.jpg" style="width: 200px; height: 150px; border: 0 none; filter: alpha(opacity=0); -moz-opacity: 0; opacity: 0;" id="blendimage" alt="" />
	</div>
	---------------
*/
//	 <a href="javascript:blendimage('blenddiv','blendimage', 'media/texts/photos_about/03aft.jpg',200)">Image 1</a>
function blendimage(divid, imageid, imagefile, millisec) {
    var speed = Math.round(millisec / 100);
    var timer = 0;
    
    //set the current image as background
    document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
    
    //make image transparent
    changeOpac(0, imageid);
    
    //make new image
    document.getElementById(imageid).src = imagefile;

    //fade in image
    for(i = 0; i <= 100; i++) {
        setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
        timer++;
    }
}
//	<a href="javascript:currentOpac('digicam3', 60, 300)">fade to 60%</a>
function currentOpac(id, opacEnd, millisec) {
    //standard opacity is 100
    var currentOpac = 100;
    
    //if the element has an opacity set, get it
    if(document.getElementById(id).style.opacity < 100) {
        currentOpac = document.getElementById(id).style.opacity * 100;
    }

    //call for the function that changes the opacity
    opacity(id, currentOpac, opacEnd, millisec)
} 
