function ShowImage1(path_to_nahled, image_name, id, width, height)
{
  window.open(encodeURI(path_to_nahled+"nahled.php?img=" + image_name + "&id=" + id), "_blank", "toolbar=no,scrollbars=no,location=no,status=no,width="+width+",height="+height+",resizable=0,screenX=150,screenY=150", false);
}

function ShowEmailWindow(path_to_form, id, width, height)
{
  window.open(encodeURI(path_to_form+"formular/index.php?id="+id+""), "_blank", "toolbar=no,scrollbars=no,location=no,status=no,width="+width+",height="+height+", resizable=0,screenX=150,screenY=150", false);
}

function VymazText()
{
	if( document.getElementById('searchtext').value == 'vyhledat:') {
		document.getElementById('searchtext').value='';
	}
}

function ShowImage2(path_to_nahled, image_name, width, height)
{
  window.open(encodeURI(path_to_nahled+"nahled2.php?img=" + image_name), "_blank", "toolbar=no,scrollbars=no,location=no,status=no,width="+width+",height="+height+",resizable=0,screenX=150,screenY=150", false);
}

function change_sum(id, v_id) {
  var formik = document.getElementById("prod");
  var sum_element = document.getElementById("number" + id + "_" + v_id);
  formik.product_id.value=id;
  formik.product_var_id.value=v_id;
  formik.product_sum.value=sum_element.value;
  formik.event.value = "change_number";
  formik.submit();
}

function oznac($form_name,$switcher) {
   //$form_handle  = document[$form_name];
   $form_handle = $form_name;
   $number_items = $form_handle.elements.length;
   
   for (var $i = 0; $i < $number_items; $i++) {
      if ($form_handle.elements[$i].name == $switcher) {
         $form_handle.elements[$i].checked = !$form_handle.elements[$i].checked;
         //($switcher) ? true : false;
      }
   }
}

function alert_me(co) {
	window.alert("Prosíme, vyplňte poloľku: " + co);
}

function validate_order(form_name) {
  var formular = document.getElementById(form_name);
  if (!formular.jmeno.value) {
	alert_me("jméno");
	formular.jmeno.focus();
	return false;
  }
  if (!formular.prijmeni.value) {
	alert_me("přímení");
	formular.prijmeni.focus();	
	return false;
  }

  if (!formular.obec.value) {
	alert_me("obec");
	formular.obec.focus();	
	return false;
  }
  
  if (!formular.PSC.value) {
	alert_me("PSČ");
	formular.PSC.focus();		
	return false;
  }

  if (!formular.telefon.value) {
	alert_me("telefon");
	formular.telefon.focus();		
	return false;
  }

  if (!formular.email.value) {
	alert_me("email");
	formular.email.focus();		
	return false;
  }
  
  return true;
  
}

function previous_page(formname) {
  formik = document.getElementById(formname);
  formik.event.value = "previous";
  formik.submit();
}

function next_page(formname) {
  formik = document.getElementById(formname);
  formik.event.value = "next";
  formik.submit();
}

function Check_Key(e) {
   var $key = 0;

   if (document.all) {
      $key = window.event.keyCode;
   } else {
      $key = e.which;
   }

   if ($key == 13) {
      document.forms.log.submit();
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function open_compare_window(){
	var f = document.forms.produkty;
	var first = true;	
	var list = "";
	var id;
	var count = 0;
	
	for(i = 0; i < f.elements.length; i++){
		if(f.elements[i].tagName == "INPUT" && f.elements[i].type == "checkbox"){
			if(f.elements[i].checked == true){
				if(first == true){
					first = false;
				}else{
					list += ",";
				}
				id = f.elements[i].name.substring(f.elements[i].name.lastIndexOf('[')+1, f.elements[i].name.lastIndexOf(']')) ;								
				list += id;
				count++;
			}
		}
	}

	if(count == 0){
		alert("Musíte zaškrtnout výrobky, které chcete porovnat.");
	}else{
		window.open('../compare/index.php?id='+list,'srov','scrollbars=yes,resizable=yes,width=800,height=600');
	}
}
