﻿function cursor_move(id){
	document.getElementById(id).style.cursor='pointer';	
}
function cursor_in(id){
	document.getElementById(id).style.color='#eee0c3';
	document.getElementById(id).style.cursor='pointer';	
}
function cursor_out(id){
	document.getElementById(id).style.color='#fff';
}
function open_cat(id,kat){
//alert(id.selectedIndex);
var option=id.selectedIndex;
	var podkat=id.options[option].value;
	window.open("index.php?act=produkty&kat="+kat+"&podkat="+podkat+"","_self");
}
//onclick="window.open(\'index.php?act=produkty&kat='.$kat.'&podkat='.$id_kat.'\',\'_self\');"
function show_div_radio_lang(id){

if(id=="pl"){	
				document.getElementById("div_pl").style.display='block';
				document.getElementById("div_en").style.display='none';
				document.getElementById("div_de").style.display='none';
			}
if(id=="en"){	
				document.getElementById("div_pl").style.display='none';
				document.getElementById("div_en").style.display='block';
				document.getElementById("div_de").style.display='none';
			}
if(id=="de"){	
				document.getElementById("div_pl").style.display='none';
				document.getElementById("div_en").style.display='none';
				document.getElementById("div_de").style.display='block';
			}
}
function powieksz (opis, obrazek, szerokosc, wysokosc)
{
    szerokosc_okna = szerokosc + 80;
    wysokosc_okna = wysokosc + 100;


    var adres = obrazek;
    var opis = opis;
    if(typeof(adres)!="object")     
    {
      
        popup_window = window.open("","","location=no, scrollbar=no, menubar=no, toolbar=no, resizable=no, left=50, top=50, width=" + szerokosc_okna + ", height=" + wysokosc_okna + " ");
       
     
        popup_window.document.write('<html><body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0"><center><table height="100%"><tr><td align="center" ><a href="javascript:window.close();"><img border="0" src="'+adres+'" height="'+wysokosc+'"></a><br/><div style="color: #795539; font-family: verdena, Times, serif; font-size: 14px;">'+opis+'</div></td></tr></table></center></body></html>');
        popup_window.document.close();
        popup_window.focus();
    }
} 

function ukryj_product(id,kat,stan){
	if(stan==0){if(confirm("Czy napewno chcesz ukryć produkt?")){ window.open('index.php?act=produkty&kat='+kat+'&id='+id+'&a=ukryj_produkt','_self'); };}
	else{if(confirm("Czy napewno chcesz pokazać produkt?")){ window.open('index.php?act=produkty&kat='+kat+'&id='+id+'&a=pokaz_produkt','_self'); };}
}

function promocja(id,kat,stan){
	if(stan==1){if(confirm("Czy napewno chcesz dodać produkt do promocji?")){ window.open('index.php?act=produkty&kat='+kat+'&id='+id+'&a=do_promocji','_self'); };}
	else{if(confirm("Czy napewno chcesz usunąć produkt z promocji?")){ window.open('index.php?act=produkty&kat='+kat+'&id='+id+'&a=usun_promocje','_self'); };}
}
function nowosc(id,kat,stan){
	if(stan==1){if(confirm("Czy napewno chcesz dodać produkt do nowości?")){ window.open('index.php?act=produkty&kat='+kat+'&id='+id+'&a=do_nowosci','_self'); };}
	else{if(confirm("Czy napewno chcesz usunąć produkt z nowości?")){ window.open('index.php?act=produkty&kat='+kat+'&id='+id+'&a=usun_nowosc','_self'); };}
}
function Info_usun_wpis(id){
if(confirm("Czy napewno chcesz usunąć?")){ window.open('index.php?act=opinie&akcja=usun_wpis&id='+id,'_self'); };
return " "
}
//testowanie ksiegi gości
function testuj(f) {

   var test=true;
 

   document.getElementById("pole_nick").style.backgroundColor="white";
	document.getElementById("alert_nick").innerHTML = "";
     
   document.getElementById("pole_email").style.backgroundColor="white";
   document.getElementById("alert_email").innerHTML = "";
   document.getElementById("pole_radio").style.backgroundColor="";
   document.getElementById("plec").innerHTML = "";
   document.getElementById("pole_gg").style.backgroundColor="white";
   document.getElementById("alert_gg").innerHTML = "";
   document.getElementById("pole_miasto").style.backgroundColor="white";
   document.getElementById("alert_miasto").innerHTML = "";
    document.getElementById("pole_strona").style.backgroundColor="white";
   document.getElementById("alert_strona").innerHTML = "";
    document.getElementById("cyfry").style.backgroundColor="white";
   document.getElementById("alert_cyfry").innerHTML = "";
   
    var check1 = document.getElementById("pole_plec1");
	var check2 = document.getElementById("pole_plec2");
	if (check1.checked || check2.checked){} else {
		document.getElementById("plec").innerHTML = "Błąd, podaj płeć.";
		document.getElementById("plec").style.color="red";
		  test=false;	
		};
    
    var pole_nick_ = document.getElementById("pole_nick");
   if (pole_nick_.value.length<2){
	
            document.getElementById("alert_nick").style.color="red";
			document.getElementById("alert_nick").innerHTML = "Błąd, podaj nick.";
			test=false;	
            } ;
	
     var pole_gg_ = document.getElementById("pole_gg");
    if (pole_gg_.value.length>0){
		 wyr_reg=/^[0-9]+$/;
		  if (wyr_reg.test(f.pole_gg.value));
			else { 
				document.getElementById("alert_gg").style.color="red";
				document.getElementById("alert_gg").innerHTML = "Błąd, podaj poprawny numer gg.";
				test=false;
				};
            } ;
			
	var pole_cyfry_ = document.getElementById("cyfry");
    if (pole_cyfry_.value.length!=2){
		 wyr_reg=/^[0-9]+$/;
		  if (wyr_reg.test(f.cyfry.value));
			else { 
				document.getElementById("alert_cyfry").style.color="red";
				document.getElementById("alert_cyfry").innerHTML = "Błąd, podaj numer z obrazka.";
					test=false;
				};
            }

			;
			
			
	  var pole_miasto_ = document.getElementById("pole_miasto");
    if (pole_miasto_.value.length>0){
		 wyr_reg=/^[a-zA-ZśćęłńóążźŚĆĘŁŃÓĄŻŹ¬\s\-]+$/;
		  if (wyr_reg.test(f.pole_miasto.value));
			else { 
				document.getElementById("alert_miasto").style.color="red";
				document.getElementById("alert_miasto").innerHTML = "Błąd, podaj poprawną nazwę miasta.";
				test=false;
				};
            } ;
	var pole_strona_ = document.getElementById("pole_strona");
    if (pole_strona_.value.length>0){
		 wyr_reg=/^www\.\w+([\.-]?\w+)*(\.\w{2,3})+$/;
		  if (wyr_reg.test(f.pole_strona.value));
			else { 
				document.getElementById("alert_strona").style.color="red";
				document.getElementById("alert_strona").innerHTML = "Błąd, podaj poprawny adres strony.";
				test=false;
				};
            } ;
	// test poprawnosci emaila
  wyr_reg = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
  if (wyr_reg.test(f.pole_email.value));
  else { 
        document.getElementById("alert_email").style.color="red";
        document.getElementById("alert_email").innerHTML = "Błąd, podaj poprawny adres email np.: jan.kowalski@wp.pl";
        test=false;
     }

 
 if (test==true){  return true;}
 else {return false;};
}
