/*
function login (link)
{

        window.open (link, "Login", "toolbars=no, location=no, directories=no, status=yes, menubar=no, scrollbars=no, resizable=no, width=200, height=170");

}*/
/*
function LocationReplace(link)
{

         location.replace (link);

}
*//*
function help (url)
{
window.open ('url', "Help", "toolbars=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=200, height=200");
}*/

function plist (url)
{
window.open (url, "List produktów", "toolbars=no, location=yes directories=no, status=yes, menubar=no, scrollbars=yes, resizable=yes, width=300, height=400");
}

/*
function PierwszePoleFormularzaDodajProdukt ()
{
         document.dodajprodukt.nazwa.select();
}*/
/*
function isIE()
{
if (navigator.appName=="Microsoft Internet Explorer") return parseFloat(navigator.appVersion);
else return false;
}

function isNN()
{
if (navigator.appName=="Netscape") return parseFloat(navigator.appVersion);
else return false;
}

function windowwidth()
{
if (isIE()) width=document.body.scrollWidth;
else if (isNN()) width=window.innerWidth;
else return document.body.scrollWidth;
return width;
}
function windowheight()
{
if (isIE()) width=document.body.scrollHeight;
else if (isNN()) width=window.innerHeight;
else return document.body.scrollHeight;
return width;
}*/

var cur='PLN';

function displaybox(id)
{
var stan=document.getElementById(id).style.display;
if (stan=='block') document.getElementById(id).style.display='none';
else if (stan=='hidden') document.getElementById(id).style.display='block';
else document.getElementById(id).style.display='block';
}

function features_set_off()
{
for (i=1; i<=nfeatures; i++)
   {
    document.getElementById('f'+i).style.display='none';
	document.getElementById('fc'+i).style.clear='none';
	document.getElementById('fc'+i).style.marginTop='2px';
	}
}

function change_display(element_id) {
    features_set_off();
	
    document.getElementById('f'+element_id).style.display='block';
	document.getElementById('fc'+element_id).style.clear='both';
	if (element_id!='1') document.getElementById('fc'+element_id).style.marginTop='30px';
	
}




function equalHeight(group) {
	var tallest = 0;
	group.each(function() {
		var thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
}


$(document).ready(function(){
         //przycisk wyszukiwania
         $('#searchform').bind('submit', function(){
                  var value = $('#form_search_inut').val();
                  if ($('#form_search_inut').val().length < 2 || value == 'szukaj produktu...')
                  {
                           alert("Kliknij na pole wyszukiwania i wpisz conajmniej 2 znaki.");
                           return false;
                  }
                  else
                           return true;
         });
         
         $('#btnEURCurrency').click(function(){
                $.ajax({
                  url: 'ax_change_currency.php?cur=EUR',
                  success:function(){window.location.reload();}
                });
         });
         $('#btnPLNCurrency').click(function(){
                $.ajax({
                  url: 'ax_change_currency.php?cur=PLN',
                  success:function(){window.location.reload();}
                });
         });
         
});

function change_currency(new_cur) {
         if (new_cur == cur) return true;
         else
         {
                  $('.cena_value').each(function(){
                           var value = $(this).html();
                           value.replace(/\s/g,'');
                           value.replace(',','.');
                           //alert(value);
                           var nval= parseFloat(value) * cur_eur;
                           $(this).html(nval.toFixed(2));
                           
                  });
                  
                  $('.cena_cur_label').each(function(){
                           $(this).html(' '+new_cur);
                           //alert(value);
                  });
                  cur=new_cur;
                 
         }
}

