function setFlashWidth(divid, newW){
	document.getElementById(divid).style.width = newW+"px";
}
function setFlashHeight(divid, newH){
	document.getElementById(divid).style.height = newH+"px";		
}
function setFlashSize(divid){
    var w = $("#bw").val();
    var h = $("#bh").val();
    var aspect_ratio = h/w;
    
    if ($("#advert").width() <= w) {
		var newW = $("#advert").width();
		var newH = Math.abs(newW * aspect_ratio);
	} else {
		var newW = w;
		var newH = h;
	}
	setFlashWidth(divid, newW);
	setFlashHeight(divid, newH);
}
$(window).resize(function(){
    //$('#top_logo').html($('#jsNewProducts').width());
	setFlashSize("flashid");
    newProductsHideShow();
});
$(document).ready(function() {
    /*var tabsCookie = $.cookie('tabs');
    if(!tabsCookie) tabsCookie = 1;*/
    $('#leftTabs').tabs({
        cookie: {
            expires: 1
        }
    });
    /*$('ul.tabs-nav').children().click(function(){
        alert($('.tabs-nav > li').index(this));
        $.cookie('tabs',$('.tabs-nav > li').index(this));
        alert($.cookie('tabs'));
    });*/
});
$(document).ready(function(){
    //$.tabs('#leftTabs');
    //$('#leftTabs').tabs();
    var link = window.location.hash.replace('#',"").toString();
    //var link = "http://test.impakt.com.pl/gp,Airdrives,72.html#mod=producers&cid=4&id=1";
    var data = link.split('&');
    var param = Array();
    var value = Array();
    for(i=0;i<data.length;++i){
        var brk = data[i].split('=');
        param[i] = brk[0];
        value[i] = brk[1];
    }
    if(value[0] == 'producers'){
        if(value[1] > 0){
            $('#tab-groups-content').hide();
            $('#tab-products-content').show();
            $('.list-tabs-active').removeClass('list-tabs-active');
            $('#tab-products').addClass('list-tabs-active');
            $('.group_main-on').removeClass('group_main-on');
            $('#linkgroup'+value[1]+'prod').addClass('group_main-on');
            if(value[2] > 0){
                showGroup(value[1],value[2],'producers');
                $('#prod'+value[1]+'-'+value[2]).load(function(){
                    $('#prod'+value[1]+''+value[2]).removeClass().addClass('groups_hideLink-on');
                });
            }
        }
    }
    $("a[rel=gallery]").fancybox({
        'titleShow'		: false,
        'transitionIn'	: 'elastic',
        'transitionOut'	: 'elastic'
    });
    //$('.tooltip').tipsy({gravity: $.fn.tipsy.autoNS});
    $('.tooltip').tipsy({gravity: 'e'});
    newProductsHideShow();
});
$(window).scroll(function(){
    /* show/hide on scrolling 
    var pos = $('#toolbar').offset();
    if(pos.top > 127) toolBar('show');
    else if(pos.top <= 127) toolBar('hide');
    /* END show/hide on scrolling */
    scrollToolBar();
});
function toolBar(action,type) // if !action || action == 0 toggle!
{
    var userSet = $.cookie('toolbarImpakt');
    if(!action || action == 0) action = 0;
    else if(action != 'show' && action != 'hide') action = 0;
    
    var upSpeed = 100;
    var downSpeed = 300;
    
    if($('#toolbar-content').css('display') == 'none' && (action == 'show' || action == 0))
    {
        if(type == 'click')
        {
            $.cookie("toolbarImpakt", "show", { expires: 1 });
        }
        $('#toolbar-arrow').removeClass('show').addClass('hide');
        $('#toolbar').animate({
            top: '-32px'
        }, upSpeed, function() {
            $('#toolbar-content').show();
            $('#toolbar').animate({top: '0px'});
        });
    }
    else if($('#toolbar-content').css('display') != 'none' && (action == 'hide' || action == 0))
    {
        if(type == 'click')
        {
            $.cookie("toolbarImpakt", "hide", { expires: 1 });
        }
        $('#toolbar-arrow').removeClass('hide').addClass('show');
        $('#toolbar').animate({
            top: '-32px'
        }, upSpeed, function() {
            $('#toolbar-content').hide();
            $('#toolbar').animate({top: '0px'});
        });
    }

}
function scrollToolBar(){
    var userSet = $.cookie('toolbarImpakt');
    if(!userSet)
    {
        var pos = $('#toolbar').offset();
        if(pos.top > 127) toolBar('show');
        else if(pos.top <= 127) toolBar('hide');
    }    
}
$(function(){
    if($.cookie("toolbarImpakt") == 'show')
        toolBar('show');
    $('#toolbar-arrow').click(function(){
        toolBar(0,'click');
    });
    $('#toolbar').children('input[name=toolbarSearch]').focus(function(){
        if($(this).val() == 'szukana fraza')
            $(this).val();
    });
    $('.input-select').click(function(){
        var pos = $(this).offset();
        $(this).css({'overflow':'none'});
       //$(this).children('ul').slideDown(100); 
    });
    $('#rss-button').click(function(){
        var pos = $(this).offset();
        $('#rss-div').css({'left':pos.left-$(this).width()}).fadeIn(200).mouseleave(function(){
            $(this).fadeOut(100);
        })
    });
    if(window.location.hash.indexOf('#newsletter=') != -1){
        var exp = /^[A-Za-z0-9]+/;
        var hash = window.location.hash.replace('#newsletter=',"");
        if(hash.match(exp)){
            var info = hash.toString();
            if(info == 'activated') alert('Newsletter pomyślnie aktywowany!');
            else if(info == 'deleted') alert('Subskrypcja pomyślnie anulowana!');
            else alert(info);
        }
    }
    $('#newsletter-form').submit(function(){
        if($('#newsletter_delete > input').val() == 1)
            var action = 'resend';
        else
            var action = 'subscribe';
        $.ajax({
            url: $(this).attr('action'),
            data: 'email='+$(this).children('input[name=email]').val()+'&action='+action,
            success: function(ret){
                alert(ret);
            },
            dataType: 'string'
        });
        return false;
    });
    $('#newsletter_delete > img').click(function(){
       var src = $(this).attr('src');
       if(src == 'gfx/checkbox_off.gif'){
            $('#newsletter_delete > img').attr('src','gfx/checkbox_on.gif');
            $('#newsletter_delete > input').val(1);
       }else{
            $('#newsletter_delete > img').attr('src','gfx/checkbox_off.gif');
            $('#newsletter_delete > input').val(0);
       }
    });
    $('.expandButton').click(function(){
        var src = $(this).children('img').attr('src');
        if(src == 'gfx/arrow-down.png')
        {
            $(this).children('img').attr('src','gfx/arrow-up.png');
            $('#expandedOptions').slideDown(300);
        }
        else if(src == 'gfx/arrow-up.png')
        {
            $(this).children('img').attr('src','gfx/arrow-down.png');
            $('#expandedOptions').slideUp(300);//300
        }
    });
    $('a[rel=MainGallery]').click(function(){
        $("a[rel=GalleryItem]").addClass('ShowInFancy');
        var index = $("a.ShowInFancy[rel=GalleryItem][href="+$(this).attr('href')+"]").index('"a.ShowInFancy[rel=GalleryItem]');
        $("a.ShowInFancy[rel=GalleryItem]").fancybox({
            'titleShow'		: false,
            'transitionIn'	: 'elastic',
            'transitionOut'	: 'elastic'
        }).eq(index).trigger('click');
        return false;
    });
    $('[dialogtip]').mouseenter(function(e){
        if($(this).attr('dialogtip')){
            $('#dialogTip').remove();
            var title = $(this).attr('dialogtip');
            $('body').append("<div id='dialogTip'>"+title+"</div>");
            
            var position = $(this).offset();
            var winWidth = $(window).width();
            var dialWidth = $('#dialogTip').width();
            
            if(winWidth < (position.left+15+dialWidth)){
               var difference = (position.left+dialWidth)-winWidth;
               $('#dialogTip').css('left',position.left-difference-30).hide().fadeIn(800); 
            }else{
                $('#dialogTip').css({'position':'absolute',
                                        'float':'left',
                                        'left':position.left+15,
                                        'top':position.top-30
                }).hide().fadeIn(500);
            }
        }
    });
    $('[dialogtip]').mousemove(function(e){
        var winWidth = $(window).width();
        var dialWidth = $('#dialogTip').width();
        var position = $('#dialogTip').offset();
        if(winWidth < (e.pageX+15+dialWidth)){
            var difference = (e.pageX+dialWidth)-winWidth;
            $('#dialogTip').css({'left':e.pageX-dialWidth-30,
                                 'top':e.pageY-30});
        }else
            $('#dialogTip').css({'left':e.pageX+15,'top':e.pageY-30});
        
    });
    $('[dialogtip]').mouseleave(function(e){
        if($('#dialogTip')){
            //$(this).attr('title',$('#dialogTip').html());
            $('#dialogTip').remove('#dialogTip').remove();
        }
    });
});
function in_array( what, where ){
	var a=false;
	for(var i=0;i<where.length;i++){
	  if(what == where[i]){
	    a=true;
        break;
	  }
	}
	return a;
}
function slideShow(option,index){
    var imageIndex = index;//$(this).index('[rel=gallery]');
    var allIndex = 0;
    var allURLs = new Array();
    $('[rel=gallery]').each(function(){
        allURLs[allIndex] = $(this).attr('href');
        ++allIndex;
    });
    var imageURL = allURLs[index];
    /*var imageURL = $(this).attr('href');
    var imageTitle = $(this).attr('title');*/
    if(option == 'create'){
        var size = getWindowSize();
        var width = Math.ceil(size[0]*0.7);
        var height = Math.ceil(size[1]*0.7);
        if(imageURL.toLowerCase().indexOf('showimage.php?src=') != -1){
            if(imageURL.indexOf('&w=') != -1 || imageURL.indexOf('&amp;w=') != -1)
                var imageURL = imageURL.replace(/w=[0-9]+/,'w='+width);
            else
                var imageURL = imageURL + '&w='+width;
            if(imageURL.indexOf('&y=') != -1 || imageURL.indexOf('&amp;y=') != -1)
                var imageURL = imageURL.replace(/y=[0-9]+/,'y='+height);
            else
                var imageURL = imageURL + '&y='+height;
        }
        var inner = "<div id='popup-overlay' onclick=\"removeDiv(['#popup-overlay','#popup-close','#popup-image']);return false;\"></div>"+
            "<div id='popup-close' onclick=\"removeDiv(['#popup-overlay','#popup-close','#popup-image']);return false;\"><img src='img/closewindow-button.png' alt='' vspace='0' hspace='0' title='Zamknij' style='cursor:pointer;' style='margin:0xp auto;'/></div>"+
            "<div id='popup-image'>"+
            "<div id='popup-prev'></div>"+
            "<div id='popup-image-td'><img src='"+imageURL+"' id='popup-image-id' alt='' vspace='0' hspace='0'/></div>"+
            "<div id='popup-next' onmouseover=\"slideShow('nextOn','"+imageIndex+1+"');\" onclick=\"slideShow('next','"+imageIndex+1+"');\" onmouseout=\"slideShow('nextOff','"+imageIndex+1+"');\"></div>"+
            "<div id='popup-loader'><img src='gfx/ajax-loader-grayb.gif' alt='' vspace='0' hspace='0'/><br />Trwa ładowanie zdjęcia</div>"+
            "</div>";
        $('#body').append(inner);
        centerElement('#popup-close');
        centerElement('#popup-image');
        $('#popup-overlay').hide().fadeIn(400);
        $('#popup-close').hide().fadeIn(650);
        
        // HIDE BEFORE IMAGE WILL BE LOADED
        $('#popup-image-td').hide();
        $('#popup-prev').hide();
        $('#popup-next').hide();
        // END
        
        $('#popup-image').hide().fadeIn(600);
        $('#popup-image-id').load(function(){
            // --- IF LOADED SHOW HIDDEN LAYERS AND HIDE LOADER --- //
            $('#popup-loader').hide();
            $('#popup-image-td').toggle();
            $('#popup-prev').toggle();
            $('#popup-next').toggle();
            centerElement('#popup-image');
        });
        $('#popup-image').resize(function(){
            centerElement('#popup-image');
        });
    }else if(option == 'nextOn'){
        if(allIndex-1 > index){
            $('#popup-next').addClass('popup_next').attr('title','Następne zdjęcie');
        }
    }else if(option == 'nextOff'){
        $('#popup-next').removeClass().removeAttr('title');
    }else if(option == 'next'){
        if(allIndex-1 > index){
            $('#popup-image-id').hide();
            centerElement('#popup-image');
            $('#popup-image-id').attr('src',allURLs[index]);
            $('#popup-image-id').load(function(){
                $('#popup-image-id').fadeIn(600);
                centerElement('#popup-image');
            });
            $('#popup-next').removeClass().removeAttr('title');
        }
    }else if(option == 'prev'){
        
    }
}
function getWindowSize(){
    var data = Array();
    data[0] = $(window).width();
    data[1] = $(window).height();
    return data;
}
function removeDiv(id){
    if(isArray(id)){
        for(x=0;x<id.length;++x){
            $(id[x]).remove();
        }
    }else $(id).remove();
}
function newProductsHideShow(){
    var winWidth = parseInt($(window).width());
    var maxWidth = $('#body').css('max-width').replace('px',"");
    var minWidth = $('#body').css('min-width').replace('px',"");
    if(winWidth > maxWidth) winWidth = maxWidth;
    else if(winWidth < minWidth) winWidth = minWidth;
    var elems = Math.ceil((winWidth-440)/180);
    $('#jsNewProductsLoader').addClass('hidden');
    $('.jsNewProductsImg,.jsNewProductsDescr,.jsNewProductsMore').addClass('hidden');
    $('.jsNewProductsImg').each(function(index){
        if(index < elems)
            $(this).removeClass('hidden');
    });
    $('.jsNewProductsDescr').each(function(index){
        if(index < elems)
            $(this).removeClass('hidden');
    });
    $('.jsNewProductsMore').each(function(index){
        if(index < elems)
            $(this).removeClass('hidden');
    });
}
function preloader(id,loader){
    if($(id).css('width').replace('px',"") > 0)
        var width = $(id).css('width');
    else
        var width = $(id).width();
    var height = $(id).height();
    if(!loader) var loader = 'ajax-loader';
    $(id).children().hide();
    $(id).append('<div id="preloader"></div>');
    $('#preloader').css({'width':width,'height':height}).append('<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" id="preloader">'+
        '<tr><td align="center" valign="middle">'+
        '<img src="/gfx/'+loader+'.gif" alt="" vspace="0" hspace="0" title="Proszę czekać."/>'+
        '</td></tr></table>');
}
function SendRequest(id,data,method,notpreloader){
    if(!id) id = '#center_float';
    if(!method) var method = 'POST';
    if(!notpreloader){
        preloader(id,'loader-orange');
        /*if($(id).css('width').replace('px',"") > 0)
            var width = $(id).css('width');
        else
            var width = $(id).width();
        //var height = $(id).height();
        //$(id).css({'width':width,'height':height}).html(
        $(id).css('width',width).html(
            '<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">'+
            '<tr><td align="center" valign="middle">'+
            '<img src="/gfx/loader-orange.gif" alt="" vspace="0" hspace="0" title="Proszę czekać."/>'+
            '</td></tr></table>');*/
    }
    $.ajax({
        type: method,
        url: 'index.ajax.php',
        data: data,
        success: function(ret){
            $(id).html(ret);
        },
        dataType: 'string'});
}
function ajaxPages(id,mod,page){
    var data = 'mod='+ mod +'& page='+ page;    
    SendRequest(id,data);
}
function showGroup(id,cid,option){
    if(option == 'producers') var type = 'prod';
    else var type = '';
     
    $('.groups_hide'+type).css('display','none');
    $('#showgroup'+id+type).css('display','block');
    $('.group_main-on').removeClass('group_main-on');
    $('#linkgroup'+id+type).addClass('group_main-on');
    $('.groups_hideLink').removeClass('groups_hideLink');
    if(type == 'prod') var data = 'mod=catalog&PRID='+id;
    else var data = 'mod=catalog&id='+id;
    if(cid) data = data + '&cid='+cid;
    SendRequest('#showgroup'+id+type,data,'GET');
}
function isArray(obj) {
   if (obj.constructor.toString().indexOf("Array") == -1)
      return false;
   else
      return true;
}
function popImage(imageURL,imageTitle,options){
    
    if(options == 'remove')
    {
        $("#popup-overlay").remove();
        $("#popup-image").remove();
        $('#popup-close').remove();
        
    }
    else
    {        
        /*if(options)
        {
            if(isArray(options))
            {
                var imageURL = imageURL.replace('w='+options[0],'w=800');
                var imageURL = imageURL.replace('y='+options[1],'y=600');
            }
            else if(options == 'resize')
            {
                var size = getWindowSize();
                var width = (size[0])/1.2;
                var height = (size[1])/1.2;
                
                if(imageURL.toLowerCase().indexOf('showimage.php?src=') != -1){
                    var imageURL = imageURL.replace(/w=[0-9]+/,'w='+width);
                    var imageURL = imageURL.replace(/h=[0-9]+/,'h='+height);
                }
                //var imageURL = imageURL+'&w='+size;
            } 
        }*/
        var size = getWindowSize();
        var width = Math.ceil(size[0]*0.7);
        var height = Math.ceil(size[1]*0.7);
        //var width = Math.ceil((size[0])/1.2);
        //var height = Math.ceil((size[1])/1.2);
                
        if(imageURL.toLowerCase().indexOf('showimage.php?src=') != -1){
            /* CHECK FOR WIDTH */
            if(imageURL.indexOf('&w=') != -1 || imageURL.indexOf('&amp;w=') != -1)
                var imageURL = imageURL.replace(/w=[0-9]+/,'w='+width);
            else
                var imageURL = imageURL + '&w='+width;
            /* CHECK FOR HEIGHT*/
            if(imageURL.indexOf('&y=') != -1 || imageURL.indexOf('&amp;y=') != -1)
                var imageURL = imageURL.replace(/y=[0-9]+/,'y='+height);
            else
                var imageURL = imageURL + '&y='+height;
        }
    var inner = "<div id='popup-overlay' onclick=\"popImage('','','remove');return false;\"></div>"+
                "<div id='popup-close' onclick=\"popImage('','','remove');return false;\"><img src='img/closewindow-button.png' alt='' vspace='0' hspace='0' title='Zamknij' style='cursor:pointer;' style='margin:0xp auto;'/></div>"+
                "<div id='popup-image'>"+
                "<div id='popup-prev'></div>"+
                "<div id='popup-image-td'><img src='"+imageURL+"' id='popup-image-id' alt='' vspace='0' hspace='0' title='"+imageTitle+"'/></div>"+
                "<div id='popup-next'></div>"+
                "<div id='popup-loader'><img src='gfx/ajax-loader-grayb.gif' alt='' vspace='0' hspace='0'/><br />Trwa ładowanie zdjęcia</div>"+
                //"<div id='popup-indexID'></div>"+
                "</div>";
    $('#body').append(inner);
    //$('#popup-indexID').hide();
    centerElement('#popup-close');
    centerElement('#popup-image');
    $('#popup-overlay').hide().fadeIn(400);
    $('#popup-close').hide().fadeIn(650);
    
    // HIDE BEFORE IMAGE WILL BE LOADED
    $('#popup-image-td').hide();
    $('#popup-prev').hide();
    $('#popup-next').hide();
    // END
    
    $('#popup-image').hide().fadeIn(600);
    $('#popup-image-id').load(function(){
        // --- IF LOADED SHOW HIDDEN LAYERS AND HIDE LOADER --- //
        $('#popup-loader').hide();
        $('#popup-image-td').toggle();
        $('#popup-prev').toggle();
        $('#popup-next').toggle();
        centerElement('#popup-image');
    });
    $('#popup-image').resize(centerElement('#popup-image'));
    
    // --- IF MOUSE ENTER --- //
    /*
        Do zrobienia:
        - jak pobrać index() wybranego elementu? "Dodałem do funkcji zmienną `number`"
        ^EDIT: pobiera klasę obrazka, usuwa nazwę klasy i zostawia tylko cyfrę
    */
    $('#popup-next').mouseenter(function(){
        var next = number+1; 
        var all = 0;
        $('.show-product-thumb').each(function(){   all++;    });
        alert((all-1)+'-'+next);
        if((all-1) > next){
            $('#popup-next').addClass('popup_next').attr('title','Następne zdjęcie').click(function(){
                alert(next);
                var src = $(".show-product-thumb").eq(2).attr('src');
                alert(src);
                popImage('','','remove');
                popImage(src,'',[60,60]);
            });
        }
    }).mouseleave(function(){
        $('#popup-next').removeClass().removeAttr('title');
    });
    // --- IF MOUSE ENTER --- //
    $('#popup-prev').mouseenter(function(){
        var prev = number-1;
        var all = 0;
        $('.show-product-thumb').each(function(){   all++;    });
        if(prev >= all){
            $('#popup-prev').addClass('popup_prev').attr('title','Poprzednie zdjęcie').click(function(){
                var src = $('.show-product-thumb').index(prev).attr('src');
                popImage('','','remove');
                popImage(src,'',[60,60]);
            });
        }
    }).mouseleave(function(){
        $('#popup-prev').removeClass().removeAttr('title');
    });
    }
}
function centerElement(div){
    var width = $(div).width();
    var winWidth = $(window).width();
    $(div).css('left',(winWidth/2)-(width/2));
}
function RemoveElement(div,parent) {
    if(parent) parent = document.getElementById(parent);
    if (document.getElementById(div)){
        var olddiv = document.getElementById(div);
        if(parent)
            parent.removeChild(olddiv);
        else
            document.body.removeChild(olddiv);
    }
}
function Tabs(type,tab){
    if(type == 'list'){
        $('#tab-groups').removeClass('list-tabs-active');
        $('#tab-products').removeClass('list-tabs-active');
        $('#'+tab).addClass('list-tabs-active');
        $('#tab-products-content').hide();
        $('#tab-groups-content').hide();
        //$('#'+tab+'-content').fadeIn(400).show();
        $('#'+tab+'-content').show();
    }else if(type == 'product'){
        $('.list-tabsblue-active').removeClass('list-tabsblue-active');
        $('#'+tab).addClass('list-tabsblue-active');
        $('.list-content-blue-pad').children('[id^=tab-]').hide();
        $('#'+tab+'-content').show();
    }
}
function thumbToPhoto(url){
    var num = $(this).index('.show-product-thumb');
    $('#divphoto').children().remove();
    preloader('#divphoto','loader-orange');
    $('#divphoto').append('<img src="'+url+'" alt="" vspace="0" hspace="0" id="photo" class="thumbNum'+num+'" />');
    $('#photo').hide().load(function(){
            $('#preloader').remove();
            $('#photo').fadeIn(600);
        });
}
var defaultStep=1 
var step=defaultStep 
function scrollDivDown(id){
    document.getElementById(id).scrollTop+=step*5 
    timerDown=setTimeout("scrollDivDown('"+id+"')",0) 
} 

