(function() {
    if (typeof console === 'undefined') { console = { log: function() {}, warn: function() {}, error: function() {}, info: function() {}, dir: function() {} }; }
    var doc = document.documentElement;
    if (doc.className === '') { doc.className = 'has_js'; } else { doc.className += ' has_js'; }
})();

var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
// Handle all the FSCommand messages in a Flash movie.
function comp_DoFSCommand(command, args) {
    var compObj = isInternetExplorer ? document.all.comp : document.comp;
    //
    // Place your code here.
    //
}

// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
    document.write('<script language=\"VBScript\"\>\n');
    document.write('On Error Resume Next\n');
    document.write('Sub comp_FSCommand(ByVal command, ByVal args)\n');
    document.write('    Call comp_DoFSCommand(command, args)\n');
    document.write('End Sub\n');
    document.write('</script\>\n');
}


jQuery.noConflict()(function(){


    // the rest is jQuery **pheeew**
    var poll_form = jQuery('#poll_form');




    poll_form.find('fieldset:eq(0) input').change(function(e){
      
    
      var state = jQuery(this).attr('checked'),
          label = jQuery(this).parent().attr('for');
      
      if(label === 'question_1_2' && state === true){
        
        poll_form.find('fieldset:gt(0)').hide();
        poll_form.find('h2:eq(0)').hide();
        poll_form.find('.actions').hide();
        poll_form.append('<h2 class="ty">Hvala na Vašem vremenu!</h2>');

      } else {

        poll_form.find('fieldset:gt(0)').show();
        poll_form.find('h2:eq(0)').show();
        poll_form.find('.actions').show();
        poll_form.find('.ty').remove();

      }
      

    });

    var checked = null;
    poll_form.find('.max2answers input').click(function(e){
      
      var checked = poll_form.find('.max2answers input:checked').size();

      if(checked > 2){
        e.preventDefault();
      }

    });





    /* business development map */
    var map_container = jQuery('.map_container'),
      coordinates;

    jQuery('.business_dev_map a').click(function(e){
      var element = jQuery(this).attr('id');          

        if (jQuery('.business_dev_note').is(':hidden')) {
          jQuery('.business_dev_note').show();
        }

        /* promjena karte */
        switch (element) {
          case 'map_croatia':
              coordinates = '-400px 0';
              break;
          case 'map_bosnia':
              coordinates = '-800px 0';
              break;
          case 'map_serbia':
              coordinates = '-1200px 0';
              break;
          case 'map_montenegro':
              coordinates = '-1600px 0';
              break;
          case 'map_kosovo':
              coordinates = '-2000px 0';
              break;
          case 'map_albania':
              coordinates = '-2400px 0';
              jQuery('.business_dev_note').hide();
              break;
          default:
              coordinates = '-400px 0';
        }
        map_container.css({ 'background-position' : coordinates});

      if (jQuery('.'+element).is(':hidden')) {
        /* promjena informacija */      
        jQuery('.note:not(.'+element+')').hide();
        jQuery('.'+element).show();
      }

      e.preventDefault();
    });


    // prototype **shudder**
    var faq = $('faq-list');
    if (faq) { new accordion('faq-list') };
    
 });
