Cufon.replace('h1, h2, h3, h4,.footer p,.designed a', { fontFamily: 'ColaborateLight'});
Cufon.replace('.btn', { fontFamily: 'Colaborate-Regular',hover:true});

$(document).ready(function(){
	if ($('.banner').length){
		var banner = $('.banner').bxSlider({
				mode: 'fade',
				pager:true,
                                auto:true,
                                pause: 7000
			});
	
		var bx_pager_w=$('.bx-pager').width();
		var banner_w = $('.bannerbox').find('.content').width();
		var bx_pager_left=Math.floor((banner_w-bx_pager_w)/2);
		$('.bx-pager').css({'left':bx_pager_left});
	}
	

	if ($('.smallslider').length){
		var banner = $('.slider').bxSlider({
				mode: 'horizontal',
				displaySlideQty: 3
			});
	
	}
	if ($('.planslider').length){
		var plan = $('.pslider').bxSlider({
				mode: 'horizontal',
				infiniteLoop: false 
			});
	
	}

	if ($('.highslider').length){
		var banner = $('.slider').bxSlider({
				mode: 'horizontal',
				displaySlideQty: 3
			});
	
	}
	
	
//set cols height
	if ($('.sameheight').length){
		$('.cols').each(function(){
			var sameheight=0;
			$(this).find('.sameheight').each(function(){
				$(this).addClass('sameheight_js');
				if (sameheight<$(this).height())
					sameheight=$(this).height();
			})
			
			$(this).find('.sameheight_js').css('height',sameheight+'px');
		
		})
	}
	
	
//	faq toggle
	if ($('.faqtxt').length){
		//hide the faq
		$('.faqtxt').hide();
		
		//click open
		$('.toggle').click(function(){
			if(!$(this).hasClass('open')){
				$('.faqtxt').slideUp();
				$('.toggle').removeClass('open');
				$(this).addClass('open').parent().find('.faqtxt').slideDown();
			}
			return false
		})
	}
	
//set the position for lightbox
	$('.forsalebox, .optionbox').each(function(){
		var lightbox=$(this).find('.lightbox');
		var box_w=$(this).width();
		var box_leftoffset = $(this).offset().left;
		var container_w = $('.blockrow').width();
		var container_leftoffset = $('.blockrow').offset().left;

		
		if ((box_leftoffset+box_w)>((container_leftoffset+container_w)/1.5)){
			 lightbox.addClass('lightbox-toright').css('right',box_w+'px');
		}
		else{
			 lightbox.addClass('lightbox-toleft').css('left',box_w+'px');;
		}	
		
	})
	
//lightbox click open
	var isopen=false;
	$('.forsalebox, .optionbox').click(function(){
		$('.forsalebox').css('z-index',0);
		$('.optionbox').css('z-index',0);
		$(this).css('z-index',999);
		if (isopen===true){
			$('.lightbox').hide();
			isopen=false;
		}

		
		$(this).find('.lightbox').show();
		isopen=true;
		
	})
	
//lightbox close
	$('.close').live('click',function(){
		$(this).closest('.lightbox').hide();
		isopen=false;
		return false;
	})
	
	
//lightbox viewer
	if ($('.bigger').length){	
       $('a.bigger').lightBox();
	}
	
	
	//top menu drop-down
	$('li.has').hover(
		function(){
			$(this).find('ul').stop(true,true).fadeIn();
		},
		function(){
			$(this).find('ul').fadeOut();
	})

        if ($('.smallfader').length){
            $(function() {
                setInterval( "slideSwitch()", 5000 );
            });

        }


});

function slideSwitch() {
    var $active = $('#fader li.active');

    if ( $active.length == 0 ) $active = $('#fader li:last');

    // use this to pull the images in the order they appear in the markup
    var $next = $active.next().length ? $active.next()
        : $('#fader li:first');
    // uncomment the 3 lines below to pull the images in random order
    // var $sibs = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next = $( $sibs[ rndNum ] );

    $active.addClass('last-active')
    .animate({opacity:0.0}, 100, function(){});

    $next.css({opacity: 0.0})
    .addClass('active')
    .animate({opacity: 1.0}, 1000, function() {
        $active.removeClass('active last-active');
    });
}
