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;
}
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];}}
}

function MM_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.getElementById(n); return x;
}

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];}
}

function insereFlash(filename,name,largura,altura,vars){
			AC_FL_RunContent(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
			'width', largura,
			'height', altura,
			'src', 'a',
			'quality', 'high',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', 'transparent',
			'devicefont', 'false',
			'id', name,
			'bgcolor', '#ffffff',
			'name', name,
			'menu', 'true',
			'allowScriptAccess','sameDomain',
			'movie', filename,
			'salign', '',
			'flashVars',vars
			); //end AC code
	
}

function limitaTexto(campo,div,tamanho)
{
	campo = document.getElementById(campo)
	div	  = document.getElementById(div)
    quant = tamanho;
    total = campo.value.length;
    if(total <= quant)
    {
        resto = quant - total;
        div.innerHTML = resto;
    }
    else
    {
         campo.value = campo.value.substr(0,quant);
    }
}


$(document).ready(function(){

	$(".showCH:eq(0)").click(function(){
		if($(".showhide:eq(0)").is(':hidden')){
			$(".showhide:eq(0)").show();
		}else{
			$(".showhide:eq(0)").hide();
		}
	});

	$(".showCH:eq(1)").click(function(){
		if($(".showhide:eq(1)").is(':hidden')){
			$(".showhide:eq(1)").show();
		}else{
			$(".showhide:eq(1)").hide();
		}
	});

	$(".showCH:eq(2)").click(function(){
		if($(".showhide:eq(2)").is(':hidden')){
			$(".showhide:eq(2)").show();
		}else{
			$(".showhide:eq(2)").hide();
		}
	});
	$(".showCH:eq(3)").click(function(){
		if($(".showhide:eq(3)").is(':hidden')){
			$(".showhide:eq(3)").show();
		}else{
			$(".showhide:eq(3)").hide();
		}
	});
	$(".showCH:eq(4)").click(function(){
		if($(".showhide:eq(4)").is(':hidden')){
			$(".showhide:eq(4)").show();
		}else{
			$(".showhide:eq(4)").hide();
		}
	});
	$(".showCH:eq(5)").click(function(){
		if($(".showhide:eq(5)").is(':hidden')){
			$(".showhide:eq(5)").show();
		}else{
			$(".showhide:eq(5)").hide();
		}
	});
	$(".showCH:eq(6)").click(function(){
		if($(".showhide:eq(6)").is(':hidden')){
			$(".showhide:eq(6)").show();
		}else{
			$(".showhide:eq(6)").hide();
		}
	});
	$(".showCH:eq(7)").click(function(){
		if($(".showhide:eq(7)").is(':hidden')){
			$(".showhide:eq(7)").show();
		}else{
			$(".showhide:eq(7)").hide();
		}
	});
	
	
	
	/* Trabalhos */
	$(".werkFotoN").css({opacity:0.95});
	
	$(".werkFotoN").mouseover(function(){
		//$(this).fadeTo("normal", 1);
		$(this).animate({width:65,height:65,opacity:10},100);
	});
	
	$(".werkFotoN").mouseout(function(){
		//$(this).fadeTo("normal", 0.7);
		$(this).animate({width:60,height:60,opacity:0.95},100);
	});
	
	$(".werkFotoN").click(function(){
		$(".projectName").html($(this).attr("title"));
		$(".projectName").css({opacity:0});
		$(".projectName").fadeTo("fast", 1);
	});
	
	//$("#divCat").css({opacity:1,zIndex:2});
	$("#divCat").css({opacity:0,zIndex:-1});
	$("#btShowCat").click(function(){
		$("#divCat").css({display:'block',zIndex:2});
		$("#divCat").fadeTo("slow", 0.95);
	});
	
	$("#btCloseCat").click(function(){
		$("#divCat").fadeTo("slow", 0,
							function(){
								$("#divCat").css({zIndex:-1});					
							});
		
	});
	
	/****************************/
	
	
});


function changeTitle(str){
	if(document.titFlash) {
		//Aqui uso a funçao flash SetVariable para enviar para a variavel flash myText o texto do input text (diferença de navegador)
		window.document["titFlash"].SetVariable("strText", str);
		//alert(1)
	}
	if(document.titFlash) {
		//Aqui uso a funçao flash SetVariable para enviar para a variavel flash myText o texto do input text (diferença de navegador)
		document.titFlash.SetVariable("strText", str);
		//alert(2)
	}
}

function validaForm(form){
	error=false
	if(form.naam.value==""){
		imgError = "<img src='images/ico_error.gif' border=0 id='imgErrorNaam' title='Required field' />"
		$("#divnaam").html(imgError);
		$('#imgErrorNaam').tooltip({ 
			track: true, 
			delay: 0, 
			showURL: false, 
			fade: 250,
			positionLeft: true,
			left:-10,
			top:-3
		});
		error=true
	}else{
		$("#divnaam").html("");
	}
	
	if(form.email.value==""){
		imgError = "<img src='images/ico_error.gif' border=0 id='imgErrorEmail' title='Required field' />"
		$("#divemail").html(imgError);
		$('#imgErrorEmail').tooltip({ 
			track: true, 
			delay: 0, 
			showURL: false, 
			fade: 250,
			positionLeft: true,
			left:-10,
			top:-3
		});
		error=true
	}else
	if(((form.email.value.indexOf("@") < 1) || (form.email.value.indexOf('.') < 7))){
		imgError = "<img src='images/ico_error.gif' border=0 id='imgErrorEmail' title='Email invalid' />"
		$("#divemail").html(imgError);
		$('#imgErrorEmail').tooltip({ 
			track: true, 
			delay: 0, 
			showURL: false, 
			fade: 250,
			positionLeft: true,
			left:-10,
			top:-3
		});
		error=true
	}else{
		$("#divemail").html("");
	}	
	
	if(form.plaats.value==""){
		imgError = "<img src='images/ico_error.gif' border=0 id='imgErrorPlaats' title='Required field' />"
		$("#divplaats").html(imgError);
		$('#imgErrorPlaats').tooltip({ 
			track: true, 
			delay: 0, 
			showURL: false, 
			fade: 250,
			positionLeft: true,
			left:-10,
			top:-3
		});
		error=true
	}else{
		$("#divplaats").html("");
	}
	
	if(form.telefoon.value==""){
		imgError = "<img src='images/ico_error.gif' border=0 id='imgErrorTelefoon' title='Required field' />"
		$("#divtelefoon").html(imgError);
		$('#imgErrorTelefoon').tooltip({ 
			track: true, 
			delay: 0, 
			showURL: false, 
			fade: 250,
			positionLeft: true,
			left:-10,
			top:-3
		});
		error=true
	}else{
		$("#divtelefoon").html("");
	}
	
	if(error==false){
		form.submit();	
	}
}
