
licz=0;
function ShowPicture(nazwa,szer,wys) {
 config='left='+(20+20*licz)+',top='+(20+20*licz)+',width='+szer+',height='+wys+',innerheight='+wys+',innerwidth='+szer+',toolbar=no,titlebar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no';
 kitekSC='oknoUSP' + licz;
 newwindow=window.open('',kitekSC,config)
 newwindow.document.write('<HTML><HEAD>');
 newwindow.document.write('<META http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-2\">');
 newwindow.document.write('<TITLE>Foto</TITLE>');
 newwindow.document.write('<SCRIPT language=\"javascript\">');
 newwindow.document.write('setTimeout(');
 newwindow.document.write('\"self.close()');
 newwindow.document.write(';\",50000)');
 newwindow.document.write('</');
 newwindow.document.write('SCRIPT>');
 newwindow.document.write('</HEAD>');
 newwindow.document.write('<BODY bgcolor=white leftmargin=0 topmargin=0 marginheight=0 marginwidth=0>');
 newwindow.document.write('<DIV ALIGN=center><A HREF=# onclick=\"javascript:self.close();\"><IMG SRC='+nazwa+' BORDER=0 TITLE=\"Kliknij aby zamkn-\"></A>');
 newwindow.document.write('</DIV>');
 newwindow.document.write('</BODY></HTML>');
 licz+=1;
}

function chmurka(e,v){  
 if(v.title){  
  var t=document.createElement('div');  
  t.className='chmurka';  
  t.innerHTML=v.title;  
  v.title='';  
  v.move=function(e){  
   e=e||event;  
   t.style.left=e.clientX+15+(document.documentElement.scrollLeft||document.body.scrollLeft)+'px'   
   t.style.top=e.clientY+22+(document.documentElement.scrollTop||document.body.scrollTop)+'px'   
  }  
  v.move(e);  
  document.body.appendChild(t);  
  v.onmousemove=function(e){v.move(e)}  
  v.onmouseout=function(e){  
   v.title=t.innerHTML;  
   document.body.removeChild(t);  
  }  
 }  
}  


function number_format(a, b, c, d) 
{
 a = Math.round(a * Math.pow(10, b)) / Math.pow(10, b);
 e = a + '';
 f = e.split('.');
 if (!f[0]) 
 {
  f[0] = '0';
 }
 if (!f[1]) 
 {
  f[1] = '';
 }
 if (f[1].length < b) 
 {
  g = f[1];
  for (i=f[1].length + 1; i <= b; i++) 
	{
   g += '0';
  }
  f[1] = g;
 }
 if(d != '' && f[0].length > 3) 
 {
  h = f[0];
  f[0] = '';
  for(j = 3; j < h.length; j+=3) 
	{
   i = h.slice(h.length - j, h.length - j + 3);
   f[0] = d + i + f[0] + '';
  }
  j = h.substr(0, (h.length % 3 == 0) ? 3 : (h.length % 3));
  f[0] = j + f[0];
 }
 c = (b <= 0) ? '' : c;
 return f[0] + c + f[1];
}

function przecinek(info) 
{
 var p_temp = ""+info;
 var p1_temp = null;
 var p2_temp = null;
 if (p_temp.indexOf(",")>-1) 
 {
  var p1_temp=p_temp.substring(0,p_temp.indexOf(","));
  var p2_temp=p_temp.substring(p_temp.indexOf(",")+1);
  p_temp=p1_temp+"."+p2_temp;
 };
 p_temp = parseFloat(p_temp);
 if (isNaN(p_temp)) {p_temp = 0};
 return p_temp;
}

function allowSigns(e) 
{
 var allowedText = "0123456789.,";
 var key;
 var keychar;
 
 if (window.event)
  key = window.event.keyCode;
 else if (e)
  key = e.which;
 else
  return true;
 
 keychar = String.fromCharCode(key);
 
 if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27))
  return true;
 else if ((allowedText.indexOf(keychar) > -1))
  return true;
 else
  return false;
}

function allowDomeny(e) 
{
 var allowedText = "0123456789_-abcdefghijklmmnoprstuvwxyz";
 var key;
 var keychar;
 
 if (window.event)
  key = window.event.keyCode;
 else if (e)
  key = e.which;
 else
  return true;
 
 keychar = String.fromCharCode(key);
 
 if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27))
  return true;
 else if ((allowedText.indexOf(keychar) > -1))
  return true;
 else
  return false;
}

/* Funkcja pozwala tylko na liczby */
function onlyNumbers(e) 
{
 var allowedText = "0123456789";
 var key;
 var keychar;
 
 if (window.event)
  key = window.event.keyCode;
 else if (e)
  key = e.which;
 else
  return true;
 
 keychar = String.fromCharCode(key);
 
 if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27))
  return true;
 else if ((allowedText.indexOf(keychar) > -1))
  return true;
 else
  return false;
}

