﻿/* Kontrola správnosti článku v blogu. */
function checkArticle(nameId, publishId) {

	var name = document.getElementById(nameId).value;
	var publish = document.getElementById(publishId).value;
	
	var pubRegex = "[0-9]{1,2}\.[0-1]?[0-9]{1}\.20[0-9]{2}";
	
	if (name.length < 3 || !publish.match(/[0-9]{1,2}\.[0-1]?[0-9]{1}\.20[0-9]{2}/)) {
	
		window.alert("Název musí mít alespoň 3 znaky a datum publikování tvaru den.měsíc.rok (např. 1.1.2007)");
		return false;
	}
	else
		return true;
}

function onArticleContentPasted(editor, commandName, oTool)
{
    if (commandName == "Paste") {

        editor.Fire("PastePlainText");
        return false;
    }
}

function openArticleImagePreview(url) {

	return window.open(url, 'articleimagedetail', 'toolbar=no,menubar=no,resizable=no,scrollbars=no,directories=no,titlebar=no,location=no,left=100,top=100');
}

function openPhotoDetailWindow(url) {
	
	return window.open(url, 'photodetail', 'toolbar=no,menubar=no,resizable=no,scrollbars=no,directories=no,titlebar=no,location=no,left=100,top=100');
}

function checkSearchInput(boxid) {
	var box = document.getElementById(boxid);
	if (box.value.length < 3) {
		window.alert("Musíte zadat alespoň 3 znaky.");
		return false;
	}
	else
		return true;
}

function resizePhotoDetailWindow(w, h) {
	
	//	změna velikosti.
	window.resizeTo(w, h);
	
	//	posunutí, aby byla stránka na střed.
	window.moveTo((screen.width - w)/2, (screen.height - h)/2);
}

function checkboxChecked(id) {

	var chk = document.getElementById(id);
	chk.checked = !chk.checked;
}

function setRememberHelpVisibility() {
	var divId = "rememberHelp";
	var help = document.getElementById(divId);
	if (help.style.display=='none')
		help.style.display = 'block';
	else
		help.style.display = 'none';
}

function checkLoginValues(loginid, passid) {

	var login = document.getElementById(loginid).value;
	var pass = document.getElementById(passid).value;
	if (login.length == 0 || pass.length == 0) {
		window.alert("Nezadali jste jméno nebo heslo.");
		return false;
	}
	else
		return true;
}

function getContainerHeight() {
	var inp = document.getElementsByName("containerHeight")[0];
	var container = document.getElementById("container");
	inp.value = container.offsetHeight;
}

function articleRemoveConfirm(name, id, beginningMark) {

	if (window.confirm("Jste si jisti, že chcete odstranit tento článek?\n\""+ name +"\"")) {
		location.href = absolutePath + beginningMark + "RemoveArticle=" + id + (pageIndex != null ? "&Page=" + pageIndex : "");
	}
	else
		return false;
}

function photoRemoveConfirm(id, beginningMark) {

	if (window.confirm("Jste si jisti, že chcete odstranit tuto fotku?")) {
		location.href = absolutePath + beginningMark + "RemovePhoto=" + id + (pageIndex != null ? "&Page=" + pageIndex : "");
	}
	else
		return false;
}

function blog_CommentRemoveConfirm(subj, id) {

	if (window.confirm("Chcete odstranit tento komentář?\n\"" + subj + "\"")) {
		location.href = absolutePath + "?CommentsPage=" + pageIndex + "&RemoveComment=" + id + "#comments";
	}
	else
		return false;
}

function gallery_runMonitors() {

	//	google.
	//urchinTracker();
	if (pageTracker != null)
	{
		pageTracker._initData();
		pageTracker._trackPageview();
	}

	//	netmonitor.
	pp_gemius_identifier		= new String('Bx1FZiMp2XeDrQZmzFwAAIXzHXKdVWMgrDocDB_Zom7.o7');
	gemius_href			= new String(document.location);

	if (document.referrer) {
		gemius_ref = new String(document.referrer);
	} else {
		gemius_ref = "";
	}

	if (typeof(Error)!='undefined')
		eval("try { if (typeof(top.document.referrer)=='string') { gemius_ref = top.document.referrer } } catch(gemius_ex) {}");

	iname				= new String('id='+pp_gemius_identifier+';ref='+escape(gemius_ref.substring(0,299))+';href='+escape(gemius_href.substring(0,299))+';');

	var		newFrame	= document.createElement("iframe");
	newFrame.src			= "http://spir.hit.gemius.pl/gemiusaudience.html";
	newFrame.name			= iname;
	newFrame.width			= "1";
	newFrame.height			= "1";
	newFrame.frameborder 		= "0";
	newFrame.scrolling		= "no";
	document.body.appendChild(newFrame);
}