$(document).ready(function(){

	// input values
	$('input, textarea').focus(function() {
		value=$(this).val();
		$(this).attr("value","");
		});
	
	$('input, textarea').blur(function() {
		if($(this).val()=="") {
		$(this).val(value);
		}
		});
      
	// navigation	
	$('.nav1,.nav2,.nav3,.nav4,.nav5,.nav6,.nav7,.nav8,.nav9,.nav10,.button').append('<span class="hover"></span>').each(function () {
		var $span = $('> span.hover', this).css('opacity', 0);
		$(this).hover(function () {
			$span.stop().fadeTo(500, 1);
			}, function () {
			$span.stop().fadeTo(500, 0);
			});
	});		
	

	// jCoverFlip
	$('#flip').jcoverflip({
		current: 2,
		beforeCss: function( el, container, offset ){
            return [
              $.jcoverflip.animationElement( el, { left: ( container.width( )/2 - 400 - 210*offset + 20*offset )+'px', bottom: '20px' }, { } ),
              $.jcoverflip.animationElement( el.find( 'img' ), { width: Math.max(10,200-20*offset*offset) + 'px' }, {} )
            ];
          },
          afterCss: function( el, container, offset ){
            return [
              $.jcoverflip.animationElement( el, { left: ( container.width( )/2 + 240 + 210*offset )+'px', bottom: '20px' }, { } ),
              $.jcoverflip.animationElement( el.find( 'img' ), { width: Math.max(10,200-20*offset*offset) + 'px' }, {} )
            ];
          },
          currentCss: function( el, container ){
            return [
              $.jcoverflip.animationElement( el, { left: ( container.width( )/2 - 180 )+'px', bottom: 0 }, { } ),
              $.jcoverflip.animationElement( el.find( 'img' ), { width: '400px' }, { } )
            ];
          },
		  
        });



	// request a quote
	maxWidth = 500;
	minWidth = 175;	
	
	$('#next').fadeTo(1000, 0);
	$('#next').css('display', 'none');
	$('#finish').fadeTo(1000, 0);
	$('#finish').css('display', 'none');
	
	$('input').click( function() { $('#next').fadeTo(1000, 1); });
	$('.one .slide-content').click( function() { 
			$('.one').animate({width: maxWidth+"px"}, { queue:false, duration:400 });
			$('.two').animate({width: minWidth+"px"}, { queue:false, duration:400});
			$('.three').animate({width: minWidth+"px"}, { queue:false, duration:400 });
			
			$('#next').fadeTo(1000, 1);
			$('#finish').fadeTo(1000, 0);
			$('#finish').css('display', 'none');
			});
			
	$('.two .slide-content').click( function() { 
			$('.one').animate({width: minWidth+"px"}, { queue:false, duration:400 });
			$('.two').animate({width: maxWidth+"px"}, { queue:false, duration:400});
			$('.three').animate({width: minWidth+"px"}, { queue:false, duration:400 });
			
			$('#next').fadeTo(1000, 0);
			$('#next').css('display', 'none');
			$('#finish').fadeTo(1000, 1);
			});
			
	$('.three .slide-content').click(function() { 
			$('.one').animate({width: minWidth+"px"}, { queue:false, duration:400 });
			$('.two').animate({width: minWidth+"px"}, { queue:false, duration:400});
			$('.three').animate({width: maxWidth+"px"}, { queue:false, duration:400 });
			
			$('#next').fadeTo(1000, 0);
			$('#next').css('display', 'none');
			$('#finish').fadeTo(1000, 0);
			$('#finish').css('display', 'none');
			});			
	
	$('#next').click(
		function(){
			$('.one').animate({width: minWidth+"px"}, { queue:false, duration:400 });
			$('.two').animate({width: maxWidth+"px"}, { queue:false, duration:400});
			$('.three').animate({width: minWidth+"px"}, { queue:false, duration:400 });

			$('#next').fadeTo(1000, 0);
			$('#finish').fadeTo(1000, 1);
			});	
			
	$('#finish').click(
		function(){
			$('.one').animate({width: minWidth+"px"}, { queue:false, duration:400 });
			$('.two').animate({width: minWidth+"px"}, { queue:false, duration:400 });
			$('.three').animate({width: maxWidth+"px"}, { queue:false, duration:400});
			
			$('#next').fadeTo(1000, 0);
			$('#finish').fadeTo(1000, 0);
			});			

	$('select').selectToUISlider({
		labels: 0
		});
		
		fixToolTipColor();
		});
		
		function fixToolTipColor(){
			$('.ui-tooltip-pointer-down-inner').each(function(){
				var bWidth = $('.ui-tooltip-pointer-down-inner').css('borderTopWidth');
				var bColor = $(this).parents('.ui-slider-tooltip').css('backgroundColor')
				$(this).css('border-top', bWidth+' solid '+bColor);
			});	
		}

		

	

	// rounded corners
	$(function(){
		$("#request").corner("round 10px");
		$("input").corner("round 4px");
		$("textarea#textarea").corner("round 4px");		
	});

function IncludeJavaScript(jsFile)
{
  document.write('<script type="text/javascript" src="'
    + jsFile + '"></scr' + 'ipt>'); 
}

