/* Author: 
	Luuk Barten
	Elicit
*/

$('#other').click(function(ev) {
 	ev.preventDefault();
  	$('#footer_pages').toggle('slow', function() {
    // Animation complete.
  });
});


//search datepickers and declare them as such.
$.datepicker.setDefaults({
   dateFormat: 'dd-mm-yy'
   });

$(function() {
		$( ".datetimepicker" ).datetimepicker({
		timeFormat: 'hh:mm:ss'}
		);
	});

$(function() {
		$( ".datepicker" ).datepicker();
	});

function insertimglink(url, title, dest)
{
	$.markItUp({ replaceWith:"<a target=\"blank\" href=\"" + dest + "\"><img src=\"" + url + "\" title=\"" + title + "\" /></a>" });
}

function insertlink(url, name)
{
	$.markItUp({ replaceWith:"<a target=\"blank\" href=\"" + url + "\" title=\"" + name + "\">" + name + "</a>" });
}

function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};


jQuery(document).ready(function() {
    jQuery('#slider').jcarousel({
        auto: 5,
        scroll: 1,
        animation: 3000,
        wrap: 'circular',
        easing: 'swing',
        buttonNextHTML: null,
        buttonPrevHTML: null,
        initCallback: mycarousel_initCallback
    });
});




//$("#mycarouseldoc").jcarousel();


$("#htmleditor").markItUp(mySettings);
$("#htmleditor_new").markItUp(mySettings);
$tabs = $("#tabs").tabs();
$tabs.tabs('select', 1);

$('#file_category_id').change(function() {
	$('#file_upload').uploadifySettings('scriptData',{file_category_id: $('#file_category_id').val()});
    var fcid = $('#file_category_id').val();
    var bodyContent = $.ajax({
       url: "/page/beheer/editor/get_files.php",
       global: false,
       type: "POST",
       data: ({file_category_id: fcid }),
       dataType: "html",
       async:false
 	}).responseText;
    $("#mycarouseldoc").html(bodyContent);
});

$('#file_upload').uploadify( {
	'uploader'  	: '/js/mylibs/uploadify/uploadify.swf',
	'script'    	: '/page/beheer/editor/put_file.php',
	'cancelImg' 	: '/js/mylibs/uploadify/cancel.png',
	'folder'    	: '/file/',
	'fileDataName' 	: 'file_id',
 	'buttonImg'     : '/js/mylibs/uploadify/upload_file.png',
	'width'         : 200,
	'auto'      	: true,
	'multi'       	: true,
	'scriptData'  	: {file_category_id: $('#file_category_id').val(),language_id: $('#language_id').val()},
	'onAllComplete' : function(event,data) {
	    var bodyContent = $.ajax({
	      url: "/page/beheer/editor/get_files.php",
	      global: false,
	      type: "POST",
	      data: ({file_category_id: $('#file_category_id').val()}),
	      dataType: "html",
	      async:false
		   }
			).responseText;
		    $("#mycarouseldoc").html(bodyContent);
		}
});

$('#image_category_id').change(function() {
    var icid = $('#image_category_id').val();
    var bodyContent = $.ajax({
       url: "/page/beheer/editor/get_images.php",
       global: false,
       type: "POST",
       data: ({image_category_id: icid }),
       dataType: "html",
       async:false
 	}).responseText;
    $("#mycarousel").html(bodyContent);
});

$('#image_id').uploadify( {
	'uploader'  	: '/js/mylibs/uploadify/uploadify.swf',
	'script'    	: '/page/beheer/editor/put_image.php',
	'cancelImg' 	: '/js/mylibs/uploadify/cancel.png',
	'folder'    	: '/img/',
	'buttonImg'     : '/js/mylibs/uploadify/upload_image.png',
	'width'         : 200,
	'fileDataName' 	: 'image_id',
	'auto'      	: true,
	'scriptData'  	: {image_category_id: 5},
	'onAllComplete' : function(event,data) {
	    var bodyContent = $.ajax({
	      url: "/page/beheer/editor/get_images.php",
	      global: false,
	      type: "POST",
	      data: ({image_category_id: 5}),
	      dataType: "html",
	      async:false
		   }
			).responseText;
		    $("#mycarousel").html(bodyContent);
		}
});

$('.infobox').qtip({
   content: {   
	   text: function(api) { 
           return $(this).next().html();
       }   	
   },
   position: {
         my: 'left center', 
         at: 'right center',
         adjust: {
                  x: 5
               }
   },
   show: 'mouseenter',
   hide: 'mouseout',
   style: {
         tip: true,
         classes: 'ui-tooltip-purple'
   }
});

$('.togglenext').click(function() {
  $(this).next().toggle('slow', function() {

  });
});




