function WinOpImg(link, width, height) {
	okno=window.open(link, '', 'toolbar="no",scrollbars="no",resizeable="no",height=' + height + ',width=' + width + '');
	return;}

function WinOp(link, width, height) {
	okno=window.open(link, '', 'toolbar="no",scrollbars=yes,resizeable=yes,height=' + height + ',width=' + width + '');
	return;}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0a
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}


// JavaScript Document

function EmailFormCheck()
{
	
	var MenoInput;
	
	var jmeno = $('#jmeno').val();
	var email = $('#email').val();
	var telefon = $('#telefon').val();
	var question = $('#question').val();
	
	//alert(jmeno + '|' + email + '|' + telefon+ '|' + question);
	
	if ( jmeno == '' || email == '' || telefon == '' || question == ''){
		alert( $('#FormCheckErrorMessage').val() );
		return false;
	}	

	return true; 
	
}

function PosliFormZHomepage_ButtonAction()
{
	b = EmailFormCheck();
	
	if (b){
		$('#PosliEmailForm')[0].submit();	
	} 
	
}

function VyplnDotazFormAction()
{					  
	var FormElement = document.getElementById("PosliEmailForm");

	var NahodneCislo = Math.round((Math.random() * 20000)) * 8513; 
	
	if (FormElement != undefined){
		FormElement.action = 'Do_PosliKontaktDotaz.php?AuthKey=' + NahodneCislo; 	
	}
	
}



/* preloading obrazku v menu */
button1 = new Image(); 
button2 = new Image(); 
button3 = new Image(); 
button4 = new Image(); 
button5 = new Image(); 
button6 = new Image();
button1.src = "img/menu_1x.png"; 
button2.src = "img/menu_2x.png"; 
button3.src = "img/menu_3x.png"; 
button4.src = "img/menu_4x.png"; 
button5.src = "img/menu_5x.png"; 
button6.src = "img/menu_6x.png"; 
img1 = new Image(); 
img2 = new Image(); 
img3 = new Image(); 
img4 = new Image(); 
img5 = new Image(); 
img6 = new Image(); 
img1.src = "img/menu_01fotoobchod_c.jpg"; 
img2.src = "img/menu_02vseprorodinu_c.jpg"; 
img3.src = "img/menu_03fotostudio_c.jpg"; 
img4.src = "img/menu_04starlingmodels_c.jpg"; 
img5.src = "img/menu_05produkce_c.jpg"; 
img6.src = "img/menu_06znamky_c.jpg"; 


// -- funkce pro kontrolu validity emailove adresy

function CheckMail(email)
{
	
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(email)) {
		return true;
	}
	else {
		return false;
	}
}


// JavaScript Document
function VyplnDotazFormAction()
{					  
	var FormElement = document.getElementById("PosliEmailForm");

	var NahodneCislo = Math.round((Math.random() * 20000)) * 8513; 
	
	if (FormElement.jmeno.value == "" || FormElement.email.value == "") { 
		alert (FormElement.ErrorMessage.value);
		return false;
	}
	
	if (!CheckMail(FormElement.email.value)) {
		alert (FormElement.ErrorMessageEmail.value);
		return false;
	}
	
	if (FormElement != undefined){
		FormElement.action = 'tools/OdesliKontaktniForm.php?AuthKey=' + NahodneCislo; 	
	}
	
}
