﻿var xmlDocFce;
var xmlDocString;
var helperVar = null;
var diskuseSelectedId = null;

function gemius_parameters() {
        var d=document;
        var href=new String(d.location.href);
        var ref;
        var f=0;
        var fv='-';
        if (d.referrer) { ref=new String(d.referrer); } else { ref=''; }
        if (typeof Error!='undefined') {
                var fo;
                eval('try { f=(d==top.document)?1:2; if (typeof top.document.referrer=="string") { ref=top.document.referrer } } catch(e) {f=3;}');
                eval('try { fv=navigator.plugins["Shockwave Flash"].description; } catch (e) {}');
                eval('if (typeof ActiveXObject!="undefined") { try { fo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"); } catch(e) { try { fo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); fv="X"; fo.AllowScriptAccess="always"; } catch(e) { if (fv=="X") { fv="WIN 6,0,20,0"; }} try { fo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); } catch(e) {} } if ((fv=="-" || fv=="X") && fo) { fv=fo.GetVariable("$version"); }}');
        }
        var url='&fr='+f+'&fv='+escape(fv)+'&tz='+(new Date()).getTimezoneOffset()+'&href='+escape(href.substring(0,499))+'&ref='+escape(ref.substring(0,499));
        if (screen) {
                var s=screen;
                if (s.width) url+='&screen='+s.width+'x'+s.height;
                if (s.colorDepth) url+='&col='+s.colorDepth;
        }
        return url;
}
function gemius_add_onload_event(obj,fn) {
        if (obj.attachEvent) {
                obj.attachEvent('onload', fn);
        } else if(obj.addEventListener) {
                obj.addEventListener('load', fn, false);
        }
}
function gemius_append_script(xp_url) {
        if (typeof Error!='undefined') {
                eval('try { xp_javascript=document.createElement("script"); xp_javascript.src=xp_url; xp_javascript.type="text/javascript"; xp_javascript.defer=true; document.body.appendChild(xp_javascript); } catch(e) {}');
        }
}
function gemius_obj_loaded() {
        window.pp_gemius_loaded+=1;
        if (window.pp_gemius_loaded==2 && window.pp_gemius_image.width && window.pp_gemius_image.width>1) {
                gemius_append_script(window.pp_gemius_script);
        }
}
var pp_gemius_proto = (document.location && document.location.protocol && document.location.protocol=='https:')?'https://':'http://';
if (typeof pp_gemius_hitcollector == 'undefined') {
        if (typeof gemius_hitcollector != 'undefined') {
                pp_gemius_hitcollector = gemius_hitcollector;
        } else {
                pp_gemius_hitcollector = 'gask.hit.gemius.pl';
        }
}
var pp_gemius_host = pp_gemius_proto+pp_gemius_hitcollector+'/_';
if (typeof pp_gemius_nhit == 'undefined') {
        if (typeof pp_gemius_identifier == 'undefined') {
                if (typeof gemius_identifier != 'undefined') {
                        pp_gemius_identifier = gemius_identifier;
                        gemius_identifier = 'USED_'+gemius_identifier;
                } else {
                        pp_gemius_identifier = '';
                }
        }
        if (typeof window.pp_gemius_cnt != 'undefined') {
                if (typeof window.pp_gemius_images == 'undefined') {
                        window.pp_gemius_images = new Array();
                }
                var gemius_l = window.pp_gemius_images.length;
                window.pp_gemius_images[gemius_l]=new Image();
                window.pp_gemius_images[gemius_l].src = pp_gemius_host+(new Date()).getTime()+'/redot.gif?l=33&id=ERR_'+pp_gemius_identifier.replace(/id=/,'id=ERR_')+gemius_parameters();
        } else {
                if (typeof pp_gemius_mode == 'undefined') {
                        window.pp_gemius_loaded = 0;
                        window.pp_gemius_script = pp_gemius_host+(new Date()).getTime()+'/pp.js?id='+pp_gemius_identifier;
                        gemius_add_onload_event(window,gemius_obj_loaded);
                        window.pp_gemius_image = new Image();
                        gemius_add_onload_event(window.pp_gemius_image,gemius_obj_loaded);
                        window.pp_gemius_image.src = pp_gemius_host+(new Date()).getTime()+'/rexdot.gif?l=30&id='+pp_gemius_identifier+gemius_parameters();
                        window.pp_gemius_cnt = 1;
                } else {
                        window.pp_gemius_image = new Image();
                        window.pp_gemius_image.src = pp_gemius_host+(new Date()).getTime()+'/rexdot.gif?l=31&id='+pp_gemius_identifier+gemius_parameters();
                        window.pp_gemius_cnt = 1;
                }
        }
        pp_gemius_identifier = 'USED_'+pp_gemius_identifier;
}
function pp_gemius_hit_int(list,rfrom,rto) {
        var gu = pp_gemius_host+(new Date()).getTime()+'/redot.gif?l=32';
        if (typeof window.xgemius_prot_cnt == 'undefined') {
                window.xgemius_prot_cnt=0;
        }
        if (typeof xgemius_prot_cnt == 'undefined') {
                xgemius_prot_cnt=0;
        }
        if (window.xgemius_prot_cnt<=xgemius_prot_cnt) {
                go=1;
                window.xgemius_prot_cnt++;
        } else {
                go=0;
        }
        xgemius_prot_cnt++;
        for (var i=rfrom ; i<rto ; i++) {
                gu += '&id='+list[i];
        }
        gu += gemius_parameters();
        if (typeof window.gemius_hit_images == 'undefined') {
                window.gemius_hit_images = new Array();
        }
        var gl = window.gemius_hit_images.length;
        window.gemius_hit_images[gl]=new Image();
        if (go) {
                window.gemius_hit_images[gl].src = gu;
        } else {
                window.gemius_hit_images[gl].src = gu.replace(/id=/,'id=DBL_');
        }
}
function pp_gemius_hit() {
        for (i=0 ; i<arguments.length ; i+=5) {
                if (i+5<arguments.length) {
                        pp_gemius_hit_int(arguments,i,i+5);
                } else {
                        pp_gemius_hit_int(arguments,i,arguments.length);
                }
        }
}
if (typeof gemius_hit != 'function') {
        gemius_hit=pp_gemius_hit;
}

