function parseScript(strcode) {
  var scripts = new Array();         // Array which will store the script's code
  
  // Strip out tags
  while(strcode.indexOf("<script") > -1 || strcode.indexOf("</script") > -1) {
    var s = strcode.indexOf("<script");
    var s_e = strcode.indexOf(">", s);
    var e = strcode.indexOf("</script", s);
    var e_e = strcode.indexOf(">", e);
    
    // Add to scripts array
    scripts.push(strcode.substring(s_e+1, e));
    // Strip from strcode
    strcode = strcode.substring(0, s) + strcode.substring(e_e+1);
  }
  
  // Loop through every script collected and eval it
  for(var i=0; i<scripts.length; i++) {
    try {
      eval(scripts[i]);
    }
    catch(ex) {
      // do what you want here when a script fails
    }
  }
}

function setAndExecute(div) {    
   var x = div.getElementsByTagName("script");   
   for( var i=0; i < x.length; i++) {  
     eval(x[i].text);  
   }  
}


function AjaxLoadReklams(co, gdzie) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari		
	
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', co, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {			
            var div =  document.getElementById(gdzie)
            div.innerHTML = self.xmlHttpReq.responseText;
            
        //    setAndExecute(div);          				
        }
    }
    //self.xmlHttpReq.send(getquerystring());
	self.xmlHttpReq.send();
}


function AjaxLoad(co, gdzie,scr) {
	scr = typeof(scr) != 'undefined' ? scr : 0;

    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
	var scroll_y;
	if (scr==-1)
	{
		scroll_y = 0;
		co+="&scroll_y="+window.pageYOffset;
	}
	else scroll_y = scr;
		
	
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', co, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {			
             var div = document.getElementById(gdzie);
             div.innerHTML = self.xmlHttpReq.responseText;		
			 //AjaxLoadReklams("/inc/reklama/reklam_load_top.php", "reklama_top");
			 AjaxLoadReklams("/inc/reklama/reklam_load_right.php", "reklama");
			 //AjaxLoadReklams("/inc/reklama/reklam_load_top.php", "reklama");
			 //AjaxLoadReklams("/inc/reklama/reklam_load_bottom.php", "reklama_bottom");
			 scroll(0,scroll_y);
			// parseScript(self.xmlHttpReq.responseText);
			// setAndExecute(div);
        }
    }
    //self.xmlHttpReq.send(getquerystring());
	self.xmlHttpReq.send();
}



function AjaxLoadImg(co, gdzie) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
	
	
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', co, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {			
             document.getElementById(gdzie).innerHTML = self.xmlHttpReq.responseText;		
			// scroll(0,0);
        }
    }
    //self.xmlHttpReq.send(getquerystring());
	self.xmlHttpReq.send();
}

