/*********************************************
* Biblioteka AXVajax zostaa zbudowana i zmodyfikowana w oparciu o biblioteki AJAX
* znajdujace sie na stronie www.dynamicdrive.com   
* Moesz uywac tej biblioteki w legany sposb pod warunkiem pozostawienia 
* informacji o zrdle pochodzenia. 
* Wiecej na temat funkcji tej biblioteki wkrotce na blogu (blog.axv.pl)
***********************************************
* Dynamic Ajax Content-  Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
/*var loadstatustext="<img src='image/loading.gif'/>"*/
var loadstatustext=""
var loadstatustext2="moment..."
var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var bustcachevar=1 
var defaultcontentarray=new Object()
var bustcacheparameter=""

function ajax(){
var page_request = false
if (window.XMLHttpRequest) 
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ 
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP"); 
} 
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP"); 
}
catch (e){}
}
}
else
return false;
return page_request;
}
function gourl(t) {
if (t.selectedIndex!=0) window.location = t[t.selectedIndex].value;
}

function ap(url, containerid){
var page_request = ajax();
document.getElementById(containerid).innerHTML=loadstatustext
page_request.onreadystatechange=function(){ loadpage(page_request, containerid) }
page_request.open('GET', url, true)
page_request.send(null)
}

function apnl(url, containerid){
var page_request = ajax();
page_request.onreadystatechange=function(){ loadpage(page_request, containerid) }
page_request.open('GET', url, true)
page_request.send(null)
}

function add(url, containerid){
var page_request = ajax();
document.getElementById(containerid).innerHTML=loadstatustext2
page_request.onreadystatechange=function(){ loadpage(page_request, containerid) }
page_request.open('GET', url, true)
page_request.send(null)
}

function del(url, containerid){
var page_request = ajax();
if(confirm("potwierd operacj"))
{
ap('plugins/hidden.php','rss');
document.getElementById(containerid).innerHTML=loadstatustext
page_request.onreadystatechange=function(){ loadpage(page_request, containerid) }
page_request.open('GET', url, true)
page_request.send(null)
}
}

function session()
{
window.setInterval("apnl('include/area_copyright.php','copyright')", 500000);
}

function refresh(containerid)
{
window.setTimeout("apnl('include/area_login.php','login')", 2000);
window.setTimeout("apnl('include/area_copyright.php','copyright')", 2000);
}

function delSchowek(url, containerid){
var page_request = ajax();
if(confirm("potwierd operacj"))
{
document.getElementById(containerid).innerHTML=loadstatustext
page_request.onreadystatechange=function(){ loadpage(page_request, containerid) }
page_request.open('GET', url, true)
page_request.send(null)
}
}

function makeRequest(url,resultFunction,containerid) {
var page_request = ajax();
document.getElementById(containerid).innerHTML=loadstatustext
if (page_request === false) 
return false; 
page_request.open('GET',url, true); 
page_request.onreadystatechange = function(){ loadpage(page_request,containerid)};
page_request.send(null);
}

function ajaxLogin(file,containerid) {
if (makeRequest(file+'?u=' + encodeURIComponent(document.getElementById('u').value) + '&p=' + encodeURIComponent(document.getElementById('p').value) + '&a=' + encodeURIComponent(document.getElementById('a').value) + '&b=' + encodeURIComponent(document.getElementById('b').value), function(text) { 
if(text != 1) {
alert('niepoprawne dane');
return;
}
document.location = 'http://axv.pl/ustawienia';},containerid) === false)
return true;
return false;
}

function getForm(file,containerid) {
if (makeRequest(file+'?u=' + encodeURIComponent(document.getElementById('u').value) + '&p=' + encodeURIComponent(document.getElementById('p').value) + '&a=' + encodeURIComponent(document.getElementById('a').value) + '&b=' + encodeURIComponent(document.getElementById('b').value), function(text) 
{ document.getElementById(containerid).innerHTML=text },containerid) === false)
return true;
return false;
}

function addLink(file,containerid) {
if (makeRequest(file+'?u=' + encodeURIComponent(document.getElementById('u').value) + '&p=' + encodeURIComponent(document.getElementById('p').value) + '&a=' + encodeURIComponent(document.getElementById('a').value) + '&b=' + encodeURIComponent(document.getElementById('b').value)  + '&d=' + encodeURIComponent(document.getElementById('d').value), function(text) 
{ document.getElementById(containerid).innerHTML=text },containerid) === false)
return true;
return false;
}

