

	var oTrefnetTV      = {} ;
	oTrefnetTV.amount   = 4 ;
	oTrefnetTV.count    = 0 ;
	oTrefnetTV.fadeTime = 300 ;
	oTrefnetTV.baseurl    = '/websites-portfolio' ;
	
	
	oTrefnetTV.init = function()
	{
		oTrefnetTV.amount = $( 'div.trefnettv_movie img' ).length ;
		if( !oTrefnetTV.amount )
			return false ;
		
		$( 'div.innerbodywrapper div.payoffbar div.trefnettv div.trefnettv_movie' ).css( 'width', oTrefnetTV.amount * 299 ) ;
		$( 'a.back' ).click( function(){ oMover.stop() ; oTrefnetTV.back() ; return false ; }) ;
		$( 'a.forw' ).click( function(){ oMover.stop() ; oTrefnetTV.forward() ; return false ;  }) ;
		$( 'a#movie_clicktarget' ).mouseenter( oTrefnetTV.enter ) ;
		$( 'a#movie_clicktarget' ).mouseleave( oTrefnetTV.leave ) ;
		oTrefnetTV.baseurl = $( 'a#movie_clicktarget' ).attr( 'href' ) ;
		oTrefnetTV.setText() ;
	} ;
	
	
	oTrefnetTV.enter = function()
	{
		if( oTrefnetTV.count == 0 )
		{
			$( 'a#movie_clicktarget' ).click( function(){ oMover.next() ;  return false ; } ) ;
		}
		else
		{
			$( 'a#movie_clicktarget' ).css( 'background', 'url(http://www.trefnet.nl/image/layout/bck_tvrollover.png) no-repeat center' ) ;
			$( 'a#movie_clicktarget' ).unbind( 'click' ) ;
		}
 
	} ;
	
	oTrefnetTV.leave = function()
	{
		$( 'a#movie_clicktarget' ).css( 'background', 'none' ) ;
	} ;
	
	oTrefnetTV.forward = function()
	{
		oTrefnetTV.count++ ;
		if( oTrefnetTV.count > (oTrefnetTV.amount -1) )
		{
			oTrefnetTV.count = 0 ; 
			$( 'div.trefnettv_movie' ).animate( { marginLeft : -299 } , oTrefnetTV.fadeTime ) ;
		}
		else
		{
			$( 'div.trefnettv_movie' ).animate( { marginLeft : -( oTrefnetTV.count * 299 ) }, oTrefnetTV.fadeTime ) ;
		}
		setTimeout( 'oTrefnetTV.setText()', oTrefnetTV.fadeTime )  ;
		return false ;
		
	} ;
	
	oTrefnetTV.back = function()
	{
		oTrefnetTV.count-- ;
		if( oTrefnetTV.count < 1 )
		{
			oTrefnetTV.count = oTrefnetTV.amount - 1 ; 
			$( 'div.trefnettv_movie' ).animate( { marginLeft : -( oTrefnetTV.count * 299 ) }, oTrefnetTV.fadeTime ) ;
		}
		else
		{
			$( 'div.trefnettv_movie' ).animate( { marginLeft : -( oTrefnetTV.count * 299 ) }, oTrefnetTV.fadeTime ) ;
		}
		setTimeout( 'oTrefnetTV.setText()', oTrefnetTV.fadeTime )  ;
		return false ;
	} ;
	 
	
	oTrefnetTV.setText = function() 
	{
		var sText = $( 'div.trefnettv_movie img' ).slice( oTrefnetTV.count, oTrefnetTV.count+1 ).attr( 'alt' ) ;
		var sLink = $( 'div.trefnettv_movie img' ).slice( oTrefnetTV.count, oTrefnetTV.count+1 ).attr( 'id' ) ;
		$( 'div.slidetitle' ).html( sText ) ;
		if( sText.length > 31 )
			$( 'div.slidetitle' ).css( 'top', 214 ) ;
		else
			$( 'div.slidetitle' ).css( 'top', 221 ) ;
		
		$( 'a#movie_clicktarget' ).attr( 'href', ( oTrefnetTV.baseurl + '/' + sLink ) ) ;
	} ;
	
	
	var oPortfolioTV      = {} ;
	oPortfolioTV.amount   = 3 ;
	oPortfolioTV.count    = 0 ;
	oPortfolioTV.fadeTime = 300 ;
	oPortfolioTV.baseurl  = '' ;
	
	
	oPortfolioTV.init = function()
	{
		oPortfolioTV.amount = $( 'div.portfolioimages img' ).length ;
		if( !oPortfolioTV.amount )
			return false ;
		
		$( 'div.portfolioimages' ).css( 'width', oPortfolioTV.amount * 372 ) ;
		$( 'a.pback' ).click( oPortfolioTV.back ) ;
		$( 'a.pforw' ).click( oPortfolioTV.forward ) ;
		 
	} ;
	
	
	oPortfolioTV.forward = function()
	{
		oPortfolioTV.count++ ;
		if( oPortfolioTV.count > ( oPortfolioTV.amount -1 ) )
		{
			oPortfolioTV.count = 0 ; 
			$( 'div.portfolioimages' ).animate( { marginLeft : 0 } , oPortfolioTV.fadeTime ) ;
		}
		else
		{
			$( 'div.portfolioimages' ).animate( { marginLeft : -( oPortfolioTV.count * 372 ) }, oPortfolioTV.fadeTime ) ;
		}
		return false ;
	} ;
	
	oPortfolioTV.back = function()
	{
		oPortfolioTV.count-- ;
		if( oPortfolioTV.count < 0 )
		{
			oPortfolioTV.count = oPortfolioTV.amount - 1 ; 
			$( 'div.portfolioimages' ).animate( { marginLeft : -( oPortfolioTV.count * 372 ) }, oPortfolioTV.fadeTime ) ;
		}
		else
		{
			$( 'div.portfolioimages' ).animate( { marginLeft : -( oPortfolioTV.count * 372 ) }, oPortfolioTV.fadeTime ) ;
		}
		return false ;
	} ;
	 
	 
	var oFontSizer = {} ;
	oFontSizer.size = 12 ;
	
	
	oFontSizer.init = function()
	{
		var nFontSizeSaved = Number( $.cookie( 'fontSize'  )  );
		var sInsert = '' ;
		
		sInsert += '<li class="toplink2 padboth" style="margin-top : 10px ;">' ; 
		sInsert += ' <span style="font-size:10px ; cursor:pointer;" id="smaller" title="letters kleiner">A</span> ' ;
		sInsert += ' <span style="font-size:12px ; cursor:pointer;" id="normal"  title="letters normaal">A</span> ' ; 
		sInsert += ' <span style="font-size:14px ; cursor:pointer;" id="larger"  title="letters groter">A</span> ' ;
		sInsert += '</li>' ;
		
		$( 'li#sitemap'   ).after( sInsert ) ;
		$( 'span#smaller' ).click( oFontSizer.smaller ) ;
		$( 'span#normal'  ).click( oFontSizer.normal  ) ;
		$( 'span#larger'  ).click( oFontSizer.bigger  ) ;
		
		if( nFontSizeSaved > 8 )
		{
			$( 'body' ).css( 'fontSize', nFontSizeSaved + 'px' ) ;
			oFontSizer.size = nFontSizeSaved ;
		}
	} ;
	
	oFontSizer.set = function()
	{
		$( 'body' ).css( 'fontSize', oFontSizer.size + 'px' ) ;
	} ;
	

	oFontSizer.smaller = function()
	{
		if( oFontSizer.size > 8 )
		{
			$.cookie( 'fontSize', --oFontSizer.size, { path : '/', expires: 62 }  ) ;
			oFontSizer.set() ;
		}
		return false ;
	} ;

	oFontSizer.bigger = function()
	{
		if( oFontSizer.size < 14)
		{
			$.cookie( 'fontSize', ++oFontSizer.size, { path : '/',  expires: 62 }  ) ;
			oFontSizer.set() ;
		}
		return false ;
	} ;
	
	
	oFontSizer.normal = function()
	{
		oFontSizer.size = 12 ;
 
		$.cookie( 'fontSize', oFontSizer.size, { path : '/',  expires: 62 }  ) ;
		oFontSizer.set() ;
 
		return false ;
	} ;

	
	
	var oContactform = {} ;
	
	oContactform.init = function()
	{
		if( !document.getElementById( 'contactform' ) )
				return false ;
		
		$( "input#contactform_newsletter_check" ).change( oContactform.news ) ;
		$( "input#contactform_phone_check"      ).change( oContactform.phone ) ;
		oContactform.news() ;
		oContactform.phone() ;
		$( 'form#contactform' ).submit( oContactform.submit ) ;
	} ;
	
	oContactform.news = function()
	{
		if( document.getElementById( 'contactform_newsletter_check' ).checked )
			$( 'div.contactform_textfields_email' ).slideDown() ;
		else
			$( 'div.contactform_textfields_email' ).slideUp() ;
	} ;
	
	oContactform.phone = function()
	{
		if( document.getElementById( 'contactform_phone_check' ).checked )
			$( 'div.contactform_textfields_phone' ).slideDown() ;
		else
			$( 'div.contactform_textfields_phone' ).slideUp() ;
	} ;
	
	oContactform.submit = function()
	{
		/* reset stuff */
		$( '#contactnotice' ).html( '' ) ;
		$( '#contacterror' ).html( '' ) ;
		
		/* Go scraping the form */
		var oForm = document.getElementById( 'contactform' ) ;
		var aChildren = oForm.getElementsByTagName( '*' ) ;
		
		var oVars = {} ;
		oVars.collection   = 'contact' ;
		oVars.element      = 'saveContact' ;
	 
		for( var t=0; t<aChildren.length; t++ )
		{
			if( aChildren[t].tagName.toLowerCase() == 'input' )
			{
				switch ( aChildren[t].type )
				{
					case 'text' :
						oVars[aChildren[t].name] = aChildren[t].value ;
						break ;
					case 'checkbox' :
						oVars[aChildren[t].name] = aChildren[t].checked ? 'on' : '' ;
						break ;
					case 'hidden' :
						oVars[aChildren[t].name] = aChildren[t].value ;
						break ;
				}
			}
			if( aChildren[t].tagName.toLowerCase() == 'textarea' )
				oVars[aChildren[t].name] = aChildren[t].value ;
			
			if( aChildren[t].tagName.toLowerCase() == 'select' )
				oVars[aChildren[t].name] = aChildren[t].options[aChildren[t].selectedIndex].value ;
		}
		
		jQuery.post( '/rpc/index.php', oVars, oContactform.callback, 'xml' ) ;
		$( 'img#contactthrobber' ).css( 'display', 'inline' ) ;
		return false ;
	} ;
	
	
	oContactform.callback = function( oData, oTexStatus, XMLhttpRequest )
	{
		var sStatus 	= null ;
		var sMessage 	= null ;
		var sContent 	= null ;
		var sCallback 	= null ;
		
		$( 'img#contactthrobber' ).css( 'display', 'none' ) ;
		
		sStatus = oData.getElementsByTagName( 'status' )[0].childNodes[0].nodeValue ;
		if( oData.getElementsByTagName( 'message' )[0] && oData.getElementsByTagName( 'message' )[0].childNodes[0] )
			sMessage = oData.getElementsByTagName( 'message' )[0].childNodes[0].nodeValue ;

		if( oData.getElementsByTagName( 'content' )[0] && oData.getElementsByTagName( 'content' )[0].childNodes[0] )
			sContent = oData.getElementsByTagName( 'content' )[0].childNodes[0].nodeValue ;	
		
		if( oData.getElementsByTagName( 'callback' )[0] && oData.getElementsByTagName( 'callback' )[0].childNodes[0] )
			sCallback = oData.getElementsByTagName( 'callback' )[0].childNodes[0].nodeValue ;	

		if( sStatus == 'OK' )
		{
			if( sMessage )
				$( '#contactnotice' ).html( sMessage ) ;
			
			$( 'div.contactform_textfields_phone' ).slideUp() ;
			$( 'div.contactform_textfields_email' ).slideUp() ;
			$( "form#contactform input[type='text']" ).val( '' ) ;
			document.getElementById( 'contactform_newsletter_check' ).checked = false ;
			document.getElementById( 'contactform_phone_check' ).checked = false ;
			
			
			
			var pageTracker = _gat._getTracker( gTracker ) ;
			pageTracker._trackPageview( '/virtual/inline-answer-form' );
		}
		else
		{
			if( sMessage )
				$( '#contacterror' ).html( sMessage ) ;
		}
		
		if( sCallback )
			eval( sCallback ) ;	
	} ;
	
 
	var oMover = {} ;
	oMover.timer     = null ;
	oMover.time      = 6000 ;
	oMover.starttime = 6000 ;
	
	oMover.start = function()
	{
		if( $( 'div.trefnettv_movie img' ).length )
			oMover.timer = setTimeout( 'oMover.next()', oMover.starttime ) ;
	} ;
	
	oMover.stop = function()
	{
		clearTimeout( oMover.timer ) ;
	} ;
	
	oMover.next = function()
	{
		clearTimeout( oMover.timer ) ;
		oTrefnetTV.forward() ;
		oMover.timer = setTimeout( 'oMover.next()', oMover.time ) ;
	} ;
	
	
	
	
	
	
	
	$( document ).ready( function()
		{
			oTrefnetTV.init() ;
			oPortfolioTV.init() ;
			oContactform.init() ;
			oFontSizer.init() ;
			oMover.start() ;
		
		});
