// Javascript

// XML http request

var xmlHttp;
function vytvorXMLHttpRequest(){
    if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else 
        if (window.XMLHttpRequest) {
            xmlHttp = new XMLHttpRequest();
        }
}



function highlightbox(layer, id, akce){


    var box = document.getElementById(layer)
    
    if (box.style.display != "block") {
        box.style.border = '1px solid #e6e6e6';
        // box.style.height = '100px';
        box.style.display = "block";
        // box.innerHTML = 'testik';
        nahled(layer, id, akce)
    }
    
}


function dehighlightbox(){
    var boxik = document.getElementById("ajax")
    // boxik.style.height = 20;
    boxik.innerHTML = "Vyckejte nahravam podrobnosti";
    boxik.style.border = 'none';
    boxik.style.display = 'none';
    
}


function nahled(layer, id, akce){

    var dotaz = "../ajaxnahled.php?id=" + id + "&akce=" + akce + "&casznamka=" + new Date().getTime();
    vytvorXMLHttpRequest();
    
    
    xmlHttp.onreadystatechange = function(){
        zpracujZmenuStavu(layer);
    }
    xmlHttp.open("GET", dotaz, true);
    xmlHttp.send(null);
    
}

function zpracujZmenuStavu(layer){


    if (xmlHttp.readyState == 4) {
        if (xmlHttp.status == 200) {
        
        
            var boxik = document.getElementById(layer);
            
            boxik.innerHTML = xmlHttp.responseText;
            
        }
    }
}


// funkce na zobrazeni velikosti

function alertSize(){
    var myWidth = 0, myHeight = 0;
    if (typeof(window.innerWidth) == 'number') {
        // Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    }
    else 
        if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
            // IE 6+ in 'standards compliant mode'
            myWidth = document.documentElement.clientWidth;
            myHeight = document.documentElement.clientHeight;
        }
        else 
            if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
                // IE 4 compatible
                myWidth = document.body.clientWidth;
                myHeight = document.body.clientHeight;
            }
    window.alert('Width = ' + myWidth);
    window.alert('Height = ' + myHeight);
}

function getScrollXY(){
    var scrOfX = 0, scrOfY = 0;
    if (typeof(window.pageYOffset) == 'number') {
        // Netscape compliant
        scrOfY = window.pageYOffset;
        scrOfX = window.pageXOffset;
    }
    else 
        if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
            // DOM compliant
            scrOfY = document.body.scrollTop;
            scrOfX = document.body.scrollLeft;
        }
        else 
            if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
                // IE6 standards compliant mode
                scrOfY = document.documentElement.scrollTop;
                scrOfX = document.documentElement.scrollLeft;
            }
    return [scrOfX, scrOfY];
}



var typakce;
function nahled2(){
	var id_r = document.getElementById("id_r").value;
    var dotaz = "ajaxnahled.php?id=" + id_r + "&akce=doporucujeme&casznamka=" + new Date().getTime();
    vytvorXMLHttpRequest();
    xmlHttp.onreadystatechange = zpracujZmenuStavu2;
    xmlHttp.open("GET", dotaz, true);
    xmlHttp.send(null);
    
}

function zpracujZmenuStavu2(){
    if (xmlHttp.readyState == 4) {
        if (xmlHttp.status == 200) {
        	
        	$("#hide_box").fadeOut("slow", function(){          
                var boxik = document.getElementById("hide_box");
                boxik.innerHTML = xmlHttp.responseText;                	
                $("#hide_box").fadeIn("slow");     
            	});
            //dd = document.getElementById("doporuceni")
           // dd.innerHTML = xmlHttp.responseText;
            
            
            
        }
    }
}


//<!-- Copyright 2006,2007 Bontrager Connection, LLC
// http://bontragerconnection.com/ and http://willmaster.com/
// Version: July 28, 2007
var cX = 0; var cY = 0; var rX = 0; var rY = 0;

	
function UpdateCursorPosition(e){ cX = e.pageX+10; cY = e.pageY+10;}

function UpdateCursorPositionDocAll(e){ cX = event.clientX+10; cY = event.clientY+10;}

if(document.all) { document.onmousemove = UpdateCursorPositionDocAll; }
else { document.onmousemove = UpdateCursorPosition; }

