function handleError() { return true; }
window.onerror = handleError;

var xmlHttp;

function ajax_update(page, id) {
xmlHttp = GetXmlHttpObject();
if ((page == "") || (id == "")) { alert("Error: neshto greshno - ajax_update();"); return; }
else if (xmlHttp == null) { return; }
else {
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4) {
document.getElementById(id).innerHTML = xmlHttp.responseText;
}
}
xmlHttp.open("GET", page, true);
xmlHttp.send(null);
}
}

function ajax_update_timer(page, id, timer) {
xmlHttp = GetXmlHttpObject();
if ((page == "") || (id == "") || (timer == "") || (timer == 0)) { alert("Error: neshto greshno - ajax_update_timer();"); return; }
else if (xmlHttp == null) { return; }
else {
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4) {
document.getElementById(id).innerHTML = xmlHttp.responseText;
}
}
xmlHttp.open("GET", page, true);
xmlHttp.send(null);
setTimeout('ajax_update_timer("' + page + '", "' + id + '", ' + timer + ');', timer);
}
}

function GetXmlHttpObject() {
if (window.ActiveXObject) { return new ActiveXObject("Microsoft.XMLHTTP"); }
else if (window.XMLHttpRequest) { return new XMLHttpRequest(); }
else { return false; }
}

var status = 0;

function up() {
if (status < 0) {
status = status + 50;
}
if (status < 0 || status == 0) {
document.getElementById("target").style.marginTop = status + "px";
}
}

function down() {
status = status - 50;
document.getElementById("target").style.marginTop = status + "px";
document.getElementById("info").innerHTML = status + " - " + pictures_height;
}

function show_pic(id, cat_id) {
document.getElementById("pic").innerHTML = "<img src='img/ajax-loader.gif' />";
document.getElementById("pic_page").innerHTML = "<img src='img/ajax-loader.gif' />";
document.getElementById("pic_info").innerHTML = "<img src='img/ajax-loader.gif' />";
setTimeout('ajax_update("showpic.php?cat_id=' + cat_id + '&pic_id=' + id + '", "pic");', 1000);
setTimeout('ajax_update("showpic.php?cat_id=' + cat_id + '&pic_page=' + id + '", "pic_page");', 1500);
setTimeout('ajax_update("showpic.php?cat_id=' + cat_id + '&pic_info=' + id + '", "pic_info");', 2000);
}

function star_on(which, count) {

var vote = new Array();
vote[1] = "Много зле!";
vote[2] = "Зле!";
vote[3] = "Средно!";
vote[4] = "Добре!";
vote[5] = "Много добре!";

for (var i = 1; i <= count; i++) {
document.getElementById("star" + i).src = "img/star_on.png";
document.getElementById("return2").innerHTML = " - " + vote[i];
}

}

function star_off(which, count) {
for (var i = 1; i <= count; i++) {
document.getElementById("star" + i).src = "img/star_off.png";
document.getElementById("return2").innerHTML = "";
}
}

function comments_show(id) {
window.open("comments.php?pic_id=" + id, "comments", "status = 1, width = 550, height = 450");
}
function codes_show(id) {
window.open("codes.php?pic_id=" + id, "codes", "status = 1, width = 550, height = 450");
}