function getOpml(file,containerid) {
if (makeRequest(file+'?opml=' + encodeURIComponent(document.getElementById('opml').value), function(text) 
{ document.getElementById(containerid).innerHTML=text },containerid) === false)
return true;
return false;
}

function search(url,containerid) {
var page_request = ajax();
if (page_request === false) return false; 
document.getElementById(containerid).innerHTML=loadstatustext
if (makeRequest(url + '?s=' + encodeURIComponent(document.getElementById('s').value) +'&time=' + new Date().getTime(), function(text) 
	{ document.getElementById(containerid).innerHTML=text },containerid	))
	return true;
	return false;
}

function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request.responseText} 

function loadobjs(){
if (!document.getElementById)
return
var time = new Date().getTime()
for (i=0; i<arguments.length; i++){
var file=arguments[i]
var fileref=""

if (file.indexOf(".js")!=-1){ 
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ 
fileref=document.createElement("link");
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}

if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" "
}
}
}

function menuajax(url, containerid, targetobj){
var page_request = ajax();
var ullist=targetobj.parentNode.parentNode.getElementsByTagName("li")
for (var i=0; i<ullist.length; i++)
ullist[i].className="" 
targetobj.parentNode.className="selected" 
if (url.indexOf("#default")!=-1){ 
document.getElementById(containerid).innerHTML=defaultcontentarray[containerid]
return
}
document.getElementById(containerid).innerHTML=loadstatustext
page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
if (bustcachevar) 
bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
page_request.open('GET', url+bustcacheparameter, true)
page_request.send(null)
}

function savedefaultcontent(contentid){
if (typeof defaultcontentarray[contentid]=="undefined") 
defaultcontentarray[contentid]=document.getElementById(contentid).innerHTML
}

function startajaxtabs(){
for (var i=0; i<arguments.length; i++){ 
var ulobj=document.getElementById(arguments[i])
var ulist=ulobj.getElementsByTagName("li") 
for (var x=0; x<ulist.length; x++){
var ulistlink=ulist[x].getElementsByTagName("a")[0]
if (ulistlink.getAttribute("rel")){
var modifiedurl=ulistlink.getAttribute("href").replace(/^http:\/\/[^\/]+\//i, "http://"+window.location.hostname+"/")
ulistlink.setAttribute("href", modifiedurl) 
savedefaultcontent(ulistlink.getAttribute("rel")) 
ulistlink.onclick=function(){
menuajax(this.getAttribute("href"), this.getAttribute("rel"), this)
return false
}
if (ulist[x].className=="selected"){
menuajax(ulistlink.getAttribute("href"), ulistlink.getAttribute("rel"), ulistlink) 
}
}
}
}
}

function displayWindow(url, width, height) 
{ 
var Win = window.open(url,"displayWindow",'width=' + width + ',height=' + height + ',resizable=1,scrollbars=no,menubar=no,left=0,top=0' );
}

function openClose(id)
{
   if(document.getElementById) {
	  element = document.getElementById(id);
   } else if(document.all) {
	  element = document.all[id];
   } else return;

   if(element.style) {
      if(element.style.display == 'block' ){
         element.style.display = 'none';
      } else {
         
         element.style.display = 'block';
      }
   }
}

function openClose2(id)
{
   if(document.getElementById) {
	  e1 = document.getElementById('box2'+id);
	  e2 = document.getElementById('b'+id);
   } else if(document.all) {
	  e1 = document.all['box2'+id];
	  e2 = document.all['b'+id];
   } else return;
   
	if(e1.style) {
      if(e1.style.display == 'block')
      {
      close(e1,e2)
	  }
	  else 
	  {
	  open(e1,e2)
	  zwin(id)
	  }
	  }
 
   function zwin(id) {
     
   for(i=0; i<100; i++)
		{
		if (id != i) 
		{ 
		var foo = document.getElementById('box2'+i) 
		if (!foo) break;
		c1 = document.getElementById('box2'+i);
		c2 = document.getElementById('b'+i);
		c1.style.display = 'none';
		c2.className='box1';
		} 
		}
   }
   
   function open(n1,n2) {
   n1.style.display='block';
   n2.className='box1-hover';
   }
   
   function close(n1,n2) {
   n1.style.display = 'none';
   n2.className='box1';
   }
}
function trim(x){return x.replace(/^\s*|\s*$/g,'')}
function insert(tag){
	
	tagi = encodeURIComponent(document.getElementById('p').value);
    insert_str = tagi+" "+encodeURIComponent(tag);
    var str = tagi.search(encodeURIComponent(tag));
    if(str==-1){ document.forms.add.p.value=trim(document.forms.add.p.value+" "+tag);}
	}
