$(document).ready(function(){
	// Top menu 
	
	var aantalsubs = $('#nav li').size();
	var menu_speed = 200;
	

	$(".subnav").addClass("notactive-menuitem");
	$("#sub-"+active_link).removeClass("notactive-menuitem").addClass("active-menuitem");
	
	for (var i=1; i<=aantalsubs; i++) { 
		$("#nav li:nth-child("+i+") a").bind("mouseover", function(){  
 			    $("#nav li a").css("background-position","top");	
				if (!$(".subnav").is(':animated') ) {
					var lnk = $(this).attr("href");
					lnk = lnk.replace(".html", "");
					if (lnk!=active_link) { 
						$(".subnav").css("top","-30px");
					}
				}
				active_link = lnk;
				$(".subnav").addClass("notactive-menuitem");
				$("#sub-"+lnk).removeClass("notactive-menuitem").addClass("active-menuitem");
				$("#sub-"+lnk).animate({top:"0px"},menu_speed);
				$(this).css("background-position","bottom");
		});
	}


	$.fn.colorbox.settings.bgOpacity = "0.8";
	$("a[rel='fotobox']").colorbox({transition:"elastic", contentCurrent:"{current} / {total}"});

	$("#inline").colorbox({fixedWidth:"468px", inline:true, href:"#inline-contact", overlayClose: false});
	
	$(".activiteiten").click(function(){ return false; });
	$(".etendrinken").click(function(){ return false; });
	$(".arrangementen").click(function(){ return false; });
	$(".julliezijn").click(function(){ return false; });
	$(".beleefbreda").click(function(){ return false; });
	
	$("#verzenden-knop").click(function(){ 
		 checkform();
		 return false;
	});
	$(".item-container").mouseover(function(){
		$(this).children(".meerinfo").addClass("hover");
	});
	$(".item-container").mouseout(function(){
		$(this).children(".meerinfo").removeClass("hover");
	});	
										
});

function checkform() {
	var dopost = true;
	var patroon = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	alerttext = 'De volgende velden dient u correct in te vullen: \n';

	if ($("#inp-naam").attr("value") == ''){
		$("#inp-naam").addClass("error");
		dopost = false;
	} else { 
		$("#inp-naam").removeClass("error");
		dopost = true;
	}
	if ($("#inp-email").attr("value") != ''){
		if (patroon.test($("#inp-email").attr("value"))==false) {
			$("#inp-email").addClass("error");
			dopost = false;
		} else { 
			$("#inp-email").removeClass("error");
			dopost = true;
		}										
	} else { 
		$("#inp-email").addClass("error");
		dopost = false;
	}
	if (!dopost) {
		$('#foutmeldingen').empty().append("Vul de gemarkeerde velden correct in.");
	} else {
		$.post("ajaxpages/contactverzenden.php",
						{ 	inpbedrijf:$("#inp-bedrijf").attr("value"),
							inpnaam:$("#inp-naam").attr("value"),
							inpadres:$("#inp-adres").attr("value"),
							inppostcode:$("#inp-postcode").attr("value"),
							inpplaats:$("#inp-plaats").attr("value"),
							inptelefoon:$("#inp-telefoon").attr("value"),
							inpemail:$("#inp-email").attr("value"),
							inpopmerkingen:$("#inp-opmerkingen").attr("value")
						},
							function(data){
								$("#contact-text").empty().append("Uw email is verzonden. We zullen u zo spoedig mogelijk een reactie sturen.");
							}
						 );	
	}

	return dopost;
} 

function isValidTime(value) {
   var hasMeridian = false;
   var re = /^\d{1,2}[:]\d{2}([:]\d{2})?( [aApP][mM]?)?$/;
   if (!re.test(value)) { return false; }
   if (value.toLowerCase().indexOf("p") != -1) { hasMeridian = true; }
   if (value.toLowerCase().indexOf("a") != -1) { hasMeridian = true; }
   var values = value.split(":");
   if ( (parseFloat(values[0]) < 0) || (parseFloat(values[0]) > 23) ) { return false; }
   if (hasMeridian) {
      if ( (parseFloat(values[0]) < 1) || (parseFloat(values[0]) > 12) ) { return false; }
   }
   if ( (parseFloat(values[1]) < 0) || (parseFloat(values[1]) > 59) ) { return false; }
   if (values.length > 2) {
      if ( (parseFloat(values[2]) < 0) || (parseFloat(values[2]) > 59) ) { return false; }
   }
   return true;
}

