// ------ Soveko - overeni formulare ---------------------- //

$(document).ready(function(){
  $("#formular").ndFormValidator();

});


function OverAkce ()
{
   if (document.design.Element0.value == "")
   {
      document.design.Element0.focus();
      alert ("Nezadal(a) jste Vaše jméno");
      return false;
   }
   if (document.design.Element1.value == "")
   {
      document.design.Element1.focus();
      alert ("Nezadal(a) jste Vaše příjmení");
      return false;
   }
   if (document.design.Element2.value == "")
   {
      document.design.Element2.focus();
      alert ("Nezadal(a) jste ulici");
      return false;
   }
   if (document.design.Element3.value == "")
   {
      document.design.Element3.focus();
      alert ("Nezadal(a) jste město");
      return false;
   }
   if (document.design.Element4.value == "")
   {
      document.design.Element4.focus();
      alert ("Nezadal(a) jste PSČ");
      return false;
   }
   inpPsc=document.design.Element4.value;
   tel=/^[0-9]{5}$/
   if (!tel.test(inpPsc))
   {
      document.design.Element4.focus();
      alert ("Chybný formát PSČ");
      return false;
   }
   
   if (document.design.Element5.value == "")
   {
      if (document.design.Element6.value == "")
      {
          alert("Zadejte e-mail nebo telefon");
          return false;
      }
      else
      {
          inpCell=document.design.Element6.value;
          tel=/^[0-9]{9,12}$/
          if (!tel.test(inpCell))
          {
              document.design.Element6.focus();
              alert ("Chybný formát telefonního čísla");
              return false;
          }
      }
   }
   else
   {
      inpMail=document.design.Element5.value;
      mail=/^.+@.+\..{2,3}$/;
      if (!mail.test(inpMail))
      {
         document.design.Element5.focus();
         alert ("Chybný formát e-mailu");
         return false;
      }
   } 
   
//    if (document.design.Element5.value == "")
//    {
//       document.design.Element5.focus();
//       alert ("Nezadal(a) jste Váš e-mail");
//       return false;
//    }
//    inpMail=document.design.Element5.value;
//    mail=/^.+@.+\..{2,3}$/;
//    if (!mail.test(inpMail))
//    {
//       document.design.Element5.focus();
//       alert ("Chybný formát e-mailu");
//       return false;
//    }
//    if (document.design.Element6.value == "")
//    {
//       document.design.Element6.focus();
//       alert ("Nezadal(a) jste telefonní číslo");
//       return false;
//    }
//    inpCell=document.design.Element6.value;
//    tel=/^[0-9]{9,12}$/
//    if (!tel.test(inpCell))
//    {
//       document.design.Element6.focus();
//       alert ("Chybný formát telefonního čísla");
//       return false;
//    }
   
   
   
   
   
   if (document.design.Element7.value == "")
   {
      document.design.Element7.focus();
      alert ("Nezadal(a) jste typ ČOV");
      return false;
   }
   if (document.design.Element8.value == "")
   {
      document.design.Element8.focus();
      alert ("Nezadal(a) jste počet osob na ČOV");
      return false;
   }
//   inpPocet=document.design.Element8.value;
//   cov=/^[0-9]{7}$/
//   if (!cov.test(inpPocet))
//   {
//      document.design.Element8.focus();
//      alert ("Chybný formát");
//      return false;
//   }
   if (document.design.Element9.value == "")
   {
      document.design.Element9.focus();
      alert ("Nezadal(a) jste místo dodání");
      return false;
   }
   if (document.design.Element10.value == "")
   {
      document.design.Element10.focus();
      alert ("Nezadal(a) jste předběžné datum dodání");
      return false;
   }
   if (document.design.Element11.value == "")
   {
      document.design.Element11.focus();
      alert ("Nezadal(a) jste zda požadujete montáž ČOV");
      return false;
   }
 }
 // ------------------- END --------------------- //

// ------ Soveko - otevreni okna s formularem ---------- //

function formOpen(url) {
var win = window.open(url, null,"width=500,height=190,left=40,top=10,scrollbars=no,location=no,resizable=no");
if (win) return false;
else return true
}
// ------ Soveko - overeni formulare  Servis---------------------- //

