/*************************
 * - www.ucreation.nl    *
 *************************
 Dit document bevat JavaScript/jQuery codering. 
 */
 
function isIE()
{
	return /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent);
}

function isMac()
{
	if(navigator.userAgent.indexOf('Mac') != -1)
	{
		return true;
	} else
	{
		return false;
	}
}

function createshadow(element)
{
	$(element).each(function()
	{
		var width = '';
		if($(this).css('width'))
		{
			width = 'width: ' + $(this).css('width') + ';';
		}
		var height = '';
		if($(this).css('height'))
		{
			height = 'height: ' + $(this).css('height') + ';';
		}
		var padding = '';
		if($(this).css('padding'))
		{
			padding = 'padding: ' + $(this).css('padding') + ';';
		}
		var paddingtop = '';
		if($(this).css('padding-top'))
		{
			paddingtop = 'padding-top: ' + $(this).css('padding-top') + ';';
		}
		$(this).html('<span class="text" style="' + width + '' + height + '' + padding + '' + paddingtop + '">' + $(this).html() + '</span>' + $(this).html() + '').addClass('shadow');
	});
}

function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

// Cufon
Cufon.replace('#offers .offertext', { fontFamily: 'Helvetica' });
Cufon.replace('#content .title', { fontFamily: 'Helvetica' });
Cufon.replace('#content .subtitle', { fontFamily: 'Helvetica' });

// jQuery document ready
$(document).ready(function()
{
	if(!isIE())
	{
		// Shaduws
		createshadow('.clientlogin a');
		createshadow('.language .row');
		createshadow('#footer h3');
		createshadow('.buttonset a');
		createshadow('.morebutton.green');
	}
/*	
	// Client login box
	$('.clientlogin a').removeAttr('href');
	$('.clientlogin a').click(function()
	{
		if(!$('#top .box').is('.open'))
		{
			$('#top .box').animate({
				top: 0
			}, 350, function()
			{
				$('#top .box').addClass('open');
			});
		} else
		{
			$('#top .box').animate({
				top: '-125px'
			}, 350, function()
			{
				$('#top .box').removeClass('open');
			});
		}
	});
*/

		
	// Navigation arrow
	$('#navigation li.selected a').each(function()
	{
		$('<div></div>').addClass('arrow').appendTo(this);
	});
	
	// jCarousel
	$('#carousel').jcarousel({
        auto: 6,
        wrap: 'last',
        initCallback: mycarousel_initCallback,
		buttonNextHTML: false,
		buttonPrevHTML: false,
		visible: 1,
		scroll: 1,
		animation: 1200
	});
	
	// Selectbox
	if($('.form .select select').is(':visible'))
	{	
		$('.form .select select').selectbox({debug: true});
	}
	if($('td.checkbox').is(':visible'))
	{
		var i = 0;
		// Checkbox
		$('.form td.checkbox input, .loginbox td.checkbox input').each(function()
		{
			i++;
			$(this).attr({'id' : 'checkbox' + i + ''}).hide();
			if($(this).is(':checked'))
			{
				$('<div class="customcheckbox"></div>').attr({'rel' : i}).addClass('checked').insertAfter(this);
			} else
			{
				$('<div class="customcheckbox"></div>').attr({'rel' : i}).insertAfter(this);
			}
		});
		
		// Checkbox
		$('.customcheckbox').click(function()
		{
			if($(this).is('.checked'))
			{
				$('#checkbox' + $(this).attr('rel') + '').removeAttr('checked');
				$(this).removeClass('checked')
			} else
			{
				$('#checkbox' + $(this).attr('rel') + '').attr({'checked' : 'checked'});
				$(this).addClass('checked')
			}
		});
	}
	
	// Tabbox
	if($('.tablinks').is(':visible'))
	{
		$('.tablinks li a').removeAttr('href');
		$('.tabblad').hide().removeClass('hide');
		if($('.tablinks li.selected').is(':visible'))
		{
			$('#box' + $('.tablinks li.selected').attr('id') + '').show();
		} else
		{
			$('.tablinks li:first').addClass('selected');
			$('.tabblad:first').show();
		}
		$('.tablinks li').click(function()
		{
			$('.tablinks li').removeClass('selected');
			$(this).addClass('selected');
			$('.tabblad').hide();
			$('#box' + $('.tablinks li.selected').attr('id') + '').show();
		});
	}
	
	if(isMac())
	{
		$('#container').addClass('applefix');
	}
});
