$h=0;

(function($)
{
    $.fn.emptyText = function(txt)
    {
        var defClass = arguments[1];
        if (defClass) $(this).addClass(defClass);

        $(this).val(txt);

        $(this).focus(function()
        {
            if ($(this).val() == txt)
            {
                if (defClass) $(this).removeClass(defClass);
                $(this).val("");
            }
        });
        $(this).blur(function()
        {
            if ($(this).val().trim() == "")
            {
                if (defClass) $(this).addClass(defClass);
                $(this).val(txt);
            }
        });
    };
})(jQuery);  


(function($) {
  // plugin definition
  $.fn.bigTarget = function(options) {
    debug(this);
    // build main options before element iteration
    var opts = $.extend({}, $.fn.bigTarget.defaults, options);
    // iterate and reformat each matched element
    return this.each(function() {
      // set the anchor attributes
      var $a = $(this);
      var href = $a.attr('href');
      var title = $a.attr('title');
      // build element specific options
      var o = $.meta ? $.extend({}, opts, $a.data()) : opts;
      // update element styles
      $a.parents(o.clickZone)
        .hover(function() {
          $h = $(this);
          $h.addClass(o.hoverClass);
          if(typeof o.title != 'undefined' && o.title === true && title != '') {
            $h.attr('title',title);
          }
        }, function() {
          
          $h.removeClass(o.hoverClass);
          if(typeof o.title != 'undefined' && o.title === true && title != '') {
            $h.removeAttr('title');
          }
        })
        // click
        .click(function() {
          if(getSelectedText() == "")
          {
            if($a.is('[rel*=external]')){
              window.open(href);
              return false;
            }
            else {
              //$a.click(); $a.trigger('click');
              window.location = href;
            }
          }
        });
    });
  };
  // private function for debugging
  function debug($obj) {
    if (window.console && window.console.log)
    window.console.log('bigTarget selection count: ' + $obj.size());
  };
  // get selected text
  function getSelectedText(){
    if(window.getSelection){
      return window.getSelection().toString();
    }
    else if(document.getSelection){
      return document.getSelection();
    }
    else if(document.selection){
      return document.selection.createRange().text;
    }
  };
  // plugin defaults
  $.fn.bigTarget.defaults = {
    hoverClass  : 'hover',
    clickZone : 'li:eq(0)',
    title   : true
  };
// end of closure
})(jQuery);

function remember( selector ){
$(selector).each(
function(){
//if this item has been cookied, restore it
var name = $(this).attr('name');
if( $.cookie( name ) ){
$(this).val( $.cookie(name) );
}
//assign a change function to the item to cookie it
$(this).change(
function(){
$.cookie(name, $(this).val(), { path: '/', expires: 365 });
}
);
}
);
}

this.tooltip = function(){	
	/* CONFIG */		
		xOffset = 10;
		yOffset = 20;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	$("a.tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    },
	function(){
		this.title = this.t;		
		$("#tooltip").remove();
    });	
	$("a.tooltip").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};


