$(document).ready(function() {
	function changeSystemEvent(option) {
		console.log(option);
	    if (option.selectedVal != "@" && option.selectedVal != "01W>") {
			$("input[name='systeem']").val("*");
	    } else {
			$("input[name='systeem']").val("_");
	    }

	    if (option.selectedVal == "01W>") {
			$("input[name='event']").val("search");
	    } else {
			$("input[name='event']").val("thsearch");
	    }
	};


    var rand= Math.floor(Math.random()*4);
    $("body").addClass("bg"+rand);

    $('#myselectbox_container').click(function(){
           //console.log('moi');
    });

    $('#myselectbox').selectbox({onChangeCallback: changeSystemEvent });
	$('#myselectbox2').selectbox({onChangeCallback: changeSystemEvent });

    //standaard de poll containter verstopppen
    $('.poll_container').hide();
    $('.archief_menu').hide();

    $('#stelling .poll_question').click(function() {
        $('.poll_container').toggle(BART.Front.Mod_Poll.animate_results());
        $('.archief_menu').show();
    });

    $('#stelling_hide').click(function() {
        $('.poll_container').slideUp();
        $('.archief_menu').hide();
    });

    $('.left .mod_event .default_block').click(function() {
          var url = $(this).find('.read_more a');
          url = url.attr('href');
          window.location = 'http://'+document.domain+"/"+url;
    });

	//qtip
	$('a.right_title[title]').qtip({
	    position: {
	        corner: {
	          target: 'leftMiddle',
         	  tooltip: 'rightMiddle'
	        }
	     },
	     style: {
		 	name: 'dark',
	        padding: '7px 13px',
	        width: {
	           max: 250,
	           min: 0
	        },
	        tip: true
	     }
	 });

	$('.bannermenu a[title]').qtip({
	    position: {
	        corner: {
	          target: 'leftMiddle',
         	  tooltip: 'rightMiddle'
	        }
	     },
	     style: {
		 	name: 'dark',
	        padding: '7px 13px',
	        width: {
	           max: 250,
	           min: 0
	        },
			height: {
				max: 100
			},
	        tip: true
	     }
	 });

	$(".target_blank").attr('target', '_blank');
	$(".target_self").attr('target', '_self');
	$(".target_parent").attr('target', '_parent');
	$(".target_top").attr('target', '_top');	  

    $("#topmenu a[title='Lees voor']").attr('href','http://app.readspeaker.com/proreader/proreader.php?cid=4303&amp;lang=nl_nl&amp;url=');
    $("#topmenu a[title='Lees voor']").attr('target','prwin');
    $("#topmenu a[title='Lees voor']").attr('onclick','window.open(this.href+escape(document.location.href)+"&selhtml="+escape(selectedString), this.target, "width=190, height=120, resizable=1, scrollbars=1, screenX=0,screenY=0, left=0, top=0"); return false;');

    $("#topmenu a[title='Print pagina']").click(function() {
             window.print();
          return false;
    });
});
