function checkQuickChoice()
{
  var rSortiment = document.getElementById( 'sortimentSeoQuickChoice' );

	if( !rSortiment.value )
  {
    window.setTimeout( "showInformation( 'Vyberte alespoň typ pneu!' )", 40 );
		return false;
	}
  else
  {
    return true;
  }
}

function goToAdvancedSearch()
{
  var rForm = document.getElementById('frm_search');
  var rSearchString = document.getElementById('searchLeft');
  var rReset = document.getElementById('resetSearch');
  var rIgnoreSortiment = document.getElementById('ignoreSortiment');

  rSearchString.value = "";
  rReset.value = 1;
  rIgnoreSortiment.value = 0;

  rForm.submit();
}

function resetCatalogueFilters()
{
  var rSwitch = document.getElementById('resetFilters');
  var rCatalogueFiltersDo = document.getElementById('catalogueFiltersDo');
  var rForm = document.getElementById('frm_filters');

  rSwitch.value = 1;
  rCatalogueFiltersDo.value = 'resetFilters';
  rForm.submit();
}

function switchSearchFilterValues( sortimentSeo )
{
  var rSortimentSelect = document.getElementById( 'sortimentSeoQuickChoice' );

  // odstraneni "vyberte" option pri prvni zmene sortimentu
  if( document.getElementById( 'sortimentReset' ) ) rSortimentSelect.remove(0);

  // properties: reference / sum options / actual value / array of new options in selected sortiment
    // width
    var rWidthSelect = document.getElementById( 'searchwidth' );
    iWidthSumOptions = rWidthSelect.length;
    sWidthValueSelected = rWidthSelect.value;
    aWidthNewValues = ( document.getElementById( sortimentSeo + '__width' ) ) ? document.getElementById( sortimentSeo + '__width' ).value.split(';') : new Array();
    // caliber
    var rCaliberSelect = document.getElementById( 'searchcaliber' );
    iCaliberSumOptions = rCaliberSelect.length;
    sCaliberValueSelected = rCaliberSelect.value;
    aCaliberNewValues = ( document.getElementById( sortimentSeo + '__caliber' ) ) ? document.getElementById( sortimentSeo + '__caliber' ).value.split(';') : new Array();
    // height
    var rHeightSelect = document.getElementById( 'searchheight' );
    iHeightSumOptions = rHeightSelect.length;
    sHeightValueSelected = rHeightSelect.value;
    aHeightNewValues = ( document.getElementById( sortimentSeo + '__height' ) ) ? document.getElementById( sortimentSeo + '__height' ).value.split(';') : new Array();

  var aPropertyNames = new Array( "Width", "Caliber", "Height" );

  for( iNameIndex in aPropertyNames )
  {
    var propertyName = aPropertyNames[iNameIndex];
    // redefine
    rPropertySelect = eval( "r" + propertyName + "Select" );
    iPropertySumOptions = eval( "i" + propertyName + "SumOptions" );
    sPropertyValueSelected = eval( "s" + propertyName + "ValueSelected" );
    aPropertyNewValues = eval( "a" + propertyName + "NewValues" );
    // removing options
    for( i = ( iPropertySumOptions - 1 ); i >= 1; i-- )
    {
      rPropertySelect.remove(i);
    }
    // adding options
    for( i in aPropertyNewValues )
    {
      var sPropertyValue = aPropertyNewValues[i];
      var oNewOption = document.createElement('option');
      oNewOption.text = sPropertyValue;
      oNewOption.value = sPropertyValue;
      try
      {
        rPropertySelect.add( oNewOption, null ); // prohlizece :)
      }
      catch(ex)
      {
        rPropertySelect.add( oNewOption ); // billova kreatura
      }
      if( sPropertyValue == sPropertyValueSelected ) oNewOption.selected = true;
    }
  }
}

function manageSearchFieldWidth(action)
{
  var element = document.getElementById('qsearchMain');

  switch(action)
  {
    case 'enlarge':
      element.style.width = '300px';
    break;
    case 'reduce':
      element.style.width = '140px';
    break;
  }
}

function checkHomepageQuickChoice()
{
  var sortimentSEO = document.getElementById('sortimentSeo');
  if(sortimentSEO.value)
  {
    window.alert('ok');
    return true;
  }
  else
  {
    showInformation('Zvolte, prosím typ požadované pneumatiky.');
    return false;
  }
}

