function loadDate()
{
	var currentTime = new Date();
	document.getElementById('year').innerHTML = currentTime.getFullYear();
}

var nav = 'gerard';
var flowCount = 0;
var stop = false;

function opacity(id, state, 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 + "','" + state + "')",(timer * speed));
            timer++;            
        }        
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "','" + state + "')",(timer * speed));
            timer++;
        }
    }
} 

function changeOpac(opacity, id, state) {
    var object = document.getElementById(id).style;
    if(state=='none'&&opacity==0) { object.display='none'; }
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

function showHover(name,xpos,w)
{
    document.getElementById('nameHover').innerHTML = name;
    document.getElementById('nameHover').style.width = w;
    document.getElementById('hover').style.left = xpos;
}

function navActivate(navActive,navPasive)
{
    // Oude nav grijs maken
    oldLoc = document.getElementById(navPasive).src;
    newLoc = oldLoc.replace("_active","");
    document.getElementById(navPasive).src = newLoc;     
    
    // Nieuwe nav rood maken
    oldLoc = document.getElementById(navActive).src;
    newLoc = oldLoc.replace(".gif","_active.gif");
    document.getElementById(navActive).src = newLoc;

    nav = navActive;
}

function submitter(form)
{
  this.form = document.getElementById(form);
  this.inputs = this.form.getElementsByTagName('input');
  this.error = '';
  for(i=0;i<this.inputs.length;i++)
  {
    if(this.inputs[i].name=='email')
    {
        document.getElementById('error['+i+']').innerHTML = '';
        if(this.inputs[i].value.indexOf('@')<0||this.inputs[i].value.indexOf('.')<0||this.inputs[i].value.length<=7)
        {
          document.getElementById('error['+i+']').innerHTML = '!';
          this.error+= this.inputs[i].name;
        }
       
    }
    else if(this.inputs[i].type=='text')
    {
        document.getElementById('error['+i+']').innerHTML = '';
        if(this.inputs[i].value=='')
        {
          document.getElementById('error['+i+']').innerHTML = '!';
          this.error+= this.inputs[i].name;
        }
    }
  }  
  if(this.error=='')
  {
    this.form.submit();
  }
  else
  {
    alert('U heeft niet alle benodigde velden juist ingevuld.\r\nVul de velden waar een "!" achter staat alsnog goed in.');
  }
}

function changeImage(section,value,active)
{
   section = section.parentNode.parentNode.parentNode.parentNode.parentNode.id;
   this.section = document.getElementById(section);
   this.images = this.section.getElementsByTagName('img');   
   for(i=0;i<this.images.length;i++)
   {
     if(this.images[i].id!='')
     {
        this.images[i].src = 'images/sub.gif';
     }
   }
   this.divs = this.section.getElementsByTagName('div');
   for(i=0;i<this.divs.length;i++)
   {
     this.divs[i].style.display = 'none';     
   }
   this.images[active].src = 'images/sub_active.gif';
   this.images[0].src = 'images/portfolio/'+value+'.jpg';
   document.getElementById(value).style.display = 'block';
}

function imageFlow(flowCount,stop)
{   
    clearTimeout(timer); 
    this.images = document.getElementById('right').getElementsByTagName('img');
    //alert(flowCount);
    //if(flowCount!=0&&stop!=true)
    //{
    //    new Effect.Opacity(this.images[flowCount], { from: 1, to: 0.5, duration: 0.5 });
    //}
    if(flowCount<2) { flowCount+=1; } else { flowCount = 1; }
    
    for(i=1;i<this.images.length;i++)
    {
        image = this.images[i].src.replace('_active','');
        this.images[i].src = image;
    }
    if(stop==true)
    {
        return;
    }
    
    image = this.images[flowCount].src.replace('_project'+flowCount,'_project'+flowCount+'_active');
    this.images[flowCount].src = image;
    //new Effect.Opacity(this.images[flowCount].id, { from: 0.5, to: 1, duration: 0.5 });
    timer=setTimeout('imageFlow('+flowCount+')',2000);
}

function imageFlowb(flowCount,stop)
{   
    clearTimeout(timer); 
    if(flowCount<3) { flowCount+=1; } else { flowCount = 1; }
    
    this.images = document.getElementById('right').getElementsByTagName('img');
    for(i=1;i<this.images.length;i++)
    {
        image = this.images[i].src.replace('_active','');
        this.images[i].src = image;
    }
    if(stop==true)
    {
        return;
    }
    image = this.images[flowCount].src.replace('_project'+flowCount,'_project'+flowCount+'_active');
    this.images[flowCount].src = image;
    
    timer=setTimeout('imageFlow('+flowCount+')',2000);
}
