$(function()
{
	
	
	// external links
	$('a.external').click(function()
	{
		$(this).attr('target', '_blank');
	});
	
	
	
	
	// latest projects stuff
	var projects = $('.latestProjectPanel');
	
	// var random = Math.ceil(Math.random() * projects.length);
	var random = 8;

	setTimeout("$('.latestProjectPanel:eq(' + (" + random + "-1) + ')').show()", 1200);
	
	// project left
	$('#projectControl_left')
	.mouseover(function()
	{
		$(this).css({'background':'url(/images/common/controllers/projectLeft2.png) no-repeat left top'});
	})
	.mouseout(function()
	{
		$(this).css({'background':'url(/images/common/controllers/projectLeft1.png) no-repeat left top'});
	})
	.click(function()
	{
		var id = $('.latestProjectPanel:visible').attr('id').replace('projectPanel_', '');
		$('#projectPanel_' + id).hide();
		var prev = (id * 1) - 1;
		if ( prev == 0 ) prev = projects.length;
		$('#projectPanel_' + prev).fadeIn();
	});
	
	// project right
	$('#projectControl_right')
	.mouseover(function()
	{
		$(this).css({'background':'url(/images/common/controllers/projectRight2.png) no-repeat left top'});
	})
	.mouseout(function()
	{
		$(this).css({'background':'url(/images/common/controllers/projectRight1.png) no-repeat left top'});
	})
	.click(function()
	{
		var id = $('.latestProjectPanel:visible').attr('id').replace('projectPanel_', '');
		$('#projectPanel_' + id).hide();
		var next = (id * 1) + 1;
		if ( next == projects.length+1 ) next = 1;
		$('#projectPanel_' + next).fadeIn();
	});
	
	
	
	
	
	// portfolio controllage
	var images = $('#portfolioImageWrap img');
	
	if ( images && images.length > 1 )
	{
		// project left
		$('#portfolioControl_left')
		.mouseover(function()
		{
			$(this).css({'background':'url(/images/common/controllers/left2.png) no-repeat left top'});
		})
		.mouseout(function()
		{
			$(this).css({'background':'url(/images/common/controllers/left1.png) no-repeat left top'});
		})
		.click(function()
		{
			var id = $('#portfolioImageWrap img:visible').attr('id').replace('image_', '');
			$('#image_' + id).hide();
			var prev = (id * 1) - 1;
			if ( prev == 0 ) prev = images.length;
			$('#image_' + prev).fadeIn();
		});
	
		// project right
		$('#portfolioControl_right')
		.mouseover(function()
		{
			$(this).css({'background':'url(/images/common/controllers/right2.png) no-repeat left top'});
		})
		.mouseout(function()
		{
			$(this).css({'background':'url(/images/common/controllers/right1.png) no-repeat left top'});
		})
		.click(function()
		{
			var id = $('#portfolioImageWrap img:visible').attr('id').replace('image_', '');
			$('#image_' + id).hide();
			var next = (id * 1) + 1;
			if ( next == images.length+1 ) next = 1;
			$('#image_' + next).fadeIn();
		});
	}
	else
	{
		$('#portfolioControl_left').hide();
		$('#portfolioControl_right').hide();
		
	}
	
	

	
	/*
	function mycarousel_initCallback(carousel)
	{
	    // pause autoscrolling if the user moves with the cursor over the clip.
	    carousel.clip.hover(function() 
	    {
	        carousel.stopAuto();
	    }, function() 
	    {
	        carousel.startAuto();
	    });
	};
	
	$('#happyClientsList').jcarousel(
	{
	    auto: 1000,
	    scroll: 5, 
	    speed: 1000, 
	    wrap: 'last'
	});
	*/
	
	

	$('#happyClients').jCarouselLite(
	{
	    auto: 4000,
	    scroll: 5, 
	    speed: 2000, 
	    circular: true, 
	    visible: 5
	});



	
	
	
	// hosting domain checker - hover row
	$('table.table tr').mouseover(function()
	{
		$(this).addClass('rowHover');
	}).mouseout(function()
	{
		$(this).removeClass('rowHover');
	});
	
	
	
	
	// domain name tld selection - check all
	$('#selectAllDomains').toggle(function()
	{
		$(this).attr('checked', 'checked');
		$('tr.clickCheckbox td input[type=checkbox]').attr('checked', 'checked');
		$('#submitContinueDomains').attr('disabled', false);
	}, 
	function()
	{
		$(this).attr('checked', false);
		$('tr.clickCheckbox td input[type=checkbox]').attr('checked', false);
		$('#submitContinueDomains').attr('disabled', 'disabled');
	});

	
	
	// hosting domain checker - enable continue button when user selected a domain
	$('tr.clickCheckbox td input[type=checkbox]').click(function()
	{
		var c = $('tr.clickCheckbox td input[type=checkbox]');
		for (i=0; i<c.length; i++)
		{
			if ( c[i].checked )
			{
				$('#submitContinueDomains').attr('disabled', false);
				return true;
			}
			else
			{
				$('#submitContinueDomains').attr('disabled', 'disabled');
			}
		}
	});
	
	
	
	
	$('#v_code_why').click(function()
	{
		$('#v_code_why_text').slideDown();
	});
	
	
	
	
	
	
	// ie6
	if ( $.browser.msie && $.browser.version < 7 )
	{
		alert('We have detected that you are using Internet Explorer 6. This web browser, first launched in 2001, \
has very reduced functionality and as a result you will be redirected to our reduced functionality website.\n\n\
For security and increased functionality we strongly recommend you update your web browser with one of the following links:\n\n\
Firefox - www.firefox.com\n\
Opera - www.opera.com/\n\
Safari - www.apple.com/safari/download\n\
');
	}
	
	




	// lightbox stuff for mailer.
	$('#lightbox_Create a').lightBox();
	$('#lightbox_Send a').lightBox();
	$('#lightbox_Report a').lightBox();
	
	
	
		
	
});
