$(document).ready(function(){
   	$(".toggleButton").click(function () {
     		$(".toggleArea").slideToggle(250);      
   	});
   	$(".addCategoryToggleButton").click(function () {
     		$(".addCategoryToggleArea").toggle();      
   	});
   	
 		$(".arrowSouth").click(function () {
     		$(this).parents(".widget").find(".widgetContent").slideToggle(250);
   	});
   	$("li.toggleA").click(function () {
     		$(this).parents(".menuWidget").find("li.toggleLI").slideToggle(250);
   	});
   	
   	$(".editLink").click(function() {
   		if($(this).attr('name')=='composed-article') {
   			var ids = $(this).attr('id').split('-');
   			$("#editWidget").load(baseurl + 'products/' + $(this).attr('name') + "/edit/id/" + ids[0] + "/art/" + ids[1]);
   		}
   		else {
   			$("#editWidget").load(baseurl + 'products/' + $(this).attr('name') + "/edit/id/" + $(this).attr('id'));
   		}
   	});
   	
   	
   	
   		
   	if	($(".widgetContent table tr").length < 2 ) 
   			{
   				$(".widgetContent tr.overviewHeader").css("border-bottom", "0px");
   			} else {
   				$(".widgetContent .trSplitLine :last").remove();		
   			};

   	// Generiek maken
  	$("#pages").treeview();
  	$("#categories").treeview({
  		collapsed: true
  	});
  	$("#tabs").tabs();

  	$("#dialog").dialog( {
		autoOpen: false,
		resizable: false
	});
	
	// Pages
	$(".page[id]").click(function() {
		$("#pageWidget").load(baseurl + 'pages/page/edit/id/' + $(this).attr('id').substring(1));
		$("#pageInfo").load(baseurl + 'pages/page/info/id/' + $(this).attr('id').substring(1));
	});

	$('div.rightWidgetHolder, div.smallLeftWidgetHolder').sortable({
		placeholder : 'ui-sortable-placeholder',
		connectWith : 'div.rightWidgetHolder' ,
		handle: '.widgetTop',
		forcePlaceholderSize: true,
		opacity 	: 0.6,
		tolerance 	: 'pointer'
	});
	var Wheight = $(document).height();
	var Cheight = $(".container").height();
	if (Wheight > Cheight) {
	$(".container").css("height", Wheight - 50);
	}
});

tinyMCE.init({
	theme : "advanced",
	skin : "ortisStyle",
	mode : "textareas",
     		editor_selector : "textAreaBig",
	plugins : "safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,imagemanager,filemanager",
	
	theme_advanced_buttons1 : "bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull,|,forecolor,backcolor,|,hr,sup,|,charmap",
	theme_advanced_buttons2 : "formatselect,link,unlink,anchor,cleanup,paste,pasteword,removeformat,code",
	theme_advanced_buttons3 : "",
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	theme_advanced_statusbar_location : "bottom",
	height : "350",
	width: "100%"
});

$(function() {
	$('.tableView').hover( 
   	function(){$(this).find('.productEditStyle').fadeIn(50);}
   	,
   	function(){$(this).find('.productEditStyle').fadeOut(200);}
   	);
});

$(function() {
	$('.filetree span.folder').hover( 
	function(){$(this).find('.editStyle').fadeIn(50);}
	,
	function(){$(this).find('.editStyle').fadeOut(100);}
	);
});
$(function() {
	$('.widgetContent table tr').hover( 
	function(){$(this).find('.editStyle').fadeIn(50);}
	,
	function(){$(this).find('.editStyle').fadeOut(100);}
	);
});
$("table tr:odd").css("background-color", "#eee");