function checkIsInteger(elementId, defaultValue, enableEmpty)
{
	var element = document.getElementById(elementId);

  if(!isNaN(parseInt(element.value)) && parseInt(element.value) > 0 )
  {
    element.value = parseInt(element.value);
  }
  else if (element.value == "" && enableEmpty == 1)
  {
    element.value = "";
  }
  else
  {
    element.value = defaultValue;
  }
}

function switchSearchedSortiment(selectedSortimentSEO)
{
	var sortimentSEO2Send = document.getElementById('sortimentSEO2Send');
	var form2Send = document.getElementById('frm_displaySortimentSpecificFilters');

	sortimentSEO2Send.value = selectedSortimentSEO;
	form2Send.submit();
}

function showInformation(information)
{
 window.alert(information);
}

function manageManufacturerCheckboxes( action, idsString, bSendAjaxRequest )
{
  if( bSendAjaxRequest == undefined ) bSendAjaxRequest = true;
  ids = idsString.split(',');
  switch(action)
  {
    case 'all':
      for(i = 0; i < ids.length; i ++)
      {
        var chBox = document.getElementById('manufacturer_' + ids[i]);
        chBox.checked = true;
      }
    break;
    case 'none':
      for(i = 0; i < ids.length; i ++)
      {
        var chBox = document.getElementById('manufacturer_' + ids[i]);
        chBox.checked = false;
      }
    break;
    default:
    break;
  }

  if( bSendAjaxRequest ) checkFilterSetup();
}

function wndgallery(productId, fileName) {

	var pp = document.getElementById('imageLarge');
    //var lnk = pp.src.substring(pp.src.lastIndexOf('/')+1);
    window.open("/inc/wnd-gallery.php?id="+productId+"&filename="+fileName, 'null', 'location=no,menubar=no,width=550,height=350,resizable=yes');

}

function setCatalogueView(view)
{
	var frmView = document.getElementById('frm_catalogueView');
	var inputView = document.getElementById('catalogueView');

	inputView.value = view;
	frmView.submit();
}

function setCatalogueOrderByDirection(orderByDirection)
{
	var frmOrderBy = document.getElementById('frm_orderBy');
	var direction = document.getElementById('catalogueOrderByDirection');

	direction.value = orderByDirection;
	frmOrderBy.submit();
}

function pd_checkVariant(variantStamp)
{
	var selectedVariant = document.getElementById('pd_variant_' + variantStamp);
	var selectedRow = document.getElementById('pd_variant_row_' + variantStamp);
	var variantTable = document.getElementById('pd_tbl_variants');
	//variantTable.rows[0].style.border = "10px solid #000000";
	var variantRows = variantTable.getElementsByTagName('tr');
	var numVariantRows = variantRows.length;

	for(i = 1; i < numVariantRows; i ++)
	{
		var variantRow = variantRows[i];
		var rowClass = variantRow.className;
		if(rowClass.indexOf("odd") == -1)
		{
			variantRow.className = "noClass";
		}
		else
		{
			variantRow.className = "odd";
		}
	}

	selectedVariant.checked = "checked";
	var selectedRowClass = selectedRow.className;
	if(selectedRowClass.indexOf("odd") == -1)
	{
		selectedRow.className = "checked";
	}
	else
	{
		selectedRow.className = "odd checked";
	}
}

function loading(){

	var data = this.req.responseXML.documentElement;
	var iCount = data.getElementsByTagName('ITEM')[0].firstChild.nodeValue;
	var btnDisplayResults = document.getElementById('btn_displayCatalogueFilterResults');
	var numFilterResults = document.getElementById('numFilterResults');
	var numCatalogueTotal = document.getElementById('numCatalogueTotal').value;

	// CSS reaction
	if(iCount != numCatalogueTotal)
	{
		numFilterResults.style.background = "#D60C0C";
		numFilterResults.style.color = "#CCCCCC";
		if(iCount == 0)
		{
		  btnDisplayResults.style.textDecoration = "line-through";
		}
		else
		{
			btnDisplayResults.style.textDecoration = "none";
		}
	}
	else
	{
		numFilterResults.style.background = "#CCCCCC";
		numFilterResults.style.color = "#D60C0C";
		btnDisplayResults.style.textDecoration = "none";
	}


	numFilterResults.innerHTML = iCount;
}

