/* Author: ThemeShaper */



/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

// SEARCH ROLLOVERS

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
$(document).ready(function () {
	

	
    //AJAX CONTACT FORM
    $("#subContact").click(function () {
        if ($('.error').length) {
            return false;
        } 
		else if($('.valid').length){
            var name = $("#name").val();
            var email = $("#email").val();
            var enquiry = $("#enquiry").val();
            var dataString = 'name=' + name + '&email=' + email + '&enquiry=' + enquiry;
            $.ajax({
                type: "POST",
                url: "form-processor.php",
                data: dataString,
                success: function (response) {
                    $('#form-holder').hide().html("<div style='padding-left:15px;'>" + response + "</div>").fadeIn();
                }
            });
        }
    });
	
	//SET UP THUMBNAILS AND GENERATE CLASSES
    $('.rollover').each(function () {
        $('.caption', this).addClass('sleek-black').wrapInner('<div class="caption-header cuf caps no-arrow">');
        $('.caption', this).append('<span class= "white-magnify"></span>');
        $('.caption', this).css({
            opacity: 0
        }, 400);
    });
    $('.thumb-rollover').each(function (index) {
        var width = $('img', this).outerWidth();
        var height = $('img', this).outerHeight();
        $('a', this).append('<span class= "thumb-magnify" style="width:' + width + 'px;height:' + height + 'px"></span>');
    });
    var start = ($('img', this).outerHeight()) * -1 - 20;
    $('.thumb-magnify').css({
        top: +start
    });
	
	//CUFON
    Cufon.replace('.cuf', {
        fontFamily: 'ColaborateLight',
        hover: 'true',
        hoverables: {
            a: true,
            button: true
        }
    });
    Cufon.replace('.letterpress', {
        fontFamily: 'ColaborateLight',
        textShadow: '1px 1px white',
        hover: 'true',
        hoverables: {
            button: true
        }
    });
    Cufon.replace('#teaser-text,.pullquote-left,.pullquote-right,blockquote', {
        fontFamily: 'ColaborateLight',
        textShadow: '1px 1px white'
    });
	Cufon.replace('H1,H2,H3', {
        fontFamily: 'ColaborateLight'
    });
	
	Cufon.replace('H4,H5', {
        fontFamily: 'ColaborateLight'
    });
	
	    //FOUC
    $('.jsfouc').css({
        visibility: 'visible'
    });
    //$('.js .fouc').css({visibility:'visible'});
    //$('.js .cuf').css({visibility:'visible'});
	
	//SEARCH ROLLOVER
    $('.search').hover(
    function () {
        if ($('.sbox', this).val() == "search...") {
            $('.sbox', this).val("");
        }
    }, function () {
        if ($('.sbox', this).val() == "") {
            $('.sbox', this).val("search...");
        }
    });
	
	//SMALL THUMB ROLLOVERS
    jQuery('.thumb-rollover').hover(function () {
        var height = $('img', this).outerHeight();
        $('img', this).stop().animate({
            opacity: 0.5
        }, 400);
        $('.thumb-magnify', this).css({
            top: 3,
            left: 2
        });
    }, function () {
        var height = $('img', this).outerHeight();
        $('img', this).stop().animate({
            opacity: 1
        }, 400);
        $('.thumb-magnify', this).css({
            top: -height / 2 - 20
        });
    });
	
	//IMAGE ROLLOVERS
    jQuery('.rollover').hover(
    function () {
        var captionheight = $('.caption', this).height();
        var imageheight = $('img', this).height();
        var captionposn = (imageheight) * .5 - (captionheight / 4);
		
		$('.caption', this).css({
            top: captionposn,
            width: "0%"
        }).animate({
            opacity: 1,
            width: "75%"
        }, 400);
        jQuery('img', this).stop().animate({
            opacity: 0.7
        }, 400);
    }, function () {
        var imageheight = $('img', this).outerHeight();
        jQuery('img', this).stop().animate({
            opacity: 1
        }, 400);
        $('.caption', this).stop().animate({
            opacity: 0,
            width: "0%"
        }, 400);
    });

	//ACCORDION ROLLOVER
	$('#accwrapper .subtle-white .arrow').hover(
    function () {
        $(this).addClass('arrow-down');
    }, function () {
		
       		$(this).removeClass('arrow-down');
		
    });

    
	//ACCORDION BUTTON ACTION	
    $('div.accordionButton').click(function () {

        $('#accwrapper .accordionButton').removeClass('sleek-black').addClass('subtle-white');
        $('#accwrapper .arrow-down').removeClass('arrow-down').addClass('arrow');
        $(this).removeClass('subtle-white').addClass('sleek-black');
        $('.arrow', this).removeClass('arrow').addClass('arrow-down');
        $('.accordionContent').slideUp();
        //Cufon.replace('div.accordionButton', { fontFamily: 'Helvetica CE 55 Roman' });
        Cufon.refresh();
        $(this).next().slideDown();
    });
	
    //HIDE THE DIVS ON PAGE LOAD	
    $("div.accordionContent").hide();
    $("#open").trigger('click');
    jQuery.easing.def = "easeInOutQuad";
	
   //PRETTYPHOTO
   $("a[rel^='prettyPhoto']").prettyPhoto({animation_speed: 'slow'});
   
   //LOF SLIDER
    var buttons = {
        previous: $('#lofslidecontent45 .lof-previous'),
        next: $('#lofslidecontent45 .lof-next')
    };
    $obj = $('#lofslidecontent45').lofJSidernews({
        interval: 4000, //time between auto slides
        direction: 'opacityn', //change to 'opacity' to use opacity slider
        easing: 'easeInOutExpo', //easing,see (http://gsgd.co.uk/sandbox/jquery/easing/ )
        duration: 1200, //transition duration
        auto: true, //auto slide true or false
        maxItemDisplay: 25,
        navPosition: 'horizontal',
        // horizontal
        navigatorHeight: 30,
        navigatorWidth: 40,
        mainWidth: 948,
        buttons: buttons
    });
});

//STYLE SWITCHER
$(document).ready(function() {$(".panel").toggle("fast");
		$(this).toggleClass("active");
	

$(".trigger").click(function(){
		$(".panel").toggle("fast");
		$(this).toggleClass("active");
		return false;
	}); 
if($.cookie("cssbar")||$.cookie("cssback")) {
		$(".barstyle").attr("href",$.cookie("cssbar"));
		$(".backstyle").attr("href",$.cookie("cssback"));
		$("a[rel=" + $.cookie("cssback") + "]").addClass('curBack');
		$("a[rel=" + $.cookie("cssbar") + "]").addClass('curBar');

	}

	$(".barswitch").click(function() { 
	$(".barswitch").removeClass('curBar');
	$(this).addClass('curBar');
		$(".barstyle").attr("href",$(this).attr('rel'));
		$.cookie("cssbar",$(this).attr('rel'), {expires: 365, path: '/'});
		//Cufon.refresh();
		return false;
	});
	$(".backswitch").click(function() { 
	$(".backswitch").removeClass('curBack');
		$(this).addClass('curBack');
		$(".backstyle").attr("href",$(this).attr('rel'));
		$.cookie("cssback",$(this).attr('rel'), {expires: 365, path: '/'});
		//Cufon.refresh();
		return false;
	});
	
	
   
});
