/**
 * Read the JavaScript cookies tutorial at:
 *   http://www.netspade.com/articles/javascript/cookies.xml
 */

/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

/*


*/

var SERVER;

function setServer(ser) {
   SERVER=ser;
}

function moveHlpWin(what) {
   try {
      hlpW=document.getElementById("hlp_win_iframe");
     
      w_state=getCookie("display");
      if(w_state==1) {
         hide(hlpW);
         what.style.backgroundImage='url("'+SERVER+'web_kult/css/img/win_max.jpg")';
      } else {
         
         show(hlpW);
         what.style.backgroundImage='url("'+SERVER+'web_kult/css/img/win_min.jpg")';
      };
         swapCookies("display");
   } catch (e) {
}
}

function displayKomentare(ieid) {
   try {
     komV=document.getElementById("vyber_z_komentaru");
     komW=document.getElementById("komentare");
     komZ=document.getElementById("komentare_zobrazit");
     w_state=(komW.style.display=="none");
     if(w_state==false) {
       hide(komW);
       show(komZ); 
       show(komV); 
     } else {
       show(komW);
       hide(komZ); 
       hide(komV); 
     };
   } catch (e) {
   }
}

function swapCookies(name) {
   x=getCookie(name);
   if(x=="1") {
      x="0";
   } else {
      x="1";
   };
   setCookie(name,x,false,"/");
}

function show(what) {
   what.style.display="inline";
}

function hide(what) {
   what.style.display="none";
}


function readKomentarState() {
  try{
     komV=document.getElementById("vyber_z_komentaru");
     komW=document.getElementById("komentare");
     w_state=getCookie("displaykom");
     komZ=document.getElementById("komentare_zobrazit");
     if(w_state==1) {
        show(komW);
        hide(komZ);
        hide(komV);
        setCookie("displaykom",0,false,"/");
     } else {
        hide(komW);
        show(komZ); 
        show(komV); 
     };
  } catch (e) {
  };
}


function oknoZCookie() {
  try{
     hlpW=document.getElementById("hlp_win_iframe");
     hlpW.style.display="inline";
     w_state=getCookie("display");
     what=document.getElementById("hlp_win_tlacitko");
     if(w_state==1) {
         show(hlpW);
         what.style.backgroundImage='url("'+SERVER+'web_kult/css/img/win_min.jpg")'; 
      } else {
         hide(hlpW);
         what.style.backgroundImage='url("'+SERVER+'web_kult/css/img/win_max.jpg")'; 
      };
      
  } catch (e) {
  
  };
  
}



function checkmail(mail) {
	var pattern=/^[^\.][a-zA-Z0-9_\.\-]+@[a-zA-Z0-9_\.\-]+\.[a-z]{1,3}[^\.]$/;
	return pattern.test(mail);		  
} //checkmail

function overKomentar() {
         with(document.komentform) {
                                 if (k_jmeno.value =="") {
                                    alert("Prosím zadejte vaše jméno!");
                                    k_jmeno.focus();
                                    return false;
                                 }
                                 if (k_text.value =="") {
                                    alert("Prosím zadejte text komentáře!");
                                    k_text.focus();
                                    return false;
                                 }
                                 if ((!checkmail(k_email.value))&&(k_email.value.length>1))  {
                                    alert("Zadejte platný e-mail, anebo nezadávejte žádnej!");
                                    k_email.focus();
                                    return false;
                                 }
         }
         setCookie("displaykom",1,false,"/");
         return true;
}


//window.status="cook loaded";
