function clearText(field){

    if (field.defaultValue == field.value) field.value = '';
    else if (field.value == '') field.value = field.defaultValue;

}

function goToByScroll(id){
     			jQuery('html,body').animate({scrollTop: jQuery("#"+id).offset().top},'slow');
		}



/*Cufon.set('fontFamily', 'DINPro-Medium');
Cufon.replace('#nav a.level-top, #nav li a, .bottom-images div h3, button span span, .collateral-tabs .tab', {hover: true});

Cufon.set('fontFamily', 'DINPro-Bold');
Cufon.replace('.blog-posts a, .footer ul.footer-links li strong, .left-menu h2, .col-main .std h2, .page-title h1, .product-view .product-name h1, .product-view .product-shop .price-box .regular-price .price, .box-collateral .box-title h2, .products-grid .price-box, .sidebar .block .block-title strong', {hover: true});

Cufon.set('fontFamily', 'DINPro-Regular');
Cufon.replace('.left-menu li, .breadcrumbs, .products-grid .product-name', {hover: true});

Cufon.set('fontFamily', 'DINPro-Light');
Cufon.replace('.footer ul.footer-links li a', {hover: true});
*/

jQuery(document).ready(function() {
	//Search prompt on Search input
		var search_init = 'Search the store';
		
		if(jQuery('input#search').val() === '') {
		    jQuery('input#search').val(search_init);
		}
	  //Search input active	
	  jQuery('input#search').focus(function() {
	  		    if(jQuery(this).val() === search_init ){
	  		      jQuery(this).val('');
	  	    }
	  	  });
	  	  
	 //leaving the search
	  	jQuery('input#search').blur(function() {
	  		    if(jQuery(this).val() === '') {
	  		      jQuery(this).val(search_init);
	  		}
	  	});
	  			
	//Check input value for item qty
		if(jQuery('input#qty').val() === '') {
			jQuery('input#qty').val('1');
		}	
	

//Default Action
	jQuery(".tab_content").hide(); //Hide all content
	jQuery("ul.tabs li:first").addClass("active").show(); //Activate first tab
	jQuery(".tab_content:first").show(); //Show first tab content
		
	//On Click Event
	jQuery("ul.tabs li").click(function() {
		jQuery("ul.tabs li").removeClass("active"); //Remove any "active" class
		jQuery(this).addClass("active"); //Add "active" class to selected tab
		jQuery(".tab_content").hide(); //Hide all tab content
		var activeTab = jQuery(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		jQuery(activeTab).show(); //Fade in the active content
		goToByScroll('customer-reviews');
		return false;



	});

	jQuery("a.review-tab-click").click(function() {
		
		jQuery(".review-tab").addClass("current"); 
		
		
	});


jQuery("ul.tabs li.description-tab").click(function() {
	jQuery("ul.tabs li.review-tab").removeClass("current"); 
	
	});
	jQuery("ul.tabs li.specifications-tab").click(function() {
	jQuery("ul.tabs li.review-tab").removeClass("current"); 
	
	});

	
	jQuery("a[rel=group1]").fancybox({
				'titleShow'		: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
			});
			
/*	jQuery(".newsletter-holder a").click(function () {
	jQuery(".newsletter-holder .newsletter-show").slideToggle("slow");});*/
	
/*	jQuery("a.close-button").click(function () {
	jQuery(".newsletter-holder .newsletter-show").hide("slow");});*/
	
	//Header Notification Bar Close and hide w/ cookie
	/*var headerclosed = jQuery.cookie('closed');
	if (headerclosed == 'yes') {
	         jQuery('#header-notification').hide();
	} else {
	         jQuery('#header-notification a.close').click(function() {
	         	jQuery('#header-notification').slideUp( 1000 );
	         	jQuery.cookie('closed', 'yes', { expires: 14, path: '/' }); //then set cookie at end of animation
	         });
	}*/
	

	jQuery(".newsletter-holder").hoverIntent(function () {
	jQuery(this).find(".newsletter-show").fadeIn('slow');}, 	
	function() {
      jQuery(this).find(".newsletter-show").delay(1000).fadeOut('slow');
}); 
		
	jQuery("a[rel=more-images]").fancybox({
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic'
				
			});
			jQuery("#various1").fancybox({
				
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic'
			});
			jQuery("a[rel=video-grupa]").fancybox({
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic'
			});
	
	/*jQuery('#slider1').bxSlider({
			auto: false,
			autoControls: false,
			autoHover: true,
			pager: true,
			controls: false,
			pause: 5000
	});
	
	jQuery('.bx-pager a:nth-child(1)').attr('id','pager-1');
	jQuery('.bx-pager a:nth-child(2)').attr('id','pager-2');
	jQuery('.bx-pager a:nth-child(3)').attr('id','pager-3');
	jQuery('.bx-pager a:nth-child(4)').attr('id','pager-4');
	jQuery('.bx-pager a:nth-child(5)').attr('id','pager-5');*/

	var windowWidth = jQuery(window).width();
	
	
	
	jQuery('.bx-wrapper').css('width',windowWidth);
	jQuery('.bx-window').css('width',windowWidth);
	jQuery('#slider1 li').css('width',windowWidth);
	
	var scrollByHow = 0;
	
	var currentSlide = 1;
	
	jQuery('#slider1').css("left",0);
	
	var homeHeroInterval = setInterval(homeHero, 10000);
	//Change the # of slides
	function homeHero() {
			if ( currentSlide == 2 ) {
				scrollByHow = 0;
				currentSlide = 1;
			} else {
				scrollByHow = ( scrollByHow + ( windowWidth * (-1) ) );
				currentSlide+=1;
			}
			
			//jQuery('#search').val( scrollByHow );
			
			jQuery('.pager-link').removeClass('pager-active');
			
			jQuery('#pager-'+currentSlide).addClass('pager-active');
				
			jQuery('#slider1').animate({left: scrollByHow}, 1000);
			
			return false;
	}
	jQuery(window).resize(function() {
			var theNewSize = jQuery(window).width();
			jQuery('.bx-wrapper').css('width',theNewSize);
			jQuery('.bx-window').css('width',theNewSize);
			jQuery('#slider1 li').css('width',theNewSize);
			//jQuery('#search').val( theNewSize );
			windowWidth = theNewSize;
			jQuery('#slider1').animate({left: 0}, 1000);
			scrollByHow = 0;
			currentSlide = 1;
			jQuery('.pager-link').removeClass('pager-active');
			jQuery('#pager-1').addClass('pager-active');
			
			if ( windowWidth > 960 ) {
					var newRight = ( ( windowWidth - 960 ) / 2 ) + 54;
					jQuery('.bx-pager').css('right',newRight);
			}
			
			return false;
	});
	jQuery('.bx-pager a').click( function(e) {
			var theID = new Number( jQuery(this).attr('id').substr(6) );
			clearInterval(homeHeroInterval);
			currentSlide = theID;
			scrollByHow = ( windowWidth * ( theID - 1 )) * (-1);
			homeHeroInterval = setInterval(homeHero, 10000);
			jQuery('.pager-link').removeClass('pager-active');
			jQuery('#pager-'+theID).addClass('pager-active');
			
			jQuery('#slider1').animate({left: scrollByHow}, 1000);
			
			e.preventDefault();
	});
	
	if ( windowWidth > 960 ) {
			var newRight = ( ( windowWidth - 960 ) / 2 ) + 54;
			jQuery('.bx-pager').css('right',newRight);
	}
});