function nwin(page)
{
 sx = screen.availWidth;
 sy = screen.availHeight;
 x = sx;
 y = screen.availHeight;
 
 px = (sx/2)-(x/2);
 py = (sy/2)-(y/2);
 var nwi = window.open(page,'mwin','top='+py+',left='+px+',width='+sx+',height='+y+',resizable=no,scrollbars=yes,status=yes,toolbar=yes,menubar=yes,fullscreen=yes,width='+screen.width+',height='+screen.height, true);
 nwi.focus();
 return;
}

/*
//CHECK WINDOW SIZE
d=document;
var winWidth;
var winHeight;
if (typeof window.innerWidth!='undefined') {
    winWidth = window.innerWidth;
    winHeight = window.innerHeight;
} else {
    if (d.documentElement && typeof d.documentElement.clientWidth!='undefined' && d.documentElement.clientWidth!=0) {
        winWidth = d.documentElement.clientWidth
        winHeight = d.documentElement.clientHeight
    } else {
        if (d.body && typeof d.body.clientWidth!='undefined') {
            winWidth = d.body.clientWidth
            winHeight = d.body.clientHeight
        }
    }
}

function schowGallery(yachtid,number) {
    $.ajax({
        type: 'POST',
        url: "galeria.php",
        data: {yacht:yachtid},
        success: function(data) {
            $("#galeria").show("fast");
            var images = "";
            var counter = 0;
            $.each(data, function(i,item){
                counter++;
                images += '<div class="showcase-slide">';
                       images += '<div class="showcase-content">';
                                images += '<img src="'+item.image+'" alt="'+counter+'" />';
                       images += ' </div>';
                       images += ' <div class="showcase-thumbnail">';
                                images += '<img src="'+item.thumb+'" alt="01" width="80px" />';
//                                images += '<div class="showcase-thumbnail-caption">Opis na miniaturce</div>';
                                images += '<div class="showcase-thumbnail-cover"></div>';
                        images += '</div>';
//                        images += '<div class="showcase-caption">';
//                                images += '<h2>Opis na zdjęciu</h2>';
//                        images += '</div>';
                images += '</div>';
            })
            galwidth = (winWidth-900-20)/2;
            $("#galeriaL").css("width",galwidth);
            $("#galeriaR").css("width",galwidth);
            $("#showcase").html(images);
        }
    });
}

$(document).ready(function() {
    $("#galeriaL").click(function () {
        $("#showcase").html("");
        $("#galeria").hide("fast");
    })
    $("#galeriaR").click(function () {
        $("#showcase").html("");
        $("#galeria").hide("fast");
    })
});
*/
//$(document).ready(function() {
//    //nowa galeria jachtów
//    $("#showcase").awShowcase(
//    {
//            content_width:			700,
//            content_height:			470,
//            fit_to_parent:			false,
//            auto:					false,
//            interval:				3000,
//            continuous:				false,
//            loading:				true,
//            tooltip_width:			200,
//            tooltip_icon_width:		32,
//            tooltip_icon_height:	32,
//            tooltip_offsetx:		18,
//            tooltip_offsety:		0,
//            arrows:					true,
//            buttons:				true,
//            btn_numbers:			true,
//            keybord_keys:			true,
//            mousetrace:				false, /* Trace x and y coordinates for the mouse */
//            pauseonover:			true,
//            stoponclick:			true,
//            transition:				'hslide', /* hslide/vslide/fade */
//            transition_delay:		300,
//            transition_speed:		500,
//            show_caption:			'onhover', /* onload/onhover/show */
//            thumbnails:				true,
//            thumbnails_position:	'outside-last', /* outside-last/outside-first/inside-last/inside-first */
//            thumbnails_direction:	'horizontal', /* vertical/horizontal */
//            thumbnails_slidex:		0, /* 0 = auto / 1 = slide one thumbnail / 2 = slide two thumbnails / etc. */
//            dynamic_height:			false, /* For dynamic height to work in webkit you need to set the width and height of images in the source. Usually works to only set the dimension of the first slide in the showcase. */
//            speed_change:			false, /* Set to true to prevent users from swithing more then one slide at once. */
//            viewline:				false /* If set to true content_width, thumbnails, transition and dynamic_height will be disabled. As for dynamic height you need to set the width and height of images in the source. */
//	});
//})

$(document).ready(function() {
    $("#seeall").click(function() {
        showElementAndHideRest("#viewall");
    })
    $("#seebelow7").click(function() {
        showElementAndHideRest("#below7");
    })
    $("#seebeetwen78").click(function() {
        showElementAndHideRest("#beetwen78");
    })
    $("#seelonger820").click(function() {
        showElementAndHideRest("#longer820");
    })
    $("#seemoto").click(function() {
        showElementAndHideRest("#moto");
    })
})

function showElementAndHideRest(show1) {
    var arrayElem = new Array("#viewall","#below7","#beetwen78","#longer820","#moto");
    var limit = arrayElem.length;
    for (i=0;i<=limit;i++) {
        if (show1 != arrayElem[i]) {
            if ($(arrayElem[i]).css("display") == 'block') {
                $(arrayElem[i]).hide("fast", function() {
                    $(show1).show("fast");
                });
            }
        }
    }
}
