//Fill URL Form on Product Page for Shipping Quote
function fillURL() {
	document.getElementById('concerning').value = location.href;
	
}

// jQuery Functions
var $j = jQuery.noConflict();

//create todays date
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1;//January is 0!
var yyyy = today.getFullYear();
if(mm<10){mm='0'+mm};//add a 0 to month if less than 10
if(dd<10){dd='0'+dd};//add a 0 to day if less than 10
var todaysDate = mm+"/"+dd+"/"+yyyy;
//document.write(todaysDate);

//jQuery Carousel
function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

$j(document).ready(function() {	
	
	//$j(".jqueryHighlight").fadeTo("slow", 0.3); // This sets the opacity of the thumbs to fade down to 30% when the page loads
	$j(".jqueryHighlight").hover(function(){
	   $j(this).stop().fadeTo(500, 0.5); // This should set the opacity to 100% on hover
    },function(){
 	   $j(this).stop().fadeTo(500, 1.0); // This should set the opacity back to 30% on mouseout
	});
	
	$j("#cartPrice").hide();
	$j(".jqueryCart").hover(function(){
	   $j("#cartPrice").show();
    },function(){
 	   $j("#cartPrice").hide();
	});

	
    $j('#mycarousel').jcarousel({
        vertical: true,
        scroll: 2,
		auto: 2,
		wrap: 'last',
        initCallback: mycarousel_initCallback

    });
	
	$j('#catCar').jcarousel({
        vertical: true,
        scroll: 2
    });
	
				
	$j('#contactform').submit(function(){
 
		var action = $j(this).attr('action');
 
		$j('#submit')
			.before('<img src="images/loading.gif" class="loader" />')
			.attr('disabled','disabled');
 
		$j.post(action, { 
			name: $j('#name').val(),
			email: $j('#email').val(),
			phone: $j('#phone').val(),
			concerning: $j('#concerning').val(),
			prodTitle: $j('#prodTitle').val(),
			message: $j('#message').val()
		},
			function(data){
				$j('#contactform #submit').attr('disabled','');
				$j('.response').remove();
				$j('#contactform').before('<span class="response">'+data+'</span>');
				$j('.response').slideDown();
				$j('#contactform img.loader').fadeOut(500,function(){$j(this).remove()});
				if(data=='Message sent!') $j('#contactform').slideUp();
			}
		);
 
		return false;
 
	});
	
	//jQuery UI Tabs
	$j('#tabs').tabs();
	function runEffect(){
		$j("#tabs").effect('highlight',{},500);
	};
	
	$j("#tabs").ready(function() {
			runEffect();
			return false;
	});


	$j("a[rel='colorbox']").colorbox({maxWidth:"85%", maxHeight:"85%", scalePhotos:true, transition:"fade"});


	
});