$(document).ready(function() {   

 if($('#bdy ul').hasClass("bbox") == false){
    $("#bdy ul").addClass("bbox");
 }



$('.foot_left').click(function(){
  window.location = 'http://www.sgbo.nl/smartsite.dws?id=4202';
}); 

// $('#content').hide();
$('#submenu1, #keurmerk').hide();

$('#it4214, #it4385').click(function() {	
	$('#submenu1').fadeIn('slow');
                         clearTimeout(); 
                         setTimeout(function()
                         {
                        $('#submenu1').fadeOut('slow');
                         }, 7000); 
	return false;
  });


var fadeDuration = 200; //time in milliseconds
      
    $('.box li a').hover(function() {
        $(this).animate({ paddingLeft: '25px' }, fadeDuration)
        .animate({ paddingLeft: '25px' }, 200 );
      }, function() {
        $(this).animate({ paddingLeft: '20px' }, fadeDuration);
      });


$("div.mask a, div.hm_bottom_left a").bigTarget({
 hoverClass: 'over', 
 clickZone : 'div:eq(0)'
}); 

$('#slider').bxSlider({
		alignment: 'horizontal',        // 'horizontal', 'vertical' - direction in which slides will move
		controls: false,                 // determines if default 'next'/'prev' controls are displayed
		speed: 1200,                     // amount of time slide transition lasts (in milliseconds)
		pager: true,                    // determines if a numeric pager is displayed (1 2 3 4...)
		pager_short: false,             // determines if a 'short' numeric pager is displayed (1/4)
		pager_short_separator: ' / ',   // text to be used to separate the short pager
		margin: 0,                      // if 'horizontal', applies a right margin to each slide, if 'vertical' a
		                                // bottom margin is applied. example: margin: 50
		next_text: 'vorige',              // text to be displayed for the 'next' control
		next_image: '[item]=5094',                 // image to be used for the 'next' control
		prev_text: 'volgende',              // text to be displayed for the 'prev' control
		prev_image: '[item]=5093',                 // image to be used for the 'prev' control
		auto: true,                    // determines if slides will move automatically
		pause: 9500,                    // time between each slide transition (auto mode only) 
		auto_direction: 'next',         // order in which slides will transition (auto mode only)
		auto_hover: true,               // determines if slideshow will pause while mouse is hovering over slideshow
		auto_controls: true,           // determines if 'start'/'stop' controls are displayed (auto mode only)
		ticker: false,                  // determines if slideshow will behave as a constant ticker
		ticker_controls: false,         // determines if 'start'/'stop' ticker controls are displayed (ticker mode only)
		ticker_direction: 'next',       // order in which slides will transition (ticker mode only)
		ticker_hover: true,             // determines if slideshow will pause while mouse is hovering over slideshow
		stop_text: 'stop',              // text to be displayed for the 'stop' control
		start_text: 'start',            // text to be displayed for the 'start' control
		wrapper_class: 'bxslider_wrap'  // class name to be used for the outer wrapper of the slideshow
	});





$('.resizeme').click(function(){
			var ourText = $('p');
			var currFontSize = ourText.css('fontSize');
			var finalNum = parseFloat(currFontSize, 10);
			var stringEnding = currFontSize.slice(-2);
			if(this.id == 'large') {
				finalNum *= 1.2;
			}
			else if (this.id == 'small'){
				finalNum /=1.2;
			}
			ourText.css('fontSize', finalNum + stringEnding);
		});

$("dl, .etal, #fog").click(function() {window.location = $('a:first', this).attr('href');}); 


$(".g1, .g2, .g3, .g4").hover(function () {
	$(this).stop().animate({
	opacity: 0.8
	}, "slow");
	},
	function () {
	$(this).stop().animate({
	opacity: 1.0
	}, "slow");
	});

$("div.newsitem a").bigTarget({
 hoverClass: 'gotnews', 
 clickZone : 'div:eq(0)'
}); 


$('.newsitem p').hover(function() {
$(this).addClass('lightup');
}, function() {
$(this).removeClass('lightup');
return false; 
});

$("#launch").change(function(){
document.location.href = $(this).children("option:selected").attr("value");
});

  $(".rounded").load(function() {
    $(this).wrap(function(){
      return '<span class="' + $(this).attr('class') + '" style="background:url(' + $(this).attr('src') + ') no-repeat center center; width: ' + $(this).width() + 'px; height: ' + $(this).height() + 'px;" />';
    });
    $(this).css("opacity","0");
  });

tooltip();

$("#address").css("text-shadow","#3B1F3F 1px 1px 1px");


$('#address').hover(function() {
$(this).css("color","#F9CFFF");
$("#address").css("text-shadow","#2C172F 1px 1px 1px");
}, function() {
$(this).css("color","#FFFFFF");
$("#address").css("text-shadow","#3B1F3F 1px 1px 1px");

return false;
});


$('#keurmerk').fadeTo(2500,1,function(){
$('#keurmerk').fadeIn("slow");
});


// $('#content').fadeIn("fast");

remember( '[name=tbxEmail]' );
remember( '[name=userName]' );
remember( '[name=tbxPassword]' );
remember( '[name=password]' );

});


$(window).load(function(){
$.geekGaTrackPage('UA-17480349-1');	
})



// Window load event used just in case window height is dependant upon images
$(window).bind("load", function() { 

 var footerHeight = 0,
 footerTop = 0,
 $footer = $("#bottomnav");

 positionFooter();

 function positionFooter() {

 footerHeight = $footer.height();
 footerTop = ($(window).scrollTop()+$(window).height()-footerHeight)+"px";

 if ( ($(document.body).height()+footerHeight) < $(window).height()) {
 $footer.css({
 position: "absolute"
 }).animate({
 top: footerTop
 })
 } else {
 $footer.css({
 position: "static"
 })
 }

 }

 $(window)
 .scroll(positionFooter)
 .resize(positionFooter)

});
