//   JavaScript Document
//tento script se vztahuje k tagu id=DIVzapomelJsemHeslo
var BOX="DIVzapomelJsemHeslo";

var xmlHttpHeslo = createXmlHttpRequestObject();

function zapomelJsemHeslo(){

FCEloader("block");

var divHeslo = document.getElementById(BOX);
/* základní nastavení hlavního boxu*/
  var vzornikX=(winW()/2)-309;
  vzornikY=200;
  odrolovano=mujScrollY();
  vzornikY=vzornikY+odrolovano;
  divHeslo.style.left=vzornikX+"px";
  divHeslo.style.top=vzornikY+"px";


divHeslo.style.width="618px";
divHeslo.style.position="absolute";
divHeslo.style.zIndex="100";
divHeslo.className="select-mask";
divHeslo.innerHTML="";
//---------------------------konec nastavení

//hlavička boxu
mujDIV=document.createElement('DIV');
mujDIV.style.width="618px";
mujDIV.style.height="36px";
if(!window.ActiveXObject)mujDIV.style.background="transparent url("+AktualDir+"G-www/detail_kosik_hlavicka_618.png) 0% 0% no-repeat";
else mujDIV.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+AktualDir+"G-www/detail_kosik_hlavicka_618.png', sizingMethod='scale')";

mujDIV.style.position="relative";
divHeslo.appendChild(mujDIV);

mujSPAN=document.createElement('DIV');
mujSPAN.setAttribute("id", BOX+"DragDrop");
mujSPAN.style.width="550px";
mujSPAN.style.height="31px";
mujSPAN.style.top="5px";
mujSPAN.style.left="10px";
mujSPAN.style.padding="6px 0px 0px 5px";
mujSPAN.style.cursor="move";
mujSPAN.style.position="absolute";
mujSPAN.style.color="black";
mujSPAN.style.fontWeight="bold";

mujSPAN.setAttribute("onmousedown", "presunOkno('"+BOX+"');");
mujSPAN.setAttribute("onmouseout", "konecPresunu('"+BOX+"');");

divHeslo.appendChild(mujSPAN);
mujText=document.createTextNode('Zapomněli jste své heslo?');
mujSPAN.appendChild(mujText);

mujIMG=document.createElement('img');
mujIMG.src=AktualDir+"G-www/zavrit_kosik.gif";
mujIMG.setAttribute("onclick", "document.getElementById('"+BOX+"').style.display ='none';");
mujIMG.className="CloseVizitka";
mujIMG.style.top="7px";
mujIMG.style.right="22px";
mujIMG.title="Zavři náhled košíku";
mujIMG.alt="Zavři náhled košíku";
divHeslo.appendChild(mujIMG);
//-------------------------------------------------------------


// tělo boxu
mujDIV=document.createElement('DIV');
if(!window.ActiveXObject)mujDIV.style.background="transparent url("+AktualDir+"G-www/detail_kosik_telo_618.png) 0% 0% repeat-y";
else mujDIV.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+AktualDir+"G-www/detail_kosik_telo_618.png', sizingMethod='scale')";
mujDIV.style.width="618px";
mujDIV.style.position="relative";
divHeslo.appendChild(mujDIV);

mujP=document.createElement('p');
mujP.style.width="575px";
//mujP.style.border="1px solid Black";
mujP.style.margin="0px 0px";
mujP.style.marginLeft="20px";
mujP.style.color="black";

mujBR=document.createElement('br');
mujP.appendChild(mujBR);

mujText=document.createTextNode('Zapomněli jste své heslo? Nevadí, my Vám zašleme nové heslo.');
mujP.appendChild(mujText);

mujBR=document.createElement('br');
mujP.appendChild(mujBR);
mujBR=document.createElement('br');
mujP.appendChild(mujBR);

mujText=document.createTextNode('Zadejte do následujícího formuláře Vaši e-mailovou adresu. Na tuto adresu pak během několika minut přijde uživatelské jméno a nové heslo k Vašemu účtu, u kterého bude odpovídající e-mailová adresa.');
mujP.appendChild(mujText);
mujBR=document.createElement('br');
mujP.appendChild(mujBR);
mujBR=document.createElement('br');
mujP.appendChild(mujBR);
mujDIV.appendChild(mujP);

mujDIV1=document.createElement('DIV');
mujDIV1.style.marginLeft="20px";
mujLABEL=document.createElement('label');
mujLABEL.setAttribute("for","usermail");
mujText=document.createTextNode('Váš e-mail:');
mujLABEL.appendChild(mujText);
			 hvezdicka=document.createElement("strong");
hvezdicka.style.color="red";
hvezdickaText=document.createTextNode("* ");
hvezdicka.appendChild(hvezdickaText);
			 novaHvezdicka= hvezdicka;
mujLABEL.appendChild(novaHvezdicka);
mujDIV1.appendChild(mujLABEL);
ObjednatInput=document.createElement("input");
ObjednatInput.setAttribute("id", "usermail");
ObjednatInput.style.borderWidth="1px";
ObjednatInput.style.borderColor="#0b0b0a";
ObjednatInput.style.color="black";
ObjednatInput.style.fontSize="11px";
ObjednatInput.style.padding="1px 1px";
ObjednatInput.style.textAlign="left";
ObjednatInput.style.width="250px";
mujDIV1.appendChild(ObjednatInput);


vysipKos=document.createElement('input');
vysipKos.type="button";
vysipKos.value="Odeslat";
vysipKos.setAttribute("title", "Odeslat ke zpracování");
vysipKos.setAttribute("id", "TLodeslatZapomelHeslo");
vysipKos.style.color="yellow";
vysipKos.style.marginRight="0px";
vysipKos.className="eshopTlacitka";

vysipKos.setAttribute("onMouseDown", "odeslatZapomelHeslo();");

mujDIV1.appendChild(vysipKos);


mujDIV.appendChild(mujDIV1);

//--------------------------------------------------------------




//patička boxu
mujDIV=document.createElement('DIV');
//mujDIV.className="pngKosikPaticka";
if(!window.ActiveXObject)mujDIV.style.background="transparent url("+AktualDir+"G-www/detail_kosik_paticka_618.png) 0% 0% no-repeat";
else mujDIV.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+AktualDir+"G-www/detail_kosik_paticka_618.png', sizingMethod='scale')";
mujDIV.style.width="618px";
mujDIV.style.height="35px";

divHeslo.appendChild(mujDIV);
//------------------------------------------------------------------------


DIVmask="<!--[if lte IE 6.5]><iframe></iframe><![endif]-->";

/*závěrečná aktivace boxu*/
reloadDIV = divHeslo.innerHTML;
divHeslo.innerHTML=reloadDIV+DIVmask;
/*
new Draggable(BOX,{handle: BOX+"DragDrop",
snap: function(x,y,draggable) {
function constrain(n, lower, upper) {
if (n > upper) return upper;
else if (n < lower) return lower;
else return n;
}
e_d = Element.getDimensions(draggable.element);
p_d = Element.getDimensions(draggable.element.parentNode);
return[
constrain(x, 0, p_d.width - e_d.width),
constrain(y, 0, p_d.height - e_d.height)];
}
});
*/
divHeslo.style.display="block";
setTimeout('zIndexOken("'+BOX+'")', 100);
setTimeout('FCEloader("none");', 500);
}

