var topOverlayInit = "";

//Tabs
$(document).ready(function(){
						  tab("nieuws", "/nieuws");
						  tab("diensten", "/diensten");
						  tab("portfolio", "/portfolio");
						  tab("contact", "/contact");
				  }
				 );
				 
//Second menu
$(document).ready(function(){
						  menu("webhosting");
						  menu("webdesign");
						  menu("internetopslag");
						  menu("fotografie");
				  }
				 );
				 
//Editor 
/*
var $j = jQuery.noConflict();
$j(function() {
    $j(".wymeditor").wymeditor();
});
*/
function tab(tab, url) {
	$("#tab"+ucFirst(tab)).hover(function(){
		topOverlayInit = $("#topOverlay").attr("class");
		$("#topOverlay").attr("class", tab);
	 }
	,function(){
		$("#topOverlay").attr("class", topOverlayInit);
	 }
	);
	
	$("#tab"+ucFirst(tab)).click(function(){
		window.location = url;		  
	 }
	);
}

function menu(item) {
	$("#menu"+ucFirst(item)).click(function(){
		window.location = $("#menu"+ucFirst(item)+" a").attr("href");		  
	 }
	);
}

// convert a string to lowercase with 1st letter capitalised
function ucFirst(s)
{
	var c = s.charAt(0);

	if (parseInt(s.length)==1){
		return c.toUpperCase();
	}
	else
	{
		return c.toUpperCase() + s.slice(1).toLowerCase();
	}
}

//Prettier forms
if( document.addEventListener ) document.addEventListener( 'DOMContentLoaded', cmxform, false );
function cmxform(){
  // Hide forms
  $( 'form' ).hide().end();
  
  // Processing
  $( 'form' ).find( 'li/label' ).not( '.nocmx' ).each( function( i ){
    var labelContent = this.innerHTML;
    var labelWidth = document.defaultView.getComputedStyle( this, '' ).getPropertyValue( 'width' );
    var labelSpan = document.createElement( 'span' );
        labelSpan.style.display = 'block';
        labelSpan.style.width = labelWidth;
        labelSpan.innerHTML = labelContent;
    this.style.display = '-moz-inline-box';
    this.innerHTML = null;
    this.appendChild( labelSpan );
  } ).end();
  
  // Show forms
  $( 'form' ).show().end();
}

// Twitter
$(document).ready(function(){
    getTwitters('tweet', { 
	  id: 'edubits', 
	  count: 3, 
	  enableLinks: true, 
	  ignoreReplies: true, 
	  clearContents: true,
	  template: '%text% <a href="http://twitter.com/%user_screen_name%/statuses/%id%/" class="time">%time%</a>'
	});
});

// Scroller
$(document).ready(function(){
		$("#scrollable").mbScrollable({ 
		width:700, 
		elementsInPage:1, 
		elementMargin:4, 
		shadow:"#999 2px 2px 2px", 
		height:"auto", 
		controls:"#controls", 
		slideTimer:600, 
		autoscroll:false, 
		scrollTimer:2000  
	});
});

// Fancybox
$(document).ready(function() {
	$("a.thickbox").fancybox({ 'zoomSpeedIn': 300, 'zoomSpeedOut': 300, 'overlayShow': false }); 
}); 