//home page slider

var showEffect;
jQuery.each(jQuery.browser, function(i) {
         if($.browser.msie){
              showEffect = 'false';
         }
});

$(document).ready(function(){
	var slider_area;
	var slider_buttons;

	// Which slider
	if ($('#slider_area').length>0){
		
		// Home Page Slider
		slider_area="#slider_area";	
		slider_buttons="#numbers";	
	
		$(slider_area).cycle({ 
			fx:     'scrollLeft', 
			timeout:  15000,
			easing: 'backout', 
			prev: '.prev', 
			next: '.next',
			cleartype:  1,
			pause:           true,     // true to enable "pause on hover"
			pauseOnPagerHover: true,   // true to pause when hovering over pager link				
			before:  onBefore, 
			after:   onAfter ,				
			pagerAnchorBuilder: function(idx) { 
				return '<a href="#" title=""><img src="http://www.bitamin.gr/images/icons/pixel.gif" width="14" heigth="14"></a>'; 
			}
		});
		
	} 

	if ($('.sub_slider').length>0){
		
		// Sub Page Slider
		sub_slider_area=".sub_slider";	

		$(sub_slider_area).cycle({ 
			fx:     'fade', 
			timeout:  4000,
			pager:'.sub_slider_pager',
			cleartype:  1
		});
		
	}
        
	
      jQuery('.prev, .next').css({opacity:0});
      jQuery('#slider').hover(function()
      {
              jQuery('.prev, .next').stop().animate({opacity:1},400);
      },
      function()
      {
              jQuery('.prev, .next').stop().animate({opacity:0},400);
      });


	function onBefore() {
		if (showEffect!="false"){
			jQuery('.desc').stop().animate({opacity:0},0);
		}else{
				
		}
	} 
	function onAfter() {
		if (showEffect!="false"){
			jQuery('.desc').stop().animate({opacity:1},400);
		}else{
				
		}			
	}
	
});


//pretty photo
$(document).ready(function(){
	$("a[rel^='prettyPhoto']").prettyPhoto();
});

//cycle
$(document).ready(function(){
	$('.bitnews').cycle({
		fx: 'scrollVert',
		speed:  300,
		next: '#next2', 
		prev: '#prev2', 
		timeout: 4000,	
		delay: -2000
	});
});

//drop down menu
$(document).ready(function() {
	$("#navigation li").each(function()
	{   
            $(this).hover(function()
            {	
                       $(this).find('ul:first').stop().css({
                             paddingTop:"8px",                              
                             height:"auto",
                             overflow:"hidden",
                             display:"none"
                             }).slideDown(200, function()
                       {
                       $(this).css({
                             height:"auto",
                             overflow:"visible"
                       });
            });
                       
            },
            
            function()
            {	
                 $(this).find('ul:first').stop().slideUp(200, function()
                 {	
                         $(this).css({
                          display:"none",
                          overflow:"hidden"
                          });
                 });
            });	
	});
        
        $("#navigation ul ").css({
            display: "none"}
         ); 
});


//search field function
$(document).ready(function() {
	var search_text=jQuery(".search_bar .search_text").val();

	jQuery(".search_bar .search_text").focus(function() {
		jQuery(".search_bar .search_text").val('');
	})
});
	 

//preloading 
$(function () {
	//$('.preload').hide();//hide all the images on the page
	$('.play,.magnifier').css({opacity:0});
	$('.preload').css({opacity:0});
	$('.preload').addClass("animated");
	$('.play,.magnifier').addClass("animated_icon");
});


var i = 0;//initialize
var cint=0;//Internet Explorer Fix
$(window).bind("load", function() {//The load event will only fire if the entire page or document is fully loaded
	var cint = setInterval("PreImage(i)",70);//500 is the fade in speed in milliseconds
});

function PreImage() {
	var images = $('.preload').length;//count the number of images on the page
	if (i >= images) {// Loop the images
		clearInterval(cint);//When it reaches the last image the loop ends
	}
	//$('.preload:hidden').eq(i).fadeIn(500);//fades in the hidden images one by one
	$('.animated_icon').eq(0).animate({opacity:1},{"duration": 500});
	$('.animated').eq(0).animate({opacity:1},{"duration": 500});
	$('.animated').eq(0).removeClass("animated");
	$('.animated_icon').eq(0).removeClass("animated_icon");
	i++;//add 1 to the count
}

//image effects 
$(document).ready(function(){
         var image_e= $(".image.portf, .image.product_image");
         image_e.mouseover(function(){$(this).stop().animate({ opacity:0.7
                         }, 400);
         }).mouseout(function(){
                 image_e.stop().animate({ 
                         opacity:1
                         }, 400 );
         });
});


//Coda slider on product detail page
$(document).ready(function() {
  if ($('#product-slider').length>0){	
        $('#product-slider').codaSlider(
                {
                dynamicArrows: false,
                dynamicTabsAlign: "left",
                dynamicTabsPosition: "top"
                }
        );
  }
});

var mySlider;
var err;

