var cookieNamebookmark = "dg3pc_bookmark";
var cookieNamebookmarkRead = "dg3pc_bookmark_read";

function bookmarkAddItem(id) {
	cookieAddId(cookieNamebookmark, id);
	//if (bookmarkWindow != null && bookmarkWindow.closed == false)
		//bookmarkWindow.location.reload("/bookmark/index.asp");*/
	//if (bookmarkWindow != null)
	bookmarkShow();
}

function bookmarkDeleteItem(id) {
	cookieDeleteId(cookieNamebookmarkRead, id);
	cookieDeleteId(cookieNamebookmark, id);
}

function bookmarkShow() {
	if (bookmarkWindow != null && bookmarkWindow.closed == false) bookmarkWindow.close();
	bookmarkWindow = window.open("/bookmark/index.asp", "bookmark", "scrollbars=1,toolbar=0,menubar=0,location=0,status=0,resizable=1,width=554,height=400,print=yes,left=180,top=130");
	bookmarkWindow.focus();
}


var bookmarkWindow = null;

function bookmarkClearAll() {
	//WM_killCookie(cookieNamebookmarkRead, cookiePath);
	//WM_killCookie(cookieNamebookmark, cookiePath);
	WM_setCookie(cookieNamebookmarkRead, '', cookieLifeTimeHours, cookiePath);
	WM_setCookie(cookieNamebookmark, '', cookieLifeTimeHours, cookiePath);
}

function bookmarkClearRead() {
	var current = WM_readCookie(cookieNamebookmarkRead);
	if (current) {
		var currentValues = current.split('|');
		for(var i=0; i < currentValues.length; i++) {
			bookmarkDeleteItem(currentValues[i]);
		}
	}
}

function bookmarkMarkItemRead(id) {
	return cookieAddId(cookieNamebookmarkRead, id);
}

function bookmarkGetSelected(formName, checkboxPrefix) {
	var current = WM_readCookie(cookieNamebookmark);
	var result = new Array();
	if (current) {
		var currentValues = current.split('|');
		/*for(var i=0; i < currentValues.length; i++) {
			if (eval("document." + formName + "." + checkboxPrefix + currentValues[i] + ".checked")) {
				result[result.length] = currentValues[i];
			}
		}*/
		for (var i=0; i < currentValues.length; i++) {
			if (document.bookmarkAktion.length > 1) {
				if (document.bookmarkAktion.Mark[i].checked)
					result[result.length] = currentValues[i];
			} else {
				if (document.bookmarkAktion.Mark.checked)
					result[result.length] = currentValues[i];
			}
		}
	}
	return result;
}

function bookmarkClearSelected(formName, checkboxPrefix) {
	var selected = bookmarkGetSelected(formName, checkboxPrefix);
	for (var i=0; i < selected.length; i++) {
		bookmarkDeleteItem(selected[i]);
	}
}

function bookmarkPrintSelected(formName, checkboxPrefix) {
	var selected = bookmarkGetSelected(formName, checkboxPrefix);
	bookmarkOpenPrintWindow(selected);
}

function bookmarkPrintAll() {
	var all = WM_readCookie(cookieNamebookmark);
	if (all != '') {
		bookmarkOpenPrintWindow(all.split('|'));
	} else {
		return new Array();
	}
}

function bookmarkOpenPrintWindow(storyList) {
	if (storyList.length > 0) {
		var url = '/bookmark/print/1,1553,PID#replace#,00.html';
		url = url.replace(/#replace#/, storyList.join('-'));
		//alert(url);
		window.open(url, 'printStory');
	} else {
		
	}
}
