var xmlHttp_help=null;
function showwgnorm(id)
		{
		if (window.XMLHttpRequest) xmlHttp_help = new XMLHttpRequest();		
		else
		if (window.ActiveXObject){
		xmlHttp_help=new ActiveXObject("Microsoft.XMLHTTP");
		if (! xmlHttp_help){
		xmlHttp_help=new ActiveXObject("Msxml2.XMLHTTP");}
		}
		if (xmlHttp_help == null ) {alert("ERROR XMLHttpRequest");return;}	
	
		
		var url= "files/listawgnorm_ajax.php?kat="+id;
		//var url= "tree/index.html";
		//var url= "files/listadin.php?kat="+id;
		xmlHttp_help.onreadystatechange = getwgnorm;
		xmlHttp_help.open("GET",url);
		xmlHttp_help.send(null);	
		
		display_help('artwgnorm');
		//document.getElementById("help").style.position='fixed';
		document.getElementById("artwgnorm").innerHTML="<img src=imgap/ajaxload.gif>";
		}
		function getwgnorm()
		{//alert(xmlHttp_help.readyState);
		if (xmlHttp_help.readyState==4)
		document.getElementById("artwgnorm").innerHTML=xmlHttp_help.responseText;
		
		}
		


function help(id)
		{
		if (window.XMLHttpRequest) xmlHttp_help = new XMLHttpRequest();		
		else
		if (window.ActiveXObject){
		xmlHttp_help=new ActiveXObject("Microsoft.XMLHTTP");
		if (! xmlHttp_help){
		xmlHttp_help=new ActiveXObject("Msxml2.XMLHTTP");}
		}
		if (xmlHttp_help == null ) {alert("ERROR XMLHttpRequest");return;}	
	
		
		var url= "files/help.php?id="+id;
		xmlHttp_help.onreadystatechange = Helpwin;
		xmlHttp_help.open("GET",url);
		xmlHttp_help.send(null);	
		
		display_help('help');
		document.getElementById("help").innerHTML="<img src=imgap/ajaxload.gif>";
		}
		function Helpwin()
		{//alert(xmlHttp_help.readyState);
		if (xmlHttp_help.readyState==4)
		{document.getElementById("help").innerHTML=xmlHttp_help.responseText;	
		//document.getElementById("help").style.top='200px';  
		//document.getElementById("help").style.left='10px';  
		var iMyWidth;
var iMyHeight;
var wWidth = 1000;
var wHeight = 850;
/*iMyWidth = (window.screen.width/2) - wWidth/2;
iMyHeight = (window.screen.height/2) - wHeight/2;
document.getElementById("help").style.top= iMyHeight+'px';
document.getElementById("help").style.left= iMyWidth+'px'; 
*/
var iMyHeight;
var wWidth = 1000;
var wHeight = 400;
iMyWidth = (window.screen.width/2) - wWidth/2;
iMyHeight = (window.screen.height/2) - wHeight/2;
document.getElementById("help").style.top= iMyHeight+'px';
document.getElementById("help").style.left= iMyWidth+'px'; 
		//window.status=iMyWidth+' '+iMyHeight;
		//alert(iMyWidth+' '+iMyHeight);
//document.getElementById("help").style.left=document.body.clientWidth/2-500+document.body.scrollLeft;
//		document.getElementById("help").style.top=document.body.clientHeight/2-400+document.body.scrollTop;		
		
		   }
		
	
				
		}
		
		
		function showformsearch(id)
		{
		if (window.XMLHttpRequest) xmlHttp_help = new XMLHttpRequest();		
		else
		if (window.ActiveXObject){
		xmlHttp_help=new ActiveXObject("Microsoft.XMLHTTP");
		if (! xmlHttp_help){
		xmlHttp_help=new ActiveXObject("Msxml2.XMLHTTP");}
		}
		if (xmlHttp_help == null ) {alert("ERROR XMLHttpRequest");return;}	
	
		
		var url= "message/search_formajax.php?nor="+id;
		xmlHttp_help.onreadystatechange = formsearchs;
		xmlHttp_help.open("GET",url);
		xmlHttp_help.send(null);	
		
		display_help('formsearch');
		//document.getElementById("help").style.position='fixed';
		document.getElementById("formsearch").innerHTML="<img src=imgap/ajaxload.gif>";
		}
		function formsearchs()
		{//alert(xmlHttp_help.readyState);
		if (xmlHttp_help.readyState==4)
		document.getElementById("formsearch").innerHTML=xmlHttp_help.responseText;
		
		}
		
		
		
				function showformsearch_dl(nor,id)
		{//alert(nor+id);
		if (window.XMLHttpRequest) xmlHttp_help = new XMLHttpRequest();		
		else
		if (window.ActiveXObject){
		xmlHttp_help=new ActiveXObject("Microsoft.XMLHTTP");
		if (! xmlHttp_help){
		xmlHttp_help=new ActiveXObject("Msxml2.XMLHTTP");}
		}
		if (xmlHttp_help == null ) {alert("ERROR XMLHttpRequest");return;}	
	
		
		var url= "message/search_formajax_dl.php?normanumer="+nor+""+id;
		xmlHttp_help.onreadystatechange = formsearchsdl;
		xmlHttp_help.open("GET",url);
		xmlHttp_help.send(null);	
		
		display_help('formsearch');
		//document.getElementById("help").style.position='fixed';
		document.getElementById("formsearchdl").innerHTML="<img src=imgap/ajaxload.gif>";
		}
		function formsearchsdl()
		{//alert(xmlHttp_help.readyState);
		if (xmlHttp_help.readyState==4)
		document.getElementById("formsearchdl").innerHTML=xmlHttp_help.responseText;
		}
		
		
		function show_result_search(nor,id,d,l,m,name)
		{//alert(nor+id);
		if (window.XMLHttpRequest) xmlHttp_help = new XMLHttpRequest();		
		else
		if (window.ActiveXObject){
		xmlHttp_help=new ActiveXObject("Microsoft.XMLHTTP");
		if (! xmlHttp_help){
		xmlHttp_help=new ActiveXObject("Msxml2.XMLHTTP");}
		}
		if (xmlHttp_help == null ) {alert("ERROR XMLHttpRequest");return;}	
	
		
		var url= "search_result_ajax.php?norma="+nor+"&numer="+id+"&srednica="+d+"&dlugosc="+l+"&mat="+m+"&nazwa="+name;
		xmlHttp_help.onreadystatechange = result_search;
		xmlHttp_help.open("GET",url);
		xmlHttp_help.send(null);	
		
		display_help('formsearch');
		//document.getElementById("help").style.position='fixed';
		document.getElementById("wincenter").innerHTML="<img src=imgap/ajaxload.gif>";
		}
		function result_search()
		{//alert(xmlHttp_help.readyState);
		if (xmlHttp_help.readyState==4)		
		document.getElementById("wincenter").innerHTML=xmlHttp_help.responseText;
		
		}
		