function AssignPosition(dd,width,height,typakce) {
if(self.pageYOffset) {
	rX = self.pageXOffset;
	rY = self.pageYOffset;
	}
else if(document.documentElement && document.documentElement.scrollTop) {
	rX = document.documentElement.scrollLeft;
	rY = document.documentElement.scrollTop;
	
	}
else if(document.body) {
	rX = document.body.scrollLeft;
	rY = document.body.scrollTop;
	}
if(document.all) {
	cX += rX; 
	cY += rY;
	}
var pozX = cX;
var pozY = cY;

 var sirkaobr = document.documentElement.clientWidth;
 var vyskaobr = document.documentElement.clientHeight;
 
if(typakce == "showimg"){
	pozX = pozX - width - 20;
	pozY = pozY+10;
	
	if((pozY+height) > vyskaobr) {
		pozY = pozY - height;
	}
}

if(typakce == "text"){
	pozX = cX+10;
	pozY = cY+10;
	
	if((pozY+height) > vyskaobr) {
		pozY = cY - height;
	}
}


dd.style.left = (pozX) + "px";
dd.style.top = (pozY) + "px";


}
function HideContent(layer) {
if(layer.length < 1) { return; }
document.getElementById(layer).style.display = "none";
document.getElementById(layer).innerHTML = "Nahravam podrobnosti"
}
function ShowContent(layer,id) {
if(layer.length < 1) { return; }
var dd = document.getElementById(layer);
AssignPosition(dd);
dd.style.display = "block";
}
function ReverseContentDisplay(layer) {
if(layer.length < 1) { return; }
var dd = document.getElementById(layer);
AssignPosition(dd);
if(dd.style.display == "none") { dd.style.display = "block"; }
else { dd.style.display = "none"; }
}

var xmlHttp;

