/*
function myCall() {
	$('#menu a').click(function() { //start function when any link is clicked
		
		$(".content").slideUp("slow");
		//var content_show = $(this).attr("title"); //retrieve title of link so we can compare with php file
		var chaine = $(this).attr("odmbalise"); //retrieve title of link so we can compare with php file
		var ident = $(this).attr("odmid"); //retrieve title of link so we can compare with php file

			$.ajax({
			method: "POST",
			url: '/index/'+chaine+'/format/text/id/'+ident,
			data: null,
			beforeSend: function(){$(".content").html('');$("#loading").show("fast");}, //show loading just when link is clicked
			complete: function(){ $("#loading").hide("fast");}, //stop showing loading when the process is complete
			success: function(html){ //so, if data is retrieved, store it in html
				$(".content").show("fast"); //animation
				$(".content").html(html); //show the html inside .content div
				
			}
		}); //close $.ajax(
	}); //close click(
}
*/
function myAjax(id,type,where) {
	var prefix = '/nadir';
	//var prefix = '';
	switch(where) {
		/**/
		case 'moveit':
			var thedata = 'dest='+type+'&'+id;
			var theurl = prefix+'/Administration/workpackages/'+where+'/text/id/0/';
			var divtopost = "#mycontent";
			break;
		default:
			var thedata = type+'='+id;
			var theurl = prefix+'/Administration/workpackages/'+where+'/text/id/0/';
			var divtopost = "#mycontent";
			break;
	}
	//alert(theurl);alert(thedata);
	$.ajax({
		method: "POST",
		url: theurl,
		data: thedata,
		success: function(html){ //so, if data is retrieved, store it in html
			if(html) {
				$(divtopost).html(html); //show the html inside .content div
			}
			
		}
	}); 
	
}

var simpleTreeCollection;
function myTree() {
	simpleTreeCollection = $('.simpleTree').simpleTree({
		autoclose: false,
		afterClick:function(node){myAjax(node.attr('odmvalue'),node.attr('odmtype'),'mycontent');},
		afterMove:function(destination, source, pos) {
			var source = source.attr('odmtype')+'='+source.attr('odmvalue');
			myAjax(source,destination.attr('odmvalue'),'moveit');
			/*
			alert(
			"destination-"+destination.attr('odmvalue')+destination.attr('odmtype')+
			" source-"+source.attr('odmvalue')+source.attr('odmtype'));
			*/
		},
		afterContextMenu:false,
		animate:true
	});

}
