/* -------------------------------------------------------------- 
  
   Javascripts for 
	 NUO087 - Spaarstroom Eindejaarscampagne
   
-------------------------------------------------------------- */

// Internet Explorer 6 or 7 ?
var ie6 = ($.browser.msie && $.browser.version < 7 ) ? true : false;
var ie7 = ($.browser.msie && $.browser.version == 7 ) ? true : false;

$(document).ready(function() {

/*Formulier op default.aspx?id=2560*/
$('.form').html('<iframe src="http://tools.emailgarage.com/Assets/lLhWTgirjkWq3UAEpL-Xtg~~/inschrijven-dm-nl.html" width="540" height="200" frameborder="0" scrolling="no"></iframe>');
$('.formfr').html('<iframe src="http://tools.emailgarage.com/Assets/lLhWTgirjkWq3UAEpL-Xtg~~/inschrijven-dm-fr.html" width="540" height="200" frameborder="0" scrolling="no"></iframe>');
/*End formulier*/

$('.tabContainer').tabs();

});




// TABS

	jQuery.fn.extend({
		tabs: function() {
			return this.each(function() {
				//
				var contentItems 		 = $('.tabContentItem',$(this));
				var tabItems     		 = $('.tabMenu a',$(this));
				var contentContainer = $('.tabContent');
				var initTab				   = $(contentItems[0]).attr('id');
				var activeTab    		 = '';
				var contentHeight    = 180;
				var activeId;
				// init
				init = function() {
					var hash = window.location.hash.replace('#','');
					contentItems.each( function() {	
						var h = $(this).height();	
						if ( h > contentHeight ) contentHeight = h; // get max content item height		
						if ( $(this).attr('id') == hash ) initTab = hash;	// check if hash corresponds with content item id		
					});		
					//contentContainer.height(contentHeight-50); 
					// click event tab items
					tabItems.each( function() {
						$(this).click(function(e){ 
							//$('.tab-content-item').stop();										 
							var id = $(this).attr('href').replace('#','');
							showTab(id);
							e.preventDefault();
						});												 
					});
					showTab(initTab);
				};
				// show tab
				showTab = function(id) {
					jQuery.fn.tabs.activeId = id;					
					contentItems.each( function(i) {
						if ( $(this).attr('id') == id ) {
							$(this).slideDown(500, function() {
								contentItems.each( function(i) {
									if ( $(this).attr('id') != jQuery.fn.tabs.activeId ) {
										$(this).slideUp(300);
									}
								});
							});
							$(tabItems[i]).addClass('active');
							activeTab = id;
						} else {
							$(this).hide();
							$(tabItems[i]).removeClass('active');
						};
					});
				};
				init();
			});
		}
	});
