﻿var cook;
function DisableCSS() {
    cook = Get_Cookie("CSSDisabled");
    if (cook==null) { Set_Cookie("CSSDisabled","false","","/","",""); }
    cook = Get_Cookie("CSSDisabled");
    
    if (cook=="false") { cook = "true"; }
    else cook = "false";
    
    Set_Cookie("CSSDisabled",cook,"","/","","");
    if (document.getElementsByTagName) document.getElementsByTagName('style')[0].disabled = (cook=="true"?true:false);
    //alert("pok " + cook);
}

function LoadCSSCookie() {
    cook = Get_Cookie("CSSDisabled");
    if (cook==null) { Set_Cookie("CSSDisabled","false","","/","",""); }
    cook = Get_Cookie("CSSDisabled");
    if (document.getElementsByTagName) document.getElementsByTagName('style')[0].disabled = (cook=="true"?true:false);
}

LoadCSSCookie();

function WriteStatus() {
    if (cook=="true") {
        document.write("<a accesskey=\"v\" href=\"javascript:DisableCSS();\">Zapnout CSS</a>");
    } else {
        document.write("<a accesskey=\"v\" href=\"javascript:DisableCSS();\">Vypnout CSS</a>");
    }
}

function dss_addLoadEvent(fn) {
  if(typeof(fn)!="function")return;
  var tempFunc=window.onload;
  window.onload=function() {
    if(typeof(tempFunc)=="function")tempFunc();
    fn();
  }
}

function checkNameBox(element) {
    if (element.value=="Jméno") {
        element.value = "";
        element.onblur = function(){return function(){
            if (element.value=="") {
                element.value="Jméno";
            }
        }};
    }
}

var newwindow;
function NewWindow(field)
{
	newwindow=window.open(field.href);
	if (window.focus) {newwindow.focus()}
	return false;
}


function changeInputType(
  oldElm, // a reference to the input element
  iType, // value of the type property: 'text' or 'password'
  iValue, // the default value, set to 'password' in the demo
  blankValue, // true if the value should be empty, false otherwise
  noFocus) {  // set to true if the element should not be given focus
  if(!oldElm || !oldElm.parentNode || (iType.length<4) || 
    !document.getElementById || !document.createElement) return;
  var newElm = document.createElement('input');
  newElm.type = iType;
  if(oldElm.name) newElm.name = oldElm.name;
  if(oldElm.id) newElm.id = oldElm.id;
  if(oldElm.className) newElm.className = oldElm.className;
  if(oldElm.size) newElm.size = oldElm.size;
  if(oldElm.tabIndex) newElm.tabIndex = oldElm.tabIndex;
  if(oldElm.accessKey) newElm.accessKey = oldElm.accessKey;
  newElm.onfocus = function(){return function(){
    if(this.hasFocus) return;
    var newElm = changeInputType(this,'password',iValue,
      (this.value.toLowerCase()==iValue.toLowerCase())?true:false);
    if(newElm) newElm.hasFocus=true;
  }}();
  newElm.onblur = function(){return function(){
    if(this.hasFocus)
    if(this.value=='' || (this.value.toLowerCase()==iValue.toLowerCase())) {
      changeInputType(this,'text',iValue,false,true);
    }
  }}();
 // hasFocus is to prevent a loop where onfocus is triggered over and over again
  newElm.hasFocus=false;
  oldElm.parentNode.replaceChild(newElm,oldElm);
  if(!blankValue) newElm.value = iValue;
  if(!noFocus || typeof(noFocus)=='undefined') {
    window.tempElm = newElm;
    setTimeout("tempElm.hasFocus=true;tempElm.focus();",1);
  }
  return newElm;
}

dss_addLoadEvent(function(){
  var ua = navigator.userAgent.toLowerCase();
  if(!((ua.indexOf('konqueror')!=-1) && (document.all || 
    (ua.indexOf('khtml/3.4')!=-1))) && !(((ua.indexOf('safari')!=-1) && 
    !window.print) || (document.defaultCharset && !window.print))) {

      // Set the third value to the text you want to appear in the field.
      changeInputType(document.forms[2].password,'text','Heslo',false,true);
  }
});


function toggleLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  
  if (elem) {
      vis = elem.style;
      // if the style.display value is blank we try to figure it out here
      if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
        vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
      vis.display = (vis.display==''||vis.display=='block')?'none':'block';
  }
  
  /*
  var elem;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];    
    
    var t1A = new Tween(elem.style,'border-size',Tween.elasticEaseOut,0,50,1,'px');
    t1A.onMotionFinished = function(){alert( 'onMotionFinished' )};
    t1A.start();  
  */
}

/*
function setCSS(visible) {
    var str;
    var vyprs=new Date();
    vyprs.setDate(vyprs.getDate() - 365);
    document.cookie="CSS="+str+"; expires="+vyprs.toGMTString()+";";
    vyprs.setDate(365 + 365 + vyprs.getDate());
    str=visible; //1
    document.cookie="CSS="+str+"; expires="+vyprs.toGMTString()+";";
    //window.location.replace("data1b.htm");
}

function getCSS(){
    var cookieList=document.cookie;
    var sp = cookieList.split("=");
    if (sp[1]==true) {
        return true;
    } else return false;
};
*/

function GoBack() {
    var url = document.referrer.toLowerCase();
    
    if (url.search('karsa.cz')==-1 && url.search('localhost')==-1) {
        history.go(-1);
    }
}