// ===========================================================================
function change_imag(url) {
    if (i = document.getElementById('r-logo'))
       i.src = url; 
}
//==============================================================
function test_info(ID) {
Pocet = 0;
  for(i=1; i<26; i++){
   if ( document.getElementById('Nab_'+i).checked) Pocet ++;
   if ( Pocet > 3) {
    ID.checked= false;
    alert (" Muzete zaskrtnout pouze 3 kategorie \n\n You can mark only 3 categorie" );
    return;
   }
  }
}
//==============================================================
function test_info_p(ID) {
Pocet = 0;
  for(i=1; i<26; i++){
   if ( document.getElementById('Pop_'+i).checked) Pocet ++;
   if ( Pocet > 3) {
    ID.checked= false;
    alert (" Muzete zaskrtnout pouze 3 kategorie \n\n You can mark only 3 categorie" );
    return;
   }
  }
}
//==============================================================
function test_info_pu(ID) {
Pocet = 0;
  for(i=1; i<26; i++){
   if ( document.getElementById('Pop_pu'+i).checked) Pocet ++;
   if ( Pocet > 3) {
    ID.checked= false;
    alert (" Muzete zaskrtnout pouze 3 kategorie \n\n You can mark only 3 categorie" );
    return;
   }
  }
}
//document.getElementById("Jmeno").focus();
//document.f.Jmeno.focus();
//==============================================================
function test_napiste(){

    Text = "";
    err  = 0;
    
    if (document.getElementById("Jmeno_").value == ""){err=1; Text+='\n Je nutné zadat pložku Jméno.';}
    if (document.getElementById("Prijmeni").value == ""){err=1; Text+='\n Je nutné zadat pložku Příjmení.';}
    if (document.getElementById("Email").value == "") {err = 1; Text+='\n Je nutné zadat pložku Email.';}
    if (checkEmail(document.getElementById("Email").value)== false)  { err = 1; Text+='\n Je nutné správne zadat pložku Email.';}
    if (document.getElementById("Mesto").value == ""){err=1; Text+='\n Je nutné zadat pložku Město.';}

    if (err == 1){
       alert(Text)
     } else {
       document.f.submit()
     }
}

// ===========================================================================
function test_new_user(x){

  Text = "";
  err  = 0;
  
  if ( document.getElementById("Jmeno_new_user").value == "" ){ err = 1; Text += '\n Je nutné zadat pložku Jméno \n(Můžete zadat i Vaši přezdívku).'; }
  if ( document.getElementById("Email_new_user").value == "" ){ err = 1; Text += '\n Je nutné zadat pložku Email.'; }
  if ( document.getElementById("Dic_").value == "" )          { err = 1; Text += '\n Je nutné zadat pložku Dič.'; }
  if ( document.getElementById("Ic_").value == "" )           { err = 1; Text += '\n Je nutné zadat pložku Ič.'; }
  
  if ( document.getElementById("Firma_").value == "" )        { err = 1; Text += '\n Je nutné zadat pložku Název firmy.'; }
  if ( document.getElementById("Anotace").value == "" )       { err = 1; Text += '\n Je nutné zadat pložku Zkrácený popis firmy.'; }
  if ( document.getElementById("Firma_popis").value == "" )   { err = 1; Text += '\n Je nutné zadat pložku Podrobný popis firmy.'; }
  if ( document.getElementById("Mesto_").value == "" )        { err = 1; Text += '\n Je nutné zadat pložku Město.'; }
  if ( document.getElementById("Ulice_").value == "" )        { err = 1; Text += '\n Je nutné zadat pložku Ulice.'; }
  if ( document.getElementById("Psc_").value == "" )          { err = 1; Text += '\n Je nutné zadat pložku PSČ.'; }
  if ( document.getElementById("Email_").value == "" )        { err = 1; Text += '\n Je nutné zadat pložku Email.'; }
  if ( document.getElementById("Telefon_").value == "" )      { err = 1; Text += '\n Je nutné zadat pložku Telefon.'; }
  if (x == 1) {
    if ( document.getElementById("kontrola").value == "" )      { err = 1; Text += '\n Je nutné opsat Kontrolní kod .'; }
  }
  
  if (err == 1) {
     alert (Text);
  } else {
     document.For.submit();
   }
}

