$(document).ready(function(){
	$('#firequotenav').hover(function(){$('#hmquotenav').show();}).mouseleave(function(){$('#hmquotenav').hide()});;
	$('#hmquotenav').mouseenter(function(){$(this).show()}).mouseleave(function(){$(this).hide()});
	
	var vidStore = '<iframe src="http://player.vimeo.com/video/31888858?title=0&amp;byline=0&amp;portrait=0&amp;color=fdbb30&amp;autoplay=1" width="641" height="359" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>';
	
	var vidNegri = '<iframe src="http://player.vimeo.com/video/32341877?title=0&amp;byline=0&amp;portrait=0&amp;color=fdbb30&amp;autoplay=1" width="641" height="359" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>';
	
	$('#vidtrigger').click(function(){
		$('#vidplayer').html(vidStore);
		$('#golVidScreen').fadeIn();
	});
	$('#vidclose').click(function(){
		$('#vidplayer').html('');
		$('#golVidScreen').fadeOut();		
	});
	
	$('#vidtrigger_negri').click(function(){
		$('#vidplayer').html(vidNegri);
		$('#golVidScreen').fadeIn();
	});
	
	$('#slideslogan').jshowoff({								
		effect:'fade',
		changeSpeed:1000,
		speed:8000,
		controls: false,
		links:false,
		hoverPause: false
	});
	$('#hmslideshow').jshowoff({								
		effect:'slideLeft',
		speed:6000,
		links:false,
		hoverPause: false
	});
	$('#btnprev').click(function(){ $('.jshowoff-prev').click(); });
	$('#btnnext').click(function(){ $('.jshowoff-next').click(); });
	
	$('#sizingguide').submit(function(e){
		$('#sizingerror').hide();
		if(!$('#pounds').val() || !$('#regrind').val() || !$('#glass').val()){
			$('#sizingerror').show().text("All fields are required. Numbers only. No percentages over 100.");
			return false;
		}
		actionSizing();
		e.preventDefault();
	});
	
	$('#calcInjection').submit(function(e){
		actionInjection();
		e.preventDefault();
	});
	$('#injReset').click(function(){
		$('#injCooling').text('---');
		$('#injGPM').text('---');
		$('#injPipeSize').text('---');
	});
	
	$('#calcExtrusion').submit(function(e){
		actionExtrusion();
		e.preventDefault();
	});
	
	$('#extReset').click(function(){
		$('#extCooling').text('---');
		$('#extGPM').text('---');
		$('#extPipeSize').text('---');
	});
	
	$('#calcConvert').submit(function(e){
		if(!$('#unitVal').val()){ $('#convError').show().text('Enter a number'); $('#unitVal').focus(); return false; }
		actionConvert();
		e.preventDefault();
	});
	
	function actionSizing(){
		$('#ajaxloader').show();		
		$.ajax({
			type: "POST",
			url: "/wp-content/themes/gol/actions/act.sizingguide.php",
			data: $('#sizingguide').serialize(),
			dataType: "json",
			success: function(msg){
				$('#ajaxloader').hide();
				if(parseInt(msg.status)==1)
				{
					$('#rsltTemp').html(msg.temp+"&deg;");
					$('#rsltInit').html(msg.init+"&#37;");
					$('#rsltReq').html(msg.req+"&#37;");
					$('#rsltTime').text(msg.time);
					$('#rsltResults').text(msg.results);
				}
				else if(parseInt(msg.status)==0)
				{
					$('#sizingerror').show().text(msg.txt);
				}											
			}
		});			
	}//actionSizing
	
	function actionInjection(){
		$('#ajaxloader').show();		
		$.ajax({
			type: "POST",
			url: "/wp-content/themes/gol/actions/act.injection.php",
			data: $('#calcInjection').serialize(),
			dataType: "json",
			success: function(msg){
				$('#ajaxloader').hide();
				if(parseInt(msg.status)==1)
				{
					$('#injCooling').html(msg.cooling);
					$('#injGPM').html(msg.gpm);
					$('#injPipeSize').html(msg.pipesize);
				}
				/*else if(parseInt(msg.status)==0)
				{
					$('#sizingerror').show().text(msg.txt);
				}*/											
			}
		});			
	}//actionInjection
	
	function actionExtrusion(){
		$('#ajaxloader').show();		
		$.ajax({
			type: "POST",
			url: "/wp-content/themes/gol/actions/act.extrusion.php",
			data: $('#calcExtrusion').serialize(),
			dataType: "json",
			success: function(msg){
				$('#ajaxloader').hide();
				if(parseInt(msg.status)==1)
				{
					$('#extCooling').html(msg.cooling);
					$('#extGPM').html(msg.gpm);
					$('#extPipeSize').html(msg.pipesize);
				}
				/*else if(parseInt(msg.status)==0)
				{
					$('#sizingerror').show().text(msg.txt);
				}	*/										
			}
		});			
	}//actionExtrusion
	
	function actionConvert(){
		$('#ajaxloader').show();		
		$.ajax({
			type: "POST",
			url: "/wp-content/themes/gol/actions/act.convert.php",
			data: $('#calcConvert').serialize(),
			dataType: "json",
			success: function(msg){
				$('#ajaxloader').hide();
				if(parseInt(msg.status)==1)
				{
					$('#convResult').html(msg.result);
					$('#convError').hide();
				}
				else if(parseInt(msg.status)==0)
				{
					$('#convError').show().text(msg.result);
				}											
			}
		});			
	}//actionExtrusion

});
