﻿	function new_window2(dokument,sirka,vyska,centrovat,pozice_l,pozice_h) {
	  if (centrovat == 1) {
			so = screen.width;
			vo = screen.height;
			zleva = ((so - sirka) / 2) - 13;
	//		shora = (vo - vyska) / 2;
			shora = 100;
		} else {
		  zleva = pozice_l;
		  shora = pozice_h;
		}
	  popup_win = window.open(dokument,"popup_okno","width="+sirka+",height="+vyska+",left="+zleva+",top="+shora+",location=0,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0");
	  popup_win.resizeTo(sirka+75,vyska+100);
	  popup_win.focus();
	}


function new_window(adress) {
	window.open(adress,"","");
}

function IsNumber( inputVal, bSelect, sMessage ) {
   var bRet = false;
   var cVal;
   
   if( typeof( bMessage ) != "boolean" )
       bMessage=true;
   
   if( typeof(inputVal.value)=="string" ) {
       cVal=inputVal.value;
       cVal=cVal.replace(",",".");       
       if( !isNaN(parseFloat(cVal)) ) {
           bRet=true;
           inputVal.value=parseFloat(cVal);
       }    
   }
   else    
   if( typeof(inputVal.value)=="number" ) 
       bRet=true;
       
   if( !bRet && bSelect) {
         alert( "Musíte zadat eíselnou hodnotu '" + sMessage + "' !" );
         inputVal.select();        
         inputVal.focus();

   }
   
   return bRet;
}

function ToNumber( inputVal ) {
   var expression;
   var nRet=0, nVal;    
   
   if( typeof(inputVal)=="string" ) {
       nVal=parseFloat(inputVal);
       if( !isNaN(nVal) )
           nRet=nVal;
   }
   else    
   if( typeof(inputVal)=="number" ) 
       nRet=inputVal;
       
   return nRet;
}


function Trim( cInput ) {
   var cStr="";
   var nLength,i;
   var nFirst,nLast;
   
   if( typeof(cInput)=="string" ) {
       nLength=cInput.length;
       nFirst=0;
       while( cInput.charCodeAt(nFirst)<33 && nFirst<nLength ) nFirst++;
       cStr=cInput.substr(nFirst,nLength);
       nLast=cStr.length-1;
       while( cStr.charCodeAt(nLast)<33 && nLast>0 ) nLast--; 
       cStr=cStr.substr(0,nLast+1);
   }
   
   return cStr; 
} 



function IsDate( inputVal, bSelect ) {
   var aStr="";
   var bRet=true;

   if( typeof(inputVal.value)=="string" && Trim(inputVal.value).length>0 ) {
       // testing length
       aStr=inputVal.value.split(".");
       if( aStr.length!=3 ) 
           bRet=false;
       else {
           dDate= new Date(aStr[2], aStr[1]-1, aStr[0]);  
           if( dDate.getDate() != parseInt(aStr[0]) ||
               dDate.getMonth()+1 != parseInt(aStr[1]) ||
               dDate.getFullYear() != parseInt(aStr[2]) )
                  bRet=false;
       }
   }
   else
      bRet=false;
       
   if( !bRet ) {           
       alert( "Musíte zadat datum ve formátu DD.MM.YYYY !" );
       if( bSelect==true ) {        
         inputVal.select();        
         inputVal.focus();
       }          
   }
       
   return bRet; 
} 


function NotEmpty( inputVal, sMessage, bSelect ) {
   var bRet = false;
   var cVal;
   
   if( typeof(inputVal.value)=="string" ) {
       cVal=Trim(inputVal.value);
       if( cVal.length>0 )
           bRet=true;                        
   }
       
   if( !bRet && bSelect) {
       alert( "Zadejte prosím "+ sMessage +"." );
       inputVal.select();        
       inputVal.focus();

   }
   
   return bRet;
}


