﻿

Ext.onReady(function(){
	if (document.getElementById('lokality') != null) {
    var lokalityCombo = new Ext.form.ComboBox({
        typeAhead: true,
        triggerAction: 'all',
        transform:'lokality',
        width:132,
        forceSelection:true
    });
  }
  if (document.getElementById('kategoria') != null) {
    var kategoriaCombo = new Ext.form.ComboBox({
        typeAhead: true,
        triggerAction: 'all',
        transform:'kategoria',
        width:132,
        forceSelection:false
    });
  }
  if (document.getElementById('den') != null) {
    var denCombo = new Ext.form.ComboBox({
        typeAhead: true,
        triggerAction: 'all',
        transform:'den',
        width:35,
        forceSelection:true
    });
  }
  
  if (document.getElementById('mesiac') != null) {
    var mesiacCombo = new Ext.form.ComboBox({
        typeAhead: true,
        triggerAction: 'all',
        transform:'mesiac',
        width:45,
        forceSelection:true
    });
  }
   if (document.getElementById('rok') != null) { 
    var rokCombo = new Ext.form.ComboBox({
        typeAhead: true,
        triggerAction: 'all',
        transform:'rok',
        width:50,
        forceSelection:true
    });
  }
   if (document.getElementById('noci') != null) { 
    var nociCombo = new Ext.form.ComboBox({
        typeAhead: true,
        triggerAction: 'all',
        transform:'noci',
        width:35,
        forceSelection:true
    });
  }
  if (document.getElementById('izba') != null) {  
    var izbaCombo = new Ext.form.ComboBox({
        typeAhead: true,
        triggerAction: 'all',
        transform:'izba',
        width:45,
        forceSelection:true
    });
  }
   if (document.getElementById('osob') != null) { 
    var osobCombo = new Ext.form.ComboBox({
        typeAhead: true,
        triggerAction: 'all',
        transform:'osob',
        width:70
    });
  }

    function getMethods(obj) {
      var result = [];
      for (var id in obj) {
        try {
          if (typeof(obj[id]) == "function") {
            result.push(id + ": " + obj[id].toString());
          }
        } catch (err) {
          result.push(id + ": inaccessible");
        }
      }
      return result;
    }

    //define select handler
    var selectHandler = function(myDP, date) {
      rokCombo.setValue(date.format('Y'));
      mesiacCombo.setValue(date.format('n'));
      denCombo.setValue(date.format('j'));
      myDP.hide();
    };
	if (document.getElementById('ukazKalendarPanelDiv') != null) { 
    var myDP = new Ext.DatePicker({
      todayText : "Dnes",
      cancelText : "Zrušiť",
      monthNames : new Array("Január", "Február", "Marec", "Apríl", "Máj", "Jún", "Júl", "August", "September", "Október", "November", "December"),
      dayNames : new Array("Ne", "Po", "Ut", "St", "Št", "Pi", "So"),
      nextText: 'Ďalší mesiac (Ctrl+&rarr;)',
      prevText: 'Predchádzajúci mesiac (Ctrl+&larr;)',
      monthYearText: 'Vyberte si mesiac (Ctrl+Up/Down na zmenu roku)',
      minDate : new Date(),
      minText : "Tento dátum je pred povoleným dátumom..",
      startDay: 1,
      listeners: {
      'select': selectHandler
      }
    });
    myDP.render('ukazKalendarPanelDiv');
    myDP.hide();

    var clickHandler = function() {
      myDP.show();
    };
    
  }
  
	if (document.getElementById('ukazKalendarPanel') != null) { 
    Ext.EventManager.on('ukazKalendarPanel', 'click', clickHandler);
  }
    if (document.getElementById('nacitaj_vdolinach') != null) { 
    Ext.Ajax.request({
    	url : 'http://www.visitliptov.sk/pocasie_ajax.php' ,
    	params : { jazyk : 'sk', ktore : 1 },
    	method: 'GET',
    	success: function ( result, request ) {
        document.getElementById('nacitaj_vdolinach').innerHTML = result.responseText;
        //document.getElementById('nacitaj_vdolinach').setAttribute('class', 'loaded');
    	}/*,
    	failure: function ( result, request) {
    		Ext.MessageBox.alert('Failed', result.responseText);
    	}*/
    });
  }
    //Ext.get('elan').click();
   /* 
    jQuery('#list1b').accordion({
      autoheight: false
    });
    */
});

$(document).ready(function(){$("a[class=submit]").click(function(){$(this).parents("form").submit();});});

//V DETAILE DTB SKOVAVA KRATKY POPIS A ZORBAZI DLHY POPIS
$(function() {
	$('#zobraz_popis').click(function(){
		$('.n_center_kratky_popis').hide();
		$(this).parent().next().slideDown();
		return false;
	});
});

//V DETAILE DTB SA ZOBRAZUJE VIAC V AKTUALITE
$(function() {
	$('.show_news').click(function(){
		$(this).parent().next().slideDown();
		$(this).parent().hide();
		return false;
	});
});

/* Copyright (c) 2008 DIYism (email/msn/gtalk:kexianbin@diyism.com web:http://diyism.com)
 * Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php) license.
 * project site: http://plugins.jquery.com/project/ajax_postup
 * Version: k9bq
 */

$.ajax_postup=function(obj)
              {//obj=={url:, file_ele_ids:, data:, success:}
               if ($('#div_form_jump').length>0)
                  {var the_div=$('#div_form_jump')[0];
                   the_div.innerHTML='';
                  }
               else
                   {var the_div = document.createElement('div');
                    the_div.id='div_form_jump';
                    the_div.style.display='none';
                   }
               var inner_html = '<form enctype="multipart/form-data" action="'+obj.url+'" method="post" target="iframe_upload" name="form_jump">';
               for (var key in obj.data)
                   {if (typeof(obj.data[key])!='object')
                       {inner_html+='<input type="text" name="'+key.replace(/"/g, '&quot;')+'" value="'+obj.data[key].replace(/"/g, '&quot;')+'" />';
                       }
                    else
                        {for (var key1 in obj.data[key])
                             {inner_html+='<input type="text" name="'+key.replace(/"/g, '&quot;')+'" value="'+obj.data[key][key1].replace(/"/g, '&quot;')+'" />';
                             }
                        }
                   }
               inner_html += '</form>';
               inner_html += '<iframe style="display: none;" name="iframe_upload" id="iframe_upload" src="" onload="upload_iframe_onload()"></iframe>';
               the_div.innerHTML = inner_html;
               document.body.appendChild(the_div);
               for (var i=0;i<obj.file_ele_ids.length;++i)
                   {var the_id=obj.file_ele_ids[i];
                    $('#'+the_id).wrap('<div id="file_ele_wrap" />');
                    var the_outer_html=$('#file_ele_wrap')[0].innerHTML;
                    $(document.form_jump).append($('#'+the_id));//won't work in IE if using ".clone()"
                    $('#'+the_id).attr('name', the_id);
                    $('#file_ele_wrap').replaceWith($(the_outer_html));
                   }
               window.upload_iframe_onload=function()
                                           {var ifr=document.getElementById('iframe_upload');
                                            if (ifr.contentWindow)
                                               {var json=ifr.contentWindow.document.body?ifr.contentWindow.document.body.innerHTML:null;
                                               }
                                            else if (ifr.contentDocument)
                                                 {var json=ifr.contentDocument.document.body?ifr.contentDocument.document.body.innerHTML:null;
                                                 }
                                            obj.success(json)
                                           };							
               document.form_jump.submit();
              }
