/********************************************************/
/*****   Slawomir Mitak slawomirmitak@yahoo.com     *****/
/*****     preview image with request HTTP          *****/
/*****              cross browsers                  *****/
/***** 												*****/
/********************************************************/
document.write('<div id="bgPreview" style="display:none; background:#000000; position:absolute; top:0px; left:0px; width:100%; height:100%; text-align:center; opacity:0.4;filter:alpha(opacity=40)"></div>');
document.write('<div id="divPrev" style="display:none; position:absolute; top:30px; left:0px; width:98%; height:auto; text-align:center;">');
document.write('<table align="center"><tr><td>');
document.write('<div id="exDiv" style="display:block; margin: auto auto; border:1px solid #cccccc; padding:20px; background-color:#000000;"></div>');
document.write('</td></tr>');
document.write('</table>');
document.write('</div>');
var imgShow;
var cart=0;

function showPicture(pic,koszyk){
		imgShow=pic;
		if(koszyk){cart=1;}
		//clear data in my div
		document.getElementById('exDiv').innerHTML='';		
		MakeRequest();		
	}

function getXMLHttp(){
  var xmlHttp
  try
  {//Firefox, Opera 8.0+, Safari
    xmlHttp = new XMLHttpRequest();
  }
  catch(e)
  {//Internet Explorer
    try
    {
      xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
      try
      {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch(e)
      {
        alert("Your browser does not support AJAX!")
        return false;
      }
    }
  }
  return xmlHttp;
}

function MakeRequest(){
  var xmlHttp = getXMLHttp();
  xmlHttp.onreadystatechange = function(){
		if(xmlHttp.readyState == 4){
			HandleResponse(xmlHttp.responseText);
			}
  }  
  if (cart==1){cart=0; xmlHttp.open("GET", "preview.php?pic="+imgShow+"&sh=1", true);}else{xmlHttp.open("GET", "preview.php?pic="+imgShow, true);}
  //xmlHttp.open("GET", "preview.php?pic="+imgShow, true); 
  xmlHttp.send(null);
}

function HandleResponse(response){ 
	document.getElementById('exDiv').innerHTML = response;
	document.getElementById('bgPreview').style.display='block';
	document.getElementById('divPrev').style.display='block';
}
