/* 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: 'yy-mm-dd'
   });

$(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('#carousel').jcarousel({
        auto: 3,
        scroll: 1,
        wrap: 'circular',
        buttonNextHTML: null,
        buttonPrevHTML: null,
        initCallback: mycarousel_initCallback
    });
*/
    
  	
    var new_position = $('#result').offset();
    window.scrollTo(new_position.left,(new_position.top -10));

});




//$("#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);
		}
});

//$('.step_0').click(function() {
//    var step_value =  $(this).val();
//    $.ajax({
//       url: "/page/choice/update.php",
//       global: false,
//       type: "POST",
//       data: ({	step_action: 'update',
//       			step_value: step_value, 
//       			step_id: 0 
//       			}),
//       dataType: "html",
//       async:false
// 	});
// 	
// 	var bodyContent = $.ajax({
//       url: "/page/choice/update.php",
//       global: false,
//       type: "POST",
//       data: ({	step_action: 'render',       			 
//       			step_id: 0}),
//       dataType: "html",
//       async:false
// 	}).responseText;
//    $("#step_0").html(bodyContent);
//        
//    
//    var bodyContent = $.ajax({
//       url: "/page/choice/update.php",
//       global: false,
//       type: "POST",
//       data: ({	step_action: 'render',       			 
//       			step_id: 1}),
//       dataType: "html",
//       async:false
// 	}).responseText;
//    $("#step_1").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-green'
   }
});

$('.filterinput').click(function() {
	
		$('#frm_koopwijzer').submit();
});


$('.myaddress').focus(function(){
		$this.val('');
});




