﻿var helperVar = null;
var currentMainArticle = 0;
var currentTimeout;
var currentTimeout2;
var _hpMapManager;
var _hpMap;
var _hpFotogalerie;

function LoadWeather(code)
{
if (code != "")
{
var html = $.ajax({
        url: "/WeatherInfo.ashx?code=" + code,
        dataType: "html",
        type: "GET",
        async: false
    }).responseText;
    document.write(html);
}
}
function Tury1()
{
	$("#dvTury2").hide();
	$("#dvTury div.dvZ6a").show();
}
function Hotdeal1()
{
	$("#dvHotdealMore").hide();
	$("#dvHotDeals2 div.dvZ6a").show();
}
function closetest(){ClosePopupRegistration();}
function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}
function Set_Cookie( name, value, expires )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) + ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" );
}


function Registrace()
{
	if(location.href == "http://www.russiantraveller.ru/" || location.href == "http://russiantraveller.ru/")
	{
		var c = Get_Cookie("lform");
		if (c == null)
			c = 0;
		Set_Cookie("lform", ++c, 360);
		if (Get_Cookie("tdLoyality") == null && c >= 3 && c <=5)
		{
			ShowPopupRegistration();
		}
	}
}
function ClosePopupRegistration()
{
	location.href = "/loyality.aspx?stats=1";
}
function ShowPopupRegistration()
{
$.modal('<iframe src="/loyality.aspx?ajax=1" height="445" width="450" frameborder="0"></iframe><div style="background-color:black;text-align:right;padding-right:20px;line-height:26px;"><a style="color:white;font-weight:bold;" href="javascript:$.modal.close();">Закрыть окно</a></div>', {
	closeHTML:"",
	containerCss:{
		backgroundColor:"white",
		border:"10px solid black",
		height:470,
		padding:0,
		width:450
	},
	opacity: 50,
	overlayCss: {backgroundColor:"black"},
	overlayClose:true
});
}

function ChangeTextSize(vel)
{
    $("#txtZoom1, #txtZoom2, #txtZoom3").removeClass("dvClanek3b");
    $("#txtZoom" + vel).addClass("dvClanek3b");
    var s;
    switch (vel) { case 1: s = "1"; break; case 2: s = "1.3"; break; case 3: s = "1.6"; break; }
    getID("dvClanek5").style.fontSize = s + "em";
}
function Hotdeals(zeme)
{
    var html = $.ajax({
        url: "/HotDealsZeme.ashx?c10id=" + (zeme ? cmsDetailID : "") + "&c15id=" + (zeme ? "" : cmsDetailID),
        dataType: "html",
        type: "GET",
        async: false
    }).responseText;
    document.getElementById("dvHotDeals").innerHTML = "<h1>Спецпредложения отелей</h1>" + html;
}
function VGallery_Load(video)
{
    getID("dvVideo").style.display = "block";
    getID("dvcontent").src = "/player.aspx?video=" + video;
    self.scrollTo(0,400);
}
function Zeme_Init(lang, zoom) {
	// zobrazeni firem
	var objs = $(".dvZ6a");
	var celkem = objs.size();
	if (celkem > 5)
	{
		var start = Math.ceil((celkem - 5) * Math.random())
		for (var i=start; (start + 5) > i; i++)
			objs.get(i).style.display = "block";
	}
	else
		objs.each(function() { this.style.display = "block"; });
	
	if (GBrowserIsCompatible()) {
		_hpMap = new GMap2(document.getElementById("mapaZeme"));
		var arr = lang.split(",");
		_hpMap.setCenter(new GLatLng(arr[0], arr[1]), zoom);
		HP_PointsProccessListener();
    
		_hpMapManager = new MarkerManager(_hpMap);
		HP_PointsProccess(map_points, true, true, true, true, true);
		_hpMap.addOverlay(new GLayer('com.google.webcams'));
	}
     
    var html = $.ajax({
        url: "/HotDealsZeme.ashx?top=2&c10id=" + c10id + "&mesto=" + (arguments.length == 2 ? "" : getID("nazevDestinace").innerHTML) + "&c15id=" + c15id,
        dataType: "html",
        type: "GET",
        async: false
    }).responseText;
    document.getElementById("dvHotDeals2").innerHTML = html;
    var html = $.ajax({
        url: "/Tury.ashx?top=4&c10id=" + c10id + "&c15id=" + (c15id ? c15id : ""),
        dataType: "html",
        type: "GET",
        async: false
    }).responseText;
    document.getElementById("dvTury").innerHTML = html;
    // pozadi
    if (arguments.length == 2)
    {
        var t = $("#dvHP17").position().top;
        $("div.dvMain").css("background", "transparent url(/gfx/hp5.gif) no-repeat scroll left " + t + "px");
    }
}

