/* external file loader */

var loadertext = "";

function alertContents() {
    if (oxmlhttp.readyState == 4) {
    if (oxmlhttp.status == 200) {
	document.all.content.innerHTML = oxmlhttp.responseText;
	initRollovers();
    }
    else
	document.all.content.innerHTML = "Error: "+oxmlhttp.status;
    }
};

function getFile(filename) {

    oxmlhttp = null; 
    
    try {
	oxmlhttp = new XMLHttpRequest();
	oxmlhttp.overrideMimeType("text/xml"); 
    }
    catch(e) { 
	try {
	    oxmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 
	} 
	catch(e) { return null; } 
    } 
    
    if(!oxmlhttp) return null; 

    try {
	oxmlhttp.open("GET",filename,false); 
	oxmlhttp.send(null); 
    } 
    catch(e) {return null; } 
    return oxmlhttp.responseText; 
} 

function ChangeToFile(filename) {
    oxmlhttp = null; 
    try {
	oxmlhttp = new XMLHttpRequest(); 
	oxmlhttp.overrideMimeType("text/xml"); 
    } 
    catch(e) {
	try {
	    oxmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 
	} 
	catch(e) { return null; } 
    } 
    
    if(!oxmlhttp) return null; 
    
    try {
	oxmlhttp.onreadystatechange = alertContents;
	oxmlhttp.open("GET",filename,true);
	oxmlhttp.send(null); 
    } 
    catch(e) { return null; } 
    return ""; 
} 

function makePOSTrequest(url, parameters) {
    oxmlhttp = null; 
    try {
	oxmlhttp = new XMLHttpRequest(); 
	oxmlhttp.overrideMimeType("text/html"); 
    } 
    catch(e) {
	try {
	    oxmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 
	} 
	catch(e) { return null; } 
    } 
    
    if(!oxmlhttp) return null; 
    
    try {
	oxmlhttp.onreadystatechange = alertContents;
	oxmlhttp.open("POST",url,true);
	oxmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	oxmlhttp.setRequestHeader("Content-length", parameters.length);
	oxmlhttp.setRequestHeader("Connection", "close");
	oxmlhttp.send(parameters); 
    } 
    catch(e) { return null; } 
    return ""; 
} 

function wstrzel(filename)
{

    document.all.content.innerHTML = loadertext;

    var ss = ChangeToFile(filename);
//    initRollovers();
//    alert();
}


function feature_check()
{
    ss = getFile("check.html");
//    alert(ss.length);
        
    if (!ss) { window.location.href = "main.php"; }
    else { window.location.href = "main.php?v=2"; }
}

function init_wstrzel()
{
  loadertext = getFile("main.php?v=1&artid=12");
//  alert(loadertext);
}

function postkontakt() {
    var poststr =
	"email=" + encodeURI( document.getElementById("email").value ) +
	"&temat=" + encodeURI( document.getElementById("temat").value ) +
	"&tresc=" + encodeURI( document.getElementById("tresc").value ) +
	"&v=1&act=submit";

   makePOSTrequest('kontakt.php', poststr);
}
	      
