$(document).ready(function() {
	
	

$(".search-string")
   .focus(function(){
      $(this).css("color", "black");
      if ($(this).val() == "") {
         $(this).val("");
      }
   })
   .blur(function(){
   	 $(this).css("color", "#6E6E6E");
      if ($(this).val() == "") {
         $(this).val("Поиск по сайту");
      }
   });
   

   
  
  
  	$('.b-bank-cards-to-courier a').click(function (e) {
		e.preventDefault();
		$('.b-bank-cards-to-courier-info').modal();
	});
	
		$('.b-express-delivery a').click(function (e) {
		e.preventDefault();
		$('.b-express-delivery-info').modal();
	});
	
		$('.b-giftpack a').click(function (e) {
		e.preventDefault();
		$('.b-giftpack-info').modal();
	});
	
		$('#schema a').click(function (e) {
		e.preventDefault();
		$('#schema-info').modal();
	});
	
		$('.pickup a').click(function (e) {
		e.preventDefault();
		$('.b-pickup').modal();
	});
	
		$('.j-stores-available a').click(function (e) {
		e.preventDefault();
		$('.b-stores-available').modal();
	});
	
	
			$('.j-delivery-today').click(function (e) {
		e.preventDefault();
		$('.b-delivery-today-box').modal();
	});


$('.b-more-images-toggle').click(function() {
  $('.b-more-images').toggle('fast', function() {
    // Animation complete.
  });
});

$('.gorbushka').click(function() {
  $('.gorbushka-store').show('fast', function() {
    // Animation complete.
  });
});

$('.presnya').click(function() {
  $('.presnya-store').show('fast', function() {
    // Animation complete.
  });
});

$('.gb').click(function() {
  $('.gb-store').show('fast', function() {
    // Animation complete.
  });
});

$('.mega-bd').click(function() {
  $('.mega-bd-store').show('fast', function() {
    // Animation complete.
  });
});

$('.mega-him').click(function() {
  $('.mega-him-store').show('fast', function() {
    // Animation complete.
  });
});




$('.j-close-store-box').click(function() {
  $('.b-map-store-box').hide('fast', function() {
    // Animation complete.
  });
});



});  
   
   
   

function conf_recycled(url,msg)
 { 
  if(window.confirm("Вы действительно хотите удалить объект?\n"+msg)) {window.location.href=url;}
 } 

function print_window(id,type,w,h,sb)
 {
  nw=window.open('/print_page.shtml?type='+type+'&id='+id, 'print_window', 'width=780,height=560,scrollbars=yes');
  nw.focus();
 }

function morefoto_window(id)
{
  nw=window.open('/morefoto.shtml?good='+id, 'morefoto_window', 'width=500,height=500,scrollbars=no');
  nw.focus();
}

/**
* Name: piroBox v.1.2.2
* Date: May 2010
* Autor: Diego Valobra (http://www.pirolab.it),(http://www.diegovalobra.com)
* Version: 1.2.2
* Licence: CC-BY-SA http://creativecommons.org/licenses/by-sa/2.5/it/
**/