function zapytaj(symbol,ilosc)
 {
if (ilosc!='')
 ilosca=document.forms['szukaj_magazyn'].elements[ilosc].value; else ilosca='';
noweOkno = window.open("zapytanie.php?numer="+symbol+"&ilosc="+ilosca, 'zapytanie','menubar=no, toolbar=no, location=no, scrollbars=yes, resizable=yes, status=no, width=650, height=750')
}

function zapytaj_forwebmaster()
 {

noweOkno = window.open("zapytanieforwebmaster.php", 'zapytanie_webamster','menubar=no, toolbar=no, location=no, scrollbars=yes, resizable=yes, status=no, width=650, height=500')
}

		function zmien(ident,zaokraglenie)
{
//ident.value=Math.ceil(ident.value/zaokraglenie)*zaokraglenie;
 }		
function hideDiv(elementID) 
{ 
 if (document.getElementById) 
 { // DOM3 = IE5, NS6 
   //document.getElementById(elementID).style.visibility = 'hidden'; //ukrywa nie zwalniajڣ miejsca
   
 document.getElementById(elementID).style.display='none';
 } 
} 

var win=true;
var y_win_art=0;
function mousePosition(e)
{
if (window.event)
        {
        x_win_art=window.event.clientX;
        y_win_art=window.event.clientY;

         }
         else
         {x_win_art=e.pageX;
         y_win_art=e.pageY;  }


//document.getElementById('m_user').style.top=(y_win_art+'px');
//window.status=(document.getElementById('m_user').style.top);
}