function isNumberKey(evt) {
	var charCode = (evt.which) ? evt.which : event.keyCode
	if (charCode > 31 && (charCode < 48 || charCode > 57))
	return false;
	
	return true;
}

function isEmpty(s) {
  return ((s == null) || (s.length == 0))
}

function isDigit (c)
{
  return ((c >= "0") && (c <= "9"))
}

function isInteger (s) {
  var i;

  if (isEmpty(s))
  if (isInteger.arguments.length == 1) return 0;
  else return (isInteger.arguments[1] == true);

  for (i = 0; i < s.length; i++)
  {
	 var c = s.charAt(i);

	 if (!isDigit(c)) return false;
  }

  return true;
}

function cursorWait() { 
	document.body.style.cursor='wait'
}
function cursorDefault() { 
	document.body.style.cursor='default'
}


// SIFR Code
function doSifr() {
  
    var cochin = {
      src: 'cochin.swf'
      ,ratios: [7, 1.32, 11, 1.31, 13, 1.24, 14, 1.25, 19, 1.23, 27, 1.2, 34, 1.19, 42, 1.18, 47, 1.17, 48, 1.18, 69, 1.17, 74, 1.16, 75, 1.17, 1.16]
    };

    var rockwell = {
      src: 'rockwell.swf'
      ,ratios: [6, 1.41, 9, 1.35, 15, 1.29, 21, 1.25, 22, 1.22, 27, 1.24, 29, 1.21, 34, 1.22, 41, 1.21, 45, 1.2, 46, 1.21, 59, 1.2, 68, 1.19, 69, 1.2, 96, 1.19, 97, 1.18, 102, 1.19, 103, 1.18, 107, 1.19, 108, 1.18, 112, 1.19, 114, 1.18, 116, 1.19, 120, 1.18, 121, 1.19, 1.18]
    };

    sIFR.activate(cochin, rockwell);

    sIFR.replace(rockwell, {
      selector: '#header h1'
      ,css: [
        '.sIFR-root { font-weight: bold; color: #FFFFFF; }'
        ,'a { text-decoration: none; }'
        ,'a:link { color: #000000; }'
        ,'a:hover { color: #CCCCCC; }'
      ]
	  ,wmode: 'transparent'
	  ,filters: {
        DropShadow: {
          knockout: false
          ,distance: 1
          ,color: '#330000'
          ,strength: 1
        }
      }
    });
	
	    sIFR.replace(rockwell, {
      selector: '#header h2'
      ,css: [
        '.sIFR-root { font-weight: bold; color: #FFFFFF; }'
        ,'a { text-decoration: none; }'
        ,'a:link { color: #000000; }'
        ,'a:hover { color: #CCCCCC; }'
      ]
	  ,wmode: 'transparent'
    });
	
	sIFR.replace(rockwell, {
      selector: '.item-container h1, .quote h1'
      ,css: [
        '.sIFR-root { font-style: italic; font-weight: bold; color: #e1001d; }'
        ,'a { text-decoration: none; }'
        ,'a:link { color: #000000; }'
        ,'a:hover { color: #CCCCCC; }'
      ]
	  ,wmode: 'transparent'
    });
	
	sIFR.replace(rockwell, {
      selector: '.ref-tekst h1'
      ,css: [
        '.sIFR-root { font-style: italic; font-weight: bold; color: #494949; }'
        ,'a { text-decoration: none; }'
        ,'a:link { color: #000000; }'
        ,'a:hover { color: #CCCCCC; }'
      ]
	  ,wmode: 'transparent'
    });
	
		sIFR.replace(rockwell, {
      selector: '.kop-meer, .activiteit-info h1, #activiteitenselector h1, .nieuws h1, .contact-info h1'
      ,css: [
        '.sIFR-root { font-weight: bold; color: #e1001d; }'
        ,'a { text-decoration: none; }'
        ,'a:link { color: #000000; }'
        ,'a:hover { color: #CCCCCC; }'
      ]
	  ,wmode: 'transparent'
    });
   
}