var DOMtype = '';
if (document.getElementById) {
	DOMtype = "std";
} else if (document.all) {
	DOMtype = "ie4";
} else if (document.layers) {
	DOMtype = "ns4";
}
var objects = new Array();
function fetch_obj(idname, forcefetch) {
    if (forcefetch || typeof(objects[idname]) == "undefined") {
	switch ( DOMtype ) {
            case "std":
	        objects[idname] = document.getElementById(idname);
		break;
	    case "ie4":
		objects[idname] = document.all[idname];
		break;
	    case "ns4":
		objects[idname] = document.layers[idname];
		break;
	}
    }
	return objects[idname];
}

function goTo ( url ) {
    location = url;
}
function get_content(div_name, get_file){
  someDiv = fetch_obj(div_name);
  advAJAX.get({
    url: get_file,
    onInitialization : function() {
        /* Ukrycie warstwy */
        someDiv.innerHTML = "Trwa wczytywanie symulacji ...";
    },
    onSuccess : function(obj) {
        /* Ustawienie nowej, pobranej z serwera wartoµci */
        someDiv.innerHTML = obj.responseText;
    },
    onError : function(obj) {
        /* W przypadku wyst‘pienia błędu wyµwietlenie komunikatu */
        alert("Error: " + obj.status);
    },
    onFinalization : function() {
        /* Ponowne pokazanie warstwy po zakończeniu wszystkich operacji */
    }
  });
}
//---------------------------------------
function set_cookie(name, value, expires) {
	if (!expires) 	{
		expires = new Date();
	}
	document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString() +  "; path=/";
}
function fetch_cookie(name) {
	cookie_name = name + "=";
	cookie_length = document.cookie.length;
	cookie_begin = 0;
	while (cookie_begin < cookie_length) {
		value_begin = cookie_begin + cookie_name.length;
		if (document.cookie.substring(cookie_begin, value_begin) == cookie_name) {
			var value_end = document.cookie.indexOf (";", value_begin);
			if (value_end == -1) {
				value_end = cookie_length;
			}
			return unescape(document.cookie.substring(value_begin, value_end));
		}
		cookie_begin = document.cookie.indexOf(" ", cookie_begin) + 1;
		if (cookie_begin == 0) {
			break;
		}
	}
	return null;
}
function delete_cookie(name) {
	var expireNow = new Date();
	document.cookie = name + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT" +  "; path=/";
}
function displayWindow(url, width, height) {
     var Win = window.open(url,"displayWindow",'width=' + width
         + ',height=' + height + ',resizable=0,scrollbars=yes,menubar=no' );
}
function Refresh(_url,i){
    if (i == 0) {
        location = _url;
        return 0;
    }
    i--;
    j = i;
    address = _url;
    setTimeout("Refresh(address,j)",1000);
}
