var ajax_url='http://www.doskonalyprezent.pl/ajax/';

function pokaz_zdjecie(sciezka,rozmiar,rodzaj)
{
	//alert(sciezka)
	//alert(rozmiar);
	var req = mint.Request();
	
	req.OnSuccess = function() {
		//alert(this.responseJSON[0].width);
		//alert(this.responseJSON[0].height);
		//alert(this.responseJSON[0].html);
		
		
		var IE = document.all?true:false; 
		
		if (IE)
		{ // grab the x-y pos.s if browser is IE 
			tempY = document.documentElement.scrollTop; 
		} 
		else
		{ // grab the x-y pos.s if browser is NS 
			tempY = window.scrollY;
		} 
		
		document.getElementById("dPowiekszZdjecie").innerHTML=this.responseJSON[0].html;
		document.getElementById("dPowiekszZdjecie").style.width=this.responseJSON[0].width+'px';
		document.getElementById("dPowiekszZdjecie").style.height=this.responseJSON[0].height+'px';
		document.getElementById("dPowiekszZdjecie").style.top=(100+tempY)+'px';
		document.getElementById("dPowiekszZdjecie").style.display='block';
		/*
        for(var i = 0; i < this.responseJSON.length; ++i) 
		{
            
			grid.InsertRow(this.responseJSON[i].name, this.responseJSON[i].mail);
        }
		*/
    }
	
	req.method='POST';
	req.getJSON = true;
	req.AddParam("sciezka", sciezka);
	req.AddParam("rodzaj", rodzaj);
	req.AddParam("rozmiar", rozmiar);
	req.Send(ajax_url+"zdjecia.php");
	
	//alert(tzdj['width']);
	//alert(tzdj['height']);
	//alert(tzdj['html']);
	
	/*
	if (document.getElementById('iKomentarz').value=='' || document.getElementById('iUser').value=='')
	{
		document.getElementById('dInfo').style.display='';
		return false;	
	}
	else
	{
		var req = mint.Request();
		req.method='POST';
		//alert($("iKomentarz").value);
		req.AddParam("komentarz", $("iKomentarz").value);
		req.AddParam("user", $("iUser").value);
		req.AddParam("id_ojca", $("iIdOjca").value);
		req.AddParam("id_obiektu", $("iIdObiektu").value);
		req.AddParam("action", $("iAction").value);
		//alert($("iAkceptuj").value);
   		if ($("iAkceptuj").value==1) { req.Send("myclass/Komentarze/ajax_komentarze.php", "dKomentarz"); document.getElementById('dDodajKomentarz0').style.display='none'; }
		else req.Send("myclass/Komentarze/ajax_komentarze.php", "dDodajKomentarz"+document.getElementById('iIdOjca').value);
	}
}



  req.OnSuccess = function() {
        for(var i = 0; i < this.responseJSON.length; ++i) {
            grid.InsertRow(this.responseJSON[i].name, this.responseJSON[i].mail);
        }
    }
   
    req.getJSON = true;
    req.Send("users.txt");
*/
}

function wyslij_polec()
{
	var req = mint.Request();	
	req.method='POST';
	//req.AddParam("sciezka", sciezka);
	//req.AddParam("rodzaj", rodzaj);
	//req.AddParam("rozmiar", rozmiar);
	req.OnSuccess = function() {
        document.getElementById('dPolecWyslij').innerHTML = this.responseText;
    }           
    req.SendForm("formPolec");
	
	//alert(tzdj['width']);
	//alert(tzdj['height']);
	//alert(tzdj['html']);
	
	/*
	if (document.getElementById('iKomentarz').value=='' || document.getElementById('iUser').value=='')
	{
		document.getElementById('dInfo').style.display='';
		return false;	
	}
	else
	{
		var req = mint.Request();
		req.method='POST';
		//alert($("iKomentarz").value);
		req.AddParam("komentarz", $("iKomentarz").value);
		req.AddParam("user", $("iUser").value);
		req.AddParam("id_ojca", $("iIdOjca").value);
		req.AddParam("id_obiektu", $("iIdObiektu").value);
		req.AddParam("action", $("iAction").value);
		//alert($("iAkceptuj").value);
   		if ($("iAkceptuj").value==1) { req.Send("myclass/Komentarze/ajax_komentarze.php", "dKomentarz"); document.getElementById('dDodajKomentarz0').style.display='none'; }
		else req.Send("myclass/Komentarze/ajax_komentarze.php", "dDodajKomentarz"+document.getElementById('iIdOjca').value);
	}
}



  req.OnSuccess = function() {
        for(var i = 0; i < this.responseJSON.length; ++i) {
            grid.InsertRow(this.responseJSON[i].name, this.responseJSON[i].mail);
        }
    }
   
    req.getJSON = true;
    req.Send("users.txt");
*/
}

function koszykAktualizuj()
{
	var req = mint.Request();
	req.OnSuccess = function()
	{
		if (document.getElementById("koszykIlosc")) document.getElementById("koszykIlosc").innerHTML=this.responseJSON[0].liczba;
		if (document.getElementById("koszykIlosc2")) document.getElementById("koszykIlosc2").innerHTML=this.responseJSON[0].liczba;
		if (document.getElementById("koszykSztuk")) document.getElementById("koszykSztuk").innerHTML=this.responseJSON[0].sztuk;
		if (document.getElementById("koszykNetto")) document.getElementById("koszykNetto").innerHTML=this.responseJSON[0].suma_netto;
		if (document.getElementById("koszykBrutto")) document.getElementById("koszykBrutto").innerHTML=this.responseJSON[0].suma_brutto;
    }
	
	req.method='POST';
	req.getJSON = true;
	req.Send(ajax_url+"koszykAktualizuj.php");
}

function opcjeOkienko(ida)
{
	if (ida=='grupa')
	{
		
	}
	else produkt=ida;
	
	okienko='dDynamiczne';
	
	var req = mint.Request();
	req.OnSuccess = function()
	{
		document.getElementById('dDynamiczne').style.display='block';
		document.getElementById('dDynamiczne').style.left=tempX+'px';
		document.getElementById('dDynamiczne').style.top=tempY+'px';
    }
	req.method='POST';
	req.AddParam("idartykulu", produkt);
	req.Send(ajax_url+"opcjeOkienko.php","dDynamiczne");
}

function captcha()
{
	var req = mint.Request();
	req.OnSuccess = function()
	{
		document.getElementById("dObrazekCaptcha").innerHTML=this.obrazek;
    }
	req.method='POST';
	//req.AddParam("idartykulu", produkt);
	req.Send(ajax_url+"captcha.php","dObrazekCaptcha");
}

function koszyk(akcja,ida)
{
	if (akcja=='' || akcja=='undefined' || !akcja) akcja='dodaj';
	if (ida=='grupa')
	{
		
	}
	else
	{
		//ilosc = document.getElementById('kupIlosc'+ida+'').value;
		koszykAkcja(akcja,ida,1);
	}
}

function koszykAkcja(akcja,ida,ile)
{
	var req = mint.Request();
	req.OnSuccess = function()
	{
		//koszykAktualizuj();
    }
	req.method='POST';
	req.AddParam("idartykulu", ida);
	req.AddParam("ilosc", ile);
	req.AddParam("akcja", akcja);
	req.Send(ajax_url+"koszykDodaj.php","dInfo");
}

