var type = "IE";	//Variable used to hold the browser name

BrowserSniffer();

//detects the capabilities of the browser
function BrowserSniffer() {
	if (navigator.userAgent.indexOf("Opera")!=-1 && document.getElementById) type="OP";		//Opera
	else if (document.all) type="IE";														//Internet Explorer e.g. IE4 upwards
	else if (document.layers) type="NN";													//Netscape Communicator 4
	else if (!document.all && document.getElementById) type="MO";							//Mozila e.g. Netscape 6 upwards
	else type = "IE";		//I assume it will not get here
}

function ShowLayer(id, action){
	if (type=="IE") eval("document.all." + id + ".style.visibility='" + action + "'");
	if (type=="NN") eval("document." + id + ".visibility='" + action + "'");
	if (type=="MO" || type=="OP") eval("document.getElementById('" + id + "').style.visibility='" + action + "'");
}

function ShowHide(id){
	if (type=="NN"){
		if (eval("document." + id + ".visibility=='hidden'")){
			eval("document." + id + ".visibility='visible'");
		}else{
			eval("document." + id + ".visibility='hidden'");
		}
	}
	if (type=="MO" || type=="OP" || type=="IE"){
		if (eval("document.getElementById('" + id + "').style.visibility=='hidden'")){
			 eval("document.getElementById('" + id + "').style.visibility='visible'");
		}else{
			 eval("document.getElementById('" + id + "').style.visibility='hidden'");
		}
	}
}

var statusmsg=""

function hidestatus(){
	window.status=statusmsg
	return true
}

function taalwissel(taal){
	new Ajax.Request('/includes/taalwissel.php?taal='+taal, {
		method: 'get',
		onSuccess: function(transport) {
				window.location=window.location;
		}
	});

/*	$.ajax({ url: '/includes/taalwissel.php?taal='+taal, context: document.body, success: function(){
				window.location=window.location;
      }});*/
}

function domail(){
	window.location='mailto:info@janvandulmen.nl';
}

function popUpFront2(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, 'Beveiligd2', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=750,height=575,left = 80,top = 50');");
}

function verwijder_image(image){
    var tekst="Weet u zeker dat u deze foto wilt verwijderen?";
    var agree=confirm(tekst);
	if(agree){
		new Ajax.Request('/beheer/includes/remove_image.php', {
			method: 'post',
			parameters:  { 
				image_name:image
			} ,
			onSuccess: function(transport) {
				var newloc=new String(window.location);
				newloc=newloc.replace('#','');
//				alert(transport.responseText);
				window.location=newloc;
			}
		});
	}
}

function KeyCode(e){
     if(e)
     {
          e = e 
     } else {
          e = window.event
     } 

     if(e.which)
     { 
          var keycode = e.which
     } 
     else 
     {
          var keycode = e.keyCode 
     }

     return keycode;
}

//var fotoNr = 1;
function addFoto(elID, max)
{
	var tbl = document.getElementById(elID);
	var lastRow = tbl.rows.length;
	// if there's no header row in the table, then iteration = lastRow + 1
	var iteration = lastRow;
	var row = tbl.insertRow(lastRow);
  
	// cell 1
/*	var cell_1 = row.insertCell(0);
	var input1 = document.createElement('input');
	input1.setAttribute('type', 'text');
	input1.setAttribute('id', 'volgnummer');
	input1.setAttribute('value', lastRow);
	input1.setAttribute('name', 'foto[extrafoto][volgnummer][]');
	cell_1.appendChild(input1);
 
	var cell_2 = row.insertCell(1);
	var input2 = document.createElement('input');
	input2.setAttribute('type', 'text');
	input2.setAttribute('id', 'omschr');
	input2.setAttribute('name', 'foto[extrafoto][omschrijving][]');
	cell_2.appendChild(input2);

*/	var cell_3 = row.insertCell(0);
	var input3 = document.createElement('input');
	input3.setAttribute('type', 'file');
	input3.setAttribute('id', 'bestand');
	input3.setAttribute('name', "bestandsnaam[]");
	input3.setAttribute('accept', "image/jpeg");
	cell_3.appendChild(input3);
	
	if(tbl.rows.length < max)
	{
		input3.onmousedown = function()
		{
			if(tbl.rows.length < max)
			{
				addFoto(elID, max);
			}
		}
	}
	
//	fotoNr++;
}
function WijzigVenster(URL,height,width) {
        window.open(URL, 'wijzig', 'left=300,top=100,width='+width+',height='+height+',menubar=0,resizable=0,toolbar=0,status=0,location=0');
}
function WijzigVenster2(URL,height,width) {
        window.open(URL, 'wijzig', 'left=300,top=100,width='+width+',height='+height+',menubar=0,resizable=1,scrollbars=yes,toolbar=0,status=0,location=0');
}

function show_mail(){
	document.write( "<span>info</span>" + "@" + "<span>janvandulmen.nl</span>");
}