function scrollDivUp(id){ 
    document.getElementById(id).scrollTop-=step*5
    timerUp=setTimeout("scrollDivUp('"+id+"')",0) 
}
function scrollDivLeft(id){ 
    document.getElementById(id).scrollTLeft+=step 
    timerLeft=setTimeout("scrollDivLeft('"+id+"')",7) 
} 

function scrollDivRight(id){
    document.getElementById(id).scrollLeft-=step
    timerRight=setTimeout("scrollDivRight('"+id+"')",7)
}
function scrollItems(number){
    var nextDelay = 2000;
    var fadeDelay = 1000;
    var number = parseInt(number);
    var number = number-1;
    if(!$('.item').eq(number).html()){
        var number = 0;
    }
    // hide all
    $('.item').css('display','none');
    // show chosen item
    $('.item').eq(number).fadeIn(fadeDelay,function(){
        // after X miliseconds change to next item
        var nextNumber = parseInt(number+2);
        if( $('#timeoutend').html() != 'stop' ){
            timer = setTimeout('scrollItems('+nextNumber+');',nextDelay);
        }
    });     
}

	function PictureSlide(){
		var e = $('picture-slides-thumbnails').getElementsByTagName('a'), className=[];
		for(var i=0;i<e.length;++i){
			if (e[i].className == 'link'){
				e[i].onclick = function() {
					$('picture-slides-image').src = 'gfx/slimbox/loading.gif';

					img = new Image();
					img.src = this.getAttribute("href");
					img.onload=function(){
						$('picture-slides-image').src = img.src;
					}
					if( img.complete ) img.onload(); 

					var x = $('picture-slides-thumbnails').getElementsByTagName('a'), className=[];
					for(var i=0;i<x.length;++i){
						x[i].className = 'link';
					}
					this.className = 'link selected';
					return false;
				}
			}
		}
	}
	function okno(x,y,pid,zglos){

		x = x + 120; 

		y = y + 120; 

		topPos = (screen.height/2)-(y/2); 

		leftPos = (screen.width/2)-(x/2); 

		if (zglos == 0) window.open('jsgallery,show,'+pid+'.html', '', 'width='+x+',height='+y+',resizable=no,scrollbars=yes,left='+leftPos+',top='+topPos+'');

	}