function ShareIt(e)
{
    var o = $("#dvShareIt");
    if (o.css("display") == "block")
        o.css("display", "none");
    else
    {
        var pos = $(".dvClanek3").position();
        o.css("display", "block").css("left", pos.left - 135).css("top", pos.top + 10);
    }
}
function share(typ) {
	var headline = escape(document.getElementById("articleHeadline").innerHTML);
	var description= escape(document.getElementById("articlePerex").innerHTML);
	switch (typ) {
	case "face":
		window.open("http://www.facebook.com/share.php?u=" + location.href.substr(7), "_blank");
		break;
	case "dig":
		window.open("http://digg.com/submit?phase=2&url=" + location.href + "&title="+escape(headline) + "&bodytext=" + escape(description) + "&media=lifestyle&topic=trevel_places", "_blank");
		break;
	case "del":
		headline = "Article from www.dobropozalovat.com";
		window.open("http://del.icio.us/post?v=4&noui&jump=close&url=" + location.href + "&title=" + escape(headline), "_blank");
		break;
	case "myspace":
		window.open("http://www.myspace.com/Modules/PostTo/Pages/?t=" + headline + "&c=" + description + "&u=" + location.href, "_blank");
		break;
	}
}
function PotD_Log(id) {
    $.ajax({
        url: "/ruFotoDne.ashx?id=" + id,
        dataType: "html",
        type: "GET",
        async: true
    });
}
function HPKontinent(l1, l2, zoom)
{
    getID("hpContent1").style.display = "none";
    getID("hpContent0").style.display = "block";
    _hpMap.setCenter(new google.maps.LatLng(l1, l2), zoom);
}
function HPInspirace() {
    var col = document.getElementsByName("c17id");
    var s = "";
    for (var i=0; i < col.length; i++) {
        if (col[i].checked)
            s += "," + col[i].value;
    }
    if (s != "")
    {
        s = s.substr(1);
        var html = $.ajax({
            url: "/Inspirace.ashx?c17id=" + s + "&c09id=" + document.getElementById("c09id").value,
            dataType: "html",
            type: "GET",
            async: false
        }).responseText;
        document.getElementById("dvInspirace2").innerHTML = html;
        document.getElementById("dvInspirace1").style.display = "none";
        document.getElementById("dvInspirace2").style.display = "block";
    } else
        alert("Выберите категорию!");
}
function GalerieSearch(q)
{
    var s = q;
    if (getID("selZeme").value != "")
        s += "&z=" + getID("selZeme").value;
    if (getID("txtSearch").value != "")
        s += "&s=" + getID("txtSearch").value;
    if (s != "")
        s = "?" + s;
    location.href = "/gallery2.aspx" + s;
}
function Dest2Change()
{
    var s = getID("selZeme2").value;
    if (s != "")
    {
        $.ajax({
        type: "GET",
        url: "SeznamDestinaci.ashx?c10id=" + s,
        dataType: "text",
        async: false,
        success: function(data) {
            getID("dvHP18b").innerHTML = data;
        }
        });
    }
}
function ZemeFotoChange(dir)
{
    if (dir == "next")
        currentPhotoIndex = currentPhotoIndex >= (photoColl.length - 1) ? 0 : currentPhotoIndex + 1;
    else
        currentPhotoIndex = currentPhotoIndex <= 0 ? photoColl.length - 1 : currentPhotoIndex - 1;
    getID("dvZeme1").style.display = "none";
    getID("dvZeme1b").style.display = "block";
    $("#dvZeme1 img").attr("src", photoColl[currentPhotoIndex]);
    $("#dvZeme1 img").load(function(){
        getID("dvZeme1").style.display = "block";
        getID("dvZeme1b").style.display = "none";
        getID("spZeme2").innerHTML = photoCollT[currentPhotoIndex];
    });
}
function DestChange()
{
    if (getID("selZeme").selectedIndex > 0)
    {
        location.href = "/country/" + getID("selZeme").value + ".aspx";
    }
    else
    {
        var o = getID("selZeme");
        while (o.options.length > 0)
            o.remove(0);
        
        $.ajax({
        type: "GET",
        url: "KontinentZeme.ashx?c09id=" + getID("selKont").value,
        dataType: "json",
        async: false,
        success: function(data) {
            for (var i=0; i < data.vals.length; i++)
            {
                var option = document.createElement("option");
                option.value = data.vals[i];
                option.text = data.txts[i];
                o.options.add(option, i+1);
            }
        }
        });
    }
}
function FirmaChange()
{
    getID("frmFirma").submit();
}
function Favs() {
	var title = document.title;
	var url = location.href;
	if (window.sidebar) {
		window.sidebar.addPanel(title, url,"");
	} else if( window.opera && window.print ) {
		var t = document.createElement('a');
		t.setAttribute('rel', 'sidebar');
		t.setAttribute('href', url);
		t.setAttribute('title', title);
		t.click();
	} else if( document.all ) {  
		window.external.AddFavorite( url, title);  
	}
}
function Map_Unload()
{
    try { GUnload(); }
    catch (e) {}
}
function LoadMap(souradnice, zoom, name)
{
    var arr = souradnice.split(",");
    _hpMap = new google.maps.Map2(document.getElementById(name));
    _hpMap.setCenter(new google.maps.LatLng(arr[0], arr[1]), zoom);
}
function HP_Init()
{
    _hpMap = new google.maps.Map2(document.getElementById("hpmapa"));
    _hpMap.setCenter(new google.maps.LatLng(32.249974,-4.921875), 2);
    HP_PointsProccessListener();
   
    if (arguments.length > 0)
    {
        _hpMap.addControl(new GLargeMapControl());
        _hpMap.addControl(new GMapTypeControl());
    }
    _hpMapManager = new MarkerManager(_hpMap);
if (arguments.lenght > 0)
	HP_MapChange(arguments[0]);
else
	HP_MapChange();

    _hpMap.addOverlay(new GLayer('com.google.webcams'));

    // kurzovni listek
    $.ajax({
        type: "GET",
        url: "/Kurzy.ashx",
        dataType: "text",
        async: true,
        success: function(data) {
            getID("dvKurzy").innerHTML = data;
        }
    });
    // hotdeals
    $.ajax({
        type: "GET",
        url: "/HotDealsHP.ashx",
        dataType: "text",
        async: true,
        success: function(data) {
            getID("dvHotdealsHp").innerHTML = data;
        }
    });
}
function HP_Init2() {
    var s = location.href.substr(location.href.length-3);
    switch (s) {
    case "#k1":
        self.scrollTo(0,700);
        HP_Menu(1);
        break;
    case "#k2":
        self.scrollTo(0,700);
        HP_Menu(2);
        break;
    case "#k3":
        self.scrollTo(0,700);
        HP_Menu(3);
        break;
    }
    // fotogalerie na hp
    $.ajax({
        type: "GET",
        url: "/HPFotogalerie.ashx",
        dataType: "json",
        async: false,
        success: function(data) {
            _hpFotogalerie = new Array();
            for (var i=0; i < data.foto.length; i++)
            {
                _hpFotogalerie[i] = data.path + data.foto[i];
            }
            HPFotogalerieChange();
            //currentTimeout2 = window.setTimeout("HPFotogalerieChange()", 3000);
        }
    });
}
function HP_TopMenu(idx) {
    var s = "k"+idx.toString();
    if (document.getElementById(s) != null) {
        self.scrollTo(0,700);
        HP_Menu(idx);
        return false;
    } else
        return true;
}
function HPFirmyChange(druh)
{
    getID("frmhp").submit();
}
function HP_PointsProccess(data, clanky, destinace, firmy, videa, fota)
{
    // ikona destinace
    var icDestinace = new GIcon(G_DEFAULT_ICON);
    icDestinace.image = "http://www.russiantraveller.ru/gfx/map1.gif";
    icDestinace.iconSize = new GSize(21,21);
    icDestinace.iconAnchor = new GPoint(0,0);
    icDestinace.shadow = "";
    // ikona firmy
    var icFirmy = new GIcon(G_DEFAULT_ICON);
    icFirmy.image = "http://www.russiantraveller.ru/gfx/map2.gif";
    icFirmy.iconSize = new GSize(21,21);
    icFirmy.iconAnchor = new GPoint(0,0);
    icFirmy.shadow = "";
    // ikona clanku
    var icClanek = new GIcon(G_DEFAULT_ICON);
    icClanek.image = "http://www.russiantraveller.ru/gfx/map5.gif";
    icClanek.iconSize = new GSize(21,21);
    icClanek.iconAnchor = new GPoint(0,0);
    icClanek.shadow = "";
    // ikona video
    var icVideo = new GIcon(G_DEFAULT_ICON);
    icVideo.image = "http://www.russiantraveller.ru/gfx/map3.gif";
    icVideo.iconSize = new GSize(21,21);
    icVideo.iconAnchor = new GPoint(0,0);
    icVideo.shadow = "";
    // ikona foto
    var icFoto = new GIcon(G_DEFAULT_ICON);
    icFoto.image = "http://www.russiantraveller.ru/gfx/map4.gif";
    icFoto.iconSize = new GSize(21,21);
    icFoto.iconAnchor = new GPoint(0,0);
    icFoto.shadow = "";

    var markers = [];
    // clanky
    if (clanky && data.clanky != null)
    {
        for (var i=0; i < data.clanky.length; i++)
        {
            var arr = data.clanky[i].s.split(",");
            if (!isNaN(parseFloat(arr[0])) && !isNaN(parseFloat(arr[1])))
            {
                var m = new GMarker(new GLatLng(arr[0],arr[1]), { title:data.clanky[i].n, clickable:true, icon:icClanek });
                markers.push(m);
            }
        }
    }
// foto
    if (fota && data.foto != null)
    {
        for (var i=0; i < data.foto.length; i++)
        {
	        var arr = data.foto[i].s.split(",");
                var m = new GMarker(new GLatLng(arr[0],arr[1]), { title:data.foto[i].n, clickable:true, icon:icFoto });
                //markers.push(m);
        }
    }
    // firmy
    if (firmy && data.firmy != null)
    {
        for (var i=0; i < data.firmy.length; i++)
        {
            var arr = data.firmy[i].s.split(",");
            if (!isNaN(parseFloat(arr[0])) && !isNaN(parseFloat(arr[1])))
            {
                var m = new GMarker(new GLatLng(arr[0],arr[1]), { title:data.firmy[i].n, clickable:true, icon:icFirmy });
                markers.push(m);
            }
        }
    }
    // video
    if (videa && data.video != null)
    {
        for (var i=0; i < data.video.length; i++)
        {
            var arr = data.video[i].s.split(",");
            if (!isNaN(parseFloat(arr[0])) && !isNaN(parseFloat(arr[1])))
            {
                var m = new GMarker(new GLatLng(arr[0],arr[1]), { title:data.video[i].n, clickable:true, icon:icVideo });
                markers.push(m);
            }
        }
    }
    // destinace
    if (destinace && data.destinace != null)
    {
        for (var i=0; i < data.destinace.length; i++)
        {
            var arr = data.destinace[i].s.split(",");
            if (!isNaN(parseFloat(arr[0])) && !isNaN(parseFloat(arr[1])))
            {
                var m = new GMarker(new GLatLng(arr[0],arr[1]), { title:data.destinace[i].n, clickable:true, icon:icDestinace });
                markers.push(m);
            }
        }
    }
    _hpMapManager.addMarkers(markers,2);
    _hpMapManager.refresh();
}
function HP_PointsProccessListener()
{
    GEvent.addListener(_hpMap, 'click', function(marker,point) {
        if (marker) {
            var img = marker.getIcon().image;
            var s = img.substr(img.lastIndexOf("/") + 1);
            switch (s)
            {
                case "map1.gif":
                    s = "dest";
                    break;
                case "map2.gif":
                    s = "firma";
                    break;
                case "map3.gif":
                    s = "video";
                    break;
                case "map4.gif":
                    s = "foto";
                    break;
                case "map5.gif":
                    s = "clanek";
                    break;
            }
            
            var url = $.ajax({
                url: "/HPmapMarkers.ashx?a=" + s + "&p=" + marker.getPoint().toUrlValue() + "&n=" + encodeURIComponent(marker.getTitle()),
                dataType: "text",
                type: "GET",
                async: false
            }).responseText;
            
            // akce
            switch (s)
            {
                case "foto":
                    var a = getID("imageboxa");
                    a.innerHTML = marker.getTitle();
                    a.href = url;
                    $.ImageBox.init( { fadeDuration: 250, loaderSRC: '/indicator.gif', closeHTML: 'Закрыть окно' } );
                    $(a).click();
                    break;
                case "video":
                    if (url != "")
                    {
                        $.modal("<iframe frameborder=\"0\" width=\"480\" height=\"391\" src=\"/player.aspx?video=" + url + "\" scrollbars=\"no\"></iframe>", { closeHTML:"<a href='#' style='font-weight:bold;line-height:25px;'>Закрыть окно</a>", overlayCss: { backgroundColor:'#000', cursor:'wait' }, containerCss: { height:'411px', width:'480px', backgroundColor:'white' } });
                    }
                    break;
                default:
                    location.href = url;
                    break;
            }
        }
    });
}
function HP_MapChange()
{
    var s = "";
    _hpMapManager.clearMarkers();
    if (arguments[0] != null)
        s = "&t=1";
    else
        s = "&t=0";

    $.ajax({
        type: "GET",
        url: "/HPmapMarkers.ashx?a=map" + s,
        dataType: "json",
        async: false,
        success: function(data) {
            HP_PointsProccess(data, getID("maparad5").checked, getID("maparad1").checked, getID("maparad2").checked, getID("maparad3").checked, getID("maparad4").checked);
        }
    });
}
function Zeme_Menu(idx, move)
{
    $(".dvHP17g").hide();
    $("#hpContent" + idx).fadeIn("fast");
    getID("hpsipka").style.top = (move * 41) + "px";
}
function HP_Menu(idx)
{
    $(".dvHP17d").hide();
    $(".dvHP17g").hide();
    $("#hpMenu" + idx).slideDown("fast");
    $("#hpContent" + idx).fadeIn("fast");
    getID("hpsipka").style.top = (idx * 41) + "px";
}

