$(document).ready(function(){
	
	var DocumentHeight = $(document).height();
	var DocumentHeight = DocumentHeight+70;

	$("<div id='modalLayer'></div>").css({"height":DocumentHeight+"px","opacity":0.5}).insertAfter("#outerwrapper").hide();
});

$(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 
}); 
}); 

$(document).ready(function(){
	var Errors = $(".errors");
	Errors.hide();
	Errors.slideDown("slow");
});

$('#gallery').cycle({
    fx:    'fade', 
    speed:1500,
    timeout: 3000
    });



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

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

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

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

// for use with ajax functions to get values from the url see testcart

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;
}

$(function(){
	$(".success").hide().slideDown("slow").delay(5000).fadeOut("slow",function(){location.href="contact"});
});
/*
$(document).ready(function(){
	$("a[rel='imageGallery']").colorbox({
		opacity:0.7
	});
});

$(document).ready(function(){
	$(".videolink").colorbox({iframe:true, innerWidth:480, innerHeight:385});
});
*/

/*************** HOME PAGE GALERY *******************************/	
$(function() {
var slidesLength = $("#content-holder ul,#content-holder dl").size();
var dlwidth = $("#content-holder ul,#content-holder dl").outerWidth(true);
var contentHolderWidth = (slidesLength * dlwidth) + 10;

$("#content-holder").css({width:contentHolderWidth});

  $("#gallerySlider").slider({
  	animate: true,
    change: handleSliderChange,
    slide: handleSliderSlide
  });
  
});

function handleSliderChange(e, ui)
{
  var maxScroll = $("#content-scroll").prop("scrollWidth") - $("#content-scroll").width();
  $("#content-scroll").animate({scrollLeft: ui.value * (maxScroll / 100) }, 1000);
}

function handleSliderSlide(e, ui)
{
  var maxScroll = $("#content-scroll").prop("scrollWidth") - $("#content-scroll").width();
  $("#content-scroll").prop({scrollLeft: ui.value * (maxScroll / 100) });
}

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


