var input_text;var bannerInt;$(document).ready(function(){    $('a[rel=lightbox]').fancybox({		'transitionIn'	: 'elastic',		'transitionOut'	: 'elastic',		'titlePosition' : 'over'	});    $('.input_text').focus(function(){        input_text = $(this).val();        $(this).val('');    });    $('.input_text').blur(function(){        if(!$(this).val()) $(this).val(input_text);    });    if($('.slideshow_m_fade').length) slideShow(0.6);    if($('.content_top .preview_category').length) bannerSlideShow();    if($('.slideshow_bottom_homepage').length) homeSlideShow();    $('.content_top .menu li').mouseenter(function(){        $(this).find('ul').stop(true, true).slideDown();    }).mouseleave(function(){        $(this).find('ul').stop(true, true).slideUp();    });    $('#preview_category_8 .previews').wSB({'position':'left', 'margin': 34, 'duration': 400, 'easing': 'swing', 'wheel':true, 'getThisHeight':true, 'buttons': {'jump': 80}});    if($('.list_category_main_realizations_list').length){        $('.list_category_main_realizations_list').wSB({'position':'right', 'margin': 49, 'duration': 400, 'easing': 'swing', 'wheel':true, 'getThisHeight':true, 'buttons': {'jump': 130}}).bottomFade();    }    if($('.products_list').length){        $('.products_list .photo_cnt').css('opacity', 0);        $('.products_list tr').mouseenter(function(){            var td = $(this).find('.photo');            if(td.html()) td.css({'display': 'table-cell', 'width': '0', 'padding': '0'}).find('.photo_cnt').stop(true, true).animate({'opacity': 1}, 400);        }).mouseleave(function(){            var td = $(this).find('.photo');            if(td.html()) td.find('.photo_cnt').stop(true,true).animate({'opacity': 0}, 400, function(){ td.css({'display': 'none'}) });        });    }});function homeSlideShow(){    var gl = $('.slideshow_bottom_homepage .photo').length;    if(gl > 6){        $('.slideshow_bottom_homepage').prepend('<div id="photos_left" class="photos_n"></div>');        $('.slideshow_bottom_homepage').append('<div id="photos_right" class="photos_n"></div>');//        $('.slideshow_bottom_homepage').addClass('sl_root_navi');        $('.slideshow_bottom_homepage').css('padding', '43px 15px 0 28px');        $('.slideshow_bottom_homepage .slideshow_container').addClass('sl_parent_navi');        $('.slideshow_bottom_homepage .slideshow_m_thumbs').addClass('sl_child_navi');        var slCont = $('.slideshow_bottom_homepage .slideshow_m_thumbs')[0];        $('#photos_left').click(function(){            if($(slCont).position().left <= -150 && !$(slCont).is(':animated')){                $(slCont).animate({                    left: $(slCont).position().left + 150                });            }        });        $('#photos_right').click(function(){            if($(slCont).position().left > -150 * (gl - 6) && !$(slCont).is(':animated')){                $(slCont).animate({                    left: $(slCont).position().left - 150                });            }        });    }}function bannerSlideShow(){    var interval = 8000;    var previews = $('.content_top .preview_category div.preview');	previews.css({/*opacity: 0.0, */'display': 'block'});    previews.find('h3, .preview_image, .preview_image_desc').css({opacity: 0.0, 'display': 'none'});    $('.content_top .preview_category').append('<div id="banner_top_navi" style="position: absolute; bottom: 13px; right: 18px;"></div>');    for(var i = 0; i<previews.length; i++) $('#banner_top_navi').append('<div class="banner_top_navi_w"></div>');    $('#banner_top_navi .banner_top_navi_w:first').addClass('show');    $('.content_top .preview_category div.preview:first').find('h3, .preview_image, .preview_image_desc').css({opacity: 1.0, 'display': 'block'});//	$('.content_top .preview_category div.preview:first').css({opacity: 1.0});//	$('.content_top .preview_category .caption').css({width: $('.slideshow_m_fade div').find('img').css('width')});//	$('.content_top .preview_category .content').html($('.slideshow_m_fade div:first').find('img').attr('alt')).animate({opacity: 1.0}, 400);    $('#banner_top_navi .banner_top_navi_w').click(function(){        if(!$(this).hasClass('show')){            clearInterval(bannerInt);//            $('.content_top .preview_category div.preview.show').removeClass('show');            $($('.content_top .preview_category div.preview')[$('#banner_top_navi .banner_top_navi_w').index(this)]).addClass('next');            bannerGallery();            bannerInt = setInterval(function(){bannerGallery();},interval);        }    });	bannerInt = setInterval(function(){bannerGallery();},interval);}function bannerGallery(){    var duration = 3000;	var current = ($('.content_top .preview_category div.preview.show').length ?  $('.content_top .preview_category div.preview.show') : $('.content_top .preview_category div.preview:first'));	var next = (($('.content_top .preview_category div.preview.next').length) ? $('.content_top .preview_category div.preview.next') : (current.next().length) ? current.next() : $('.content_top .preview_category div.preview:first'));    next.addClass('show').removeClass('next')/*.css({opacity: 1.0})*/;    next.find('.preview_image').css({opacity: 0.0, 'display': 'block'}).animate({opacity: 1.0}, duration);    var nextLinks = next.find('h3, .preview_image_desc');    nextLinks.pause(duration/2, function(){ $(nextLinks).css({opacity: 0.0, 'display': 'block'}); }).animate({opacity: 1.0}, duration/2);    current.removeClass('show')/*.css({opacity: 0.0})*/;	current.find('.preview_image').animate({opacity: 0.0}, duration);    var currentLinks = current.find('h3, .preview_image_desc');    currentLinks.css({opacity: 1.0}).animate({opacity: 0.0}, duration/2, function(){ $(currentLinks).css('display', 'none'); });    $('#banner_top_navi .banner_top_navi_w.show').removeClass('show');    $($('#banner_top_navi .banner_top_navi_w')[$('.content_top .preview_category div.preview').index(next)]).addClass('show');//	$('.slideshow_m_fade .caption').animate({opacity: 0.0}, {queue:false, duration:50}).animate({top: '-' + $('.slideshow_m_fade .caption').height() + 'px'}, {queue:true, duration:300, complete:function(){$('.slideshow_m_fade .content').html(caption);}});//	$('.slideshow_m_fade .caption').animate({opacity: op},100 ).animate({top: '0px'},500 );}function slideShow(op){	$('.slideshow_m_fade div').css({opacity: 0.0});	$('.slideshow_m_fade div:first').css({opacity: 1.0});	$('.slideshow_m_fade .caption').css({opacity: op});	$('.slideshow_m_fade .caption').css({width: $('.slideshow_m_fade div').find('img').css('width')});	$('.slideshow_m_fade .content').html($('.slideshow_m_fade div:first').find('img').attr('alt')).animate({opacity: 1.0}, 400);	setInterval(function(){gallery(op);},8000);}function gallery(op){	var current = ($('.slideshow_m_fade div.show').length ?  $('.slideshow_m_fade div.show') : $('.slideshow_m_fade div:first'));	var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('.slideshow_m_fade div:first') :current.next()) : $('.slideshow_m_fade div:first'));	var caption = next.find('img').attr('alt');			next.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 1000);	current.animate({opacity: 0.0}, 1000).removeClass('show');	$('.slideshow_m_fade .caption').animate({opacity: 0.0}, {queue:false, duration:50}).animate({top: '-' + $('.slideshow_m_fade .caption').height() + 'px'}, {queue:true, duration:300, complete:function(){$('.slideshow_m_fade .content').html(caption);}});	$('.slideshow_m_fade .caption').animate({opacity: op},100 ).animate({top: '0px'},500 );}$.fn.wSB = function(params){    var container, newTop;	var scrollable = $(this);	var parent = scrollable.parent();    if(params.getThisHeight){        container = $.create('div', {'class': 'wsb_wrapper', 'style': 'overflow:hidden; height:' + scrollable.height() + 'px; position:relative;'});        scrollable.css({'height': 'auto', 'overflow': 'visible'});    }    else{    	container = $.create('div', {'class': 'wsb_wrapper', 'style': 'overflow:hidden; height:' + parent.height() + 'px; position:relative;'});    }	parent.append($(container));	$(container).append(scrollable);	var topRange;	topRange = scrollable.height() - $(container).height();	if(topRange>0){      var paddingOnSide = scrollable.css('padding-' + params.position);	  scrollable.css({'position': 'absolute', 'top':'0px',/* 'width':'100%',*/ 'padding': 0});      scrollable.css(params.position, params.margin + 'px');      $(container).css('padding-' + params.position, paddingOnSide);      topRange = scrollable.height() - $(container).height();	  var scrollRange;      var scrollCnt = $.create('div', {'class': 'scroll_container', 'style': 'float:' + params.position + ';'});	  var scrollBar = $.create('div', {'class': 'scroll_bar', 'style': 'position:relative; height:100%'});	  var scroll = $.create('div', {'class': 'scroll', 'style': 'position:absolute; top:0px; cursor:pointer;'});      if(params.buttons){          var btnUp = $.create('div', {'class': 'btn_up'});          var btnDown = $.create('div', {'class': 'btn_down'});          $(scrollCnt).prepend($(btnUp));          $(scrollCnt).append($(scrollBar).append($(scroll)));          $(scrollCnt).append($(btnDown));          $(container).prepend($(scrollCnt));          $(scrollBar).css('height', $(scrollBar).height() - ($(btnUp).height() + $(btnDown).height()) );      }      else $(container).prepend($(scrollCnt).append($(scrollBar).append($(scroll))));	  scrollRange = ($(scrollBar).height() - $(scroll).height());	  $(scroll).draggable({		refreshPositions: true,		axis: 'y',		containment: 'parent',		drag: function(event, ui){            scrollable.stop(true,false).animate({'top': "-" + parseInt(calculateTop(topRange, scrollRange)) + "px"},params.duration,params.easing);		},		stop: function(event, ui){            scrollable.animate({'top': "-" + parseInt(calculateTop(topRange, scrollRange)) + "px"},params.duration,params.easing);		}	  });      if(params.buttons){      	$(btnUp).click(function(){            newTop = parseInt(scrollable.css('top').substring(0,(scrollable.css('top').length - 2))) + params.buttons.jump;            newTop = newTop>0?0:newTop;            scrollable.animate({'top': newTop + "px"},params.duration,params.easing);            $(scroll).css('top', Math.round(-newTop*scrollRange/topRange) + "px");        });        $(btnDown).click(function(){            newTop = parseInt(scrollable.css('top').substring(0,(scrollable.css('top').length - 2))) - params.buttons.jump;            newTop = -newTop>topRange?-topRange:newTop;            scrollable.animate({'top': newTop + "px"},params.duration,params.easing);            $(scroll).css('top', Math.round(-newTop*scrollRange/topRange) + "px");        });      }        if(params.wheel)		$(container).wheel(function(event, delta){            event.preventDefault();			newTop = parseInt(calculateTopOnScroll(scrollable, topRange, delta));            scrollable.stop(true,false).animate({'top': "-" + newTop + "px"},params.duration,params.easing);			$(scroll).css('top', Math.round(newTop*scrollRange/topRange) + "px");		});    }	function calculateTop(topRange, scrollRange){		var top;		var position;		position = parseInt($(scroll).css('top').substring(0,($(scroll).css('top').length - 2)))/scrollRange;		top = topRange * position;		return Math.round(top);	}	function calculateTopOnScroll(scrollable, topRange, delta){		var newTop = -parseInt(scrollable.css('top').substring(0,(scrollable.css('top').length - 2))) + parseInt(40 * -delta);		newTop = newTop<0?0:newTop;		newTop = newTop>topRange?topRange:newTop;		return newTop;	}    return $(this);};$.fn.bottomFade = function( intIndex ){    var jImg = $( this );    var jParent = null;    var jDiv = null;    var intStep = 0;    jParent = jImg.parent();//    jParent.css( "position", "relative" ).width( jImg.width() ).height( jImg.height() );    for (intStep = 0; intStep <= 25 ; intStep++ ){        jDiv = $( "<div></div>" );        jDiv.css(                {                    backgroundColor: "#000000",                    opacity: (intStep * 1.5 / 100),                    bottom: ((50 - (intStep * 2) ) + "px"),                    right: "49px",                    position: "absolute"                }                )            .width( jImg.width() )            .height( 2 );        jParent.append( jDiv );    }};jQuery.create = function() {    if (arguments.length == 0) return [];    var args = arguments[0] || {}, elem = null, elements = null;    var siblings = null;    // In case someone passes in a null object,    // assume that they want an empty string.    if (args == null) args = "";    if (args.constructor == String) {        if (arguments.length > 1) {            var attributes = arguments[1];                if (attributes.constructor == String) {                            elem = document.createTextNode(args);                            elements = [];                            elements.push(elem);                            siblings =        jQuery.create.apply(null, Array.prototype.slice.call(arguments, 1));                            elements = elements.concat(siblings);                            return elements;                    } else {                            elem = document.createElement(args);                            // Set element attributes.                            var attributes = arguments[1];                            for (var attr in attributes)                                jQuery(elem).attr(attr, attributes[attr]);                            // Add children of this element.                            if(arguments[2]){                                var children = arguments[2];                                children = jQuery.create.apply(null, children);                                jQuery(elem).append(children);                            }                            // If there are more siblings, render those too.                            if (arguments.length > 3) {                                    siblings =        jQuery.create.apply(null, Array.prototype.slice.call(arguments, 3));                                    return [elem].concat(siblings);                            }                            return elem;                    }            } else return document.createTextNode(args);      } else {              elements = [];              elements.push(args);              siblings =        jQuery.create.apply(null, (Array.prototype.slice.call(arguments, 1)));              elements = elements.concat(siblings);              return elements;      }};$.fn.pause = function(duration, callback) {    if(callback === undefined) callback = function(){};    $(this).animate({dummy: 1}, duration, callback);    return this;};