function OverServis ()
{
   if (document.design.Element0.value == "")
   {
      document.design.Element0.focus();
      alert ("Nezadal(a) jste Název firmy");
      return false;
   }
   if (document.design.Element1.value == "")
   {
      document.design.Element1.focus();
      alert ("Nezadal(a) jste Vaše IČO");
      return false;
   }
   if (document.design.Element2.value == "")
   {
      document.design.Element2.focus();
      alert ("Nezadal(a) jste Vaše DIČ");
      return false;
   }
   if (document.design.Element3.value == "")
   {
      document.design.Element3.focus();
      alert ("Nezadal(a) jste Vaše jméno");
      return false;
   }
   if (document.design.Element4.value == "")
   {
      document.design.Element4.focus();
      alert ("Nezadal(a) jste Vaše příjmení");
      return false;
   }
  if (document.design.Element5.value == "")
   {
      document.design.Element5.focus();
      alert ("Nezadal(a) jste telefonní číslo");
      return false;
   }
   inpCell=document.design.Element5.value;
   tel=/^[0-9]{9,12}$/
   if (!tel.test(inpCell))
   {
      document.design.Element5.focus();
      alert ("Chybný formát telefonního čísla");
      return false;
   }
   if (document.design.Element6.value == "")
   {
      document.design.Element6.focus();
      alert ("Nezadal(a) jste Váš e-mail");
      return false;
   }
   inpMail=document.design.Element6.value;
   mail=/^.+@.+\..{2,3}$/;
   if (!mail.test(inpMail))
   {
      document.design.Element6.focus();
      alert ("Chybný formát e-mailu");
      return false;
   }
   if (document.design.Element7.value == "")
   {
      document.design.Element7.focus();
      alert ("Nezadal(a) jste typ výrobku");
      return false;
   }
   if (document.design.Element8.value == "")
   {
      document.design.Element8.focus();
      alert ("Nezadal(a) jste začátek servisního zásahu");
      return false;
   }
   if (document.design.Element9.value == "")
   {
      document.design.Element9.focus();
      alert ("Nezadal(a) jste konec servisního zásahu");
      return false;
   }
 }
 // ------------------- END --------------------- //

// ------ Soveko - overeni formulare ---------------------- //

function Over ()
{
   if (document.design.Element0.value == "")
   {
      document.design.Element0.focus();
      alert ("Nezadal(a) jste Vaše jméno");
      return false;
   }
   if (document.design.Element1.value == "")
   {
      document.design.Element1.focus();
      alert ("Nezadal(a) jste Vaše příjmení");
      return false;
   }
   if (document.design.Element2.value == "")
   {
      document.design.Element2.focus();
      alert ("Nezadal(a) jste Váš e-mail");
      return false;
   }
   inpMail=document.design.Element2.value;
   mail=/^.+@.+\..{2,3}$/;
   if (!mail.test(inpMail))
   {
      document.design.Element2.focus();
      alert ("Chybný formát e-mailu");
      return false;
   }
   if (document.design.Element3.value == "")
   {
      document.design.Element3.focus();
      alert ("Nezadal(a) jste telefonní číslo");
      return false;
   }
   inpCell=document.design.Element3.value;
   tel=/^[0-9]{9,12}$/
   if (!tel.test(inpCell))
   {
      document.design.Element3.focus();
      alert ("Chybný formát telefonního čísla");
      return false;
   }
 }
 // ------------------- END --------------------- //
 // --------- Soveko - overeni formulare - cenik ------------ //

 function OverPrice() {
   if (document.design.Element0.value == "")
   {
      document.design.Element0.focus();
      alert ("Nezadal(a) jste Vaše jméno");
      return false;
   }
   
   if (document.design.Element1.value == "")
   {
      document.design.Element1.focus();
      alert ("Nezadal(a) jste Váš e-mail");
      return false;
   }
   inpMail=document.design.Element1.value;
   mail=/^.+@.+\..{2,3}$/;
   if (!mail.test(inpMail))
   {
      document.design.Element1.focus();
      alert ("Chybný formát e-mailu");
      return false;
   }
   if (document.design.Element2.value == "")
   {
      document.design.Element2.focus();
      alert ("Nezadal(a) jste telefonní číslo");
      return false;
   }
   inpCell=document.design.Element2.value;
   tel=/^[0-9]{9,12}$/
   if (!tel.test(inpCell))
   {
      document.design.Element2.focus();
      alert ("Chybný formát telefonního čísla");
      return false;
   }
   
   if (document.design.Element5.value == "Vyberte kraj")
   {
      document.design.Element5.focus();
      alert ("Nezadal(a) jste kraj");
      return false;
   }
 }
 // --------------------- END ----------------------------- //
 // --------- Soveko - overeni formulare - chci vice informaci ------------ //

 function OverPlus ()
{
   if (document.design.Element1.value == "")
   {
      document.design.Element1.focus();
      alert ("Nezadal(a) jste Vaše jméno");
      return false;
   }
   
   if (document.design.Element2.value == "")
   {
      document.design.Element2.focus();
      alert ("Nezadal(a) jste Váš e-mail");
      return false;
   }
   inpMail=document.design.Element2.value;
   mail=/^.+@.+\..{2,3}$/;
   if (!mail.test(inpMail))
   {
      document.design.Element2.focus();
      alert ("Chybný formát e-mailu");
      return false;
   }
   if (document.design.Element3.value == "")
   {
      document.design.Element3.focus();
      alert ("Nezadal(a) jste telefonní číslo");
      return false;
   }
   inpCell=document.design.Element3.value;
   tel=/^[0-9]{9,12}$/
   if (!tel.test(inpCell))
   {
      document.design.Element3.focus();
      alert ("Chybný formát telefonního čísla");
      return false;
   }
 }
 // --------------------- END ----------------------------- //
 
 /* ------ DropDown Menu Position ------ */
