jQuery(document).ready(function($) {
	$('#slide').cycle({
		//fx:'scrollHorz',
		fx:'scrollLeft',
		speed: 200,
		timeout: 0,
		delay: -3000,
		prev:    '#prev', 
	        next:    '#next',
        	after: onBefore,
		cleartype:1
	});

	//$('#slide').cycle(3);
	
	var a = $('a.slider_button');

	for(i=0;i<a.length;i++)
	{
		$(a[i]).bind('click',function(){
			var id = parseInt($(this).attr('rel'));
			$('#slide').cycle(id);
			return false;
		});
	}
	
	$('#lastnewslist').cycle({
		fx:'scrollVert',
		speed: 300,
		timeout: 5000,
		delay: -1000
	});
	
	$('#send').bind('click',function(){
		var opt1 = $('#opt1').val();
		var opt3 = $('#opt3').val();
		if(!opt1.match(/.+/) || !opt3.match(/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/))
		{
			
			$('#send').val('Try again');
			setTimeout(function(){ $('#send').val('Submit');},2000);
			return false;
		}
	
		$('#contact_form').attr('action',$('#fac').html());
		$('#fac').html('/non/existent');
		$('#send').attr('disabled','disabled');
	});



});

onBefore = function(curr,next,opts,fwd)
{
	var a = $('a.slider_button');
	for(i=0;i<a.length;i++)
	{
		$(a[i]).removeClass('active');
	}
	for(i=0;i<a.length;i++)
	{
		if($(a[i]).attr('rel') == opts.currSlide)
		{
			$(a[i]).addClass('active');
		}
	}
}


try {
stepcarousel.setup({
	prefix: _base_url,
	galleryid		: 'mygallery', //id of carousel DIV
	beltclass		: 'belt', //class of inner "belt" DIV containing all the panel DIVs
	panelclass		: 'panel', //class of panel DIVs each holding content
	autostep		: {enable:false, moveby:1, pause:3000},
	panelbehavior	: {speed:500, wraparound:false, persist:true},
	defaultbuttons	: {enable: true, moveby: 1, leftnav: ['images/arrow_prev.gif', -5, 90], rightnav: ['images/arrow_next.gif', -20, 90]},
	statusvars		: ['statusA', 'statusB', 'statusC'], //register 3 variables that contain current panel (start), current panel (last), and total panels
	contenttype		: ['inline'] //content setting ['inline'] or ['external', 'path_to_external_file']
});
} catch(e) { }