function odeslatZapomelHeslo(){

var povolit=kontrolaEmailu('usermail',true);
if(povolit==true){
FCEloader("block");
usermailValue = document.getElementById('usermail').value;
  // proceed only if the xmlHttp object isn't busy
  if (xmlHttpHeslo.readyState == 4 || xmlHttpHeslo.readyState == 0)
 {
    // execute the quickstart.php page from the server
    xmlHttpHeslo.open("GET", AktualDir+"ajaxZapomelJsemHeslo.php?usermail="+usermailValue, true);
    // define the method to handle server responses
    xmlHttpHeslo.onreadystatechange = zpravaZapomenuteHeslo;
    // make the server request
    xmlHttpHeslo.send(null);

  }
  else
    // if the connection is busy, try again after one second
    setTimeout('obsahKosiku()', 1000);
}

}
function zpravaZapomenuteHeslo(){

 // move forward only if the transaction has completed
  if (xmlHttpHeslo.readyState == 4)
  {
    // status of 200 indicates the transaction completed successfully
    if (xmlHttpHeslo.status == 200)
    {
      // extract the XML retrieved from the server
      xmlResponse = xmlHttpHeslo.responseXML;
      // obtain the document element (the root element) of the XML structure
      xmlDocumentElement = xmlResponse.documentElement;
      // get the text message, which is in the first child of
      // the the document element


      //helloMessage = xmlDocumentElement.firstChild.data;
      var htmlVystup="";
      zpravaodeslaniArray = xmlDocumentElement.getElementsByTagName("zpravaodeslani");
      odeslanoArray = xmlDocumentElement.getElementsByTagName("odeslano");
      var zpravaVystup =zpravaodeslaniArray.item(0).firstChild.data;
      var odeslanoVystup =odeslanoArray.item(0).firstChild.data;

       alert(zpravaVystup);
       setTimeout('FCEloader("none")', 100);

if(odeslanoVystup==1){

setTimeout("document.getElementById('"+BOX+"').style.display ='none';",100);
}/*else{
setTimeout('FCEzpetnaKrok2()', 100);
}*/
      // restart sequence
     // setTimeout('pridejPolozku()', 1000);
    }
    // a HTTP status different than 200 signals an error
    else
    {
      alert("Nastal problém ve spojejí se serverem: " + xmlHttpHeslo.statusText);
    }
  }
}