function updateView(pixels)
{
	var pageHeight = $(document).height();
	var pageWidth = $(document).width();
	document.getElementById('container').style.height = (pageHeight - pixels) + 'px';
	var width = pageWidth - 968;
	var zijkanten = width / 2;
	
	
	document.getElementById('footerleft').style.width = zijkanten + 'px';
	document.getElementById('footercenter').style.width = 968 + 'px';
	document.getElementById('footerright').style.width = zijkanten + 'px';
	
	
}	


function setTableWidth()
{
	var pageWidth = $(document).width();
	document.getElementById('tablehome').style.width = pageWidth + 'px';
}
function checkEmpty(vraagval)
{
	var naam 	= false;
	var email 	= false;
	var telnr 	= false;
	var vraag 	= false;
	
	if($('#naam').val() == 'Mijn naam' || $('#naam').val() == '')
		$('#naam').val('')
	else
		naam = true;
	
	if($('#email').val() == 'Mijn email' || $('#email').val() == '')
		$('#email').val('')
	else
		email = true;
	
	if($('#telnr').val() == 'Mijn telefoonnummer' || $('#telnr').val() == '')
		$('#telnr').val('')
	else
		telnr = true;
	
	if($('#vraag').val() == vraagval || $('#vraag').val() == '')
		$('#vraag').val('')	
	else
		vraag = true;
		
	
	  setTimeout( function()
	  {
		  if(!naam)
			  $('#naam').val('Mijn naam');
		  if(!email)
			  $('#email').val('Mijn email')
		  if(!telnr)
			  $('#telnr').val('Mijn telefoonnummer')
		  if(!vraag)
			  $('#vraag').val(vraagval)
			  
	  }, 100);
}

function changeFooter()
{
	var pageHeight = $(document).height();
	var pageWidth = $(document).width();
	var width = pageWidth - 968;
	var zijkanten = width / 2;
	document.getElementById('footerleft').style.width = zijkanten + 'px';
	document.getElementById('footercenter').style.width = 968 + 'px';
	document.getElementById('footerright').style.width = zijkanten + 'px';
}
function ChangeColor(id, color)
{
	document.getElementById(id).style.color = color;
}

function ChangeColorBack(id, color)
{
	document.getElementById(id).style.color = color;
}

function changeHref()
{
	document.getElementById('menu0').href = '#';

	
}

function popitup(url)
{
	newwindow=window.open(url,'name','height=800,width=800,menubar=no,status=no,toolbar=no,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
	return false;
}

function changeValue(name, value){
	if (document.getElementById(name).value == value) {
		document.getElementById(name).value = '';
		document.getElementById(name).style.fontStyle = 'normal';
		document.getElementById(name).style.color = '#000000';
	}
}

$(document).ready(function()
{
	var prevpage = $("#prevpageid").val();
	$(".titletype13").after("<div class='goback'><a class='gobackbutton' href='#' onClick='refreshPage("+prevpage+")'>terug</a></div>");
	$(".titletype12").after("<div class='goback'><a class='gobackbutton' href='/producten/'>terug</a></div>"); 
	$(".contentwrappertype12").after("<span style='position: absolute; ' class='meerzien'>Meer zien?<a  class='gobackbutton' href='/archief/'>bekijk het archief</a></span>"); 
	var pathname = window.location.pathname;
	pathname = pathname.split("/");
	$(".submenutop:last").html(pathname[1].replace("-", " "));
	$("a.leesmeer").html("<img class='leesmeer' src='/images/siteimages/leesmeer.png' onmouseout=\"this.src = '/images/siteimages/leesmeer.png'\" onmouseover=\"this.src ='/images/siteimages/leesmeer_over.png'\" alt='lees meer' />");
	$(".title").html("<br /><img onClick=\"history.back()\" style='cursor: pointer' src='/images/siteimages/terug.png' onmouseout=\"this.src = '/images/siteimages/terug.png'\" onmouseover=\"this.src ='/images/siteimages/terug_over.png'\" alt='lees meer' /><br /><br />ERVARINGEN");
});


function openLinkSelector(id)
{
	$("#" + id + "_popup").slideDown();
	
	$("#" + id + "_popup").focusout(function() {
		alert('test');
	});
}


(function($){
 $.fn.linkSelector = function(options) {

  var defaults = {
   length: 300,
   minTrail: 20
  };
  var options = $.extend(defaults, options);
    
  return this.each(function() {
	  
	  var html = '<div class="detaillink_popup" style="width: 300px; height: 200px; border: 1px solid black; background-color: white; display: none; position: absolute; z-index: 999;">' +
		  		'<div class="links" style="height: 200px; overflow: scroll; "></div>' +
		  		'</div>';
	  var obj = $(this);
	  $(this).append(html);
	  $.ajax({
		 url: path + "verwerking.php?request=Menumodule&cmd=listMenuItems&id=0",	
			success: function(data) {
				$(".links", obj).html(data);		
			}
		}),
	  $("input", obj).focus(function() {
	      
		  $(".detaillink_popup", obj).slideDown();
	      return false;
       }),
       $("a", obj).live('click', function() {
    	   $("input", obj).val($(this).attr("href"));
    	   $(".detaillink_popup", obj).slideUp();
    	   return false;
       }),
       $(this).focusout(function() {
    	   $("#detaillink_popup", obj).focusout(function() {
    		   
    		   alert('ja');
    		   $(".detaillink_popup", obj).slideUp();
    		   
    	   });
    	  
    	   return false;
       });
	  
  });
 };
})(jQuery);

$().ready(function() {  
	$("#detailwrapper").linkSelector();
});

