/******************************************************
    Title:   Wizzard
    Author:  Wizzard
******************************************************/

$(function() {
    Wizzard.CustomSelect('.Wizz_sel', {
        theme: 'oringe',
        animation: 'slide',
        scrollable: true,
		disable_first_elem: true
    });

    if($('.poll').length > 0) {
        $('.vote').click(function() {
            $.ajax({
              type: "POST",
              dataType: 'json',
              url: root + 'application/xml_http_request/?method=poll_vote',
              data: $('.poll form').serialize(),
              success: function(data) {
                  if(data.status == 'success') {
                      $('.poll form fieldset').fadeOut(500, function() {
                          $(this).html(data.results);
                      }).fadeIn(500)
                  }
              }
            })
        })

        $('#poll_results').click(function() {
            $.ajax({
              type: "POST",
              dataType: 'json',
              url: root + 'application/xml_http_request/?method=get_poll_results',
              data: $('.poll form').serialize(),
              success: function(data) {
                  if(data.status == 'success') {
                      $('.poll form fieldset').fadeOut(500, function() {
                          $(this).html(data.results);
                      }).fadeIn(500)
                  }
              }
            })
        })
    }

    if($('ul.tv a').length > 0) {
    	$('ul.tv a').click(function(e) {
    		window.open($(this).attr('href'));
    		return false;
    	})
    }

    /*
    var materials_over = false;

    //
    $('li.materials').mouseover(function() {
    	materials_over = true;
    	// $('ul', $(this)).toggle();
    });

    //
    $('ul', $('li.materials')).mouseover(function() {
    	if (materials_over) {
    		return;
    	}
    });
    */

})
