﻿//	AJAX connectfunction starthttpRequest(){	if (window.ActiveXObject){		httpRequest = new ActiveXObject("Microsoft.XMLHTTP");		}else{		httpRequest = new XMLHttpRequest();	}}// zpožděné zobrazení SUBMENUfunction submenu(){	$('#sub_menubox').slideDown(800);}// ukládám cookie pro zobrazení a skrytífunction SetCookie(nazev, hodnota, doba){	// var doba = 365;	var datum= new Date(); // získá aktuální datum v milisekundách	datum.setTime(datum.getTime() + 1000 * 60 * 60 * 24 * doba); // k datu přidá počet dnů		// samotný zápis cookie//	document.cookie="meno=hodnota;path=/"; 	document.cookie = nazev +"="+ hodnota +"; path=/;expires=" + datum.toGMTString();	}// aktuální čas do záhlavífunction naplnCas(){var datum = new Date();var mesicek = datum.getMonth() +1; // protože leden = 0aktualniCas = datum.getHours() + ":" + datum.getMinutes() + ":" + datum.getSeconds();// aktualniCas = datum.getFullYear()+"-"+ mesicek + "-"+datum.getDate()+" "+datum.getHours() + ":" + datum.getMinutes() + ":" + datum.getSeconds();window.document.getElementById("cas").innerHTML = aktualniCas;}// funkce pro zavírání/etevírání left_menufunction rozbal(ind){	var m = document.getElementById("m" + ind);	var s = document.getElementById("sub" + ind);	if (s.style.display == "none"){		$("#sub" + ind).fadeIn(200); 		SetCookie("sub"+ind, "block", 365)		}else{		$("#sub" + ind).fadeOut(200); 		SetCookie("sub"+ind, "none", 365)		}}// funkce pro zavírání/otevírání aktualit a rychlé úpravyfunction show_list(co, ind, add){	var s = document.getElementById(co + ind);	if (s.style.display == "none"){		$("#" + co + ind).fadeIn(220);		SetCookie(co + ind, "block", 365);		}else{		$("#" + co + ind).fadeOut(220);		SetCookie(co + ind, "none", 365);if (co == 'l'){		$("#r" + ind).fadeOut(200); // zabalím i rychlou úpravu		SetCookie("r" + ind, "none", 365);		}	}// show_list('r',<? echo $id; ?>, 'true')// kliknu do konkrétního pole volám// if (add == 'false'){select_pole("start_page" + ind);}}// kliknu do konkrétního pole funkcefunction select_pole(co){	document.getElementById(co).select();	}// funkce pro editaci URL mod_rewritefunction show_rychlovka(ind,co){	document.getElementById(co + ind).readOnly = !(document.getElementById("ch_mod" +ind).checked)				// jen obarvení políčka pro editaci				if (document.getElementById("ch_mod" +ind).checked){document.getElementById(co + ind).style.background = "#ddf6e4";}else{				document.getElementById(co + ind).style.background = "#ffedea";				}	}// funkce pro zavírání/otevírání aktualit najednou (ind, view) (pocet, rozbalit=1 sbalit=2)function show_list_all(ind, view){	var i;	for (i=1; i<=ind; i++){		var l = document.getElementById("l" + i);		if (view == 1){				$("#l" + i).fadeIn(200);				SetCookie("l"+i, "block", 365);				SetCookie("r"+i, "none", 365);				}		if (view == 2){				$("#r" + i).fadeOut(200); // zabalím i všechny rychlé úpravy				$("#l" + i).fadeOut(200);				SetCookie("r"+i, "none", 365); // nastavím cookie všechny rychlé úpravy				SetCookie("l"+i, "none", 365);				}		}}// zavírání všeho pro seznam PAGE stejné jako fce show_list_allfunction show_list_all_add(ind, view, co){	for (i=1; i<=ind; i++){		var l = document.getElementById(co + i);	if (view == 1){				$("#" + co + i).fadeIn(200);				SetCookie(co + i, "block", 365);				}	if (view == 2){				$("#" + co + i).fadeOut(200);				SetCookie(co + i, "none", 365);				}	}}// skrývací funkce pro mazání aktualitfunction list_blok(ind){	var list = document.getElementById("list" + ind);	var l = document.getElementById("l" + ind);		SetCookie("l"+ind, "none", 365);		// tady spustit ajax pro smazání aktuality		// při provedeném smazání skrýt aktualitu		$("#list" + ind).fadeOut(300);}// zobrazování a skrývání live náhledu v edit_news a edit_pagesfunction show_live(){	var q = document.getElementById("livepreviewbox");	if (q.style.display == "none"){			$("#livepreviewbox").slideDown(300);				SetCookie("livepreviewbox", "block", 365);			}else{			$("#livepreviewbox").slideUp(300);			SetCookie("livepreviewbox", "none", 365);			}}// aktualizace šířky divu livepreviewfunction sirka_divu(){		var ind = document.getElementById("livesizewidth").value;		var inx = document.getElementById("livesizeheight").value;				$("#livepreview").animate( { width: ind +"px"}, 700 );				$("#livecontent").animate( { height: inx +"px"}, 700 );				SetCookie("livewidth", ind, 365);				SetCookie("liveheight", inx, 365);}// datumyfunction datum(x, pole){keykey(0);if (x == ""){var x =0;}promenna = new Date(); // vytvoří proměnnou obsahující aktuální datummesic = promenna.getMonth() + 1; //leden je 0den = promenna.getDate() + x;rok = promenna.getFullYear();hodina = promenna.getHours("H");minuta = promenna.getMinutes("m");vterina = promenna.getSeconds("s");tendatum = rok + "-" + mesic + "-" + den + " " + hodina + ":" + minuta + ":" + vterina;// parametr 99 -> nastavení expirace do konce aktuálního rokuif(x == 99){tendatum = rok + "-12-31 23:59:59";}document.getElementById(pole).value=tendatum;}	/*	// animace scroll TOP$(document).ready(function(){	$('#nahoru').click(function() {		    $('html, body').animate({scrollTop: '0px'}, 500);			return false;				  });});*/// textarea resizer pro editaci stránek    // textarea resizer    $(function init()    {        // copyright Drupal, GNU General Public License        $('textarea.resizable:not(.textarea-processed)').each(function() {            var textarea = $(this).addClass('textarea-processed'), staticOffset = null;            // When wrapping the text area, work around an IE margin bug.  See:            // http://jaspan.com/ie-inherited-margin-bug-form-elements-and-haslayout            $(this).wrap('<div class="resizable-textarea"><span></span></div>')                .parent().append($('<div class="grippie"></div>').mousedown(startDrag));            var grippie = $('div.grippie', $(this).parent())[0];            grippie.style.marginRight = (grippie.offsetWidth - $(this)[0].offsetWidth) +'px';            function startDrag(e) {                staticOffset = textarea.height() - e.pageY;                textarea.css('opacity', 0.80);                $(document).mousemove(performDrag).mouseup(endDrag);                return false;            }            function performDrag(e) {                textarea.height(Math.max(32, staticOffset + e.pageY) + 'px');                return false;            }            function endDrag(e) {                $(document).unbind("mousemove", performDrag).unbind("mouseup", endDrag);                textarea.css('opacity', 1);            }        });    });// zakázíní odeslání formu po stisknutí enter v inputu resize livepreviewfunction notEnter(ev) {    var code;    if (!ev) var ev = window.event;    if (ev.keyCode) code = ev.keyCode;    else if (ev.which) code = ev.which;     if(code == 13) {       return false;    } else {       return true;    }}// délka znaků k liveprewiefunction LenghtText(){document.getElementById("pocet_znaku").innerHTML = document.getElementById("message").value.length;}// color box paletafunction show_color(){	var c = document.getElementById("colorbox");	if (c.style.display == "none"){			$("#colorbox").fadeIn(100);				}else{			$("#colorbox").fadeOut(50);			}}// BLOK koncept_info blokfunction show_koncept_info(){	$("#koncept_info").fadeIn(200);	stoper();	show_save_info();		}function hide_koncept_info(){$("#koncept_info").fadeOut(200);}//	ICO save infofunction show_save_info(){$("a.ico_safe_info").fadeIn(200);}function hide_save_info(){$("a.ico_safe_info").fadeOut(200);}var timer;function autosave(){timer = setTimeout("save_news(1,5)",  1 * 10 * 1000); // nastavení auto ukládání }// stopnutí timerufunction stoper() {clearTimeout(timer);}// save news PROCESfunction UlozilJsemNews(ind){  if (httpRequest.readyState == 4){		if(httpRequest.status == 200){//		OK			stoper();			document.getElementById("ulozit").visibility = 'hidden';			$("#ulozit").fadeOut(450);			show_koncept_info();			show_save_info();			}else{		alert("Chyba pri nacitani stanky "+ httpRequest.status +":"+ httpRequest.statusText);		}  }}// save news // pocet je pocet kategorií k procházenífunction save_news(ind, pocet){starthttpRequest();if (ind == 2){var id_news = document.getElementById("id_news").value;}else{	var id_news = 0;	}var name_news = document.getElementById("name_news").value;var text_news = document.getElementById("message").value;var script_news = document.getElementById("script_news1").value;var id_lang = document.getElementById("id_lang").value;var start_news = document.getElementById("start_news").value;var exp_news = document.getElementById("exp_news").value;var unique_id_news = document.getElementById("unique_id_news").value;if (document.getElementById("status2").checked == true){var status_news = 2;}if (document.getElementById("status1").checked == true){var status_news = 1;}var kat_news_new = "";for (i = 1; i < pocet; i++){if (document.getElementById("kat" + i).checked == true){	kat_news_new += "kat_news_new["+i+"]="+i+"&";	}}// document.write(pole[2]);var retezec = "?script_news=" + script_news + "&name_news=" + name_news + "&text_news=" + text_news +"&id_news=" + id_news + "&id_lang=" + id_lang + "&start_news=" + start_news + "&exp_news=" + exp_news + "&" + kat_news_new  + "edit=" + ind + "&status_news=" + status_news + "&unique_id_news=" + unique_id_news;var url =  retezec;// document.write(url);httpRequest.open('POST', "edit_news.ajax.php", true);httpRequest.onreadystatechange = function() {UlozilJsemNews(ind);};httpRequest.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=utf-8;');httpRequest.send(url); }// mazání news ze seznamu news PROCESfunction SmazalJsemNews(ind){  if (httpRequest.readyState == 4){		if(httpRequest.status == 200){		$("#list" + ind).fadeOut(300);				}else{		alert("Chyba pri nacitani stanky "+ httpRequest.status +":"+ httpRequest.statusText);		}  }}// mazání news ze seznamu newsfunction delete_news(ind){starthttpRequest();var retezec = "edit=3&id_news=" + ind;var url =  retezec;	httpRequest.open('POST', "edit_news.ajax.php?", true);httpRequest.onreadystatechange = function() {SmazalJsemNews(ind);};httpRequest.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=utf-8;');httpRequest.send(url); }// mazání news ze seznamu news PROCESfunction SmazalJsemPage(ind){  if (httpRequest.readyState == 4){		if(httpRequest.status == 200){		$("#pg_" + ind).fadeOut(300);				}else{		alert("Chyba pri nacitani stanky "+ httpRequest.status +":"+ httpRequest.statusText);		}  }}function delete_page(ind){starthttpRequest();var retezec = "edit=3&id_page=" + ind;var url =  retezec;	httpRequest.open('POST', "edit_page.ajax.php?", true);httpRequest.onreadystatechange = function() {SmazalJsemPage(ind);};httpRequest.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=utf-8;');httpRequest.send(url); }/* * 	Easy Tooltip 1.0 - jQuery plugin *	written by Alen Grakalic	 *	http://cssglobe.com/post/4380/easy-tooltip--jquery-plugin * *	Copyright (c) 2009 Alen Grakalic (http://cssglobe.com) *	Dual licensed under the MIT (MIT-LICENSE.txt) *	and GPL (GPL-LICENSE.txt) licenses. * *	Built for jQuery library *	http://jquery.com * */ (function($) {	$.fn.easyTooltip = function(options){	  		// default configuration properties		var defaults = {				xOffset: 5,					yOffset: 30,			tooltipId: "easyTooltip",			clickRemove: false,			content: "",			useElement: ""		}; 					var options = $.extend(defaults, options);  		var content;						this.each(function() {  							var title = $(this).attr("title");							$(this).hover(function(e){											 							   				content = (options.content != "") ? options.content : title;				content = (options.useElement != "") ? $("#" + options.useElement).html() : content;				$(this).attr("title","");									  								if (content != "" && content != undefined){								$("body").append("<div id='"+ options.tooltipId +"'>"+ content +"</div>");							$("#" + options.tooltipId)						.css("position","absolute")						.css("top",(e.pageY - options.yOffset) + "px")						.css("left",(e.pageX + options.xOffset) + "px")												.css("display","none")						.fadeIn("fast")				}			},			function(){					$("#" + options.tooltipId).remove();				$(this).attr("title",title);			});				$(this).mousemove(function(e){				$("#" + options.tooltipId)					.css("top",(e.pageY - options.yOffset) + "px")					.css("left",(e.pageX + options.xOffset) + "px")								});				if(options.clickRemove){				$(this).mousedown(function(e){					$("#" + options.tooltipId).remove();					$(this).attr("title",title);				});							}		});	  	};})(jQuery);
