var xmlHttpa = createXmlHttpRequestObjecta();

function createXmlHttpRequestObjecta() 
{
  // will store the reference to the XMLHttpRequest object
  var xmlHttpa;
  // this should work for all browsers except IE6 and older
  try
  {
    // try to create XMLHttpRequest object
    xmlHttpa = new XMLHttpRequest();
  }
  catch(e)
  {
    // assume IE6 or older
    var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",
                                    "MSXML2.XMLHTTP.5.0",
                                    "MSXML2.XMLHTTP.4.0",
                                    "MSXML2.XMLHTTP.3.0",
                                    "MSXML2.XMLHTTP",
                                    "Microsoft.XMLHTTP");
    // try every prog id until one works
    for (var i=0; i<XmlHttpVersions.length && !xmlHttpa; i++) 
    {
      try 
      { 
        // try to create XMLHttpRequest object
        xmlHttpa = new ActiveXObject(XmlHttpVersions[i]);
      } 
      catch (e) {} // ignore potential error
    }
  }
  // return the created object or display an error message
  if (!xmlHttpa)
    alert("Error creating the XMLHttpRequest object.");
  else 
    return xmlHttpa;
}


function ShowProd(id, title) 
{
	xmlHttpa.onreadystatechange=function()
	{
		if(xmlHttpa.readyState == 4 && xmlHttpa.status == 200)
	{
		document.getElementById("maintext").innerHTML = xmlHttpa.responseText;
		document.title = title +' FYTONA';	
		document.getElementById("mainnadpis").innerHTML = title;
//fh = fopen('incl/'+id+'.htm', 0); // Open the file for reading
//		var nNadpis = document.getintextElementById("mainnadpis");
//		nNadpis.innerHTML = xmlHttp1.responseText;
	}
	}
xmlHttpa.open("GET","ajax-produkt.php" +"?id="+id);
	xmlHttpa.send(null);
//	xmlHttp.open("GET",url,true);
	//xmlHttp.send(null);

}
function FiltrRada(id) 
{
	xmlHttpa.onreadystatechange=function()
	{
		if(xmlHttpa.readyState == 4 && xmlHttpa.status == 200)
	{
		document.getElementById("maintext").innerHTML = xmlHttpa.responseText;
	}
	}
xmlHttpa.open("GET","ajax-filtrrada.php" +"?id="+id);
	xmlHttpa.send(null);
//	xmlHttp.open("GET",url,true);
	//xmlHttp.send(null);

}
function FiltrDiag(id) 
{
	xmlHttpa.onreadystatechange=function()
	{
		if(xmlHttpa.readyState == 4 && xmlHttpa.status == 200)
	{
		document.getElementById("maintext").innerHTML = xmlHttpa.responseText;
	}
	}
xmlHttpa.open("GET","ajax-filtrdiag.php" +"?id="+id);
	xmlHttpa.send(null);
//	xmlHttp.open("GET",url,true);
	//xmlHttp.send(null);

}

function InitS() {
	
stepcarousel.setup({
	galleryid: 'mygallery', //id of carousel DIV
	beltclass: 'belt', //class of inner "belt" DIV containing all the panel DIVs
	panelclass: 'panel', //class of panel DIVs each holding content
	autostep: {enable:true, moveby:1, pause:0},
	panelbehavior: {speed:5000, wraparound:false, wrapbehavior:'slide', persist:false},
	defaultbuttons: {enable: false, moveby: 1, leftnav: ['images/arrleft.png', -5, 80], rightnav: ['images/arrright.png', -20, 80]},
	statusvars: ['statusA', 'statusB', 'statusC'], //register 3 variables that contain current panel (start), current panel (last), and total panels
	contenttype: ['ajax','ajax-top.php'] //content setting ['inline'] or ['ajax', 'path_to_external_file']
})

}


function GivePovinn(dataSource,typ, POV)
{
	document.getElementById("overlay").style.display='';
	document.getElementById("overlay").style.position='absolute';
	document.getElementById("overlay").style.top='0';
	document.getElementById("overlay").style.left='0';
	document.getElementById("overlay").style.height='100%';
	document.getElementById("overlay").style.width='100%'; 
	winHeight = document.documentElement.clientHeight;
	vyska=winHeight/2;
	var obr= document.getElementById("overlay");
	obr.innerHTML = '<div style="padding-top:'+vyska+'px; text-align:center; color:white; font-weight:bold">Ověřuji<img 			src="images/loading.gif" /></div>';
xmlHttpa = createXmlHttpRequestObjecta();
	xmlHttpa.open("GET", dataSource);
	xmlHttpa.onreadystatechange = function()
	{
		if (xmlHttpa.readyState == 4 && xmlHttpa.status == 200)
		{
			if(xmlHttpa.responseText == "neni")
			{
				alert('Nesprávna hodnota');
				document.getElementById("form"+typ).value="";
				document.getElementById("form"+typ).focus();
					document.getElementById("form"+typ).style.backgroundColor="#F00";
					var obr= document.getElementById("over"+typ);
					obr.innerHTML = '';
				document.getElementById("overlay").style.display='none';
				if(pov=='P')
				{
					document.getElementById("form"+typ).style.backgroundColor="#F00";
					var obr= document.getElementById("over"+typ);
					obr.innerHTML = '';
				document.getElementById("overlay").style.display='none';
				}
			}
			else
			{
				document.getElementById("form"+typ).style.backgroundColor="#a1bb99";
				var obr= document.getElementById("over"+typ);
			obr.innerHTML = '<img src="images/ok.png" alt="" />';
				document.getElementById("overlay").style.display='none';
			}
		}
	
	}
	xmlHttpa.send(null);
}


