/* Author: Paul Sawyer
	preload
	superfish
	mymodal
	errors on submission of form .. slide down
	cycle plug in call 
	jquery tools tooltip (inactive)
	input.btn hover
	search form focus
	input focus
	legend transform
	getUrlVars function
	contact form success - slide down
	colorbox call (inactive)
	jscrollpane call with options listed
*/
$(document).ready(function() {
		
    $('ul.sf-menu').superfish({ 
    
    delay:       500,                            // one second delay on mouseout 
    animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
    speed:       'fast',                          // faster animation speed 
    autoArrows:  false,                      // disable generation of arrow mark-up 
    dropShadows: false   // disable drop shadows 
    }); 
    
    $(".pane,.paneFullWidth,.paneTwoThirdsWidth").jScrollPane({
		scrollbarWidth:20, 
		scrollbarMargin:20,
		verticalDragMinHeight:30,
		verticalDragMaxHeight:30
		
	});
    

    $('.infiniteCarousel').infiniteCarousel();	
    
	$("#imageGallery").cycle({
		fx:'fade',
			pause: 1,
			speed:2500,
			timeout: 2000
	});


	$("input.btn").hover(function(){
		$(this).addClass("hover");
	},
	function() {
		$(this).removeClass("hover");	
	});

	var searchForm = $("form.search input:not(:submit)")

	var searchValue = searchForm.val();
	searchForm.focus(function(){
	if ($(this).val() == searchValue)
	{
		searchForm.val("");
	}
	});
	
	$("#carousel").jMyCarousel({   
		  
		  visible:'1000px',
		  auto:true,
		  speed:1000,
		  eltByElt: false
	}); 


	$("input.btn").focus(function(){
		$(this).addClass("hover");
	});

	$("form:not(.search) input:not(:submit),textarea ").focus(function(){
		$(this).addClass("inputFocus");
	}).
	blur(function(){
		$(this).removeClass("inputFocus");
	}).
	keyup(function(){
		$(this).removeClass("inputFocus");
	});

	$("fieldset").each(function(){
		var heading = $("legend",this).remove().text();
		$("<h3></h3>").text(heading).prependTo(this);
	});

function getUrlVars(url)
{
 
	var vars = [], hash;
    var hashes = url.slice(url.indexOf('?') + 1).split('&');
    
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}

	$(".success").hide().slideDown("slow").delay(5000).fadeOut("slow",function(){location.href="contact"});

	$('#loading').ajaxStart(function() {
    $(this).show();
	}).ajaxStop(function() {
    $(this).hide();
	});
  
});


