function GetCustomMenuPositionRoot(pos)
{
   pos.x=-1;
   pos.y=125;
}

function GetCustomMenuElementTagName(root)
{
	return "BODY";
}

//*********************************** GALLERY ***************************************

function ClickEvent(e)
{
	var obj;
	var i=0;
	var title = "DISA Group GALLERY";
	
	if (Br.IE)
		obj = window.event.srcElement;
	else
		obj = e.target;

	while(obj.parentNode.tagName!="TBODY" && obj.parentNode.tagName!="TABLE" && i<20)
	{
		obj = obj.parentNode;
		i++;
	}
	obj = obj.childNodes[0].childNodes[0];

	if (typeof(obj)=='object')
		if (obj.tagName=='IMG')
		{
			if (obj.alt!="") title=obj.alt;
			GaleryView(obj, title);
		}
} 

function GaleryView(obj, title)
{
	var ImgURL="";
	var nDot=0;
	var nWidth=10, nHeight=30;
	var _child;
	if (typeof(obj)!='object') return false;
	ImgURL = obj.src;
	if (ImgURL=="" && ImgURL=="undefined") return false;
	nDot = ImgURL.lastIndexOf(".");
	ImgURL = ImgURL.substr(0, nDot) + "big" + ImgURL.substr(nDot, ImgURL.length);

	if (Br.NS)
	{
		nWidth += 14;
		nHeight += 23;
	}

	_child=window.open("about:blank","","height=200,width=200");
	_child.document.write('<html>\n')
	_child.document.write(' <head><title>' + title + '</title></head>\n')
	_child.document.write(' <body leftMargin=0 topMargin=0  onclick="window.close()" style="cursor:pointer; font-family:Verdana; font-size:14px;font-weight:bold;">\n')
	_child.document.write('<script language="javascript">\n');
	_child.document.write('function ResizeWin()');
	_child.document.write('	{window.resizeTo(document.getElementById("foto").width+' + nWidth + ',document.getElementById("foto").height+' + nHeight + ');}\n');
	_child.document.write('function notLoaded()');
	_child.document.write('	{document.getElementById("foto").style.display="none";\n');
	_child.document.write('	document.getElementById("errTxt").style.display="block";');
	_child.document.write('	window.resizeTo(350, 40)}');
	_child.document.write('</script>\n');
	_child.document.write('<div style="display:none;width:100%;padding-top:25px;text-align:center;" id="errTxt">THE PICTURE IS NOT AVAILABLE.</div>\n');
	_child.document.write('<img src="' + ImgURL + '" alt="Click to close this window." id=foto onload="ResizeWin()" onerror="notLoaded()">\n');
	_child.document.write(' </body>\n');
	_child.document.write('</html>\n');
}



function FitWindowToImage(oimg)
{
 //elm = document.getElementById('Image');
 if (oimg)
 {
    //alert("width: " + elm.width + "; Image.height: " + elm.height);
    window.resizeTo(oimg.width + 71, oimg.height + 260)
  }
}


// Funkce k novemu webu START

function KillDefaultText() {
  if(document.getElementById("txtExpresion").value == "vyhledávání...") {
    document.getElementById("txtExpresion").value = "";
  }
}

function frmSearchSubmit() {
  if (GetElement('txtExpresion').value.length<3) {
    alert('Uveďte minimálně 3 znaky.');
    return false;
  }   
}

function GenerateCustomFckGallery(files_array)
{
		var result="<br>";
		for (var a=0;a<files_array.length;a++)
			result+="<a href=\""+files_array[a].path+"\" rel=\"lightbox[roadtrip]\"><img class=\"body-gallery\" alt=\"\" src=\""+files_array[a].thumb+"\" /></a>";
		return result;
}

/*
sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" over";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" over\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);*/

