function getObject(ObjectId){
	if (document.getElementById){ return document.getElementById(ObjectId);
	} else {
		if (document.all){
			return document.all(ObjectId);
		} else {
			return false
		}
	}
}
function getWidth() {
	if (navigator.userAgent.indexOf("Opera") > -1 || Boolean(!document.documentElement.clientWidth)) {
		return document.body.clientWidth
	} else {
		if (document.documentElement.clientWidth){
			return document.documentElement.clientWidth
		} else {
			return document.innerWidth
		}
	}
}
function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}
function getDocWidth() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollWidth, D.documentElement.scrollWidth),
        Math.max(D.body.offsetWidth, D.documentElement.offsetWidth),
        Math.max(D.body.clientWidth, D.documentElement.clientWidth)
    );
}
function getScrollX() {
  var scrOfX = 0
  if( typeof( window.pageXOffset ) == 'number' ) {
    //Netscape compliant
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft ) ) {
    //DOM compliant
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft ) ) {
    //IE6 standards compliant mode
    scrOfX = document.documentElement.scrollLeft;
  }
  return scrOfX;
}
function getScrollY() {
  var scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
  } else if( document.body && ( document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
  } else if( document.documentElement && ( document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
  }
  return scrOfY;
}

function getWinWidth() {
  var myWidth = 0
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  return myWidth;
}
function getWinHeight() {
  var myHeight = 0;
  if( typeof( window.innerHeight ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}


function intval( mixed_var, base ) {
    var tmp;
 
    var type = typeof( mixed_var );
 
    if(type == 'boolean'){
        if (mixed_var == true) {
            return 1;
        } else {
            return 0;
        }
    } else if(type == 'string'){
        tmp = parseInt(mixed_var * 1);
        if(isNaN(tmp) || !isFinite(tmp)){
            return 0;
        } else{
            return tmp.toString(base || 10);
        }
    } else if(type == 'number' && isFinite(mixed_var) ){
        return Math.floor(mixed_var);
    } else{
        return 0;
    }
}
function isNumeric(sText)

{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
}
function str_replace(search, replace, subject) {
    var s = subject;
    var ra = r instanceof Array, sa = s instanceof Array;
    var f = [].concat(search);
    var r = [].concat(replace);
    var i = (s = [].concat(s)).length;
    var j = 0;
    
    while (j = 0, i--) {
        if (s[i]) {
            while (s[i] = (s[i]+'').split(f[j]).join(ra ? r[j] || "" : r[0]), ++j in f){};
        }
    }
 
    return sa ? s : s[0];
}
function strlen (string) {
 
    var str = string+'';
    var i = 0, chr = '', lgth = 0;
 
    var getWholeChar = function (str, i) {
        var code = str.charCodeAt(i);
        var next = '', prev = '';
        if (0xD800 <= code && code <= 0xDBFF) { // High surrogate(could change last hex to 0xDB7F to treat high private surrogates as single characters)
            if (str.length <= (i+1))  {
                throw 'High surrogate without following low surrogate';
            }
            next = str.charCodeAt(i+1);
            if (0xDC00 > next || next > 0xDFFF) {
                throw 'High surrogate without following low surrogate';
            }
            return str[i]+str[i+1];
        } else if (0xDC00 <= code && code <= 0xDFFF) { // Low surrogate
            if (i === 0) {
                throw 'Low surrogate without preceding high surrogate';
            }
            prev = str.charCodeAt(i-1);
            if (0xD800 > prev || prev > 0xDBFF) { //(could change last hex to 0xDB7F to treat high private surrogates as single characters)
                throw 'Low surrogate without preceding high surrogate';
            }
            return false; // We can pass over low surrogates now as the second component in a pair which we have already processed
        }
        return str[i];
    };
 
    for (i=0, lgth=0; i < str.length; i++) {
        if ((chr = getWholeChar(str, i)) === false) {
            continue;
        } // Adapt this line at the top of any loop, passing in the whole string and the current iteration and returning a variable to represent the individual character; purpose is to treat the first part of a surrogate pair as the whole character and then ignore the second part
        lgth++;
    }
    return lgth;
}
function strpos( haystack, needle, offset){
    var i = haystack.indexOf( needle, offset ); // returns -1
    return i >= 0 ? i : false;
}
function is_numeric( mixed_var ) {
    return !isNaN( mixed_var );
}

function substr1( f_string, f_start, f_length ) {
    f_string += '';
 
    if(f_start < 0) {
        f_start += f_string.length;
    }
 
    if(f_length == undefined) {
        f_length = f_string.length;
    } else if(f_length < 0){
        f_length += f_string.length;
    } else {
        f_length += f_start;
    }
 
    if(f_length < f_start) {
        f_length = f_start;
    }
 
    return f_string.substring(f_start, f_length);
}
function formatNum(num, char){
	if(isNumeric(num)){
		end = "";
		
		while(strlen(num) > 3){
			tmp = substr1(num, strlen(num) - 3, 3);

			if(!end){
				end = tmp;	
			} else {
				end = tmp + char + end;
			}
			num = substr1(num, 0, strlen(num)-3);
			
		}
		end = num + char + end;
		
		return end;	
	} else {
		return num;	
	}
}

function getChild(node){
	if (node.firstChild) node = node.firstChild;
	else return false;
	while(node.nodeName == "#text"){
		if (node.nextSibling) node = node.nextSibling;
		else return false;
	}
	return node;
}

function getNext(node){
	if (node.nextSibling) node = node.nextSibling;	
	else return false;
	while(node.nodeName == "#text"){
		if (node.nextSibling) node = node.nextSibling;	
		else return false;
	}
	return node;
}
function getPrev(node){
	if (node.previousSibling) node = node.previousSibling;	
	else return false;
	while(node.nodeName == "#text"){
		if (node.previousSibling) node = node.nextSibling;	
		else return false;
	}
	return node;
}

function insertFlash(file, width, height, className, id){
	document.write("<OBJECT CLASSID=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" CODEBASE=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0\" class=\""+className+"\" id=\""+id+"\" WIDTH=\""+width+"\" HEIGHT=\""+height+"\"> <PARAM NAME=movie VALUE=\""+file+"\"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#ffffff> <param name=\"wmode\" value=\"transparent\" /><EMBED  wmode=\"transparent\" SRC=\""+file+"\" QUALITY=high BGCOLOR=#ffffff WIDTH=\""+width+"\" HEIGHT=\""+height+"\" TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\"> </EMBED></OBJECT>");
}


var arrTimerA;
var objectA;
var leftPosA;
var dA;
var incA;
var overA;

function showArrow(obj, img, d){
	d = 1.3;
	if(overA != true){
		overA = true;
		dA = d;
		objectA = obj;
		obj.style.backgroundImage = "url("+img+")";
		objectA.style.backgroundPosition = "-17px center";
		leftPosA = -16;
		incA = 2;
		arrTimerA = setInterval("slideArr()", 20);
	}
}
function slideArr(){
	if(leftPosA >= 0){
		objectA.style.backgroundPosition = "left center";		
		clearInterval(arrTimerA);
	} else {
		objectA.style.backgroundPosition = leftPosA + "px center";
		leftPosA = leftPosA + incA;
		incA = intval(incA*dA);
	}
}
function hideArrow(obj){
		objectA.style.backgroundImage = "none";
		clearInterval(arrTimerA);
		overA = false;
}

var tipCount = 1;
var anime = false;
function nextTip(){
	if(anime == false){
		anime = true;
	
		tip2id = (tipCount > 2 ? 1 : tipCount+1);	
		
		var tip1 = getObject('tip' + tipCount);
		var tip2 = getObject('tip' + tip2id);
		
		tipCount = (tipCount > 2 ? 1 : tipCount+1);
	
		tip1.style.zIndex = 2;
		tip2.style.zIndex = 1;
	
		tip2.style.opacity = 1;
		tip2.style.MozOpacity = 1;
		tip2.style.KhtmlOpacity = 1;
		tip2.style.filter = "alpha(opacity=100)";
	
		
			opacity(tip1, 100, 0, 500);

			if(tipCount == 1){
				getObject('tipOdm').style.display = "block";
			} else {
				getObject('tipOdm').style.display = "none";
			}
		anime = false;
		
	}
}


var fadeObj1;

function opacity(obj, opacStart, opacEnd, millisec) {
	fadeObj1 = obj;
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 1;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ")",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ")",(timer * speed));
            timer++;
        }
    }
}
function changeOpac(opacity) {
    var object = fadeObj1.style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

function showMailForm(){
	var opacit = 0;
	getObject('mailform').style.top = ((getWinHeight()/2) + getScrollY() - 160) + "px";
	getObject('mailform').style.left = ((getWinWidth()/2) + getScrollX() - 246) + "px";

	divBg = getObject('mailFormBg');
	divBg.style.width = getDocWidth() + "px";
	divBg.style.height = getDocHeight() + "px";

    divBg.style.opacity = (opacit / 100);
    divBg.style.MozOpacity = (opacit / 100);
    divBg.style.KhtmlOpacity = (opacit / 100);
    divBg.style.filter = "alpha(opacity=" + opacit + ")";

	divBg.style.display = "block";


	getObject('formBlackBg').onmousedown = function() { opacity(getObject('mailFormBg'), 100, 0, 300); setTimeout("getObject('mailFormBg').style.display = 'none'", 300); }

	opacity(getObject('mailFormBg'), 0, 100, 300);
}
function sendMail(){
		if(getObject("itext").value == ""){
			alert("Vyplňte prosím text zprávy.");
			return;
		}
		if(getObject("ijmeno").value == ""){
			alert("Vyplňte prosím jméno.");
			return;
		}
		if(getObject('imail').value == "" || strpos(getObject('imail').value, '.') == false || strpos(getObject('imail').value, '@') == false || strlen(getObject('imail').value) < 3){
			alert("Vyplňte prosím správně email.");
			return;		
		}
		if(getObject('itelefon').value == "" || !is_numeric(getObject('itelefon').value) || strlen(getObject('itelefon').value) != 9){
			alert("Vyplňte prosím správně telefon.");
			return;					
		}
		getObject("mailfrm").submit();
}

function showPoslete(left){
	var opacit = 0;
	getObject('poslete_dal').style.left = ((getWinWidth()/2) + getScrollX() - 67 - left) + "px";

	divBg = getObject('mailFormBg2');
	divBg.style.width = getDocWidth() + "px";
	divBg.style.height = getDocHeight() + "px";
	
    divBg.style.opacity = (opacit / 100);
    divBg.style.MozOpacity = (opacit / 100);
    divBg.style.KhtmlOpacity = (opacit / 100);
    divBg.style.filter = "alpha(opacity=" + opacit + ")";

	divBg.style.display = "block";

	getObject('formBlackBg2').onmousedown = function() { opacity(getObject('mailFormBg2'), 100, 0, 300); setTimeout("getObject('mailFormBg2').style.display = 'none'", 300); }

	opacity(getObject('mailFormBg2'), 0, 100, 300);
}
function posleteDal(){
		if(getObject('pemail').value == "" || strpos(getObject('pemail').value, '.') == false || strpos(getObject('pemail').value, '@') == false || strlen(getObject('pemail').value) < 3){
			alert("Vyplňte prosím správně email.");
			return;		
		}
		getObject('formdal').submit();
}

function clearInpText(obj, text){
	if(obj.value == text){
		if(text == "Váš @ email"){
			obj.value = "@";			
		} else {
			obj.value = "";
		}
	} else if (obj.value == "" || obj.value == "@"){
		obj.value = text;
	}
	
}

// =========================================== SLEDOVANE =========================================== >
var xmlhttp;
function GetXmlHttpObject(){
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}

function stateChanged(id, action){
	if (xmlhttp.readyState==4){
		if(action == "add"){
			var newP = document.createElement('p');
			newP.id = "sled-container" + id;
			newP.innerHTML = xmlhttp.responseText;
			
			getObject('sledovane').appendChild(newP);
		} else if (action == "rem") {
			getObject('sledovane').removeChild(getObject('sled-container'+id));
		}
		
	}
}

function setOcicko(id){
	xmlhttp=GetXmlHttpObject();

	if (xmlhttp==null){
		alert ("Váš prohlížeè nepodporuje XMLHTTP!");
		return;
  	}

	if(getObject('ocicko'+id).className == 'ocicko'){
		var url="/sledovane.php";
		url=url+"?id="+id;
		url=url+"&action=add";
		url=url+"&sid="+Math.random();
		getObject('ocicko'+id).className = "ocicko-sel";
		action = "add";
	} else {
		var url="/sledovane.php";
		url=url+"?id="+id;
		url=url+"&action=rem";
		url=url+"&sid="+Math.random();
		getObject('ocicko'+id).className = "ocicko";
		action = "rem";
	}
	
	xmlhttp.onreadystatechange= function(){ stateChanged(id, action); }
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

// ================================================================================================= >
