
function open_window(url)
{
	okno = window.open(url,"nazev","width=600,height=560,menubar=no,toolbar=no,scrollbars=yes,resizable=yes");
	wasOpen = false;
	if (typeof(okno) == "object"){
	wasOpen = true;
	}
	return wasOpen;
}

function open_image(image)
{
	var win=window.open("","Fotografie","width=750,height=550,menubar=no,toolbar=no,scrollbars=yes");
	win.focus();
	win.document.open();
	win.document.write("<html><head><title>Detail fotografie</title></head><body bgcolor='#F5F5F5'>");
	win.document.write("<table width='100%' height='100%'><tr><td valign='middle' align='center'><a href='javascript:window.close()'><img src='"+image+"' border='0' alt='Kliknut�m na obr�zek zav�ete okno' /></td></tr></table>");
	win.document.write("</body></html>");

}

function check_writeus_form()
{
  with(document.form){
   	if(name.value=="" || text.value==""){
		alert("Vyplňte prosím všechny povinné údaje.");
		return false;
	}			
	if((email.value.length<=5) || (email.value.indexOf('@')==-1)) {
		alert("Vaše emailová adresa není zadána správně!")
		return false;
	}
  }
  return true;
}


function check_faq_form()
{
  with(document.form){
   	if(question.value==''){
		alert("Nevyplněno pole Text dotazu.");
		return false;
	}
	
	var x = email.value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(x))
	{
		alert("Vaše emailová adresa není zadána správně!")
		return false;		
	}
  }
  return true;
}

function isInt(x) {
   var y=parseInt(x);
   if (isNaN(y)) return false;
   return x==y && x.toString()==y.toString();
 } 

function check_customer_form()
{
  with(document.form){
   	if(name.value=='' || address.value=='' || zip.value=='' || phone.value==''){
		alert("Vyplňte prosím všechna povinná pole (označená hvězdičkou).");
		return false;
	}
	
	var x = email.value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (x!='' && !filter.test(x))
	{
		alert("Vaše emailová adresa není zadána správně!");
		return false;		
	}
	
	if(!isInt(zip.value))
	{
		alert("Do pole PSČ zadejte číselnou hodnotu!");
		return false;				
	}
	if(ic.value!='' && !isInt(ic.value))
	{
		alert("Do pole IČ zadejte číselnou hodnotu!");
		return false;				
	}
  }
  return true;
}

function switch_visibility(id)
{
	var adv_form=document.getElementById(id);
	if(adv_form.style.display=="none")
		{
		adv_form.style.display="block";
		}
	else
		{
		adv_form.style.display="none";
		}
}

//nahradi cast retezce jinym retezcem
function str_replace(search, replace, subject)
{
	var result = "";
	var  oldi = 0;
	for (i = subject.indexOf (search); i > -1; i = subject.indexOf (search, i))
	{
		result += subject.substring (oldi, i);
		result += replace;
		i += search.length;
		oldi = i;
	}
	return result + subject.substring (oldi, subject.length);
}

function convert_and_redirect(string)
{
	location.href= 'mailto:'+str_replace('(zavináč)','@',string);
}

function addZeroes(price)
{
	var output = '';
	if(price - Math.floor(price) > 0 && (price*100) - Math.floor(price*100) == 0)
	{
		output = price + '0';
	}
	else if(price - Math.floor(price) == 0)
	{
		output = price + '.00';
		
	}
	else
	{
		output = price;
	}

	return output;
}