function close_win_menu()
{
win=false;
displey_block_menu();
}

function close_help(ident)
{
document.getElementById(ident).style.display='none';
}

function display_help(ident)
{
document.getElementById(ident).style.display='block';
}
function display_menu(ident)
{
display_block();
displey_block_menu();
document.getElementById(ident).style.display='block';

 }
 function display_menu_art(ident)
{
if (win!=false){
	 
displey_block_menu();
document.getElementById(ident).style.display='block';
document.getElementById(ident).style.top=(y_win_art-10)+"px";


} 

 }
function display_block()
{
document.getElementById('m_user').style.display='none';


 }
 function displey_block_menu()
 {
 if (document.getElementById('grupa1')!=undefined) document.getElementById('grupa1').style.display='none';
 document.getElementById('grupa1').style.display='none';
if (document.getElementById('grupa2')!=undefined) document.getElementById('grupa2').style.display='none';
document.getElementById('grupa2').style.display='none';
if (document.getElementById('grupa3')!=undefined) document.getElementById('grupa3').style.display='none';
document.getElementById('grupa3').style.display='none';
if (document.getElementById('grupa4')!=undefined) document.getElementById('grupa4').style.display='none';
document.getElementById('grupa4').style.display='none';
if (document.getElementById('grupa5')!=undefined) document.getElementById('grupa5').style.display='none';
document.getElementById('grupa5').style.display='none';
if (document.getElementById('grupa6')!=undefined) document.getElementById('grupa6').style.display='none';
document.getElementById('grupa6').style.display='none';
if (document.getElementById('grupa7')!=undefined) document.getElementById('grupa7').style.display='none';
document.getElementById('grupa7').style.display='none';
if (document.getElementById('grupa8')!=undefined) document.getElementById('grupa8').style.display='none';
document.getElementById('grupa8').style.display='none';
if (document.getElementById('grupa9')!=undefined) document.getElementById('grupa9').style.display='none';
document.getElementById('grupa9').style.display='none';
if (document.getElementById('grupa10')!=undefined) document.getElementById('grupa10').style.display='none';
document.getElementById('grupa10').style.display='none';
if (document.getElementById('grupa11')!=undefined) document.getElementById('grupa11').style.display='none';
document.getElementById('grupa11').style.display='none';
if (document.getElementById('grupa12')!=undefined) document.getElementById('grupa12').style.display='none';
document.getElementById('grupa12').style.display='none';
if (document.getElementById('grupa13')!=undefined) document.getElementById('grupa13').style.display='none';
document.getElementById('grupa13').style.display='none';
if (document.getElementById('grupa14')!=undefined) document.getElementById('grupa14').style.display='none';
document.getElementById('grupa14').style.display='none';
if (document.getElementById('grupa15')!=undefined) document.getElementById('grupa15').style.display='none';
document.getElementById('grupa15').style.display='none';
if (document.getElementById('grupa16')!=undefined) document.getElementById('grupa16').style.display='none';
document.getElementById('grupa16').style.display='none';
if (document.getElementById('grupa17')!=undefined) document.getElementById('grupa17').style.display='none';
document.getElementById('grupa17').style.display='none';
if (document.getElementById('grupa18')!=undefined) document.getElementById('grupa18').style.display='none';
document.getElementById('grupa18').style.display='none';
if (document.getElementById('grupa19')!=undefined) document.getElementById('grupa19').style.display='none';
document.getElementById('grupa19').style.display='none';

 
 }
 //document.onmousemove=mousePosition;
 
 
 function go_all(norma,numer,srednica,dlugosc)
{
   window.location.href = 'index.php?dzial=search&norma='+norma+'&numer='+numer+'&srednica='+srednica+'&dlugosc='+dlugosc;
   //http://192.168.1.135/~efekt_l/index.php?dzial=search&norma=DIN&numer=931&srednica=10&dlugosc=140
}
 function go_all_all(norma,numer,srednica,dlugosc,material,klasa)
{
   window.location.href = 'index.php?dzial=search&norma='+norma+'&numer='+numer+'&srednica='+srednica+'&dlugosc='+dlugosc+'&mat='+material+'&klasa='+klasa;
   //http://192.168.1.135/~efekt_l/index.php?dzial=search&norma=DIN&numer=931&srednica=10&dlugosc=140
}
function go_dl(srednica,dlugosc)
{
   window.location.href = 'index.php?dzial=search&srednica='+srednica+'&dlugosc='+dlugosc;
   //http://192.168.1.135/~efekt_l/index.php?dzial=search&norma=DIN&numer=931&srednica=10&dlugosc=140
}

