$(document).ready(function(){

	$('.scroll-pane').jScrollPane({
		scrollbarWidth: 13,
		showArrows: true,
		arrowSize: 14
	});

	imgscroller();

	$('.imginner a').after("<a href='' class='blanker'><img src='images/links/blanker.gif' /></a>");
	$('.imginner a.blanker').attr('href', function(){
		return $(this).prev('a').attr('href');
	});
	
	//ajax calls
	$('#leftPage .item a').click(function(){
		var link = $(this).attr('href');
		var res1 = link.split('?');
		var res2 = res1[1].split('&');
		var c_id = res2[0].split('=');
		var p_id = res2[1].split('=');
		var media_type = res2[2].split('=');
		$('#rightPage').empty().html('<div class="loading"><img src="images/loading.gif" alt="loading" /></div>');
		
		setTimeout(function(){
			$('#rightPage').load('http://www.ralphandco.com/www/inc_ourwork.php', {'c_id': c_id[1],'p_id':p_id[1],'media_type':media_type[1]}, function(){
				$('.loading').remove();
				$('.scroll-pane').jScrollPane({
					scrollbarWidth: 13,
					showArrows: true,
					arrowSize: 14
				});
				imgscroller();
			});
		}, 1000);
		return false;	
	});


});


function formHandler(form){
var URL = document.form.site.options[document.form.site.selectedIndex].value;
window.open(URL,"_blank");
}

function imgscroller() {
	$(".imginner").hover(
    	function () {
    		$(this).children('a').cycle({
      			fx:'scrollUp',
      			speed:1,
      			timeout:50});
      	}, 
      	function () {
      		$(this).children('a').cycle('stop');
      	}
	);

	$('.mainimgholder').cycle({
		fx:'scrollUp',
		speed: 1000,
		timeout: 1000,
		fit: true,
		autostop: true
	});

	buttons();

}

function buttons() {	

	$('#play').click(function(){
		$('.mainimgholder').cycle({
			fx:'scrollUp',
			speed: 1000,
			timeout: 1000,
			fit: true,
			autostop: true
		});
		$('#controls a#play').removeClass('on');
		$('#controls a#stop').addClass('on');
		return false;
	});

	$('#stop').click(function(){
		$('.mainimgholder').cycle('stop1');
		$('#controls a#play').addClass('on');
		$('#controls a#stop').removeClass('on');
	    
		return false;
	});

}