$(document).ready(function(){

	$('#project').cycle({
		fx: 'fade',
		timeout: 7000
	});

    $('#cycle-scroll').before('<div id="cycle-nav">').cycle({ 
        fx:     'fade',
        speed:  'slow',
        timeout: 7000,
        pager:  '#cycle-nav',
		slideExpr: 'img'
    });
	$('#cycle-nav a:last-child').addClass('last');

	$('#services-carousel').bxCarousel({
		display_num: 4,
		move: 2,
		prev_image: '/wp-content/themes/bb/images/arrow-left.png',
		next_image: '/wp-content/themes/bb/images/arrow-right.png',
		margin: 10
	});

	$('#wire ul li:nth-child(2), #wire ul li:last-child').addClass('last');
	
	$('dl.gallery-item a').attr('rel','gallery');
	$('dl.gallery-item a[rel="gallery"]').fancybox();
	
	$('.gallery dl.gallery-item:nth-child(4n+3)').addClass('last');
	
	$('a.modal').fancybox({
		type: 'iframe',
		width: 640,
		height: 390,
		autoScale: false,
		opacity: false
	});
	
	$('.home a.modal').fancybox({
		type: 'iframe',
		width: 700,
		height: 575,
		padding: 0,
		margin: 0,
		autoScale: false,
		opacity: false
	});
	
	$('a.fancybox').fancybox();	
	
	$('a.swf').fancybox({
		type: 'swf'
	});	

	$('#get-started a.toggle').click(function(){
		$('.meerkat').destroyMeerkat();
		$('.meerkat').meerkat({
			background: '#B4FF17',
			height: '220px',
			width: '100%',
			position: 'bottom',
			close: '.close-meerkat',
			animationIn: 'slide',
			animationSpeed: 500,
			removeCookie: '.reset'
		}).removeClass('pos-top pos-left pos-right').addClass('pos-bot');
	});
	

	if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod') {
		$("#get-started").css("position", "absolute");
		$("#get-started").css("bottom", "-415px");
	};
	
	
	if ($(window).width() >= 1200) { 
		$("#curl").css('display', 'block');
	}
	
	function textReplacement(input){
		var originalvalue = input.val();
		input.focus( function(){
			if( $.trim(input.val()) == originalvalue ){ input.val(''); }
		});
		input.blur( function(){
			if( $.trim(input.val()) == '' ){ input.val(originalvalue); }
		});
	}

	textReplacement($('#s'));	
	
//tabs
	
	$('#tabs-content').before('<ul id="tabs"><li id="tab-1" class="selected">Homepage</li><li id="tab-2">Category Page</li><li id="tab-3">Product Page</li><li id="tab-4">Cart Page</li><li id="tab-5">Chackout Page</li></ul>');
	$('#tabs-content').addClass('js'); 
		$("#tabs li").each(function() {
			$(this).click(function() {
				var tabId = $(this).attr('id');
				var tabId = tabId.split('-');
				var tabContent = document.getElementById('tab-content-' + tabId[1]);
				tabContent.style.display = 'block';
				$(this).addClass('selected');
				$(this).siblings().removeClass('selected');
				$(tabContent).siblings().css('display','none');
			});
		});

	
});