function checkFilterSetup2( bSendAjaxRequest )
{

  if( bSendAjaxRequest == undefined ) bSendAjaxRequest = true;
	var sortimentSeo = document.getElementById('sortimentSeo').value;
  var categoryId = document.getElementById('categoryId').value;
  var manufacturerId = document.getElementById('manufacturerId').value;
  var userType = document.getElementById('userType').value;

  var numFilterResults = document.getElementById('numFilterResults');
  var btnDisplayResults = document.getElementById('btn_displayCatalogueFilterResults');
  var enableAjaxQuestion = true;
  // manufacturer
  var filterManufacturerCollection = document.getElementsByName('filterManufacturer[]');
  // price (from + to)

	var filterSeason = document.getElementById('filterPocetder').value;
	var filterHeight = document.getElementById('filtersirkarafku').value;
	// season
	var filterEt = document.getElementById('filteret').value;
	var filterPrumer = document.getElementById('filterprumerkola').value;
	// availability
	 var filterPriceFrom = document.getElementById('filterPriceFrom');
  var filterPriceTo = document.getElementById('filterPriceTo');
	var filterAvailabilityCollection = document.getElementsByName('filterAvailability[]');
  var filters = document.getElementById('frm_filters');

  // filter manufacturers
  var filterManufacturerValues = new Array();
  for(var i = 0; i < filterManufacturerCollection.length; i ++)
  {
    eval("var manufacturerChecked = document.getElementById('manufacturer_" + filterManufacturerCollection[i].value + "').checked;");
    if(manufacturerChecked) filterManufacturerValues.push(filterManufacturerCollection[i].value);
  }
  if(!filterManufacturerValues.length) enableAjaxQuestion = false;

  // filter availability
  var filterAvailabilityValues = new Array();
  for(var i = 0; i < filterAvailabilityCollection.length; i ++)
  {
    eval("var availabilityChecked = document.getElementById('availability_" + filterAvailabilityCollection[i].value + "').checked;");
    if(availabilityChecked) filterAvailabilityValues.push(filterAvailabilityCollection[i].value);
  }
  if(!filterAvailabilityValues.length) enableAjaxQuestion = 0;


  if( !enableAjaxQuestion )
  {
  	btnDisplayResults.style.textDecoration = "line-through";
		numFilterResults.style.background = "#CCCCCC";
		numFilterResults.style.color = "#D60C0C";
  	numFilterResults.innerHTML = "0";
  }
  else if ( bSendAjaxRequest )
  {
		var ajaxUrl =
			"/ajax/catalogueFiltr2.php?sortimentSeo=" + sortimentSeo +
			"&iManufacturers=" + filterManufacturerValues +
			"&iPriceFrom=" + filterPriceFrom.value +
			"&iPriceTo=" + filterPriceTo.value +
			"&filtersirkarafku=" + filterHeight +
			"&filteret=" + filterEt +
			"&filterprumer=" + filterPrumer +
			"&iAvailability=" + filterAvailabilityValues +
			"&categoryId=" + categoryId +
			"&manufacturerId=" + manufacturerId +
			"&filterSeason=" + filterSeason +
			"&userType=" + userType;
		//window.alert(ajaxUrl);
  	var ajax = new net.ContentLoader(ajaxUrl, loading);
  }

  return enableAjaxQuestion;

}