function vytvorXMLHttpRequest() {
  if (window.ActiveXObject) {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
  else if (window.XMLHttpRequest) {
    xmlHttp = new XMLHttpRequest();
  }
}
var typakce;
function nahled3(layer,id,akce){
	dd = document.getElementById("ajax")
 	AssignPosition(dd);
	dd.style.display = "block";
  	var dotaz = "ajaxnahled.php?id="+id+"&akce="+akce+"&casznamka="+ new Date().getTime();
  	vytvorXMLHttpRequest();
  	typakce = akce;
  xmlHttp.onreadystatechange = zpracujZmenuStavu3;
  xmlHttp.open("GET", dotaz, true);
  xmlHttp.send(null);

}

function zahajPozadavek() {
  vytvorXMLHttpRequest();
  xmlHttp.onreadystatechange = zpracujZmenuStavu;
  xmlHttp.open("GET", dotaz, true);
  xmlHttp.send(null);
}

function zpracujZmenuStavu3() {
  if(xmlHttp.readyState == 4) {
    if(xmlHttp.status == 200) {
    dd = document.getElementById("ajax")
    dd.innerHTML = xmlHttp.responseText;
	var width 
	var height 
    width = dd.offsetWidth;
    height = dd.offsetHeight;

 	AssignPosition(dd, width, height,typakce );
// dd.style.display = "block";
    
    
// number = number + 1;
// setTimeout("nahled('ajax',cislo,'showimg',number)",10000);

	
    }
  }
}







function nahled4(layer,id,akce){
	dd = document.getElementById("overDiv")
 	AssignPosition(dd);
	dd.style.display = "block";
  	var dotaz = "ajaxnahled.php?id="+id+"&akce="+akce+"&casznamka="+ new Date().getTime();
  	vytvorXMLHttpRequest();
  	typakce = akce;
  xmlHttp.onreadystatechange = zpracujZmenuStavu4;
  xmlHttp.open("GET", dotaz, true);
  xmlHttp.send(null);

}

function zahajPozadavek() {
  vytvorXMLHttpRequest();
  xmlHttp.onreadystatechange = zpracujZmenuStavu;
  xmlHttp.open("GET", dotaz, true);
  xmlHttp.send(null);
}

function zpracujZmenuStavu4() {
  if(xmlHttp.readyState == 4) {
    if(xmlHttp.status == 200) {
    
// xmlHttp.responseText;
	overlib(xmlHttp.responseText, VAUTO, HAUTO);
// dd.style.display = "block";
    
    
// number = number + 1;
// setTimeout("nahled('ajax',cislo,'showimg',number)",10000);

	
    }
  }
}

// ////////////////////////////////////////////////////////////////
// qTip - CSS Tool Tips - by Craig Erskine
// http://qrayg.com | http://solardreamstudios.com
//
// Inspired by code from Travis Beckham
// http://www.squidfingers.com | http://www.podlob.com
// ////////////////////////////////////////////////////////////////

/*
 * var qTipTag = "a"; //Which tag do you want to qTip-ize? Keep it lowercase!//
 * var qTipX = -30; //This is qTip's X offset// var qTipY = 25; //This is qTip's
 * Y offset//
 * 
 * //There's No need to edit anything below this line// tooltip = { name :
 * "qTip", offsetX : qTipX, offsetY : qTipY, tip : null }
 * 
 * tooltip.init = function () { var tipNameSpaceURI =
 * "http://www.w3.org/1999/xhtml"; if(!tipContainerID){ var tipContainerID =
 * "qTip";} var tipContainer = document.getElementById(tipContainerID);
 * 
 * if(!tipContainer) { tipContainer = document.createElementNS ?
 * document.createElementNS(tipNameSpaceURI, "div") :
 * document.createElement("div"); tipContainer.setAttribute("id",
 * tipContainerID);
 * document.getElementsByTagName("body").item(0).appendChild(tipContainer); }
 * 
 * if (!document.getElementById) return; this.tip = document.getElementById
 * (this.name); if (this.tip) document.onmousemove = function (evt)
 * {tooltip.move (evt)};
 * 
 * var a, sTitle; var anchors = document.getElementsByTagName (qTipTag);
 * 
 * for (var i = 0; i < anchors.length; i ++) { a = anchors[i]; sTitle =
 * a.getAttribute("title"); if(sTitle) { a.setAttribute("tiptitle", sTitle);
 * a.removeAttribute("title"); //a.onmouseover = function()
 * {tooltip.show(this.getAttribute('tiptitle'))}; a.onmouseover = function()
 * {tooltip.show(this.getAttribute('tiptitle'))}; a.onmouseout = function()
 * {tooltip.hide()}; } } }
 * 
 * tooltip.move = function (evt) { var x=0, y=0; if (document.all) {//IE x =
 * (document.documentElement && document.documentElement.scrollLeft) ?
 * document.documentElement.scrollLeft : document.body.scrollLeft; y =
 * (document.documentElement && document.documentElement.scrollTop) ?
 * document.documentElement.scrollTop : document.body.scrollTop; x +=
 * window.event.clientX; y += window.event.clientY; } else {//Good Browsers x =
 * evt.pageX; y = evt.pageY; } this.tip.style.left = (x + this.offsetX) + "px";
 * this.tip.style.top = (y + this.offsetY) + "px"; }
 * 
 * tooltip.show = function (text) { if (!this.tip) return; this.tip.innerHTML =
 * text; this.tip.style.display = "block"; }
 * 
 * 
 * 
 * tooltip.hide = function () { if (!this.tip) return; this.tip.innerHTML = "";
 * this.tip.style.display = "none"; }
 * 
 * window.onload = function () { tooltip.init (); }
 */

function antispam(email, predmet){
	
	var real_email = str_replace(email, '(zavinac)', '@');
	
	// alert('mailto:'+real_email+predmet)
	window.location = 'mailto:'+real_email+predmet;
}

function str_replace(haystack, needle, replacement) {
    var temp = haystack.split(needle);
    return temp.join(replacement);
}



function fbs_click(){
	u = location.href;
	t = document.title;
	window.open('http://www.facebook.com/sharer.php?u=' + encodeURIComponent(u) + '&t=' + encodeURIComponent(t), 'sharer', 'toolbar=0,status=0,width=626,height=436');
	return false;
}
       

function showDeveloperList(div){
	
	var divbox = document.getElementById(div);
	
	
	
		if(divbox.style.height == '0px' || divbox.style.height == 0 || divbox.style.height == '0pt'){
		divbox.style.height = 'auto';
		divbox.style.visibility = 'visible';
		divbox.style.overflow = 'visible';
		} else {
			divbox.style.height = '0';
			divbox.style.visibility = 'hidden';
			divbox.style.overflow = 'hidden';
			
		}

}

// Google adresa

function vloz_adresu(){

	var id_op = document.getElementById('id_reality').selectedIndex;
	var id = document.getElementById('id_reality').options[id_op].value;
	
    var dotaz = "../ajaxnahled.php?id=" + id + "&akce=vloz_adresu_google&casznamka=" + new Date().getTime();
    vytvorXMLHttpRequest();
    
    
    xmlHttp.onreadystatechange = function(){
        zpracujZmenuStavu5();
    }
    xmlHttp.open("GET", dotaz, true);
    xmlHttp.send(null);
    
}

function zpracujZmenuStavu5(){


    if (xmlHttp.readyState == 4) {
        if (xmlHttp.status == 200) {
        
            document.getElementById("address").value = xmlHttp.responseText;
            
        }
    }
}
