jQuery(document).ready(function($) {
  document.getElementById('search_input').value = searchText;
   if (document.getElementById('mcs_container'))      $("#mcs_container").mCustomScrollbar("vertical",300,"easeOutCirc",1.05,10,"yes","yes",10);
   if (document.getElementById('mcs2_container'))     $("#mcs2_container").mCustomScrollbar("vertical",300,"easeOutCirc",1.05,10,"yes","yes",10);

  $(window).resize(function() {
    if (document.getElementById('bottom') && $(window).width() > $('#bottom').width())
      document.getElementById('bottom').style.width = ($(window).width() + 5)+"px";
    if (document.getElementById('bottom_yellow1') && $(window).width() > $('#bottom_yellow1').width())
      document.getElementById('bottom_yellow1').style.width = ($(window).width() + 0)+"px";
  });
		       

//   alert($(window).width() + $(document).width());  
  if (document.getElementById('bottom'))
    document.getElementById('bottom').style.width= $(document).width()+"px"; //window.scrollMaxX + window.innerWidth+"px";
  

  if (document.getElementById('bottom_yellow1'))
    document.getElementById('bottom_yellow1').style.width= $(document).width()+"px"; //window.scrollMaxX + window.innerWidth+"px";
  
  
  if (document.getElementById('thumbs')){
	// We only want these styles applied when javascript is enabled
	$('div.content').css('display', 'block');

	// Initially set opacity on thumbs and add
	// additional styling for hover effect on thumbs
	var onMouseOutOpacity = 0.67;
	$('#thumbs ul.thumbs li').opacityrollover({
		mouseOutOpacity:   onMouseOutOpacity,
		mouseOverOpacity:  1.0,
		fadeSpeed:         'fast',
		exemptionSelector: '.selected'
	});
	
// 	if (!galleryAutoStart) galleryAutoStart =false;
	
	// Initialize Advanced Galleriffic Gallery
	var gallery = $('#thumbs').galleriffic({
		delay:                     7000,
		numThumbs:                 15,
		preloadAhead:              10,
		enableTopPager:            true,
		enableBottomPager:         true,
		maxPagesToShow:            7,
		imageContainerSel:         '#slideshow',
		controlsContainerSel:      '#controls',
		captionContainerSel:       '#caption',
		loadingContainerSel:       '#loading',
		renderSSControls:          true,
		renderNavControls:         true,
		playLinkText:              'Play Slideshow',
		pauseLinkText:             'Pause Slideshow',
		prevLinkText:              '&lsaquo; Previous Photo',
		nextLinkText:              'Next Photo &rsaquo;',
		nextPageLinkText:          'Next &rsaquo;',
		prevPageLinkText:          '&lsaquo; Prev',
		enableHistory:             false,
		autoStart:                 galleryAutoStart,
		syncTransitions:           true,
		defaultTransitionDuration: 900,
		onSlideChange:             function(prevIndex, nextIndex) {
			// 'this' refers to the gallery, which is an extension of $('#thumbs')
			moving(nextIndex);
			$('#caption').find('div.caption').fadeTo(500, 0);
			this.find('ul.thumbs').children()
				.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
				.eq(nextIndex).fadeTo('fast', 1.0);
			},
			onPageTransitionOut:       function(callback) {
				this.fadeTo('fast', 0.0, callback);
			},
			onPageTransitionIn:        function() {
				this.fadeTo('fast', 1.0);
			},
			onTransitionIn: function(slide, caption, isSync) { onTrans(slide, caption, isSync); }
		});
    
  }
	
// 				moving();
});
var imgID = 5;
function moving(imgID){
// 				imgID ++;
// 				$.galleriffic.gotoImage(imgID+"");		
// 				if (imgID >8) imgID =5;
    if ($("#move_block")){
	$("#move_block").animate({
		top:  (46 + imgID * 74),
		duration: 2500,
		completeX: function(){document.getElementById('block').innerHTML += 'V'; f2(this);},
		easingX: "easein",
		easing: "linear",
		completeXX: function(){$(this).html("Animation Completed"); }
	}

	);
    }
}
			
function f1(){
	document.getElementById('block').innerHTML += 'M';
}
function f2(thiss){
	thiss.innerHTML += 'X';
}

     function show(element){
           element.className += "hover";
           }



   function hide(element){
           element.className = element.className = "";
     }


function onTrans(newSlide, newCaption, isSync){
	newSlide.fadeTo(1500, 1.0);
// 	newCaption.find('div.caption').fadeTo(1500, 1.0);
	newCaption.find('div.caption').css('opacity', '1');
	newCaption.find('div.caption').css('left', 300);
	newCaption.find('div.caption').delay(1500);
	newCaption.find('div.caption').animate({left:0},1500);

	

  return;
					// Construct new hidden caption for the image
					newCaption = this.$captionContainer
						.append('<span class="image-caption current"></span>')
						.find('div.caption').css('opacity', '0')
// 						.find('span.current').css('opacity', '0')
						.append(imageData.caption);  
  
}


function removeSearchText(){
   if (document.getElementById('search_input').value == searchText)
      document.getElementById('search_input').value ="";
  
}