function go_ds(symbol)
{
   window.location.href = 'index.php?dzial=dopasowania_symbolu&symbol_s='+symbol; 
   
   //http://127.0.0.1/~efekt_l/index.php?dzial=dopasowania_symbolu&symbol_s=E908210140OC
}

function go_sk(symbol)
{
   
   window.location.href = 'index.php?dzial=su_user&idtowar='+symbol;
   //http://127.0.0.1/~efekt_l/index.php?dzial=dopasowania_symbolu&symbol_s=E908210140OC
}


function go_din(norma,numer)
{
   window.location.href = 'index.php?dzial=search&norma='+norma+'&numer='+numer;
   //http://127.0.0.1/~efekt_l/index.php?dzial=search&norma=DIN&numer=571
}

function go_detal(id,title)
{
   window.location.href = 'index.php?dzial=detal&action=show&dinart='+id+'&title='+title;
   //http://192.168.1.135/~efekt_l/index.php?dzial=detal&action=show&dinart=14&title=DIN125PN82006ISO7089ART 
   
}
function SetCookie(NazwaCookie,wartosc) 
{ 

  Teraz=new Date(); 
  Teraz.setTime(Termin = (24*60*60*1000) + Teraz.getTime()); 
  Termin= (Teraz.toGMTString()); 
  document.cookie= NazwaCookie+"=" + wartosc + "; expires="+Termin; 

} 

function getCookie(Name)
  {
  var search = Name + "=";

  // jeżeli są jakiekolwiek ciasteczka
  if (document.cookie.length > 0)
    {
    // określenie początku ciasteczka o zadanej nazwie
    offset = document.cookie.indexOf(search);

    // jeżeli ciasteczko istnieje
    if (offset != -1)
      {
      //określenie początku wartości ciasteczka
      offset += search.length;

      //określenie końca ciasteczka
      end = document.cookie.indexOf(";", offset)
      if (end == -1) end = document.cookie.length

        //zwrócenie wartości ciasteczka
        return unescape(document.cookie.substring(offset, end))
      }
    }
  }