(function($) {
	$.fn.piroBox = function(opt) {
		opt = jQuery.extend({
		my_speed : null,
		close_speed : 300,
		bg_alpha : 0.5,
		close_all : '.piro_close,.piro_overlay',
		slideShow : null,
		slideSpeed : null
		}, opt);

		function start_pirobox() {
		  var corners = 
			  '<tr>'+					   
			  '<td colspan="3" class="pirobox_up"></td>'+
			  '</tr>'+	
			  '<tr>'+	
			  '<td class="t_l"></td>'+
			  '<td class="t_c"></td>'+
			  '<td class="t_r"></td>'+
			  '</tr>'+
			  '<tr>'+
			  '<td class="c_l"></td>'+
			  '<td class="c_c"><span><span></span></span><div></div></td>'+
			  '<td class="c_r"></td>'+
			  '</tr>'+
			  '<tr>'+
			  '<td class="b_l"></td>'+
			  '<td class="b_c"></td>'+
			  '<td class="b_r"></td>'+
			  '</tr>'+
			  '<tr>'+
			  '<td colspan="3" class="pirobox_down"></td>'+
			  '</tr>';
			var window_height =  $(document).height();
			var bg_overlay = $(jQuery('<div class="piro_overlay"></div>').hide().css({'opacity':+opt.bg_alpha,'height':window_height+'px'}));
			var main_cont = $(jQuery('<table class="pirobox_content" cellpadding="0" cellspacing="0"></table>'));
			var caption = $(jQuery('<div class="caption"></div>'));
			var piro_nav = $(jQuery('<div class="piro_nav"></div>'));
			var piro_close = $(jQuery('<a href="#close" class="piro_close" title="close"></a>'));
			var piro_play = $(jQuery('<a href="#play" class="play" title="play slideshow"></a>'));
			var piro_stop = $(jQuery('<a href="#stop" class="stop" title="stop slideshow"></a>'));
			var piro_prev = $(jQuery('<a href="#prev" class="piro_prev" title="previous image"></a>'));
			var piro_next = $(jQuery('<a href="#next" class="piro_next" title="next image"></a>'));				
			$('body').append(bg_overlay).append(main_cont);
			main_cont.append(corners);
			$('.pirobox_up').append(piro_close);
			$('.pirobox_down').append(piro_nav);
			$('.pirobox_down').append(piro_play);
			piro_play.hide();
			$('.pirobox_down').append(piro_prev).append(piro_next);
			piro_nav.append(caption);
			var my_nav_w = piro_prev.width();
			main_cont.hide();
			var my_gall_classes = $("a[class^='pirobox']");
			var map = new Object();
				for (var i=0; i<my_gall_classes.length; i++) {
					var it=$(my_gall_classes[i])
					map['a.'+it.attr('class')]=0;
				}
			var gall_settings = new Array();
				for (var key in map) {
					gall_settings.push(key);
				}
				for (var i=0; i<gall_settings.length; i++) {
					$(gall_settings[i]).each(function(rel){this.rel = rel+1 + "&nbsp;of&nbsp;" + $(gall_settings[i]).length;});
						var add_first = $(gall_settings[i]+':first').addClass('first');
						var add_last = $(gall_settings[i]+':last').addClass('last');
				}						
			$(my_gall_classes).each(function(rev){this.rev = rev+0});
			var imgCache = $(my_gall_classes).each(function(){this.href});
			var hidden = $('body').append('<div id="imgCache" style="display:none"></div').children('#imgCache');
			$.each(imgCache, function (i,val) {
				$('<div/>').css({'background':'url('+val+')'/*,'width':'600px','height':'200px'*/}).appendTo(hidden);
			});
			var piro_gallery = $(my_gall_classes);
			$.fn.fixPNG = function() {
				return this.each(function () {
					var image = $(this).css('backgroundImage');
					if (image.match(/^url\(["']?(.*\.png)["']?\)$/i)) {
						image = RegExp.$1;
						$(this).css({
							'backgroundImage': 'none',
							'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=" + ($(this).css('backgroundRepeat') == 'no-repeat' ? 'crop' : 'scale') + ", src='" + image + "')"
						}).each(function () {
							var position = $(this).css('position');
							if (position != 'absolute' && position != 'relative')
								$(this).css('position', 'relative');
						});
					}
				});
			};
			$.browser.msie6 =($.browser.msie && /MSIE 6\.0/i.test(window.navigator.userAgent));
			if( $.browser.msie6 && !/MSIE 8\.0/i.test(window.navigator.userAgent)) {
				$('.t_l,.t_c,.t_r,.c_l,.c_r,.b_l,.b_c,.b_r,a.piro_next, a.piro_prev,a.piro_prev_out,a.piro_next_out,.c_c,.piro_close,a.play,a.stop').fixPNG();
				var ie_w_h =  $(document).height();
				bg_overlay.css('height',ie_w_h+ 'px'); 
			}
			if( $.browser.msie) {
			opt.close_speed = 0;
			}
			$(window).resize(function(){
				var new_w_bg = $(document).height();
				bg_overlay.css({'visibility':'visible','height':+ new_w_bg +'px'});				  
			});	
			piro_prev.add(piro_next).bind('click',function(c) {
				c.preventDefault();
				var image_count = parseInt($(piro_gallery).filter('.item').attr('rev'));
				var start = $(this).is('.piro_prev_out,.piro_prev') ? $(piro_gallery).eq(image_count - 1) : $(piro_gallery).eq(image_count + 1);
				if(!start.size()) {
					start = $(this).is('.piro_prev_out,.piro_prev') ? $(piro_gallery).eq($(piro_gallery).size() - 1) : $(piro_gallery).eq(0);
				}
				start.click();
				piro_close.add(caption).add(piro_next).add(piro_prev).css('visibility','hidden');
			});
			$(piro_gallery).each(function(array) {
					var item = $(this);
					item.unbind(); 
					item.bind('click',function(c) {
						c.preventDefault();
						piro_open(item.attr('href'));
						var this_url = item.attr('href');
						//var descr = item.children('span').html();
						var descr = item.attr('title');	
						var number = item.attr('rel');

						if(item.is('.last')){
							$('.number').css('text-decoration','underline');
							
						}else{
							$('.number').css('text-decoration','none');
							}				
						if(item.is('.first')){
							piro_prev.hide();
							piro_next.show();		
						}else{
							piro_next.add(piro_prev).show();		  
						}
						if(item.is('.last')){
							piro_prev.show();
							piro_next.hide();
							piro_play.css('width','0');	  
						}else{
							piro_play.css('width','40px');
							}
						if(item.is('.last') && item.is('.first') ){
							piro_prev.add(piro_next).hide();
							$('.number').hide();
							piro_play.remove();
						}					
							$(piro_gallery).filter('.item').removeClass('item');
							item.addClass('item');
							$('.c_c').removeClass('unique');		
					});
				});
				var piro_open = function(my_url) {
					piro_play.add(piro_stop).hide();
					piro_close.add(caption).add(piro_next).add(piro_prev).css('visibility','hidden');
					if(main_cont.is(':visible')) {
						$('.c_c div').children().fadeOut(300, function() {
							$('.c_c div').children().remove();
							load_img(my_url);
						});
					} else {
						$('.c_c div').children().remove();
						main_cont.show();
						bg_overlay.fadeIn(300,function(){
						load_img(my_url);
						});
					}
				}
				var load_img = function(my_url) {
				if(main_cont.is('.loading')) {return;}
				main_cont.addClass('loading');
				var img = new Image();
				img.onerror = function (){
					var main_cont_h = $(main_cont).height();
					main_cont.css({marginTop : parseInt($(document).scrollTop())-(main_cont_h/1.9)});
				  $('.c_c div').append('<p class="err_mess">There seems to be an Error:&nbsp;<a href="#close" class="close_pirobox">Close Pirobox</a></p>');
					$('.close_pirobox').bind('click',function(c) {
						c.preventDefault();
						piro_close.add(bg_overlay).add(main_cont).add(caption).add(piro_next).add(piro_prev).hide(0,function(){ img.src = '';});
						main_cont.removeClass('loading');
					});
				}
				img.onload = function() {
					var imgH = img.height;
					var imgW = img.width;
					var main_cont_h = $(main_cont).height();
					var w_H = $(window).height();
					var w_W = $(window).width();
					$(img).height(imgH).width(imgW).hide();
						$('.c_c div').animate({height:imgH+'px',width:imgW+'px'},opt.my_speed);
						var fix = imgH/w_H*2.3;
						if(w_H < imgH){h_fix = fix;}else{h_fix = 2;}
						main_cont.animate({
						height : (imgH+40) + 'px' ,
						width : (imgW+40) + 'px' , 
						marginLeft : '-' +((imgW)/2+20) +'px',
						marginTop : parseInt($(document).scrollTop())-(imgH/h_fix)},opt.my_speed, function(){
						$('.piro_nav,.caption').css({width:(imgW)+'px','margin-bottom':'10px'});
						$('.piro_nav').css('margin-left','-'+(imgW)/2+'px');
							var caption_height = caption.height();
							$('.c_c div').append(img);					
							piro_close.css('display','block');
							piro_next.add(piro_prev).add(piro_close).css('visibility','visible');
							caption.css({'visibility':'visible','display':'block','opacity':'0.8','overflow':'hidden'});
							main_cont.hover(function(){
								caption.stop().fadeTo(200,0.8);},
								function(){caption.stop().fadeTo(200,0);
								});
								$(img).fadeIn(300);
									main_cont.removeClass('loading');
									if(opt.slideShow === true){
									   piro_play.add(piro_stop).show();
									}else{
										 piro_play.add(piro_stop).hide();
									}	
							});			
						}
					img.src = my_url;
					$('html').bind("keyup", function (c) {
						 if(c.keyCode == 27) {
							c.preventDefault();
							if($(img).is(':visible') || $('.c_c>div>p>a').is('.close_pirobox')){
								$(piro_gallery).removeClass('slideshow').removeClass('item');
								piro_close.add(bg_overlay).add(main_cont).add(caption).add(piro_next).add(piro_prev).hide(0,function(){ img.src = '';});
								main_cont.removeClass('loading');
								clearTimeout(timer);
								$(piro_gallery).children().removeAttr('class');
								$('.stop').remove();
								$('.c_c').append(piro_play);
								$('.sc_menu').css('display','none');
								$('ul.sc_menu li a').removeClass('img_active').css('opacity','0.4');	
								piro_next.add(piro_prev).show().css({'top':'50%'});	
								$(piro_gallery).children().fadeTo(100,1);
							}
						}
					});
					$('html').bind("keyup" ,function(e) {
						 if ($('.item').is('.first')){
						}else if(e.keyCode == 37){
						e.preventDefault();
							if($(img).is(':visible')){
								clearTimeout(timer);
								$(piro_gallery).children().removeAttr('class');
								$('.stop').remove();
								$('.c_c').append(piro_play);
								piro_prev.click();
							}
						 }
					});
					$('html').bind("keyup" ,function(z) {
						if ($('.item').is('.last')){
						}else if(z.keyCode == 39){
						z.preventDefault();
							if($(img).is(':visible')){
								clearTimeout(timer);
								$(piro_gallery).children().removeAttr('class');
								$('.stop').remove();
								$('.c_c').append(piro_play);
								piro_next.click();
								//alert('click')
							}
						}
					});
					var win_h = $(window).height();
					piro_stop.bind('click',function(x){
						x.preventDefault();
						clearTimeout(timer);
						$(piro_gallery).removeClass('slideshow');
						$('.stop').remove();
						$('.pirobox_down').append(piro_play);
						piro_next.add(piro_prev).css('width',my_nav_w+'px');
					});
					piro_play.bind('click',function(w){
						w.preventDefault();
						clearTimeout(timer);
						if($(img).is(':visible')){
						$(piro_gallery).addClass('slideshow');
						$('.play').remove();
						$('.pirobox_down').append(piro_stop);
						}
						piro_next.add(piro_prev).css({'width':'0px'});
						return slideshow();
					});
				  $(opt.close_all).bind('click',function(c) {
					$(piro_gallery).removeClass('slideshow');
					clearTimeout(timer);
					if($(img).is(':visible')){
						c.preventDefault();
						piro_close.add(bg_overlay).add(main_cont).add(caption).add(piro_next).add(piro_prev).hide(0,function(){ img.src = '';});
						main_cont.removeClass('loading');
						$(piro_gallery).removeClass('slideshow');
						piro_next.add(piro_prev).css('width',my_nav_w+'px').hide();
						$('.stop').remove();
						$('.pirobox_down').append(piro_play);
						piro_play.hide();
					}
				  });	
					if(opt.slideShow === true){
						function slideshow(){
							if( $(piro_gallery).filter('.item').is('.last')){
							clearTimeout(timer);
							$(piro_gallery).removeClass('slideshow');
							$('.stop').remove();
							$('.pirobox_down').append(piro_play);
							piro_next.add(piro_prev).css('width',my_nav_w+'px');								 
							} else if($(piro_gallery).is('.slideshow' ) && $(img).is(':visible')){
								clearTimeout(timer);
								piro_next.click();
							}
						}					
						var timer = setInterval(slideshow,opt.slideSpeed*1000 );
					}


				}
			}

		start_pirobox();
	}
})(jQuery);

$(document).ready(function() {
	$().piroBox({
			my_speed: 0, //animation speed
			bg_alpha: 0.1, //background opacity
			close_all : '.piro_close,.piro_overlay'// add class .piro_overlay(with comma)if you want overlay click close piroBox

	});
	
	
	
	//AJAX-загрузка города
	
    $('#msk').click(function(){      
        $('.city').load('/php/geoip.php?msk');
        $('#banner_place').load('/ssi/geo-banner/msk.shtml');
    })	
	  $('#spb').click(function(){     
        $('.city').load('/php/geoip.php?spb');
        $('#banner_place').load('/ssi/geo-banner/spb.shtml'); 
    })
	  $('#vladimir').click(function(){     
        $('.city').load('/php/geoip.php?vladimir'); 
        $('#banner_place').load('/ssi/geo-banner/vladimir.shtml');
    })
	  $('#tula').click(function(){     
        $('.city').load('/php/geoip.php?tula');
        $('#banner_place').load('/ssi/geo-banner/tula.shtml'); 
    })    
	  $('#kaluga').click(function(){     
        $('.city').load('/php/geoip.php?kaluga');
        $('#banner_place').load('/ssi/geo-banner/kaluga.shtml');
    })    
	  $('#ryazan').click(function(){     
        $('.city').load('/php/geoip.php?ryazan');
        $('#banner_place').load('/ssi/geo-banner/ryazan.shtml'); 
    })    
	  $('#tver').click(function(){     
        $('.city').load('/php/geoip.php?tver'); 
        $('#banner_place').load('/ssi/geo-banner/tver.shtml');
    })    
	  $('#yaroslavl').click(function(){     
        $('.city').load('/php/geoip.php?yaroslavl');
        $('#banner_place').load('/ssi/geo-banner/yaroslavl.shtml'); 
    })    
	  $('#orel').click(function(){     
        $('.city').load('/php/geoip.php?orel'); 
        $('#banner_place').load('/ssi/geo-banner/orel.shtml');
    })    
	  $('#bryansk').click(function(){     
        $('.city').load('/php/geoip.php?bryansk');
        $('#banner_place').load('/ssi/geo-banner/bryansk.shtml'); 
    })
	  $('#vologda').click(function(){     
        $('.city').load('/php/geoip.php?vologda');
        $('#banner_place').load('/ssi/geo-banner/vologda.shtml'); 
    })
	  $('#ivanovo').click(function(){     
        $('.city').load('/php/geoip.php?ivanovo');
        $('#banner_place').load('/ssi/geo-banner/ivanovo.shtml'); 
    }) 
	  $('#chelyabinsk').click(function(){     
        $('.city').load('/php/geoip.php?chelyabinsk');
        $('#banner_place').load('/ssi/geo-banner/chelyabinsk.shtml'); 
    }) 
	  $('#tyumen').click(function(){     
        $('.city').load('/php/geoip.php?tyumen');
        $('#banner_place').load('/ssi/geo-banner/tyumen.shtml'); 
    }) 
		  $('#nijnov').click(function(){     
        $('.city').load('/php/geoip.php?nijnov');
        $('#banner_place').load('/ssi/geo-banner/nijnov.shtml'); 
    }) 
		  $('#yekaterinburg').click(function(){     
        $('.city').load('/php/geoip.php?yekaterinburg');
        $('#banner_place').load('/ssi/geo-banner/yekaterinburg.shtml'); 
    }) 
	  $('#other').click(function(){     
        $('.city').load('/php/geoip.php?other');
        $('#banner_place').load('/ssi/geo-banner/other.shtml'); 
    })




$.ajaxSetup({
  'beforeSend' : function(xhr) {
    xhr.overrideMimeType('text/html; charset=windows-1251');
  },
});




    $('#other_regions_select #msk').click(function(){      
        $('#delivery_load').load('/ssi/delivery/msk.shtml');
    })	
	  $('#other_regions_select #spb').click(function(){     
        $('#delivery_load').load('/ssi/delivery/spb.shtml'); 
    })
	  $('#other_regions_select #vladimir').click(function(){     
        $('#delivery_load').load('/ssi/delivery/vladimir.shtml');
    })
	  $('#other_regions_select #tula').click(function(){     
        $('#delivery_load').load('/ssi/delivery/tula.shtml'); 
    })    
	  $('#other_regions_select #kaluga').click(function(){     
        $('#delivery_load').load('/ssi/delivery/kaluga.shtml');
    })    
	  $('#other_regions_select #ryazan').click(function(){     
        $('#delivery_load').load('/ssi/delivery/ryazan.shtml'); 
    })    
	  $('#other_regions_select #tver').click(function(){     
        $('#delivery_load').load('/ssi/delivery/tver.shtml');
    })    
	  $('#other_regions_select #yaroslavl').click(function(){     
        $('#delivery_load').load('/ssi/delivery/yaroslavl.shtml'); 
    })    
	  $('#other_regions_select #orel').click(function(){     
        $('#delivery_load').load('/ssi/delivery/orel.shtml');
    })    
	  $('#other_regions_select #bryansk').click(function(){     
        $('#delivery_load').load('/ssi/delivery/bryansk.shtml'); 
    })
	  $('#other_regions_select #vologda').click(function(){     
        $('#delivery_load').load('/ssi/delivery/vologda.shtml'); 
    })
	  $('#other_regions_select #ivanovo').click(function(){     
        $('#delivery_load').load('/ssi/delivery/ivanovo.shtml'); 
    }) 
	  $('#other_regions_select #chelyabinsk').click(function(){     
        $('#delivery_load').load('/ssi/delivery/chelyabinsk.shtml'); 
    })      
	  $('#other_regions_select #tyumen').click(function(){     
        $('#delivery_load').load('/ssi/delivery/tyumen.shtml'); 
    })   
	  $('#other_regions_select #nijnov').click(function(){     
        $('#delivery_load').load('/ssi/delivery/nijnov.shtml'); 
    })   
	  $('#other_regions_select #other').click(function(){     
        $('#delivery_load').load('/ssi/delivery/other.shtml'); 
    })    

  

$("#other_regions_select a").click(function(){
 
        $(this).toggleClass("active-region");
        $(this).siblings("a").removeClass("active-region");
     }); 
 
 
 
    
    
               
});
(function($){$.fn.slides=function(option){option=$.extend({},$.fn.slides.option,option);return this.each(function(){$('.'+option.container,$(this)).children().wrapAll('<div class="slides_control"/>');var elem=$(this),control=$('.slides_control',elem),total=control.children().size(),width=control.children().outerWidth(),height=control.children().outerHeight(),start=option.start-1,effect=option.effect.indexOf(',')<0?option.effect:option.effect.replace(' ','').split(',')[0],paginationEffect=option.effect.indexOf(',')<0?effect:option.effect.replace(' ','').split(',')[1],next=0,prev=0,number=0,current=0,loaded,active,clicked,position,direction,imageParent,pauseTimeout,playInterval;function animate(direction,effect,clicked){if(!active&&loaded){active=true;switch(direction){case'next':prev=current;next=current+1;next=total===next?0:next;position=width*2;direction=-width*2;current=next;break;case'prev':prev=current;next=current-1;next=next===-1?total-1:next;position=0;direction=0;current=next;break;case'pagination':next=parseInt(clicked,10);prev=$('.'+option.paginationClass+' li.current a',elem).attr('href').match('[^#/]+$');if(next>prev){position=width*2;direction=-width*2;}else{position=0;direction=0;}
current=next;break;}
if(effect==='fade'){option.animationStart();if(option.crossfade){control.children(':eq('+next+')',elem).css({zIndex:10}).fadeIn(option.fadeSpeed,option.fadeEasing,function(){if(option.autoHeight){control.animate({height:control.children(':eq('+next+')',elem).outerHeight()},option.autoHeightSpeed,function(){control.children(':eq('+prev+')',elem).css({display:'none',zIndex:0});control.children(':eq('+next+')',elem).css({zIndex:0});option.animationComplete(next+1);active=false;});}else{control.children(':eq('+prev+')',elem).css({display:'none',zIndex:0});control.children(':eq('+next+')',elem).css({zIndex:0});option.animationComplete(next+1);active=false;}});}else{option.animationStart();control.children(':eq('+prev+')',elem).fadeOut(option.fadeSpeed,option.fadeEasing,function(){if(option.autoHeight){control.animate({height:control.children(':eq('+next+')',elem).outerHeight()},option.autoHeightSpeed,function(){control.children(':eq('+next+')',elem).fadeIn(option.fadeSpeed,option.fadeEasing);});}else{control.children(':eq('+next+')',elem).fadeIn(option.fadeSpeed,option.fadeEasing,function(){if($.browser.msie){$(this).get(0).style.removeAttribute('filter');}});}
option.animationComplete(next+1);active=false;});}}else{control.children(':eq('+next+')').css({left:position,display:'block'});if(option.autoHeight){option.animationStart();control.animate({left:direction,height:control.children(':eq('+next+')').outerHeight()},option.slideSpeed,option.slideEasing,function(){control.css({left:-width});control.children(':eq('+next+')').css({left:width,zIndex:5});control.children(':eq('+prev+')').css({left:width,display:'none',zIndex:0});option.animationComplete(next+1);active=false;});}else{option.animationStart();control.animate({left:direction},option.slideSpeed,option.slideEasing,function(){control.css({left:-width});control.children(':eq('+next+')').css({left:width,zIndex:5});control.children(':eq('+prev+')').css({left:width,display:'none',zIndex:0});option.animationComplete(next+1);active=false;});}}
if(option.pagination){$('.'+option.paginationClass+' li.current',elem).removeClass('current');$('.'+option.paginationClass+' li:eq('+next+')',elem).addClass('current');}}}
function stop(){clearInterval(elem.data('interval'));}
function pause(){if(option.pause){clearTimeout(elem.data('pause'));clearInterval(elem.data('interval'));pauseTimeout=setTimeout(function(){clearTimeout(elem.data('pause'));playInterval=setInterval(function(){animate("next",effect);},option.play);elem.data('interval',playInterval);},option.pause);elem.data('pause',pauseTimeout);}else{stop();}}
if(total<2){return;}
if(start<0){start=0;}
if(start>total){start=total-1;}
if(option.start){current=start;}
if(option.randomize){control.randomize();}
$('.'+option.container,elem).css({overflow:'hidden',position:'relative'});control.children().css({position:'absolute',top:0,left:control.children().outerWidth(),zIndex:0,display:'none'});control.css({position:'relative',width:(width*3),height:height,left:-width});$('.'+option.container,elem).css({display:'block'});if(option.autoHeight){control.children().css({height:'auto'});control.animate({height:control.children(':eq('+start+')').outerHeight()},option.autoHeightSpeed);}
if(option.preload&&control.find('img').length){$('.'+option.container,elem).css({background:'url('+option.preloadImage+') no-repeat 50% 50%'});var img=control.find('img:eq('+start+')').attr('src')+'?'+(new Date()).getTime();if($('img',elem).parent().attr('class')!='slides_control'){imageParent=control.children(':eq(0)')[0].tagName.toLowerCase();}else{imageParent=control.find('img:eq('+start+')');}
control.find('img:eq('+start+')').attr('src',img).load(function(){control.find(imageParent+':eq('+start+')').fadeIn(option.fadeSpeed,option.fadeEasing,function(){$(this).css({zIndex:5});elem.css({background:''});loaded=true;});});}else{control.children(':eq('+start+')').fadeIn(option.fadeSpeed,option.fadeEasing,function(){loaded=true;});}
if(option.bigTarget){control.children().css({cursor:'pointer'});control.children().click(function(){animate('next',effect);return false;});}
if(option.hoverPause&&option.play){control.bind('mouseover',function(){stop();});control.bind('mouseleave',function(){pause();});}
if(option.generateNextPrev){$('.'+option.container,elem).after('<a href="#" class="'+option.prev+'">Prev</a>');$('.'+option.prev,elem).after('<a href="#" class="'+option.next+'">Next</a>');}
$('.'+option.next,elem).click(function(e){e.preventDefault();if(option.play){pause();}
animate('next',effect);});$('.'+option.prev,elem).click(function(e){e.preventDefault();if(option.play){pause();}
animate('prev',effect);});if(option.generatePagination){elem.append('<ul class='+option.paginationClass+'></ul>');control.children().each(function(){$('.'+option.paginationClass,elem).append('<li><a href="#'+number+'">'+(number+1)+'</a></li>');number++;});}else{$('.'+option.paginationClass+' li a',elem).each(function(){$(this).attr('href','#'+number);number++;});}
$('.'+option.paginationClass+' li:eq('+start+')',elem).addClass('current');$('.'+option.paginationClass+' li a',elem).click(function(){if(option.play){pause();}
clicked=$(this).attr('href').match('[^#/]+$');if(current!=clicked){animate('pagination',paginationEffect,clicked);}
return false;});$('a.link',elem).click(function(){if(option.play){pause();}
clicked=$(this).attr('href').match('[^#/]+$')-1;if(current!=clicked){animate('pagination',paginationEffect,clicked);}
return false;});if(option.play){playInterval=setInterval(function(){animate('next',effect);},option.play);elem.data('interval',playInterval);}});};$.fn.slides.option={preload:false,preloadImage:'/img/loading.gif',container:'slides_container',generateNextPrev:false,next:'next',prev:'prev',pagination:true,generatePagination:true,paginationClass:'pagination',fadeSpeed:350,fadeEasing:'',slideSpeed:350,slideEasing:'',start:1,effect:'slide',crossfade:false,randomize:false,play:0,pause:0,hoverPause:false,autoHeight:false,autoHeightSpeed:350,bigTarget:false,animationStart:function(){},animationComplete:function(){}};$.fn.randomize=function(callback){function randomizeOrder(){return(Math.round(Math.random())-0.5);}
return($(this).each(function(){var $this=$(this);var $children=$this.children();var childCount=$children.length;if(childCount>1){$children.hide();var indices=[];for(i=0;i<childCount;i++){indices[indices.length]=i;}
indices=indices.sort(randomizeOrder);$.each(indices,function(j,k){var $child=$children.eq(k);var $clone=$child.clone(true);$clone.show().appendTo($this);if(callback!==undefined){callback($child,$clone);}
$child.remove();});}}));};})(jQuery);
