$(document).ready(function() {

   //Bind ajaxForm to the FreeForm 
$('#contact-form').ajaxForm(
  {  target:"#hiddenDIV",     //set response to go into hidden div    
  beforeSubmit:function()  //before sending submit, give user notification...
  {
     $("#msg").html("Versturen...");
     $("#msg").css({border:"1px solid #a00", backgroundColor:"#fdd"});
  },
success:function(rtn)
   {
   // the reason why im checking for the word "success" is that I've created an 
   // EE template called "site/success" which just has the word "success" in it, and
   // it is the "return" variable in the exp:FreeForm:Form tag... eg: return="success"
    if(rtn=="success")
    {
      $("#contact-form").resetForm();
      $("#contact-form").hide();
      $("#msg").html("Bedankt voor uw aanvraag. Wij zullen deze zo spoedig mogelijk in behandeling nemen. Mocht u niets van ons vernemen neem dan contact met ons op.");
     }else{
        // there was an error, so grab the UL in the content ID from the ERROR HTML that comes back from EE
        // the reason why it is placed in hiddenDIV is because i set the target of the call to "hiddenDIV"
        // Here, i am grabbing the UL bullet list from the returned HTML content and placing it in my message box
        // then discarding the hiddenDIV since it messes up my main HTML page
      $("#msg").html(  $("#hiddenDIV #content ul").html() );
      $("#hiddenDIV").empty(); 
     }
   }
  }
);

$.fn.colorbox.settings.bgOpacity = "0.9";
$("a[href='http://remo10.default.nh1816.nl/index.php?url=www.gs-assurantien.nl']").colorbox({fixedWidth:"66%", fixedHeight:"66%", iframe:true});
$("a[href='http://www.uitvaartplein.com/Monuta/Comasy/MI.nsf/KMStart?OpenForm&code=4690540&ref=&']").colorbox({fixedWidth:"66%", fixedHeight:"66%", iframe:true});

$('#searchform').hide();

$('#login').hide();

$('#kantoorlogin').click(function() {
   $('#login').slideToggle(500);
   return false;
  });

$('#search').click(function() {
    $('#searchform').slideToggle(500);
     return false;
 });

$('#slideshow').cycle({ 
    fx:    'fade',    speed:  2500,    timeout: 7000  
 });

$('#partners').cycle({ 
    fx:    'fade',    speed:  1000,    timeout: 500  
 });


function initMenus() {
	$('ul.menu ul').hide();
	$.each($('ul.menu'), function(){
		$('#' + this.id + '.expandfirst ul:first').show();
	});

	$.each($('ul.menu ul .active'), function(){
		$('#' + this.id + '.expandfirst ul:first').slideDown("slow");
	});

	$('ul.menu li a').click(
		function() {
			var checkElement = $(this).next();
			var parent = this.parentNode.parentNode.id;

			if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
				if($('#' + parent).hasClass('collapsible')) {
					$('#' + parent + ' ul:visible').slideUp('normal');
				}
				return false;
			}
			if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
				$('#' + parent + ' ul:visible').slideUp('normal');
				checkElement.slideDown('normal');
				return false;
			}
		}
	);
}
$(document).ready(function() {initMenus();});


function initMenus_ext() {
	$('ul.menu_ext ul').hide();
	$.each($('ul.menu_ext'), function(){
		$('#' + this.id + '.expandfirst ul:first').show();
	});
	$('ul.menu_ext li a').click(
		function() {
			var checkElement = $(this).next();
			var parent = this.parentNode.parentNode.id;

			if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
				if($('#' + parent).hasClass('collapsible')) {
					$('#' + parent + ' ul:visible').slideUp('normal');
				}
				return false;
			}
			if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
				$('#' + parent + ' ul:visible').slideUp('normal');
				checkElement.slideDown('normal');
				return false;
			}
		}
	);
}
$(document).ready(function() {initMenus_ext();});

});