function SetHomePage(page) {
	if (navigator.appName != 'Netscape') {
		document.body.style.behavior='url(#default#homepage)'; 
		document.body.setHomePage(page); 
		return false; 
	} else 
		return true; 
}
function getID(name) {
	return document.getElementById(name);
}
function OpenSendByEmailWindow(path) {
	if (path.indexOf("path") <=0)
		path = path + "&path=" + location.href;
	window.open(path, "sendByEmail", "location=no,menubar=no,resizable=yes,scrollbars=yes,titlebar=no,toolbar=no,height=250px,width=320px");
}
function OpenPrintWindow(path) {
	window.open(path, "printIt", "location=no,menubar=no,resizable=yes,scrollbars=yes,titlebar=no,toolbar=no");
}
function Email() {
    var typ, r;
    if (arguments.length == 0)
    {
        typ = 'c';
        r = cmsRubrikaID;
    } else {
        typ = arguments[0];
        r = "739";
    }
	var arr = location.href.substr(7).split("/");
	var filename = arr[arr.length-1];
	var path = "/" + arr.join("/");
    path = location.href;
	location.href = "/sendbyemail2.aspx?te="+tRubriky+r+"&t="+(typ=="c"?"clanek":"firma")+"&i="+cmsDetailID+"&p="+path+"&d="+typ+"&dp=" + (typ=="c" ? tClanky : tFirmy) + filename;
}
function Tisk() {
    var typ, r;
    if (arguments.length == 0)
    {
        typ = 'c';
        r = cmsRubrikaID;
    } else {
        typ = arguments[0];
        r = "739";
    }
    var arr = location.href.substr(7).split("/");
    var filename = arr[arr.length-1];
    var path = "/" + arr.join("/");
    OpenPrintWindow("/print.aspx?t="+(typ=="c"?"clanek":"firma")+"&path=" + (typ=="c" ? tClanky : tFirmy) + filename + "&url=" + path);
}