function checkFilterSetup( bSendAjaxRequest )
{
  if( bSendAjaxRequest == undefined ) bSendAjaxRequest = true;
	var sortimentSeo = document.getElementById('sortimentSeo').value;
  var categoryId = document.getElementById('categoryId').value;
  var manufacturerId = document.getElementById('manufacturerId').value;
  var userType = document.getElementById('userType').value;

  var numFilterResults = document.getElementById('numFilterResults');
  if(bSendAjaxRequest != false) numFilterResults.innerHTML = "hledám";
  var btnDisplayResults = document.getElementById('btn_displayCatalogueFilterResults');
  var enableAjaxQuestion = true;
  // manufacturer
  var filterManufacturerCollection = document.getElementsByName('filterManufacturer[]');
  // price (from + to)
  if(document.getElementById('filterPriceFrom')) {
  	var filterPriceFrom = document.getElementById('filterPriceFrom');
  	var filterPriceTo = document.getElementById('filterPriceTo');
  } else {
	  var filterPriceFrom = "";
	  var filterPriceTo = "";
  }
	// caliber
  var filterCaliber = document.getElementById('filtercaliber').value;
	// width
	var filterWidth = document.getElementById('filterwidth').value;
	// height
	var filterHeight = document.getElementById('filterheight').value;
	// season
	if(document.getElementById('filterSeason')) {
		var filterSeason = document.getElementById('filterSeason').value;
	} else {
		var filterSeason = "";
	}
	// availability
	var filterAvailabilityCollection = document.getElementsByName('filterAvailability[]');
  var filters = document.getElementById('frm_filters');

  // filter manufacturers
  var filterManufacturerValues = new Array();
  for(var i = 0; i < filterManufacturerCollection.length; i ++)
  {
    eval("var manufacturerChecked = document.getElementById('manufacturer_" + filterManufacturerCollection[i].value + "').checked;");
    if(manufacturerChecked) filterManufacturerValues.push(filterManufacturerCollection[i].value);
  }
  if(!filterManufacturerValues.length) enableAjaxQuestion = false;

  // filter availability
  var filterAvailabilityValues = new Array();
  for(var i = 0; i < filterAvailabilityCollection.length; i ++)
  {
    eval("var availabilityChecked = document.getElementById('availability_" + filterAvailabilityCollection[i].value + "').checked;");
    if(availabilityChecked) filterAvailabilityValues.push(filterAvailabilityCollection[i].value);
  }
  if(!filterAvailabilityValues.length) enableAjaxQuestion = 0;

  // check price FROM
  if(!isNaN(parseInt(filterPriceFrom.value)))
  {
    filterPriceFrom.value = parseInt(filterPriceFrom.value);
  }
  else
  {
    filterPriceFrom.value = "";
  }
  // check price TO
  if(!isNaN(parseInt(filterPriceTo.value)))
  {
    filterPriceTo.value = parseInt(filterPriceTo.value);
  }
  else
  {
    filterPriceTo.value = "";
  }

  if( !enableAjaxQuestion )
  {
  	btnDisplayResults.style.textDecoration = "line-through";
		numFilterResults.style.background = "#CCCCCC";
		numFilterResults.style.color = "#D60C0C";
  	numFilterResults.innerHTML = "0";
  }
  else if ( bSendAjaxRequest )
  {
		var ajaxUrl =
			"/ajax/catalogueFiltr.php?sortimentSeo=" + sortimentSeo +
			"&iManufacturers=" + filterManufacturerValues +
			"&iPriceFrom=" + filterPriceFrom.value +
			"&iPriceTo=" + filterPriceTo.value +
			"&filterCaliber=" + filterCaliber +
			"&filterWidth=" + filterWidth +
			"&filterHeight=" + filterHeight +
			"&filterSeason=" + filterSeason +
			"&iAvailability=" + filterAvailabilityValues +
			"&categoryId=" + categoryId +
			"&manufacturerId=" + manufacturerId +
			"&userType=" + userType;

  	var ajax = new net.ContentLoader(ajaxUrl, loading);
  }

  return enableAjaxQuestion;

}
function submitFilters2()
{

  var passed = checkFilterSetup2( false );
  if(passed)
  {

    if (document.getElementById('numFilterResults').innerHTML == 0) {

    	window.alert("Vámi nastavený filtr vrací nulový počet výsledků.");
     	return false;
	} else return true;
  }
  else
  {
  	window.alert("Vámi nastavený filtr vrací nulový počet výsledků. Zkuste snížit omezení filtrů.");
    return false;
  }
}

function submitFilters()
{

  var passed = checkFilterSetup( false );
  if(passed)
  {

    if (document.getElementById('numFilterResults').innerHTML == 0) {

    	window.alert("Vámi nastavený filtr vrací nulový počet výsledků.");
     	return false;
	} else return true;
  }
   else
  {
  	window.alert("Vámi nastavený filtr vrací nulový počet výsledků. Zkuste snížit omezení filtrů.");
    return false;
  }
	return true;
}

function openProductComparison()
{
	var productCompareForm = document.getElementById('productCompareRequest');
	var productCompareId = document.getElementById('productCompareId');
	var productCompareAction = document.getElementById('productCompareAction');

	productCompareId.value = '';
	productCompareAction.value = 'openProductComparison';
	productCompareForm.submit();
}

function manageProductCompare(productId, action)
{
	var productCompareForm = document.getElementById('productCompareRequest');
	var productCompareId = document.getElementById('productCompareId');
	var productCompareAction = document.getElementById('productCompareAction');

	productCompareId.value = productId;
	productCompareAction.value = action;
	productCompareForm.submit();
}

