window.addEvent('resize', function()
{
	$('modal').setStyle('left', ((window.getScrollWidth()/2)-230)+'px');
});

var imgarr = Array('http://www.cjindustries.com/images/banner2.jpg','http://www.cjindustries.com/images/banner3.jpg','http://www.cjindustries.com/images/banner4.jpg','http://www.cjindustries.com/images/banner5.jpg','http://www.cjindustries.com/images/banner6.jpg');
var banner_num = 1;

window.addEvent('load', function()
{
	new Asset.images(imgarr, {
		onComplete: function(){
		setInterval('changeBanner()', 5000);
		}
	});
});

function changeBanner()
{
	banner_num = (banner_num % 6) + 1;
	$('banner').className = 'b'+banner_num;
}

function getModalContent(content)
{
	new Ajax('/modalcontent.php', {method: 'post', data: 'type='+content, update: $('modal'), evalScripts: true, 
	onComplete:function()
	{
		overlayOn();
	}
	}).request();
}

function overlayOn()
{
	$('modal').setStyle('left', ((window.getScrollWidth()/2)-230)+'px');
	
	$('overlay').effect('opacity', {duration: 150, 
	onStart: function()
	{
		$('overlay').setStyle('height', window.getScrollHeight()+'px'); 
		$('modal').setStyles({top: '-600px', visibility: 'visible'});
	}, 
	onComplete: function()
	{
		$('modal').effect('top', {duration: 500, transition: Fx.Transitions.Cubic.easeOut}).start(-600, 80);
	}
	}).start(0,0.8);
}

function overlayOff()
{
	$('overlay').effect('opacity', {duration: 150, 
	onStart: function()
	{
			$('modal').setStyles({top: '-600px', visibility: 'hidden'});
	}
	}).start(0);
}

function submitRapidResponse()
{
	if($('rapid_form_name').value == '')
	{
		$('rapid_form_name').addClass('error');
		alert('Please enter your name.');
	}
	else
	{
		$('rapid_form_name').removeClass('error');
		new Ajax('/submit_rapid_response.php', {method: 'post', data: $('rapid_response_form'), onComplete:
		function()
		{
			$E('#modal').effect('height',{onComplete:function(){$E('#modal .content p').effect('opacity').start(0,1);}}).start(540,60);
			$E('#modal .content').innerHTML = "<p style=\"visibility: hidden;\">Thank you for contacting C&J Industries with your project needs.  One of our New Business Development Engineers will be contacting you shortly to answer your questions or to review your program with you.  If you need an even faster response, please call 814-724-4950 and ask for a Sales Engineer.</p>";
		}
		}).request();
	}
}