
$(document).ready( function(){
	
	do_cufon();
	
	$(window).ready(function(){
	
		var contentHeight = $('.content_div').height();
		var windowWidth = $(window).width();
		
		$('#container').height(contentHeight);
		$('#container').width(windowWidth);
		$('#footer').css({"margin":"500px 0 0 0"});
	
	});
	
	$(window).resize(function(){
		
		var contentHeight = $('.content_div').height();
		var windowWidth = $(window).width();
		
		$('#container').height(contentHeight);
		$('#container').width(windowWidth);
		
	});
	
	var slideNum = 0;
	
	function slideShow(){
	
	var images = document.getElementById('hidden_image_count').value;

		if(slideNum == (images-1)){
			slideNum = 1;
			
		}else{
			slideNum++;
		}	
				//$("#img1"+slideNum).show();
				
				$("#image_back_"+slideNum).fadeTo(1300,1).delay(4000).fadeTo(1300,0,function(){
								
				$("#image_back_"+slideNum).hide();
				
					slideShow();
		
				});		
	}
	
	slideShow();
	
	wheelSelectGallery();
	function wheelSelectGallery(){
	
			
		$('#wheelSelectGallery').change(function(){
			
			var wheelSelectGallery = document.getElementById('wheelSelectGallery');
			var product = wheelSelectGallery.options[wheelSelectGallery.selectedIndex].value;
			
			window.location = 'gallery.php?product='+product;
			
						
			
		});
		
	}
	
	aeroSelectGallery();
	function aeroSelectGallery(){
		
		
		$('#aeroSelectGallery').change(function(){
			
			var aeroSelectGallery = document.getElementById('aeroSelectGallery');
			var product = aeroSelectGallery.options[aeroSelectGallery.selectedIndex].value;
			
			window.location = 'gallery.php?product='+product;
			
		});
		
	}
	
	autoSelectGallery();
	function autoSelectGallery(){
		
		$('#autoSelectGallery').change(function(){
			
			var autoSelectGallery = document.getElementById('autoSelectGallery');
			var product = autoSelectGallery.options[autoSelectGallery.selectedIndex].value;
			
			window.location = 'gallery.php?product='+product;			
			
		});
		
	}
	
	blowUp();
	
	function blowUp(){
	
		$('.imgBlowUp').click(function(){
				
				var source = $(this).attr("src");
				
				$('#blowUp').show();
				$('#blowUp').html("Close</br></br><img src='"+source+"' alt='"+source+"' style='height:500px;margin:20px auto 0 auto;opacity:1.0 ! important;background:#000;'/>");
				
				$('#blowUp').click(function(){
					
					$('#blowUp').hide();
					
				});
				
		});	
	}
	
	sendInquiry();
	
	function sendInquiry(){

		$('.submit_inquiry').click(function(){

			var make = document.getElementById('v_make').value;
			var model = document.getElementById('v_model').value;
			var year = document.getElementById('v_year').value;
			var inquiry = document.getElementById('v_inquiry').value;
			var product_info = document.getElementById('product_info').value;
			var phone = document.getElementById('phone').value;
			var email = document.getElementById('email').value;
			var c_name = document.getElementById('name').value;
			var email_type = document.getElementById('email_type').value;
			


			if(email != "" || inquiry != ""){
				$.post("php/send_inquiry.php?action=inquiry&make="+make+"&model="+model+"&year="+year+"&inquiry="+inquiry+"&product_info="+product_info+"&email="+email+"&phone="+phone+"&name="+c_name+"&email_type="+email_type, function(data){

					$('#result').html("Thank you for your inquiry. Someone from the sales department will contact you soon.<br/><br/>Automotive Emporium<br/>888 831 4711 x 100");
					
				});
			}else{
				alert("Please enter your email address and inquiry.");
			}

		});

	}
	
	
	function do_cufon(){
		Cufon.replace('h1,h2,h3,h4,.info_div,.nav_link,#content_title,.nav_link_active,.searchSpan,.quick_text', {hover:true});
	}


});