function compareDisabledNotice()
{
	window.alert(" V jednu chvíli je možné srovnávat pouze 3 produkty. chcete-li některý z již vybraných vyměnit za jiný, odstraňte nejdříve tento vybraný produkt ze seznamu k porovnání.");
}

function switchCssIconCompare(id, cssClass)
{
	var element = document.getElementById(id);
	element.className = "cssClass";
}

function validateSearch( idSearchField, sDefault )
{
  var iMinChars = 3;

	var rSearch = document.getElementById( idSearchField );

	if( rSearch.value == sDefault ) rSearch.value = "";

	if( ( rSearch.value.replace( / /gi, "" ) ).length < iMinChars )
  {
    window.setTimeout( "showInformation( 'Vložte minimálně " + iMinChars + " znaky!' )", 40 );
		return false;
	}
  else
  {
    return true;
  }
}

function switchElementLoading()
{
	var data = this.req.responseXML.documentElement;
	var elementAlert = data.getElementsByTagName('ALERT')[0].firstChild.nodeValue;
	var action = data.getElementsByTagName('ACTION')[0].firstChild.nodeValue;
	var viewAlert = Number(data.getElementsByTagName('VIEW_ALERT')[0].firstChild.nodeValue);

	if(viewAlert == "1" && action == "hide")
	{
		window.alert(elementAlert + " jsou skryté. Chcete-li je opět zobrazit, klepněte na stejné tlačitko.");
	}
}

function switchElement(id)
{
  var element = document.getElementById(id);
  var elementBtmHsep = document.getElementById(id + "Hsep");
  var elementDisplayStatus = element.style.display;

  if(elementDisplayStatus == "none" || elementDisplayStatus == undefined)
  {
    var action = "unhide";
    element.style.display = "block";
    elementBtmHsep.style.background = "none";
  }
  else
  {
  	var action = "hide";
    element.style.display = "none";
    elementBtmHsep.style.background = "url('/bg/hsep_line_lightocher.gif') repeat-x";
  }
  var url = "../ajax/switch_element.php?element="+ id + "&action=" + action;
  //window.alert(url);
	var ajax = new net.ContentLoader(url, switchElementLoading);
}

function pd_switchImageLarge(imageFilename, imageAlt) {

	var htmlImageLarge = document.getElementById("imageLarge");
	var htmlLinkLarge = document.getElementById("linkLarge");

	htmlImageLarge.src = "/picts/thumb-large/" + imageFilename;
	htmlImageLarge.alt = imageAlt;
	htmlLinkLarge.title = imageAlt;
	//htmlLinkLarge.href = "/picts/" + imageFilename;

}

function MM_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.getElementById(n); return x;
}

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_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;
}

function MM_swapImage() { //v3.0
  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 setPayment(choice){
	var element = document.getElementById('payment');
	if(choice == 4 && element.value == 1){
	  element.value = 2;
	  window.alert("Pro tento způsob dopravy je možnost platby pouze hotově. Způsob platby byl automaticky nastaven.");
	}else if (choice != 4 && element.value == 2){
	  element.value = 1;
	  window.alert("Pro tento způsob dopravy je možnost platby pouze dobírkou. Způsob platby byl automaticky nastaven.");
	}
}

function setShipping(choice){
	var element = document.getElementById('shipping');
	if(choice == 1 && element.value == 4){
	  element.value = 1;
	  window.alert('Způsob platby dobírkou není možný v případě osobního odběru. Způsob dopravy byl automaticky změněn na "Česká pošta - obyčejný balík".');
	}else if (choice == 2 && element.value != 4){
	  element.value = 4;
	  window.alert("V hotovosti lze platit pouze při osobním odběru. Způsob dopravy byl automaticky nastaven.");
	}
}

function cartadd(frm, session_id, currency, user_type){

	if(user_type == '') user_type = '1';
	var url = "../ajax/cart_add.php?currency="+currency+"&user_type="+user_type+"&session_id="+session_id+"&productStamp="+frm.productStamp.value+"&qty="+frm.qty.value;
	//window.location=url;
	var ajax = new net.ContentLoader(url, cartloading);

}

function zmenaHledani() {

	var element = document.getElementById('hledani');

	if (element.value == 'hledat...') {
		element.value = '';
	}

}

function cartloading(){
	var elmnt = document.getElementById('cart-ajax');
	var data = this.req.responseXML.documentElement;
	var ks = Number(data.lastChild.firstChild.nodeValue);
	var cena = data.firstChild.firstChild.nodeValue;
	if(!isNaN(ks)){
		elmnt.innerHTML = ks + "<br />"+cena;
		alert("Vybrané zboží bylo přidáno do košíku. Děkujeme.");
	}
}


function watchDog(e, productId){
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY)
	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY)
	{
		posx = e.clientX + document.documentElement.scrollLeft;
		posy = e.clientY + document.documentElement.scrollTop;
	}


	var frm = document.getElementById('frm_watchDog');
	frm.wdProductId.value = productId;
	var wdBox = document.getElementById('watchDog');

	wdBox.style.top = (posy + 5) + "px";
	wdBox.style.left = (posx +5) + "px";
	wdBox.style.display = 'block';
}