var xmlHttp=null;
function info(id,symbol)
{
    if (window.XMLHttpRequest) xmlHttp = new XMLHttpRequest();
    else
    if (window.ActiveXObject){
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        if (! xmlHttp){
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
    }
    if (xmlHttp == null ) {
        alert("ERROR XMLHttpRequest");
        return;
    }


    var url= "files/infoart.php?id="+id+"&symbol="+symbol;
    xmlHttp.onreadystatechange = Setinfo;
    xmlHttp.open("GET",url);
    xmlHttp.send(null);


    document.getElementById("infoart").innerHTML="<img src=imgap/ajaxload.gif>";
}

function Setinfo()
{
    display_help('infoart');
    if (xmlHttp.readyState>3)
    {
        document.getElementById("infoart").innerHTML=xmlHttp.responseText;
        //document.title= MOUSE_Y+'px';

        document.getElementById('infoart').style.top=(MOUSE_Y-10)+'px';
        //document.getElementById('infoart').style.left=(100)+'px';

    }
//alert(xmlHttp.readyState);


}

 function write_jed(tekst)
    {
        document.getElementById('przeliczmasy').innerHTML=tekst;
    }

    /*function przelicz(id)
{

//x_przelicz_jed(id,write_jed);
document.getElementById('przeliczmasy').innerHTML="<img src=imgap/ajaxload.gif>";
}*/
    function przelicznakg()
    {
        alert('Pezeliczam');
    }

    var xmlHttp=null;
    function przelicz(id,unitt)
    {
        if (window.XMLHttpRequest) xmlHttp = new XMLHttpRequest();		
        else
            if (window.ActiveXObject){
                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                if (! xmlHttp){
                    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
        }
        if (xmlHttp == null ) {alert("ERROR XMLHttpRequest");return;}	


        var url= "files/stan_magazyn1.php?id="+id+"&unitt="+unitt;
        xmlHttp.onreadystatechange = Setmsg;
        xmlHttp.open("GET",url);
        xmlHttp.send(null);	


        document.getElementById("przeliczmasy").innerHTML="<img src=imgap/ajaxload.gif>";
    }

    function Setmsg()
    {display_help('przeliczmasy');
        if (xmlHttp.readyState>3)
        {document.getElementById("przeliczmasy").innerHTML=xmlHttp.responseText;



            //document.title= MOUSE_Y+'px'; 
            document.getElementById('przeliczmasy').style.top=(MOUSE_Y)+'px';

        }
        //alert(xmlHttp.readyState);


    }

    function isInteger(x,un)
    {
        //if(unit=='szt') 

        var liczba=/^[0-9]+([\.,])[0-9]+$/;

        if ((liczba.test(x))&&(un=='szt')) {          
            alert('Liczba nie jest całkowita');
            return false;

        }

        return true; 



    }
    function adbasket(nazwa,nr,ile,unit)
    {
        ilea=ile.replace(',','.');
        if (isInteger(ile,unit))
        {//alert(ile);
            if (ilea>0)
            {

                if (confirm('Czy dodać do kosza? \n'+' '+ile+' '+unit+'\n'+nazwa))
                {

                    if (window.XMLHttpRequest) xmlHttp_help = new XMLHttpRequest();		
                    else
                        if (window.ActiveXObject){
                            xmlHttp_help=new ActiveXObject("Microsoft.XMLHTTP");
                            if (! xmlHttp_help){
                                xmlHttp_help=new ActiveXObject("Msxml2.XMLHTTP");}
                    }
                    if (xmlHttp_help == null ) {alert("ERROR XMLHttpRequest");return;}	


                    var url= "files/addbasket.php?id="+nr+"&ile="+ile;
                    xmlHttp_help.onreadystatechange = adbask_win;
                    xmlHttp_help.open("GET",url);
                    xmlHttp_help.send(null);	

                    display_help('help');
                    document.getElementById("help").innerHTML="<img src=imgap/ajaxload.gif>";
                    var iMyWidth;
                    var iMyHeight;
                    var wWidth = 1000;
                    var wHeight = 400;
                    iMyWidth = (window.screen.width/2) - wWidth/2;
                    iMyHeight = (window.screen.height/2) - wHeight/2;
                    document.getElementById("help").style.top= iMyHeight+'px';
                    document.getElementById("help").style.left= iMyWidth+'px'; 
                }
            }
        }
    }
    function adbask_win()
    {//alert(xmlHttp_help.readyState);
        if (xmlHttp_help.readyState==4)
        {document.getElementById("help").innerHTML=xmlHttp_help.responseText;
            orderbutton();
        }
    }


    function orderbutton()
    {



        if (window.XMLHttpRequest) xmlHttp_orbutt = new XMLHttpRequest();		
        else
            if (window.ActiveXObject){
                xmlHttp_orbutt=new ActiveXObject("Microsoft.XMLHTTP");
                if (! xmlHttp_orbutt){
                    xmlHttp_orbutt=new ActiveXObject("Msxml2.XMLHTTP");}
        }
        if (xmlHttp_orbutt == null ) {alert("ERROR XMLHttpRequest");return;}	


        var url= "files/basketbutton.php";
        xmlHttp_orbutt.onreadystatechange = basketbutton_win;
        xmlHttp_orbutt.open("GET",url);
        xmlHttp_orbutt.send(null);	

        //display_help('help');
        //document.getElementById("war_basket").innerHTML="<img src=imgap/ajaxload.gif>";

    }
    function basketbutton_win()
    {//alert(xmlHttp_help.readyState);
        if (xmlHttp_orbutt.readyState==4)
        {document.getElementById("war_basket").innerHTML=xmlHttp_orbutt.responseText;
        }
    }
