/**
 * common theme behaviours
 * 
 */
 
function getParameterByName(name)
{
  name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
  var regexS = "[\\?&]" + name + "=([^&#]*)";
  var regex = new RegExp(regexS);
  var results = regex.exec(window.location.href);
  if(results == null)
    return "";
  else
    return decodeURIComponent(results[1].replace(/\+/g, " "));
}

 
jQuery(document).ready(function($){
	$("*").removeClass("marinelli-hide-no-js"); // remove the hide class (see common.css)
	
	if($('#block-block-16').length){
		$('.webform-client-form .form-submit').removeAttr('value');
		$('.webform-client-form .form-submit').width($('#block-block-16 form input.button').width()+16);
		$('.webform-client-form .form-submit').css('padding-left', $('#block-block-16 form input.button').css('padding-left')); 
	}
	
	if($('#block-block-25').length){
		$('.webform-client-form .form-submit').removeAttr('value');
		$('.webform-client-form .form-submit').width($('#block-block-25 form input.button').width()+16);
		$('.webform-client-form .form-submit').css('padding-left', $('#block-block-25 form input.button').css('padding-left')); 	
	}	
	
	if($('#block-block-26').length){
		$('.webform-client-form .form-submit').removeAttr('value');
		$('.webform-client-form .form-submit').width($('#block-block-26 form input.button').width()+16);
		$('.webform-client-form .form-submit').css('padding-left', $('#block-block-26 form input.button').css('padding-left')); 	
	}
	
	if($('#block-block-27').length){
		$('.webform-client-form .form-submit').removeAttr('value');
		$('.webform-client-form .form-submit').width($('#block-block-27 form input.button').width()+16);
		$('.webform-client-form .form-submit').css('padding-left', $('#block-block-27 form input.button').css('padding-left')); 	
	}	
	

	
	
	var startdatum = getParameterByName('startdatum');
	var einddatum = getParameterByName('einddatum');
	$('#ctl00_secure_inhoud_txtAankomst').ready(function() {
		$('#ctl00_secure_inhoud_txtAankomst').val(startdatum);
	});
	$('#ctl00_secure_inhoud_txtVertrek').ready(function() {	
		$('#ctl00_secure_inhoud_txtVertrek').val(einddatum);
	});
	
	$('.node-guest-book .page-previous').html('<<< previous');
	$('.node-guest-book .page-next').html('next >>>');
	
	
	$('.book-navigation').clone().prependTo($('#content'));
	
	
});;
/**
 * Top region js
 * bartext and bartext2 come from theme settings through template.php
 */
jQuery(document).ready(function($) {

  	// Hide region (don't hide in the demo block page)
	if(!Drupal.settings.marinelli.blockdemo){
		$('#topBar').hide();
	}
	
	// set the right text in the blcok demo page
	if(Drupal.settings.marinelli.blockdemo){
		$('#topBarLink a').text("↑ " + Drupal.settings.marinelli.bartext2 + "");
	}
	
	// Make the spy effect
	$('#topBarLink a').live('mouseover mouseout', function(event) {
    if (event.type == 'mouseover' && $(this).text() == "↓ " + Drupal.settings.marinelli.bartext + "") {
      $('#topBarLink').animate({
        'padding-top':'5px'
      });
    }
    else if (event.type == 'mouseout' && $(this).text() == "↓ " + Drupal.settings.marinelli.bartext + "") {
    $('#topBarLink').animate({
      'padding-top':'0px'
    });
    }
	});
  
	// Click logics
	$('#topBarLink a').click(function () {
    if ($(this).text()=="↓ " + Drupal.settings.marinelli.bartext + "") {
      $(this).text("↑ " + Drupal.settings.marinelli.bartext2 + "");
      $(this).attr('title','Close this region');
    }
    else if ($(this).text()=="↑ " + Drupal.settings.marinelli.bartext2 + "") {
      $(this).text("↓ " + Drupal.settings.marinelli.bartext + "");
      $(this).attr('title','Open this region');
    }
    $('#topBar').slideToggle("slow");
    return false;
  });

	// Link positioning
	var linkWidth = $('#topBarLink a').width();
	var windowWidth = $(window).width();

  	// Set start margin
	$('#topBarLink a').css('margin-left', ((windowWidth / 2) - (linkWidth / 2) -10) + 'px');

	$(window).bind('resize', function(event) {
		$('#topBarLink a').css('margin-left', (($(window).width() / 2) - (linkWidth / 2) - 10) + 'px');
	});

});;
/**
 * jQuery.ajax mid - CROSS DOMAIN AJAX 
 * ---
 * @author James Padolsey (http://james.padolsey.com)
 * @version 0.11
 * @updated 12-JAN-10
 * ---
 * Note: Read the README!
 * ---
 * @info http://james.padolsey.com/javascript/cross-domain-requests-with-jquery/
 */

jQuery.ajax = (function(_ajax){
    
    var protocol = location.protocol,
        hostname = location.hostname,
        exRegex = RegExp(protocol + '//' + hostname),
        YQL = 'http' + (/^https/.test(protocol)?'s':'') + '://query.yahooapis.com/v1/public/yql?callback=?',
        query = 'select * from html where url="{URL}" and xpath="*"';
    
    function isExternal(url) {
        return !exRegex.test(url) && /:\/\//.test(url);
    }
    
    return function(o) {
        
        var url = o.url;
        
        if ( /get/i.test(o.type) && !/json/i.test(o.dataType) && isExternal(url) ) {
            
            // Manipulate options so that JSONP-x request is made to YQL
            
            o.url = YQL;
            o.dataType = 'json';
            
            o.data = {
                q: query.replace(
                    '{URL}',
                    url + (o.data ?
                        (/\?/.test(url) ? '&' : '?') + jQuery.param(o.data)
                    : '')
                ),
                format: 'xml'
            };
            
            // Since it's a JSONP request
            // complete === success
            if (!o.success && o.complete) {
                o.success = o.complete;
                delete o.complete;
            }
            
			
				o.success = (function(_success){
					return function(data) {
						
						if (_success) {
												
								// Fake XHR callback.
								_success.call(this, {
									responseText: data.results[0]
										// YQL screws with <script>s
										// Get rid of them
										.replace(/<script[^>]+?\/>|<script(.|\s)*?\/script>/gi, '')
								}, 'success');
							
						}
						
					};
				})(o.success);
				
            
        }
        
        return _ajax.apply(this, arguments);
        
    };
    
})(jQuery.ajax);;