function HlavniClanekTimeout() {
    var i = currentMainArticle + 1;
    if (i > 4) i = 0;
    HlavniClanek(i);
    StartHlavniClanekTimeout();
}
function HPFotogalerieChange() {
    if (currentTimeout2 != null) window.clearTimeout(currentTimeout2);
    var o = getID("imgFotoHP");
    var idx = 0;
    for (var i=0; i < _hpFotogalerie.length; i++)
    {
        if (o.src == _hpFotogalerie[i])
        {
            idx = (i == (_hpFotogalerie.length - 1) ? 0 : ++i);
            break;
        }
    }
    o.src = _hpFotogalerie[idx];
    o.style.visibility = "visible";
    currentTimeout2 = window.setTimeout("HPFotogalerieChange()", 8000);
}
function StartHlavniClanekTimeout() {
    currentTimeout = window.setTimeout("HlavniClanekTimeout()", 5000);
}
function HlavniClanek2(dir) {
    var idx = currentMainArticle + (dir == "prev" ? -1 : 1);
    if (idx < 0) idx = 0;
    if (idx > 4) idx = 0;
    HlavniClanek(idx);
}
function HlavniClanek(idx) {
    if (currentTimeout != null) window.clearTimeout(currentTimeout);
    
    $("#spHlavniClanek").css("visibility", "hidden");
    var html = $.ajax({
        url: "/ruHlavniClanek.ashx?idx=" + idx,
        dataType: "html",
        type: "GET",
        async: false
    }).responseText;

    document.getElementById("spHlavniClanek").innerHTML = html;
    $("#spHlavniClanek").css("visibility", "visible");
    $("#spHlavniClanek img").fadeIn("slow");
    
    var x = (idx * 8) * -1;
    var pos = "left " + x + "px";
    $("#spHlavniClanek2").css("background-position", pos)
    currentMainArticle = idx;
}

