$(document).ready(function(){  
  if($(".slideshow")){
    $(".slideshow").cycle({ 
      fx:    'fade',
      speed:  2500,
      pause:  1
    });
  }
  
  if($("#uploadify")){
    $("#uploadify").uploadify({
      'uploader'       : 'uploadify.swf',
      'script'         : 'scripts/uploadify_upload.php',
      'cancelImg'      : 'img/cancel.png',
      'folder'         : 'content/',
      'queueID'        : 'fileQueue',
      'auto'           : true,
      'multi'          : true
    });
	}
  
  if($("#gb_captref")){
    $("#gb_captref").bind("click", function(){
      var rand=(Math.random()*10);
      $("#gb_captimg").attr("src","captcha.php?"+(rand));
    });
  }
  
  if($("#cropbox")){
    function showCoords(c){
      jQuery('#x').val(c.x);
      jQuery('#y').val(c.y);
      jQuery('#x2').val(c.x2);
      jQuery('#y2').val(c.y2);
      jQuery('#w').val(c.w);
      jQuery('#h').val(c.h);
    };
			
    jQuery('#cropbox').Jcrop({
      onChange: showCoords,
      onSelect: showCoords,
       boxWidth: 750,
       boxHeight: 750
    });
    
    $('#jcropreset').click(function(e) {
      // Release method clears the selection
      $.Jcrop('#cropbox').release();
    });
  }
  
  if($("#resizebox")){
    function getDimensions(id) {
      var element = document.getElementById(id);
      if (element && element.tagName.toLowerCase() == 'img') {
        return {
          width: element.width,
          height: element.height
        };
      }
    }

    // using the function on the above image:
    var dims;
    dims = getDimensions('resizebox');
    
    if(dims != null && $("#w")){
      $("#w").val(dims.width);
    }
    
    if(dims != null && $("#h")){
      $("#h").val(dims.height);
    }    
  }
});

function insertImg(path, title)
{
  var website = 'http://www.restaurant-intenz.nl/';
  tinyMCE.execCommand('mceInsertContent',false,'<img src="'+path+'" alt="' +title+ '" title="' +title+ '" />');
}