function FormPovinn(udalost,typ,kolik,pov)
{
	udalost = (udalost) ? udalost: window.event;
	txt = (udalost.target) ? udalost.target : udalost.srcElement;
	
	if (udalost.type == "blur")
	{
				if (txt.value) {GivePovinn("validpovinn.php?co=" + txt.value +"&kolik=" + kolik,typ,pov);}
	}
}


function GiveEmail(dataSource,typ,pov)
{
	document.getElementById("overlay").style.display='';
	document.getElementById("overlay").style.position='absolute';
	document.getElementById("overlay").style.top='0';
	document.getElementById("overlay").style.left='0';
	document.getElementById("overlay").style.height='100%';
	document.getElementById("overlay").style.width='100%'; 
	winHeight = document.documentElement.clientHeight;
	vyska=winHeight/2;
	var obr= document.getElementById("overlay");
	obr.innerHTML = '<div style="padding-top:'+vyska+'px; text-align:center; color:white; font-weight:bold">Ověřuji<img src="images/loading.gif" /></div>';
xmlHttpa = createXmlHttpRequestObjecta();
	xmlHttpa.open("GET", dataSource);
	xmlHttpa.onreadystatechange = function()
	{
		if (xmlHttpa.readyState == 4 && xmlHttpa.status == 200)
		{
			if(xmlHttpa.responseText == "full")
			{
				alert('Emailová adresa je již zaregistrována');
				document.getElementById("form"+typ).value="";
				document.getElementById("form"+typ).focus();
				document.getElementById("form"+typ).style.backgroundColor="#F00";
				document.getElementById("overlay").style.display='none';
					var obr= document.getElementById("over"+typ);
					obr.innerHTML = '';
			}
			else
			{
				if(xmlHttpa.responseText == "false")
				{
					alert('Nesprávna hodnota');
					document.getElementById("form"+typ).value="";
					document.getElementById("form"+typ).focus();	
					document.getElementById("form"+typ).style.backgroundColor="#F00";
					document.getElementById("overlay").style.display='none';
					var obr= document.getElementById("over"+typ);
					obr.innerHTML = '';
				}
				else
				{
					document.getElementById("form"+typ).style.backgroundColor="#a1bb99";
					document.getElementById("overlay").style.display='none';
				var obr= document.getElementById("over"+typ);
			obr.innerHTML = '<img src="images/ok.png" alt="" />';
				}
			}
		}
	
	}
	xmlHttpa.send(null);
}


function ControlEmail(udalost,typ, pov, cont)
{
	udalost = (udalost) ? udalost: window.event;
	txt = (udalost.target) ? udalost.target : udalost.srcElement;
	if (udalost.type == "blur")
	{
				if (txt.value) {GiveEmail("validemail.php?co=" + txt.value + "&cont=" + cont,typ, pov);}
	}
}

function GivePovinnC(dataSource,typ, POV)
{
	document.getElementById("overlay").style.display='';
	document.getElementById("overlay").style.position='absolute';
	document.getElementById("overlay").style.top='0';
	document.getElementById("overlay").style.left='0';
	document.getElementById("overlay").style.height='100%';
	document.getElementById("overlay").style.width='100%'; 
	winHeight = document.documentElement.clientHeight;
	vyska=winHeight/2;
	var obr= document.getElementById("overlay");
	obr.innerHTML = '<div style="padding-top:'+vyska+'px; text-align:center; color:white; font-weight:bold">Ověřuji<img 			src="images/loading.gif" /></div>';
xmlHttpa = createXmlHttpRequestObjecta();
	xmlHttpa.open("GET", dataSource);
	xmlHttpa.onreadystatechange = function()
	{
		if (xmlHttpa.readyState == 4 && xmlHttpa.status == 200)
		{
			if(xmlHttpa.responseText == "neni")
			{
				alert('Nesprávna hodnota');
				document.getElementById("form"+typ).value="";
				document.getElementById("form"+typ).focus();
					var obr= document.getElementById("over"+typ);
					obr.innerHTML = '';
				document.getElementById("overlay").style.display='none';
				if(pov=='P')
				{
					document.getElementById("form"+typ).style.backgroundColor="#F00";
					var obr= document.getElementById("over"+typ);
					obr.innerHTML = '';
				document.getElementById("overlay").style.display='none';
				}
			}
			else
			{
				document.getElementById("form"+typ).style.backgroundColor="#a1bb99";
				var obr= document.getElementById("over"+typ);
			obr.innerHTML = '<img src="images/ok.png" alt="" />';
				document.getElementById("overlay").style.display='none';
			}
		}
	
	}
	xmlHttpa.send(null);
}


function FormPovinnC(udalost,typ,kolik,pov)
{
	udalost = (udalost) ? udalost: window.event;
	txt = (udalost.target) ? udalost.target : udalost.srcElement;
	
	if (udalost.type == "blur")
	{
				if (txt.value) {GivePovinnC("validpovinnc.php?co=" + txt.value +"&kolik=" + kolik,typ,pov);}
	}
}

function EditBal(prod_id, ses) {
		window.open('admin-editbal.php?prod_id='+prod_id+'&ses=' + ses,'Text', 'width=600, height=600, scrollbars=yes');
}
