var planeheight = 0;
var maxplaneheight = 535;
var planespeed = 30;
var framerate = 15;
var animate = false;

function expandModelPlane() {
  document.getElementById('modellenLabel').style.background = "#cdcdcd";
  document.getElementById('modellenLabelDiv').style.background = "#EEEEEE";
  document.getElementById('modellenLabelText').style.color = "#707070";
  animate = true;
}

setInterval("animateModelPlane()", framerate);
function animateModelPlane() {
  if (animate) {
    planeheight += planespeed;
    if (planeheight >= maxplaneheight) {
      planeheight = maxplaneheight;
    }
    document.getElementById('modellenPlane').style.height = planeheight + "px";
    document.getElementById('modellenContent').style.top = ((-maxplaneheight + planeheight) / 10) + "px";
  }
}


function collapseModelPlane() {
  document.getElementById('modellenLabel').style.background = "none";
  document.getElementById('modellenLabelDiv').style.background = "none";
  document.getElementById('modellenLabelText').style.color = "#FFFFFF";
  $('#modellenLabelDiv').uncorner();
  planeheight = 0;
  animate = false;
  document.getElementById('modellenPlane').style.height = "0px";
}

$(document).ready( function(){
      $('.divSubmenuBG').corner();
      $('.divMainVisual').corner("8px"); 
    });    
    
  $(function() {
		$('td.tdSubnavItemBG').hover(function(){
			$(this).find('div').animate({left:'30px'},{queue:false,duration:200});
		}, function(){
			$(this).find('div').animate({left:'0px'},{queue:false,duration:200});
		});
		$('#nextSlide').click(function(){
			$('#slideImages').animate({left:'-=700px'},{queue:false,duration:500});
		});
		
    $("#divPrev").click(function(){
      leftPos = Math.round($("#slideImages").position().left / 700) * 700;
      maxRight = 0;
      if(leftPos >= maxRight){
    		$("#slideImages").animate({ 
        left: (($("#slideImages").width() - 700) * -1) + "px"}, 0);
      }
      $("#slideImages").animate({left: "+=700px"}, 500, function() {
        $("#divNext").show();
        $("#divPrev").show();
      });
      $("#divNext").hide();
      $("#divPrev").hide();
    });
    
    $("#divNext").click(function(){
      leftPos = Math.round($("#slideImages").position().left / 700) * 700;
      maxLeft = ($("#slideImages").width() - 700) * -1;
      $("#divNext").hide();
      $("#divPrev").hide();
  		if(leftPos <= maxLeft){
    		$("#slideImages").animate({left: "0px"}, 0);
      }
      $("#slideImages").animate({left: "-=700px"}, 500, function() {
        $("#divNext").show();
        $("#divPrev").show();
      });
    });
    $("#actieClose").click(function(){
        pageTitle = $('#iframeContent').contents().find("#pageCheck").val();
        pageTitleArr = pageTitle.split(" - ");
        if(pageTitleArr[0] == "Vergroting"){
          $('#iframeContent').attr('src', "/actie/index.php?page=1&start="+pageTitleArr[1]);
          $('#iframeContent').css("width","900px");
          $('#actieContent').css("width","900px");
          $('#actieFrame').css("width","900px");
          $('#iframeContent').css("height","600px");
          $('#actieContent').css("height","600px");
          $('#actieFrame').css("height","600px");   
        } else { 
          $("#actiePanel").css("display","none");
        }
    });    
  });