$(document).ready(function() {
	try	{
		$("#imageSlideshow").sliderWallHorizontalList({
			cssClassSuffix: "",
			domainKeys: "1c96996bc8f39fa60e1bf67c16c64178",
			imageAlign: "middleCenter", /* topLeft, topCenter, topRight, middleLeft, middleCenter (default), middleRight, bottomLeft, bottomCenter, bottomRight */
			imageScaleMode: "scaleCrop", /* scale, scaleCrop (default), crop, stretch */
			loopContent: true,
			rssFeed: null,
			selectableContent: true,
			
			// slideshow options
			autoSlideShow: true,
			slideShowSpeed: 4,
			
			// timer control options
			showTimer: true,
			
			// control bar options
			autoHideControlBar: true,
			controlsHideDelay: 5,
			controlsShowHideSpeed: 0.2,
			showControlBar: true,
			playlistPosition: "bottom", /* bottom (default), top */
			thumbnailPaging: "bullets", /* bullets (default), numbering, none */
			slideItemBackground: true,
			showImageThumbnail: true,
			
			// navigation options
			autoHideNavButtons: true,
			showNavigationButtons: false,
			
			// text options
			showText: false,
			autoHideText: true,
			
			// interaction options
			useGestures: true,
			useKeyboard: true,
			useMouseScroll: true,
			pauseOnMouseOver: true,
			disableAutohideOnMouseOver: false,
			
			// transitions
			transitionType: {
				optimizeForIpad: false,  /* If set to true, it would use only the Alpha and Slide effects. */
				random: false,
				transitions: [
					/*
					Possible transitions: Alpha, AlphaBars, BrightSquares, Disc, FlipBars, Iris, LensGlare, None, Slide, SquareFade, SquareLight, Stripes, Waves, WaveScale, Wavy
					Possible tween types: Back, Bounce, Circ, Cubic, Elastic, Expo (default), Quad, Quart, Quint, Sine
					Possible easing types: easeIn, easeOut, easeInOut
					*/
					/*
					{
						name: "Alpha",
						duration: 0.75,
						tweenType: "Expo",
						easing: "easeInOut"
					}, 
					{
						name: "AlphaBars",
						duration: 1,
						tweenType: "Expo",
						easing: "easeOut",
						direction: "l2r",
						random: false,
						barWidth: 50
					}, 
					*/
					{
						name: "BrightSquares",
						duration: 1,
						tweenType: "Expo",
						easing: "easeOut",
						direction: "tl2br",
						random: false,
						tileWidth: 100,
						tileHeight: 100
					}, 
					/*
					{
						name: "Disc",
						duration: 1,
						tweenType: "Expo",
						easing: "easeInOut"
					}, 
					{
						name: "FlipBars",
						duration: 1,
						tweenType: "Expo",
						easing: "easeOut",
						direction: "l2r",
						random: false,
						barWidth: 80
					}, 
					{
						name: "Iris",
						duration: 1,
						tweenType: "Expo",
						easing: "easeInOut"
					}, 
					{
						name: "LensGlare",
						duration: 1,
						tweenType: "Expo",
						easing: "easeOut",
						gradientWidth: 100,
						margins: 20,
						lightOffset: 0,
						lightDirection: false
					}, 
					{
						name: "Slide",
						duration: 0.75,
						tweenType: "Expo",
						easing: "easeInOut",
						direction: "horizontal"
					}, 
					*/
					{
						name: "SquareFade",
						duration: 1.5,
						tweenType: "Expo",
						easing: "easeOut",
						direction: "tl2br",
						random: false,
						tileWidth: 100,
						tileHeight: 100
					},
					/*
					{
						name: "SquareLight",
						duration: 1,
						tweenType: "Expo",
						easing: "easeOut",
						direction: "tl2br",
						random: false,
						tileWidth: 100,
						tileHeight: 100
					}, 
					*/
					{
						name: "Stripes",
						duration: 1.5,
						tweenType: "Expo",
						easing: "easeInOut",
						direction: "l2r",
						random: false,
						barWidth: 50
					}, 
					/*
					{
						name: "Waves",
						duration: 1,
						tweenType: "Expo",
						easing: "easeIn",
						direction: "l2r",
						random: false,
						barWidth: 60
					}, 
					*/
					{
						name: "WaveScale",
						duration: 1.5,
						tweenType: "Expo",
						easing: "easeOut",
						maxWidth: 100
					}, 
					{
						name: "Wavy",
						duration: 1,
						tweenType: "Expo",
						easing: "easeOut",
						direction: "l2r",
						random: false,
						barWidth: 60
					}
				]
			},
			
			// callback functions
			init: null,
			contentLoadStart: null,
			contentLoadComplete: null,
			contentLoadError: null,
			contentShow: null,
			contentHide: null,
			slideClick: null,
			slideshowStart: null,
			slideshowStop: null,
			pageChange: null
		});
		
		// SliderWall methods (mySlider.next(), mySlider.getSelectedIndex()).
		mySlider = $("#imageSlideshow").data("sliderWall");
		
	} catch(err) { /* handle any error messages */ }
});


