var ns6=document.getElementById&&!document.all;
var ie4=document.all;
var ns4=document.layers;
var opp=false;
if (document.all){ if (navigator.userAgent.search('Opera')>=0){ ie4=false; opp=true;} else {ie4=true; opp=false;}}

function pomoc(id,txt)
{

}

function newWindow(url, width, height,windname) {
        var Win = window.open(url,windname,'width=' + width + ',height=' + height + ',resizable=0,scrollbars=yes,menubar=no' )
}
function newWindowNR(url, width, height,windname) {
        var Win = window.open(url,windname,'width=' + width + ',height=' + height + ',resizable=0,noresize,scrollbars=yes,menubar=no' )
}

function change_sort(buttonID)
{
	var subsectionID = buttonID.split("_");
	subsectionID = subsectionID[1];
	
	var currentSort = document.getElementById(buttonID).value;
	
	var newSort;
	
	if (currentSort=="ASC") {newSort="DESC";} else {newSort="ASC";}
	
	var read_result;
    var oXmlHttp = zXmlHttp.createRequest();
	var oParser = new DOMParser();
    var oXmlDom = document.implementation.createDocument("", "", null);
     
    oXmlHttp.open("get", "i_web_subsec_op.php?operation=change_sort&lev2="+subsectionID+"&lev3="+currentSort, true);

    oXmlHttp.onreadystatechange = function () 
    {
    	if (oXmlHttp.readyState == 4) 
	    {
	    	if (oXmlHttp.status == 200)
	    	{
	    			document.getElementById(buttonID).value = newSort;
			}
			else
			{
				alert("An error occurred: " + oXmlHttp.statusText);
			}
	    }            
    };
    oXmlHttp.send(null);
    return true;
}

function change_number_of_elements(selectID)
{
	var subsectionID = selectID.split("_");
	subsectionID = subsectionID[1];
}
/*
function go(link)
{
var url=link; 
if(ns6) {  parent.ramkaIE.document.location=url;}
  if(ns4) {  document.layers["BlokNN"].src = plik; }
 if(ie4) {  frames['ramkaIE'].document.location=url;} 
 if(opp) {  parent.ramkaIE.document.location=url;}

	

//window.document.open(link);
}*/


function go_form(gg,url)
{
phrase=gg.phrase.value;
limit=gg.limit.value;
Xurl=url + '&phrase='+phrase+'&limit='+limit+'';
go(Xurl);


}

 function curr_time()
{
 var time_now=new Date();
 var hours=time_now.getHours();
 var mins=time_now.getMinutes();
 var secs=time_now.getSeconds();
/*
11 if (hours>=12)
12 ampm="P.M.";
13 else
14 ampm="A.M.";
15
16 if (hours>=13) hours-=12;
17 if (hours==0) hours=12;
18 if (secs<10) secs="0"+secs;
19 if (mins<10) mins="0"+mins;
20*/
 przepisz_time(hours+": "+mins+": "+secs);
 setTimeout('curr_time()',1000);
 return true;
}
function toolbox(id,id_page,id_field)
  {
  var xmlHttp;
  var xmlHttp2;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    xmlHttp2=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      xmlHttp2=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        xmlHttp2=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
      {
	        document.getElementById('toolbox').innerHTML=xmlHttp.responseText;
      }
      }
	 xmlHttp2.onreadystatechange=function()
      {
      if(xmlHttp2.readyState==4)
      {
	        document.getElementById('mini').innerHTML=xmlHttp2.responseText;
      }
      }
	xmlHttp2.open("GET","toolbox.php?id_page="+ id_page +"&id_field=" + id_field + "",true);
    xmlHttp2.send(null);
	xmlHttp.open("GET","toolbox.php?id_obj="+ id +"&ID=" + id_page +  "&id_field=" + id_field + "",true);
    xmlHttp.send(null);
  }
function show_stuff_foto(id,id_cat,set_ok)
  {
  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;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
      {
	        document.getElementById('add_category'+id+'').innerHTML=xmlHttp.responseText;
	//	if(!set_ok)	show_cat(id);
      }
      }

	xmlHttp.open("GET","damis_storage_stuff_foto.php?id="+ id +"&id_cat="+id_cat+"&set_ok="+set_ok+"",true);
    xmlHttp.send(null);
  }
function state_bar(link)
  {
  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;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
      {
			if(xmlHttp.responseText)
	        document.getElementById('state_bar').innerHTML=xmlHttp.responseText;
      }
      }
      
	xmlHttp.open("GET","toolbox.php?state_bar=1&file="+ link + "",true);
    xmlHttp.send(null);
  }
function set_focus(id)
{
	document.getElementById(id).focus();
}
function show_cat(id)
		{

var ggg="add_category"+id+"";
var val;
//alert(id + " " + ile + " " +obj + " " + MENU[id]);
  if(ns6) { val=document.getElementById(ggg).style.display }
  if(ie4 || opp) { val=document.all[ggg].style.display } 
  if(ns4) { val=document.layers[ggg].visibility }

if(val=="none" || val=="hidden") { roll_down(ggg);  }
else {roll_up(ggg);  }


		}
function show_cat_edit(id,id_cat)
		{

var ggg="edit_category"+id+"";
var val;
//alert(id + " " + ile + " " +obj + " " + MENU[id]);
  if(ns6) { val=document.getElementById(ggg).style.display }
  if(ie4 || opp) { val=document.all[ggg].style.display } 
  if(ns4) { val=document.layers[ggg].visibility }

if(val=="none" || val=="hidden") { roll_down(ggg);  

//show_stuff_foto(id,id_cat,0);

}

else {roll_up(ggg);  }


		}



function show_op(id)
		{

var ggg="add_option"+id+"";
var val;
//alert(id + " " + ile + " " +obj + " " + MENU[id]);
  if(ns6) { val=document.getElementById(ggg).style.display }
  if(ie4 || opp) { val=document.all[ggg].style.display } 
  if(ns4) { val=document.layers[ggg].visibility }

if(val=="none" || val=="hidden") { roll_down(ggg);  }
else {roll_up(ggg);  }


		}
function edit_div(ggg)
		{

var val;
//alert(id + " " + ile + " " +obj + " " + MENU[id]);
  if(ns6) { val=document.getElementById(ggg).style.display }
  if(ie4 || opp) { val=document.all[ggg].style.display } 
  if(ns4) { val=document.layers[ggg].visibility }

if(val=="none" || val=="hidden") { roll_down(ggg);  }
else {roll_up(ggg);  }


		}