function DiskuseLabelSeznam3(id)
{
	var druh = arguments.length == 1 ? "fg" : arguments[1];
	$.ajax({
        	url: "/DiskuzeVSeznamu.ashx?t=" + druh + "&ids=" + id,
	        dataType: "json",
        	type: "GET",
	        success: function(data) {
			var s;
			switch (data.druh)
			{
			case "fg":
				s = "/galerie/"+data.ids[0]+".aspx?dis="+data.ids[0];
				break;
			case "rec":
				s = location.href + "?dis=" + data.ids[0];
				break;
			default:
				s = location.href + "?dis=" + data.ids[0];
				break;
			}
			var o = "&nbsp;(<a title='Diskuse: "+data.vals[0]+"' class='fg2b' href='" + s + "'>"+data.vals[0]+"</a>)";
			$(".SP_Diskuse1 strong").after(o);
		},
		error: function(XMLHttpRequest, textStatus, errorThrown) { }
	});
}
function GaleriePohybLoad() {
	$.ajax({
        url: "/GaleriePohyb.ashx?id=" + cmsDetailID + "&catid=" + document.getElementById("catid").value,
        dataType: "text",
        type: "GET",
        success: function(data) { document.getElementById("dvPohyb").innerHTML = data; },
	error: function(XMLHttpRequest, textStatus, errorThrown) { document.getElementById("dvPohyb").style.display = "none"; }
    });
}
function DiskuseLabelSeznam()
{
	var s = "";
	$(".aDiskuzeLabel").each(function() {
		s += "," + this.id.substr(13);
	});
	s = s.substr(1);
	$.ajax({
        	url: "/DiskuzeVSeznamu.ashx?ids=" + s,
	        dataType: "json",
        	type: "GET",
	        success: function(data) {
			for (var i=0; i < data.ids.length; i++)
			{
				getID("aDiskuzeLabel" + data.ids[i]).innerHTML += "(" + data.vals[i] + ")";
			}
		},
		error: function(XMLHttpRequest, textStatus, errorThrown) { alert(textStatus); }
	});
}
function FpShowRegion() {
	$("#dvFP2a").slideDown("normal");
}
function PobockaOpen(id) {
	var s = document.getElementById("pobocka"+id).style.display;
	document.getElementById("pobocka"+id).style.display = s == "block" ? "none" : "block";
}
function TextSnippet(id) {
	var html = $.ajax({
        url: "/TextSnippet.ashx?i=" + id,
        type: "GET",
        dataType: "text",
        async: false
    }).responseText;
	document.write(html);
}
function RecVote_Load() {
var randomnumber=Math.floor(Math.random()*101);var randomnumber=Math.floor(Math.random()*101);
    $.ajax({
        url: "/HlasovaniRecept.ashx?a=get&id=" + cmsDetailID + "&druh=" + cmsDetailType2 + "&r=" + randomnumber,
        dataType: "text",
        type: "GET",
        success: function(data) { document.getElementById("dvRecept5").innerHTML = data; RecVote_Init(); },
	error: function(XMLHttpRequest, textStatus, errorThrown) { document.getElementById("dvRecept5").style.display = "none"; }
    });
}
function RecVote_Init() {
    $('#dvHodnoceni img').preload({
	find:'_0.gif',
        replace:'_1.gif'
    });
    
    $('#dvHodnoceni img').click(function() {
        var bodu = this.id.substr(4);
	var surl = "/HlasovaniRecept.ashx?a=save&id=" + cmsDetailID + "&bodu=" + bodu + "&druh=" + cmsDetailType2;
        var html = $.ajax({
            url: surl,
            type: "GET",
            dataType: "text",
            async: false
        }).responseText;
        document.getElementById("dvRecept5").innerHTML = html;
    });
    $('#dvHodnoceni img').hover(function(){
		var idx = parseInt(this.id.substr(4));
        for (i=1; i <=5; i++) {
            var r1 = idx >= i ? "_0" : "_1";
            var r2 = idx >= i ? "_1" : "_0";
            var o = document.getElementById("vote"+i);
            if (o.src.toString().indexOf(r2) == -1)
                o.src = o.src.replace(r1, r2);
        }
	},function(){
		this.src = this.src.replace('_1','_0');
	});
}
function RecVote_Out() {
    for (i=1; i <=5; i++) {
        document.getElementById("vote"+i).src = document.getElementById("vote"+i).src.replace("_1", "_0");
    }  
}
function Body_Unload() {
    try {
        if(GUnload != null) GUnload();
    } catch (e) {}
}
function OdhlasitWithBack() {
    var ret = escape(location.href);
	location.href = "/l_main.aspx?odhlasit=1&ret=" + ret;
	return false;
}
function PrihlasitWithBack() {
	var ret = escape(location.href);
	location.href = "/l_login.aspx?ret=" + ret;
	return false;
}
function DetailFirmy(sysname, id) {
    window.open("/firmadetail.aspx?id=" + id, "_blank", "width=500,height=500,scrollbars=yes");
/*    var sUrl = "FirmaDetail.ashx?id=" + id + "&sysname=" + sysname;
    var response = $.ajax({
            type: "GET",
            url: sUrl,
            dataType: "text",
            async: false
        }).responseText;
    $("p#pFirmaPerex").html(response);
*/
}
function OpenLeftMenu(idx) {
    $("div.lMenu2b:visible").hide();
    document.getElementById("lMenu2_"+idx).style.display = "block";
    return false;
}
function CheckKeywords() {
	loadXMLDoc("KlicovaSlovaClanek.ashx?t60id="+cmsDetailID, "CheckKeywords2");
}
function CheckKeywords2(text) {
	if (text != "") {
		document.getElementById("dvKeywords").innerHTML = text;
	}
}
function OnCallbackStart() {
	var d = document.createElement("DIV");
	d.style.position = "absolute";
	d.style.top = "1px";
	d.style.right = "100px";
	d.style.width = "90px";
	d.style.backgroundColor = "red";
	d.innerHTML = "loading";
	d.id = "OnCallbackStartDiv";
	document.body.appendChild(d);
}
function OnCallbackEnd() {
	var o = document.getElementById("OnCallbackStartDiv");
	if (o != null)
		document.body.removeChild(o);
}
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 loadXMLDoc(url, fce) {
	xmlDocFce = fce;
	
	req = false;
    if(window.XMLHttpRequest) {
    	try {
			req = new XMLHttpRequest();
        } catch(e) {
			req = false;
        }
    } else if(window.ActiveXObject) {
       	try {
        	req = new ActiveXObject("Msxml2.XMLHTTP");
      	} catch(e) {
        	try {
          		req = new ActiveXObject("Microsoft.XMLHTTP");
        	} catch(e) {
          		req = false;
        	}
		}
    }
    
	if (req) {
		req.onreadystatechange = processReqChange;
		req.open("GET", url, true);
		req.send("");
	}
}
function processReqChange() {
	if (req.readyState == 4) {
		if (req.status == 200) {
			eval(xmlDocFce + "(req.responseText);");
		} else {
			alert("There was a problem retrieving the data:\n" + req.statusText);
		}
	}
}
function MainSelection(idx) {
    switch (idx) {
    case "fp":
        document.getElementById("aMainSelectionFP").className = "aSelFirmy aSelFirmy1";
        document.getElementById("aMainSelectionProd").className = "aSelProd aSelProd0";
        break;
    case "prod":
        document.getElementById("aMainSelectionFP").className = "aSelFirmy aSelFirmy0";
        document.getElementById("aMainSelectionProd").className = "aSelProd aSelProd1";
        break;
    }
    $("div#dvSelFP, div#dvSelProd").toggle();
}
function SelectionProdukt() {
	var q = "";
	if (getID("tabSelectionProdukt") != null) {
		var col = getID("tabSelectionProdukt").getElementsByTagName("select");
		for (var i=0; i < col.length; i++) {
			if (col[i].value != "")
				q += "&" + col[i].id + "=" + col[i].value;
		}
		if (q != "") q = "?" + q.substr(1);
	}
	loadXMLDoc("SelectionProdukt.ashx" + q, "SelectionProdukt2");
}
function SelectionProdukt2(text) {
	document.getElementById("dvSelProd").innerHTML = text;
}
function Anketa(id81,id82) {
	xmlDocString = id81;
	loadXMLDoc("Anketa.ashx?id81=" + id81 + "&id82=" + id82, "Anketa2");
}
function Anketa2(text) {
	document.getElementById("anketa" + xmlDocString).innerHTML = text;
}
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";
document.getElementById("SPjs_DiskuseForm").style.display = "block";
}
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";
document.getElementById("SPjs_DiskuseForm").style.display = "none";
}
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_DiskuseForm").style.display = "block";
    document.getElementById("SPjs_dis_predmet").value = "";
    document.getElementById("SPjs_dis_text").value = "";
}
function SP_DiskusePreviewNew(id, message) {
    /*if (t09nick == null)
        alert(message);
    else*/
        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 = EncodeString(document.getElementById("SPjs_dis_predmet").value);
        var text = EncodeString(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();
        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("|");
}
