var TYPE;
var ID_CAT;
var ID_SUB_MENU;
function show_hide_block(id)
{
var block=document.getElementById(id);
if(block=='block') block.style.display='none';
else block.style.display='block';
}
function show_and_hide(id)
{
var block=document.getElementById(id);
if(block.style.display=="none")  block.style.display='';
else block.style.display='none';
}
function show_hide(id)
{
	hide('danad_foto_cat_1');
	hide('danad_foto_cat_2');
	hide('danad_foto_cat_3');
	show(id);
}
function hide(id)
{ document.getElementById(id).style.display='none'; }
function show(id)
{ document.getElementById(id).style.display=''; }

function danad_go_foto(type,id_cat,i,offset)
{
var no_ID_CAT=0;

//alert('type '+type+' ID_CAT '+ID_CAT+' id_cat '+id_cat);
if(type=='0') type=TYPE;
if(ID_CAT  ) 
document.getElementById('menu_fiz_'+ID_CAT+'').style.display='none';
document.getElementById('menu_fiz_'+id_cat+'').style.display='';
show_and_hide('danad_sub_menu_'+id_cat+'');
ID_CAT=id_cat;
get_danad_sciecha(id_cat,i);
get_danad_foto(id_cat,offset);
//parseInt(i*13);
TYPE=type;

}
function get_danad_realizacje()
{
	try
  {
    xmlHttp3=new XMLHttpRequest();
  }
  catch (e)
  {
    try
    {
      xmlHttp3=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
      try
      {
        xmlHttp3=new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch (e)
      {
        alert("Your browser does not support AJAX!");
        return false;
      }
    }
  }
  xmlHttp3.onreadystatechange=function()
  {
     if(xmlHttp3.readyState==4)
     {
	 		document.getElementById('realizacje').innerHTML=xmlHttp3.responseText;

     }
  }
var	action='get_danad_realizacje';
  	xmlHttp3.open("GET","modules/Danad/ajax.php?action="+action+"",true);

    xmlHttp3.send(null);


}

function get_danad_sciecha(id,I)
{
	try
  {
    xmlHttp2=new XMLHttpRequest();
  }
  catch (e)
  {
    try
    {
      xmlHttp2=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
      try
      {
        xmlHttp2=new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch (e)
      {
        alert("Your browser does not support AJAX!");
        return false;
      }
    }
  }
  xmlHttp2.onreadystatechange=function()
  {
     if(xmlHttp2.readyState==4)
     {
	 		document.getElementById('sciecha').innerHTML=xmlHttp2.responseText;

     }
  }
var	action='get_danad_sciecha';
  	xmlHttp2.open("GET","modules/Danad/ajax.php?action="+action+"&id_cat="+ id +"&I="+I+"",true);

    xmlHttp2.send(null);


}

function get_danad_foto(id,offset)
{
	try
  {
    xmlHttp=new XMLHttpRequest();
  }
  catch (e)
  {
    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;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
  {
     if(xmlHttp.readyState==4)
     {
	 		if(do_danad) document.getElementById('prawa').innerHTML=xmlHttp.responseText;
	 		else document.getElementById('danad_foto').innerHTML=xmlHttp.responseText;

     }
  }
  var do_danad=0;
  if (!document.getElementById("danad_foto")) { do_danad=1;}
var	action='get_danad_foto';
  	xmlHttp.open("GET","modules/Danad/ajax.php?action="+action+"&id_cat="+ id +"&offset_foto="+offset+"&do_danad="+do_danad+"",true);

    xmlHttp.send(null);


}
function get_danad_search(offset)
{
	try
  {
    xmlHttp=new XMLHttpRequest();
  }
  catch (e)
  {
    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;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
  {
     if(xmlHttp.readyState==4)
     {
	 		if(do_danad) document.getElementById('prawa').innerHTML=xmlHttp.responseText;
	 		else document.getElementById('danad_foto').innerHTML=xmlHttp.responseText;

     }
  }
  var do_danad=0;
  if (!document.getElementById("danad_foto")) { do_danad=1;}
var	action='get_danad_search';
  	xmlHttp.open("GET","modules/Danad/ajax.php?action="+action+"&offset_foto="+offset+"&do_danad="+do_danad+"",true);

    xmlHttp.send(null);


}

function add_kosz(id,plik)
{
	try
  {
    xmlHttp=new XMLHttpRequest();
  }
  catch (e)
  {
    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;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
  {
     if(xmlHttp.readyState==4)
     {
	 		document.getElementById('koszyk_mini').innerHTML=xmlHttp.responseText;

     }
  }


	createCookie('DanadKoszyk['+id+']',plik,'');
  	xmlHttp.open("GET","modules/Danad/ajax.php?action=getBasket",true);
    xmlHttp.send(null);


}
function del_kosz(id)
{
	try
  {
    xmlHttp=new XMLHttpRequest();
  }
  catch (e)
  {
    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;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
  {
     if(xmlHttp.readyState==4)
     {
	 		document.getElementById('koszyk_mini').innerHTML=xmlHttp.responseText;

     }
  }


	eraseCookie('DanadKoszyk['+id+']');
  	xmlHttp.open("GET","modules/Danad/ajax.php?action=getBasket",true);
    xmlHttp.send(null);


}
function get_big_kosz(id)
{
	try
  {
    xmlHttpB=new XMLHttpRequest();
  }
  catch (e)
  {
    try
    {
      xmlHttpB=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
      try
      {
        xmlHttpB=new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch (e)
      {
        alert("Your browser does not support AJAX!");
        return false;
      }
    }
  }
  xmlHttpB.onreadystatechange=function()
  {
     if(xmlHttpB.readyState==4)
     {
	 		document.getElementById('prawa').innerHTML=xmlHttpB.responseText;

     }
  }


	
  	xmlHttpB.open("GET","modules/Danad/ajax.php?action=getBasketBig",true);
    xmlHttpB.send(null);


}


function createCookie(name,value,days) {
	if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name) {
	createCookie(name,"",-1);
}


