var win = null;
//show dialog
function showDialog(id) {
	var el = document.getElementById(id);
		
	if(typeof(el)=='object') {
		if (el.style.display == "none") {
			el.style.display = "block";
			//el2.style.display = "block";
		}
		else {
			el.style.display = "none";
			//el2.style.display = "none";
		}
	}
}
//show Monthly index
function showIndex(file) {
    //var el = document.getElementById('MonthIndexFrame');
    //alert(window.frames["MonthIndexFrame"].location);
    window.frames["MonthIndexFrame"].location = file;
//    if (win != null) {
//        win = window.open(file, 'Win', 'resizable=yes,scrollbars=no,width=' + xwidth + ',height=' + yheight + ',status=no,location=no,toolbar=no');
//        win.focus();
//    }
//    else
//        win = window.open(file, 'Win', 'resizable=yes,scrollbars=no,width=' + xwidth + ',height=' + yheight + ',status=no,location=no,toolbar=no');
}

//Displays random pic on firstpage
function getRandomIndex() {
    var p = collImages.length;
    var showindex = Math.round(Math.random() * (p - 1));
    var el = document.getElementById('coverPic');

    if (el != null && typeof (el) == "object")
        el.src = "first/" + collImages[showindex];
}
// Read Cookie
function readCookie(Name) {
    var cookies = " " + document.cookie;
    if (cookies.indexOf(" " + Name + "=") == -1) return null;
    var start = cookies.indexOf(" " + Name + '=') + (Name.length + 2);
    var finish = cookies.substring(start,cookies.length);
    finish = (finish.indexOf(";") == -1) ? cookies.length : start + finish.indexOf(";");
    return unescape(cookies.substring(start,finish));
}
// Set Cookie
function setCookie(name, value, expires, path, domain, secure) { 

    if (expires != null && !isNaN(expires)) {
        var datenow = new Date();
        datenow.setTime(datenow.getTime() + Math.round(86400000*expires));
        expires = datenow.toGMTString();
    }
    var curCookie = name + "=" + escape(value) + 
        ((expires) ? "; expires=" + expires : "") + 
        ((path) ? "; path=" + path : "") + 
        ((domain) ? "; domain=" + domain : "") + 
        ((secure) ? "; secure" : ""); 
    document.cookie = curCookie; 
    //alert( name + " store cookie val:" + value);
} 
// Delete Cookie
function deleteCookie(Name) {
    var datenow = new Date();
    datenow.setTime(datenow.getTime() - Math.round(86400000));
    expires = datenow.toGMTString();
    document.cookie = Name + "=; expires=" + expires;
}

