var popupWinzindex = 4000;

$(document).ready(function(){  
     $(" #nav ul ").css({display: "none"}); // Opera Fix
	 $(" #nav li").hover(function(){	 	
		$(this).addClass("activeMenuItem").find('ul:first').slideDown(300);
		$(this).find('ul:first').slideDown(300);
		},function(){
			if ($(this).find('ul:first').length > 0) {
				//$(this).find('ul:first').slideUp(300);
				$(this).find('ul:first').slideUp(300,function(){
					$(this).parent().removeClass("activeMenuItem");
					});
			} else {
				$(this).removeClass("activeMenuItem");
			}
			
		}); 
		
			
		
	$("#rollImgContainer").cycle({
		fx:      'turnLeft',
		delay:   -4000
	});
	$("#rollTxtContainer").cycle({
		fx:      'turnRight',
		delay:   -4000
	});
	$("#headerImgContainer").cycle({
		fx:      'fade',
		speed:   600,
		timeout: 3000
	});
	$(".rectangle").dropShadow({
		left: 2,
		top: 2	
	});
	
	$(".scroll-content").jScrollPane({
		scrollbarWidth: 3,
		scrollbarMargin:0
	});
	$(".scroll-content2").jScrollPane({
		scrollbarWidth: 5
	});
	
	$(".headlines_container").hover(function(){
	   $(this).css({"background-color":"#99FFFF"});
	},function(){
	   $(this).css({"background":"none"});	 
	});
	$(".headline_date,.infoText h2,.headline_text").hover(function(){
	   $(this).parent().parent().css({"background-color":"#99FFFF"});
	},function(){
	   $(this).parent().parent().css({"background":"none"});	 
	});
	$(".rectangle,.infoImage").hover(function(){
	   $(this).parent().css({"background-color":"#99FFFF"});
	},function(){
	   $(this).parent().css({"background":"none"});	 
	});
	/*$("#leftMenu li").hover(function(){
		$(this).find('ul:first').slideDown(200);
		},function(){
		$(this).find('ul:first').slideUp(200);
	}); 
	$("#leftMenu a").click(function(){
		return false;
		});*/
	
  $('#leftMenu ul').hide();
  $('#leftMenu .first').click(
    function() {
        $('#leftMenu li ul').hide();	
        $(this).parent().find('ul:first').slideToggle('normal');	
      });
  
  
  $("img.rollover").hover(function(){
				this.src = this.src.replace("_off","_on");
			},function(){
				this.src = this.src.replace("_on","_off");
			}
   );	

   $(".menu a").each(function(){
    var loc = window.location +'';
    loc = loc.toLowerCase();
        if ($(this).attr('href').toLowerCase() == loc){
            $(this).addClass('current');
            $(this).parent().find("ul:first").show();
            if ($(this).parent().parent().css('display') == 'none') {
                $(this).parent().parent().css({'display':'block'});
            }
            return;
        }
   });
   
   $(".time").jclock();
   
   $('a[@rel*=lightbox]').lightBox();
		
}); 

$.preload(".rollover");

/*function popupWindow(winName,objId,speed,titleText,top,left,width,height){
    var content = $("#"+objId).html();
    openPopupWindow(winName,content,speed,titleText,top,left,width,height)
}

function popupWindowAjax(winName,pageUrl,speed,titleText,top,left,width,height){
    var content = $.ajax({url: pageUrl,async: false}).responseText;
    openPopupWindow(winName,content,speed,titleText,top,left,width,height);
} 

function popupWindowIframe(winName,pageUrl,speed,titleText,top,left,width,height){
    var iframeHeight = height.replace('px','') *1 - 40;
    var content = "<iframe src='"+pageUrl+"' width='100%' height='"+iframeHeight+"' frameborder='0' allowTransparency='true'></iframe>";
    openPopupWindow(winName,content,speed,titleText,top,left,width,height);
} 

function openPopupWindow(winName,content,speed,titleText,valTop,valLeft,valWidth,valHeight){
    if($('#'+winName).length > 0){
		$('#'+winName).remove();
	}
    $('body').append('<div id="'+winName+'" class="popupWindowContainer"><div class="titleBar"><span class="titleText">'+titleText+'</span><span class="closeWindow">[x]</span></div><div class="contentArea"></div></div>');
    
       popupWinzindex++;
       $("#"+winName).css({top:valTop,left:valLeft,width:valWidth,height:valHeight,'z-index':popupWinzindex}).show(speed);
       //$(".popupWindowContainer").bgiframe();
       $("#"+winName+" .contentArea").html(content);
       $("#"+winName+" .contentArea").mousedown(function(){
           popupWinzindex++;
           $(this).parent().css('z-index',popupWinzindex);
           });
       $(".titleBar").mousedown(function(){
           popupWinzindex++;
            $(this).parent().draggable().css('z-index',popupWinzindex);
       }).mouseup(function(){
            $(this).parent().draggable('destroy');
       });
       
       $(".closeWindow").click(function(){
           $(this).parent().parent().hide(speed,function(){$(this).remove()});
       });
}*/

function saveTestimonial(form){ 
    for (var i=0; i < form.length; i++) {
        if (!form[i].value) { 
            alert('Geef alle waarden'); 
            return false; 
        } 
    }
       
    $.ajax({
           type: 'POST',
           url: 'modules/testimonials/add.php',
           data: 'autor='+form.autor.value+'&text='+form.text.value+'&save=1',
           success: function(msg){
			   if (msg) {
	             alert( "Verzenden");
			   }
           }
    });
}

function saveQuestion(form){ 
    for (var i=0; i < form.length; i++) {
        if (!form[i].value) { 
            alert('Geef alle waarden'); 
            return false; 
        } 
    }   
    $.ajax({
           type: 'POST',
           url: 'modules/questions/add.php',
           data: 'name='+form.autor.value+'&text='+form.text.value+'&email='+form.email.value+'&save=1',
           success: function(msg){
			   if (msg) {
	             //alert( "Verzenden");
	             alert(msg);
			   }
           }
    });
}
