var stateCat = 0; // 1 = verberg cat, 0 = toon cat
var statePreview = 0;
var stateSearch = 0;
var isFullPx = 0;
var goDOM = 0;
var prevThumb;
var prevBanner;
var inhoudPreview;
var breedtePreview;
var verify_captcha;
var stateContainer = 1;
var menu_zichtbaar = 1;

$(document).ready(function() {
						   
  $("img[@src$=banner-nbw-v9.0.png], #banner").ifixpng(); 						   
  $(".nbw-after").css( { cursor: "pointer" } );

  //var links_sub = document.getElementById("mnu-nbw").offsetLeft;
  //var links_sub_sub = document.getElementById("mnu-nbw").offsetLeft;

  $("#banner").css( { display: "block", cursor: "pointer" } ); 
  $("#banner").attr( { title: "nullbeta.net home" } );

  $("#query-zoeken").mouseover(function() {
    $(this).css( { cursor: "pointer" } );
  });

  $("#toggle-cats").click(function() {
	
	if ($("#container-cats-links").is(":hidden")) {
      $("#container-cats-links, #container-cats-rechts").show("slow");
	  $("#toggle-cats").css( { background: "url('/img/stijlen/ico/ico-verberg-cats.gif') 100% 0 no-repeat" } ); 
    } 
	else {
      $("#container-cats-links, #container-cats-rechts").slideUp("slow");
	  $("#toggle-cats").css( { background: "url('/img/stijlen/ico/ico-toon-cats.gif') 100% 0 no-repeat" } );	  
    }
		
  });
  
  $("#banner").click(function() {
    location.href="/";							  
  });

  $("#banner").mouseover(function() {
    $(this).css( { background: "transparent url('/img/stijlen/banner/banner-nbw-v9.0-hover.png') 0 0 no-repeat" } );							  
  });

  $("#banner").mouseout(function() {
    $(this).css( { background: "transparent url('/img/stijlen/banner/banner-nbw-v9.0.png') 0 0 no-repeat" } );							  
  });

  $(".nbw-after").css( { display: "block" } );

  $(".nbw-after").click(function() {

	if ( menu_zichtbaar == 1 ) {
      $(".menu-main div").fadeOut("fast");
	  menu_zichtbaar = 0;
	  $(".nbw-after").html("subnavigatie tonen");
	  
	  statusMenu("0");
	  
	}
	else {	
      $(".menu-main div").fadeIn("slow");
	  $(".menu-sub div").css( {display: "none" } );
	  menu_zichtbaar = 1;
	  $(".nbw-after").html("subnavigatie verbergen");
	  
	  statusMenu("1");

	}
	
  });


  if ( status_menu == 0 ) {

      $(".menu-main div").css( { display: "none" } );
	  menu_zichtbaar = 0;
	  $(".nbw-after").html("subnavigatie tonen");

  }

});

function showSearch() {
	var containerzoeken = document.createElement("div");
	var zoekformulier = document.createElement("form");
	var zoekterm = document.createElement("input");
	var zoekknop = document.createElement("input");
	var containerzoekresultaten = document.createElement("div");
	containerzoeken.id = "container-zoeken";
	zoekterm.type = "text";
	zoekterm.length = "25";
	zoekterm.id = "zoekennaar";
	zoekterm.name = "zoekennaar";
	zoekterm.style.margin = "1px 1px 0 0";
	zoekformulier.id = "zoek-formulier";
	zoekknop.type = "submit";
	zoekknop.id = "query-zoeken";
	zoekknop.value = "zoek";
	containerzoekresultaten.id = "container-zoekresultaten";
	document.getElementById("placeholder-zoek").appendChild(containerzoeken);
	
	containerzoeken.appendChild(zoekformulier);
	zoekformulier.appendChild(zoekterm);
	zoekformulier.appendChild(zoekknop);
	zoekformulier.appendChild(containerzoekresultaten);
	containerzoeken.style.display = "block";

    zoekformulier.onsubmit = function() {queryTerms(zoekterm.value); return false; };	
}

function queryTerms(term) {
	
  $("#container-zoekresultaten").fadeIn("slow");

  queryBlog(escape(term));
  	  
}

function setCaptchaId(idCaptcha,zout) {
  if (document.getElementById) {
	var formulier = document.getElementById("form-contact");
	var verify_captcha = document.getElementById(zout);
	if (document.getElementsByTagName) {
      var arrA = document.getElementsByTagName("a");
      for (var i=0; i<arrA.length; i++) {
		if (arrA[i].className == "a-captcha") {
          document.getElementById(arrA[i].id).style.background = "transparent";
		}
      }
    }
	
	document.getElementById(idCaptcha).style.background = "#ebebbe";
    verify_captcha.value = idCaptcha;
  }
	
}

function statusMenu(status) {

  $.ajax({
    type: "GET",
    url: "http://www.nullbeta.net/wp-content/themes/nbw/sesvars.php",
    cache: false,
    dataType: "text",
    data: "actie_menu="+status,
    success: function(text) {			
			
    }
		  
  });
	
		
}

function queryBlog(term) {

        $.ajax({
          type: "GET",
          url: "http://www.nullbeta.net/wp-content/themes/nbw/async-searchblog.php",
          cache: false,
          dataType: "text",
          data: "term="+term,
          success: function(text) {
			  
			var btn_sluit_zoek = "<div id=\"\"><img id=\"btn-sluit-zoek\" src=\"/img/stijlen/ico/ico-sluit.gif\" /></div>";  
            var zoekresultaten = text;

			var output = btn_sluit_zoek + zoekresultaten;
            $("#container-zoekresultaten").html(output);
			$("#btn-sluit-zoek").css( { cursor: "pointer", paddingTop: "5px", paddingRight: "10px", float: "right" } );
			$("#btn-sluit-zoek").click(function() {
		      $("#container-zoekresultaten").fadeOut("fast");									
			});
			
			
          }
		  
        });
	
		
}
