
var lbls = new Array();
	lbls[1] = 'one';
	lbls[2] = 'two';
	lbls[3] = 'thr';
	lbls[4] = 'fou';
var LastChanged = 0;

	function rand(min, max) 
	{
		return max ? min + rand(max - min) : Math.random() * ++min << .5;
	}
	
	function getUr()
	{
		var ur = '&types[1]='+$('div.one img').attr('src').split('/').pop();
			ur += '&types[2]='+$('div.two img').attr('src').split('/').pop();
			ur += '&types[3]='+$('div.thr img').attr('src').split('/').pop();
			ur += '&types[4]='+$('div.fou img').attr('src').split('/').pop();
			
		return ur;
	}
	
	function doImageRandomChange()
	{	
		var f = false;
		while (f == false) {
			var _d = rand(1, 4);
			if (_d != LastChanged) {
				LastChanged = _d;
				_number = _d;
				f = true;
			}
		}
		
		if ($('body#page-home div#local').length) {
			$('body#page-home div#local div.'+lbls[_number]).load('/?module=Home&event=WSrandomImages&type='+_number+getUr());
		}
	}
	
	
$(document).ready(function(){

	if ($('body#page-home div#local').length) {
		setInterval("doImageRandomChange()", 2000);
	}
	
	/**
	 *	Safari specific css
	 */
	if (jQuery.browser.safari == true) {
		$('body#page-home div#local').css('padding-left', '1px');
		$('.colone').css("width", '210px');
		$('.colone').css("padding-left", '5px');
	}
	
	if ($('div#portfolio-images-left').length) {
		$('div#portfolio-images-left').addClass('enlarge');
		
		$('div#portfolio-images-left img').each(function() {
			$(this).after('<img style="border: 0px solid blue; margin-top: -10px;" src="/images/lo/clicktoenlarge.jpg" border="0" height="20" width="198" />');
		});
	}
	
	if ($('.enlarge').length) {
	    if ($('#portfolio-images-left').length) {
	    	$('#portfolio-images-left img').css('cursor', 'pointer');
	    	$('#portfolio-images-left img').click(function() { 
				var url = $('#portfolio-images-left img').attr('src').replace('images/projects/', 'images/projects/fullsize/');
				window.open(url, 1, 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=500');
			});
	    }
		
		if ($('#portfolio-images-right').length) {
	    	$('#portfolio-images-right img').css('cursor', 'pointer');
	    	$('#portfolio-images-right img').click(function() { 
				var url = $('#portfolio-images-right img').attr('src').replace('images/projects/', 'images/projects/fullsize/');
				window.open(url, 1, 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=500');
			});
	    }
	}
	
	if ($('form#contactform').length) {
		$('input#contactsubmit').click(function() {
			if ($("input[name='name']").val().length < 3) {
				alert('Please provide your name');
				return false;
			}
			if ($("input[name='email']").val().length < 3) {
				alert('Please provide an email address');
				return false;
			}
		});
	}
});
