function main () {
velikost_pisma('s');

if (odrolovani) {
odroluj( 0, 400);
}

return true;
}


function checkAnsform(objednavatel,mail){

if( objednavatel==""){ 
window.alert("Prosím vyplňte jméno objednavatele");
return false;
}
else if ( mail=="@" || mail==""){
window.alert("Prosím vyplňte kontaktní e-mail");
return false;
}
else { 
return true;
}

}
// test pro odeslani formu
function mailtry(mail) {

if (mail == "./images/email_ok.gif") {
 } else {
  alert("Musíte vyplnit platnou e-mailovou adresu");
  return false;
 }

}
// test pro odeslani formu - kupodivu zase
function mailtry2(jmeno, text) {

if( jmeno==""){ 
window.alert("Prosím vyplňte jméno");
return false;
}
else if ( text==""){
window.alert("Prosím vyplňte reakci");
return false;
}
else { 
return true;
}

}

// funkce pro zmenu obrazku pri validnim mailu - prvni ajax
function validation(val, send) {
if (val=="yop") {document.images['validationPicture'].src = './images/email_ok.gif';
if (send == 'yes') {document.forms.ansform.submit();}
}
else {document.images['validationPicture'].src = './images/email_pozor.gif'; 
if (send == 'yes') { window.alert('Musíte vyplnit platnou e-mailovou adresu'); }
}
}

// tohle je tedy konecne ten ajax
function check(text, send) {
        var http_request = false;
        var request = "string="+ text;

        
       if (window.XMLHttpRequest) {
            http_request = new XMLHttpRequest();       
        } else if (window.ActiveXObject) {
            try {
              http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (eror) {
              http_request = new ActiveXObject("Microsoft.XMLHTTP");
            }
        }

        http_request.onreadystatechange = function() { zpracuj(http_request, send);};
        http_request.open('POST', './script/mail_test.php', true);
        http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        http_request.send(request);
   
   }

    function zpracuj(http_request, send) {
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
               validation (http_request.responseText, send);
            } else {
                alert('Chyba');
                return false;
            }
        }
    }
  
function checkSimilar( m, m2){
if( m == m2 ){ valid = "yop"; } else { valid = "nop"; }

if (valid == "yop") {document.images['validationPicture2'].src = './images/email_ok.gif';
return valid;
}
else {document.images['validationPicture2'].src = './images/email_pozor.gif'; 
return valid;
}
}    
    
// check formu s lektory    
function photo_form_check(jmeno,foto) {
inp = foto;
pripona=/jpg/;
pripona2=/jpeg/;
pripona3=/pjpg/;
pripona4=/JPG/;
if (pripona.test(inp)==true || pripona2.test(inp)==true || pripona3.test(inp)==true || pripona4.test(inp)==true ) {
if (jmeno !="") {return true;
} else {alert('musíte vyplnit jméno lektora');return false; }
}else {
alert('uploadovaný soubor musí být ve formátu jpg');
return false; 
}
}

function login() {

username = document.getElementById('log01').value;
pass = document.getElementById('log02').value;
if (username == "") {document.getElementById('log01').value = "Vyplňte jméno"; return false;}
if (pass == "") {window.alert('Nesprávné heslo'); return false;}

document.forms.loginform.submit();


return false;
}

function erase (id) {
document.getElementById(id).value = "";
return true;
}

function messages(msg) {
if(msg !="" ) {

switch (msg) {

case "heslo":
mSg = "Zadali jste špatné uživatelské heslo";
break;

case "ok":
mSg = "Váš požadavek proběhl úspěšně";
break;

default:
mSg = "Váš požadavek proběhl úspěšně";
}
alert(mSg);
}
return true;
}
/* addfavorite ------------------------------( není moje dílo)-----------------------------------------*/
function AddFavorite(linkObj,addUrl,addTitle) 
{ 
  if (document.all && !window.opera) 
  { 
    window.external.AddFavorite(addUrl,addTitle); 
    return false; 
  } 
  else if (window.opera && window.print) 
  { 
    linkObj.title = addTitle; 
    return true; 
  } 
  else if ((typeof window.sidebar == 'object') && (typeof window.sidebar.addPanel == 'function')) 
  { 
    if (window.confirm('Přidat oblíbenou stránku jako nový panel?')) 
    { 
      window.sidebar.addPanel(addTitle,addUrl,''); 
      return false; 
    } 
  } 
  window.alert('Po potvrzení stiskněte CTRL+D,\nstránka bude přidána k vašim oblíbeným odkazům.'); 
  return false; 
}
/* velikost pisma ----------------------------------------------------------------------------*/
function velikost_pisma(velikost) {
s = "off"; m = "off"; l = "off";

if(!velikost) {velikost = 's';}

if(velikost == 's') {velikost = 13; s = "on"; }
if(velikost == 'm') {velikost = 16; m = "on"; }
if(velikost == 'l') {velikost = 18; l = "on"; }


P_id = document.getElementById("hlavni_obsah_center");
P_id.style.fontSize = velikost + "px";


trida = getElementsByClassName('velikost_sm');
trida.style.background = "url('./images/text_small_" + s +".png')";

trida2 = getElementsByClassName('velikost_md');
trida2.style.background = "url('./images/text_med_" + m +".png')";

trida3 = getElementsByClassName('velikost_bg');
trida3.style.background = "url('./images/text_big_" + l +".png')";
}

/* scroll ----------------------------------------------------------------------------*/
function odroluj( zac, kon) {
zacatek = zac; konec = kon;

if(zacatek < konec) {
window.scrollTo(0, zacatek);
zacatek = zacatek + 399;
window.setTimeout('odroluj(zacatek, konec);', 0.001);
  }
}

/* slideform ----------------------------------------------------------------------------*/

function slideform(zmizet, objevit){

Iid1 = document.getElementById(zmizet);
Iid1.style.display = 'none'; 

Iid2 = document.getElementById(objevit);
Iid2.style.display = 'inline'; 

}

/* image preload script */
function imagePreload(){
if (document.images)
{ 
  pic1.src=""; 
  pic2.src=""; 
  pic3.src=""; 
}
}
/* pdf cereator */
function createPdf(o2){
window.location.href="./script/pdf.php?o2="+o2;
}

/* share button hoover */
function changeShareButton(state){
shb1 = document.getElementById('shareButton');
shb2 = document.getElementById('shareButton2');

if(state == "on") { 
shb1.style.color = '#97C000'; 
shb2.src = "./images/icons/sdil_on.png";
shb2.style.marginRight = '-1px';

 } else {  
shb1.style.color = '#BBBBBF'; 
shb2.src = "./images/icons/sdil_off.png"; 
shb2.style.marginRight = '0';
 }

return true;
}

/* text lenght */
function checkTextLenght(id, impId, Maxlength) {
imput = document.getElementById(impId);
imputValue = imput.value;
area = document.getElementById(id).value.length;
imput.value = Maxlength - area;
if ( (Maxlength - area) < 1 ) { alert('Povolený počet znaků byl překročen;'); return false;} else {
return true;}

}