function IsEmail( inputVal, bSelect ) {
  var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
  var check=/@[\w\-]+\./;
  var checkend=/\.[a-zA-Z]{2,3}$/;
  var emailad=inputVal.value.trim();

  inputVal.value=emailad;
  
	if(((emailad.search(exclude) != -1)||(emailad.search(check)) == -1)||(emailad.search(checkend) == -1)){
		 alert("Prosím zadejte správnou emailovou adresu.");
     if( bSelect ) { 
         inputVal.select();        
         inputVal.focus();
     }    
     return false;
	}
  return true;
}

function openform(param, winname ) {
	//******************
	var lwidth=780
	var lheight=screen.height-25
	var New_win = window.open(param, "","menubar=no,location=no,personalbar=no,titlebar=no,status=no,toolbar=no,directories=no,scrollbars=yes,resizable=no")
	
	New_win.resizeTo(lwidth,lheight)
	New_win.moveTo((screen.width-lwidth)/2,0)
}

String.prototype.trim = function()
{
    return this.replace(/(^\s*)|(\s*$)/g, "");
}
var nazev_obr;
var nazev_dvere;
var nazev_jake;
var nazev_co;

function changePicture(nazev_obr,nazev_jake,nazev_dvere,nazev_co ){
	
				
	
		document.getElementById('first_img').src = ""+nazev_co+"/"+nazev_dvere+"/"+nazev_jake+"/big/"+nazev_obr+".jpg"; 
	
	
	//	document.getElementById('link').onclick= popup_window2('imgorg/'+kategorie+'/'+nazev+'_o.jpg','+w+','+h+',1,10,10);  return false; 
	//	document.getElementById('link_text').href = "imgorg/"+kategorie+"/"+nazev+"_o.jpg"; 
	}
	
	function img_window(zdroj, nazev, sirka, vyska, centrovat, pozice_l, pozice_h) {
	  centrovat = 1;
	  if (centrovat == 1) {
			zleva = ((screen.width - sirka) / 2) - 13;
			shora = (screen.height - vyska) / 2;
		} else {
		  zleva = pozice_l;
		  shora = pozice_h;
		}
	  popup_win = window.open("", "popup_okno", "width=" + sirka + ",height=" + vyska + ",left=" + zleva + ",top=" + shora + ",location=0,menubar=0,resizable=1,scrollbars=1,status=0,titlebar=0,toolbar=0");
	  popup_win.resizeTo(sirka + 9,vyska + 58);
	  popup_win.document.open();
 	  popup_win.document.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n");
 	  popup_win.document.write("<html>\n");
 	  popup_win.document.write("  <head>\n");
 	  popup_win.document.write("    <title>" + nazev + "</title>\n");
 	  popup_win.document.write("    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n");
 	  popup_win.document.write("    <style type=\"text/css\">\n");
 	  popup_win.document.write("    <!--\n");
 	  popup_win.document.write("    body {\n");
 	  popup_win.document.write("    	background-color: #fdfbec;\n");
 	  popup_win.document.write("    	margin-left: 0px;\n");
 	  popup_win.document.write("    	margin-top: 0px;\n");
 	  popup_win.document.write("    	margin-right: 0px;\n");
 	  popup_win.document.write("    	margin-bottom: 0px;\n");
 	  popup_win.document.write("    }\n");
 	  popup_win.document.write("    img { border: none; }\n");
 	  popup_win.document.write("    -->\n");
 	  popup_win.document.write("    </style>\n");
 	  popup_win.document.write("  </head>\n");
 	  popup_win.document.write("  <body>\n");
 	  popup_win.document.write("    <a href=\"\" title=\"Zavřít okno\" onclick=\"javascript:window.close()\"><img id=\"foto\" src=\"" + zdroj + "\" alt=\"" + nazev + "\" /></a>\n");
 	  popup_win.document.write("  </body>\n");
 	  popup_win.document.write("</html>\n");
	  popup_win.document.close();
	  popup_win.focus();
	}


	
	

