$(document).ready(function(){
	// Top menu 
	
	var reserveringsurl = $("#reserveren-knop3").attr("href");	
	var aantalsubs = $('#nav li').size();
	var menu_speed = 200;
	
	/*	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) { 
						for (var j=1; j<=aantalsubs; j++) { 
							var tmp_lnk = $("#nav li:nth-child("+j+") a").attr("href")
							tmp_lnk = tmp_lnk.replace(".html", "");
							if (tmp_lnk==active_link) {
								$("#sub-"+tmp_lnk).animate({top:"30px"},menu_speed);
							} else { 
								$("#sub-"+tmp_lnk).css("top","-30px");
							}
						} 				
					}
					active_link = lnk;
					$("#sub-"+lnk).animate({top:"0px"},menu_speed);
					$(this).css("background-position","bottom");
				}
			});
		}
	*/
	$(".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(){  
				$(".subnav").stop();												   
 			    $("#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");
		});
	}

	$("#sub-"+active_link).css("top","0");
	$("."+active_link).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});
	$(".inlinenb").colorbox({fixedWidth:"468px", inline:true, href:"#inline-nieuwsbrief", 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; });
	
	$("#inp_zoekveld").focus(function(){ 
		$(this).attr("value", ""); 
	});
	$("#inp_zoekveld").blur(function(){ 
		var txt = $(this).attr("value");
		if (txt=="") { 
			$(this).attr("value", "Zoeken..."); 
		} ; 
	});
	$("#inp_zoeksubmit").click(function(){ 
		 var txt = $("#inp_zoekveld").attr("value");
		 if (txt!="" && txt!="Zoeken...") { 
			document.frm_zoeken.submit();
		 }; 
		 return false;
	});
	
	$("#verzenden-knop").click(function(){ 
		 checkform();
		 return false;
	});
	$("#verzenden-knop-nb").click(function(){ 
		 checkform_nb();
		 return false;
	});	
	$(".item-container").mouseover(function(){
		$(this).children(".meerinfo").addClass("hover");
	});
	$(".item-container").mouseout(function(){
		$(this).children(".meerinfo").removeClass("hover");
	});	
	
	$(".radio-optie").click(function() { 
		var tmp = reserveringsurl;							 
		tmp = tmp.replace(/.html/i, "-"+$(this).attr("value")+".html");
		$("#reserveren-knop3").attr("href",tmp);
		$("#reserveren-knop3").css("display","block");
	});
	
	$(".vraag").click(function() { 
		$(".antwoord").css("display","none");
		$(this).next(".antwoord").css("display","block");
		return false;
    });
										
});

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

	return dopost;
}

function checkform_nb() {
	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-nb-naam").attr("value") == ''){
		$("#inp-nb-naam").addClass("error");
		dopost = false;
	} else { 
		$("#inp-nb-naam").removeClass("error");
		dopost = true;
	}
	if ($("#inp-nb-email").attr("value") != ''){
		if (patroon.test($("#inp-nb-email").attr("value"))==false) {
			$("#inp-nb-email").addClass("error");
			dopost = false;
		} else { 
			$("#inp-nb-email").removeClass("error");
			dopost = true;
		}										
	} else { 
		$("#inp-nb-email").addClass("error");
		dopost = false;
	}
	if (!dopost) {
		$('#contact-foutmeldingen-nb').empty().append("Vul de gemarkeerde velden correct in.");
	} else {
		$.post("ajaxpages/nieuwsbriefaanmelden.php",
						{ 	inpnaam:$("#inp-nb-naam").attr("value"),
							inpemail:$("#inp-nb-email").attr("value")
},
							function(data){
								$("#contact-text-nb").empty().append("U ontvangt vanaf nu onze nieuwsbrief.");
							}
						 );	
	}

	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'
}
function backToTop() {
    var x1 = x2 = x3 = 0;
    var y1 = y2 = y3 = 0;

    if (document.documentElement) {
        x1 = document.documentElement.scrollLeft || 0;
        y1 = document.documentElement.scrollTop || 0;
    }

    if (document.body) {
        x2 = document.body.scrollLeft || 0;
        y2 = document.body.scrollTop || 0;
    }

    x3 = window.scrollX || 0;
    y3 = window.scrollY || 0;

    var x = Math.max(x1, Math.max(x2, x3));
    var y = Math.max(y1, Math.max(y2, y3));

    window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));

    if (x > 0 || y > 0) {
        window.setTimeout("backToTop()", 25);
    }
}

// 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'
    });
   
}