function addItem(box, id) {
   var sel = document.getElementById(box);
   var opt = document.createElement("OPTION");
   opt.value = id;

	var txt = document.createTextNode(id);
	opt.appendChild(txt);
   sel.appendChild(opt);
}


function ValidateEmail( email){
	var regStr = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if( !regStr.test(email)){
		alert("Vámi zadaná e-mailová adresa nemá platný formát.");
		return false;
	}
	return true;
}

function ValidateEmailNotStrict( email){
	if(email == '') return true;
	var regStr = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if( !regStr.test(email)){
		alert("Vámi zadaná e-mailová adresa nemá platný formát.");
		return false;
	}
	return true;
}

function ValidateNotEmpty( values){
	for(var i=0; i<values.length; i++){

		if(values[i] == ''){
			alert("Vyplňte prosím požadované údaje.");
			return false;
		}
	}
	return true;
}

function ValidateAreNumbers( values  ){
	var regStr = /^(\d)+$/;
	for(var i=0; i<values.length; i++){
		if(!regStr.test(values[i])){
			alert("Do číselných polí prosím vložte nezáporné celé číslo.");
			return false;
		}
	}
	return true;
}

function ShowTooltip(e, tip)
{
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY)
	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY)
	{
		posx = e.clientX + document.documentElement.scrollLeft;
		posy = e.clientY + document.documentElement.scrollTop;
	}

	var tooltipBox = document.getElementById('tooltip');
	tooltipBox.innerHTML = tip;

	tooltipBox.style.top = (posy + 5) + "px";
	tooltipBox.style.left = (posx +5) + "px";
	tooltipBox.style.display = 'block';

}

function HideTooltip(){

	var tooltipBox = document.getElementById('tooltip');

	tooltipBox.style.display = 'none';
}

function setSearch(){
    document.getElementById('searchbox').style.display='block';
}

$(document).ready(function(){
 $(".class_tooltip").tooltip();
 // obrasky
    $("a.imageGallery").colorbox({
        'width'            :    810,
        'height'        :    500,
        'speed'            :    300,
        'opacity'        :    0.75,
        'next'            :    "další",
        'previous'        :    "předchozí",
        'close'            :    "zavřít",
	'current'	:	"obrázek {current} z {total}"
    });
    
  /* Searchbox - posouvani a zavirani */

  function getPageScroll() {
    var xScroll, yScroll;
    if (self.pageYOffset) {
      yScroll = self.pageYOffset;
      xScroll = self.pageXOffset;
    } else if (document.documentElement && document.documentElement.scrollTop) {
      yScroll = document.documentElement.scrollTop;
      xScroll = document.documentElement.scrollLeft;
    } else if (document.body) {// all other Explorers
      yScroll = document.body.scrollTop;
      xScroll = document.body.scrollLeft;
    }
    return new Array(xScroll,yScroll)
  }

  function closeSearchBox() {

    $("#searchbox").hide();

    if($.browser.msie) {
      document.execCommand("Stop");
    } else {
      window.stop();
    }

    return false;
  }

  //$("#searchbox").show();

  // pozicování
	$(window).bind('scroll', function(){
    var arrs = getPageScroll();
    $("#searchbox .pt").css('padding-bottom', parseInt(arrs[1])+100);
  });

  // skryvani
  $("#searchbox .information").bind('click', function(event){
    event.stopPropagation();
  });

  $("#searchbox, #searchbox #searchboxButton").bind('click', function(){
    closeSearchBox();
  });

  // esc
  $(document).keydown(function(event) {
    if (($("#searchbox:visible").length > 0) && (event.which == 27)) {
    closeSearchBox();
    }
  });

});

