function addEvent(o,e,f){
	if (o.addEventListener){ o.addEventListener(e,f,true); return true; }
	else if (o.attachEvent){ return o.attachEvent("on"+e,f); }
	else { return false; }
}

/*==================================================
  Cookie functions
  ==================================================*/
function setCookie(name, value, expires, path, domain, secure) {
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}
function deleteCookie(name, path, domain) {
    if (getCookie(name)) {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

var timer = null;
var IMG = null;
var NewWindow = null;
function ViewImage(Isrc,title) {
	IMG = new Image;
	IMG.src = Isrc;
	if (typeof(title)=="undefined" || title=="") title="Gallery";
	if (NewWindow) { NewWindow.close(); }
	if (NewWindow==null || NewWindow.closed) {
		settings=
		 "left="+50+","
		 +"top="+50+","
		 +"width="+640+","
		 +"height="+480+","
		 +"toolbar=no,"
		 +"location=no,"
		 +"directories=no,"
		 +"status=no,"
		 +"menubar=no,"
		 +"scrollbars=no,"
		 +"resizable=yes"
		 NewWindow = window.open("",'Gallery',settings);
	}
	NewWindow.document.open();
	//NewWindow.document.clear();
	NewWindow.document.write(
         "<html><head><title>"+ title +"</title>"
        +"</head>\n"
        +"<body onclick=\"window.close();\" style=\"text-align:left;margin:15px;\">\n"
        +"<img src=\"" + IMG.src + "\" border=\"0\" alt=\""+title+"\" />\n"
        +"</body>\n"
        +"</html>"
	);
	NewWindow.document.close();
	NewWindow.focus();
	timer = setInterval("resize()",250);
}

function resize() {
    if(!IMG.complete){ return; }
    clearInterval(timer);
	resizeWindowTo(NewWindow,(IMG.width+40),(IMG.height+100));
	IMG = null;
}

function resizeWindowTo(WindowObject,w,h) {
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
			WindowObject.outerWidth=w;
			WindowObject.outerHeight=h;
		}
		else WindowObject.resizeTo(w,h);
	}
}

function CreateMainMenu()
{
    var m = document.getElementById('mainmenu')
    if (m)
    {
        var lis = m.getElementsByTagName('LI');
        // var sipka_span = null;
        for (var i = 0 ; i < lis.length ; i++)
        {
            // sipka_span = document.createElement('SPAN');
            // sipka_span.className = 'sipka';
            // lis[i].insertBefore(sipka_span,lis[i].firstChild);
            lis[i].onmouseover = function() {
                this.className += ' hover';
            };
            lis[i].onmouseout = function() {
                this.className = this.className.replace(' hover','');
                this.className = this.className.replace('hover','');
            };
        }
    }
}
// addEvent(window,'load',CreateMainMenu);

function ProceedViewImagers()
{
    var im = document.getElementsByTagName('a');
    if (im)
    {
        for (var i = 0 ; i < im.length ; i++)
        {
            if (im[i].className == 'viewImage')
            {
                im[i].onclick = function() {
                    ViewImage(this.href,'');
                    return false;
                };
            }
        }
    }
}
addEvent(window,'load',ProceedViewImagers);