// ===========================================================================
function zobrazit(id){
if (document.getElementById(id).style.display == "") {
   document.getElementById(id).style.display = "none";
}else {
   document.getElementById(id).style.display = "";
   }
}
// ===========================================================================
function test_login(){

Text = "";
err  = 0;

if (document.getElementById("imapuser").value   == "") {err = 1; Text+='\n Je nutné zadat pložku Jméno.'; }
if (document.getElementById("pass").value       == "") {err = 1; Text+='\n Je nutné zadat pložku Heslo.'; }

if (err == 1){
   Err(Text);
 } else {
  document.Fo.submit();
 }
}
// --------------------------------
function Err(Text) {
   window.alert(Text)
 }
function checkEmail(Text) {
  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(Text)) {
      return (true)
  }
 return (false)
}
// ===========================================================================
function add_Favorite(){
 var wdt = window.document.title;
 var cookieDate = new Date;

 cookieDate.setTime (cookieDate.getTime()+ 360 * 24 * 60 * 60 * 1000);

 if(window.sidebar) {
     window.sidebar.addPanel(wdt,"http://www.b2b-gate.com","");
     document.cookie = "add_Favorite=1;expires=" + cookieDate.toGMTString();
  } else {
     if(window.external) {
         window.external.AddFavorite("http://www.b2b-gate.com",wdt);
         document.cookie = "add_Favorite=1;expires=" + cookieDate.toGMTString();
     } else {
         if(window.opera&&window.print) {
           alert("Pro ulo\u017een\xed www.b2b-gate.com do obl\xedben\xfdch stiskn\u011bte CTRL + D!");
         }
    }
  }
}
// ===========================================================================
function set_home_page(){
 var cookieDate = new Date;
 cookieDate.setTime (cookieDate.getTime()+ 360 * 24 * 60 * 60 * 1000);

 if(navigator.appName != "Netscape") {
  document.body.style.behavior="url(#default#homepage)";
  document.body.setHomePage("http://www.b2b-gate.com");
  document.cookie = "set_home_page=1;expires=" + cookieDate.toGMTString();
 }
}
// ===========================================================================
function Err(Text){
window.alert(Text)
}
// ===========================================================================
function checkEmail(Text) {
  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(Text)){
  //alert(Text);
  return (true)
  }
return (false)
}
// ===========================================================================
function test(){

Text = "";
err  = 0;

if (document.getElementById("Jmeno_").value == "")  { err = 1; Text += '\n Je nutné zadat pložku Jméno.';}
if (document.getElementById("Prijmeni").value == ""){ err = 1; Text += '\n Je nutné zadat pložku Příjmení.';}
if (document.getElementById("Email").value == "")   { err = 1; Text += '\n Je nutné zadat pložku Email.';}

if (err == 1){
   Err(Text);
 } else {
   document.f.submit();
 }
}
// ===========================================================================
function Image_rot(){
  document.getElementById('r-logo').src = Obrx[Obr_pol];
  Obr_pol ++;
  if (Obr_pol >= Obrx.length) Obr_pol = 1;
  window.setTimeout("Image_rot()", 3500); 
}
// ===========================================================================
function Bg_Image(id, image) {
 	document.getElementById("M"+id).style.backgroundImage = "url("+image+")" ;
  if ((document.getElementById("A"+id).style.color == "rgb(255, 0, 0)")||(document.getElementById("A"+id).style.color == "#ff0000")){ 
      document.getElementById("A"+id).style.color      = "#262627";
  }  else{
      document.getElementById("A"+id).style.color      = "#FF0000";
  }  
return false;
}
/***********************************************
* Form Field Progress Bar- By Ron Jonk- http://www.euronet.nl/~jonkr/
* Modified by Dynamic Drive for minor changes
* Script featured/ available at Dynamic Drive- http://www.dynamicdrive.com
* Please keep this notice intact
***********************************************/

function textCounter(field,counter,maxlimit,linecounter) {
	// text width//
	var fieldWidth =  parseInt(field.offsetWidth);
	var charcnt = field.value.length;        

	// trim the extra text
	if (charcnt > maxlimit) { 
		field.value = field.value.substring(0, maxlimit);
	}

	else { 
	// progress bar percentage
	var percentage = parseInt(100 - (( maxlimit - charcnt) * 100)/maxlimit) ;
	document.getElementById(counter).style.width =  parseInt((fieldWidth*percentage)/100)+"px";
	document.getElementById(counter).innerHTML="Limit: "+percentage+"%"
	// color correction on style from CCFFF -> CC0000
	setcolor(document.getElementById(counter),percentage,"background-color");
	}
}

function setcolor(obj,percentage,prop){
	obj.style[prop] = "rgb(80%,"+(100-percentage)+"%,"+(100-percentage)+"%)";
}