function SP_DiskuseRe(idx) {
    if (t09nick == null) {
        //alert(dis_notLoggedMessage);
        //return;
    }
    
    diskuseSelectedId = idx;
    $("div.SP_Diskuse6[id!='SPjs_dis"+idx+"']").hide("normal");
    $("div#SPjs_dis"+idx+" div a").hide();
    document.getElementById("SPjs_dis_predmet").value = "Re: " + $("div#SPjs_dis"+idx+" div strong").text();
    helperVar = idx;
    document.getElementById("SPjs_DiskuseForm").style.visibility = "visible";
}
function SP_DiskuseCancel() {
    SP_DiskuseClearEdit();
    helperVar = null;
}
function SP_DiskuseClearEdit() {
    $("div.SP_Diskuse6:hidden").show();
    if (helperVar != null)
        $("div#SPjs_dis"+helperVar+" div a").show();
    
    document.getElementById("SPjs_dis_predmet").value = "";
    document.getElementById("SPjs_dis_text").value = "";
    document.getElementById("SPjs_DiskuseForm").style.visibility = "hidden";
}
function SP_DiskuseNew() {
    if (t09nick == null) {
        //alert(dis_notLoggedMessage);
        //return;
    }
    
    diskuseSelectedId = null;
    $("div.SP_Diskuse6").hide("normal");
    document.getElementById("SP_DiskuseNew").style.display = "none";
    document.getElementById("SPjs_DiskuseForm").style.visibility = "visible";
    document.getElementById("SPjs_dis_predmet").value = "";
    document.getElementById("SPjs_dis_text").value = "";
}
function SP_DiskusePreviewNew(id, message) {

        location.href = "?dis="+id+"&dis2=new";
}
function SP_DiskuseSave() {
    if (jQuery.trim(document.getElementById("SPjs_dis_predmet").value) == "" || jQuery.trim(document.getElementById("SPjs_dis_text").value) == "") {
        alert(dis_saveErr)
    } else {
	var subject = encodeURIComponent(document.getElementById("SPjs_dis_predmet").value);
	var text = encodeURIComponent(document.getElementById("SPjs_dis_text").value);

        var sUrl = "Diskuse.ashx?id=" + cmsDetailID + "&master=" + (diskuseSelectedId == null ? "" : diskuseSelectedId) + "&type=" + cmsDetailType;
        var sData = "subject=" + subject;
        sData += "&text=" + text;

        var response = $.ajax({
            type: "POST",
            url: sUrl,
            dataType: "text",
            async: false,
            data: sData
        }).responseText;
        SP_DiskuseClearEdit();
        
        alert("Комментарий принят и отправлен на согласование администратору.");
        
        /*if (diskuseSelectedId == null) {
            if ($("div.SP_Diskuse6").size() == 0)
                $(response).hide().insertAfter("div#SP_Diskuse5").fadeIn("slow").find("p").css("font-weight", "bold");
            else
                $(response).hide().insertAfter("div.SP_Diskuse6:last").fadeIn("slow").find("p").css("font-weight", "bold");
        } else
            $(response).hide().insertAfter("div#SPjs_dis"+helperVar).fadeIn("slow").find("p").css("font-weight", "bold");*/
        diskuseSelectedId = null;
        helperVar = null;
    }
}
function SP_DiskusePocetReakci(pocet) {
    if (document.getElementById("dvClanekDiskuse")) {
        var s = "<a href='?dis=" + cmsDetailID + "' title='Diskuze pod článkem'><img src='/gfx/diskuse2.gif' />";
        if (parseInt(pocet) > 0)
            s += "(" + pocet + ")";
        s += "</a>";
        document.getElementById("dvClanekDiskuse").innerHTML = s;
        document.getElementById("dvClanekDiskuse").style.visibility = "visible";
    }
}
function EncodeString(input) {
  var arr = new Array();
  for (var i=0; i < input.length; i++)
    arr[i] = input.charCodeAt(i);
  return arr.join("|");
}
