$(document).ready(function(){
						   
	$("#actiontabs").tabs();
 
  	$("#sharewithtabs").tabs();
	
	$("[title]").mbTooltip({
		opacity : 1, //opacity
		wait:200, //before show
		ancor:"mouse", //"parent"
		cssClass:"default", // default = default
		timePerWord:100, //time to show in milliseconds per word
		hasArrow:false,
		color:"white",
		imgPath:"images/",
		shadowColor:"black",
		fade:500
	});
	
	$("#accordion1").accordion({
		active: false,
		autoHeight: false,
		collapsible: true
	});
	
	$("#accordion2").accordion({
		active: false,
		autoHeight: false,
		collapsible: true
	});
	
	$("#accordion3").accordion({
		active: false,
		autoHeight: false,
		collapsible: true
	});
	
	$("#accordion4").accordion({
		active: false,
		autoHeight: false,
		collapsible: true
	});
	
	$("#accordion5").accordion({
		active: false,
		autoHeight: false,
		collapsible: true
	});

	$(".draggable").draggable({ 
		revert: 'valid',
		helper: 'clone',
		containment: '#content'		
	});
	$(".droppable").droppable({
		hoverClass: 'ui-state-active',
		drop: function(event, ui) {
			//$(this).addClass('ui-state-highlight').find('p').html('Dropped!');
			var target = $(this).attr('id');
			var target_array = target.split(" ");
			var target = target_array[0];
			var target2 = ui.draggable.attr('id');
			var target2_array = target2.split(" ");
			var target2 = target2_array[0];
			var owner = target2_array[1];

			ajaxFunction(target,target2,owner);	
	
			//now do ajax to update the database
			function ajaxFunction(target,file,owner){
				//the one for the user's own folder...
				var ajaxRequest;  // The variable that makes Ajax possible!
				try{
					// Opera 8.0+, Firefox, Safari
					ajaxRequest = new XMLHttpRequest();
			
				} catch (e){
					// Internet Explorer Browsers
					try{
						ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
					} catch (e) {
						try{
							ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
						} catch (e){
							//try{
							//	ajaxRequest = new XDomainRequest();
							//} catch (e){
								// Something went wrong
								alert("Your browser broke!");
								return false;
							//}
						}
					}
				}

				// Create a function that will receive data sent from the server
				ajaxRequest.onreadystatechange = function(){
					if(ajaxRequest.readyState == 4){
						var ajaxDisplay = document.getElementById('ajaxDiv');		//the div that the result appears on
						ajaxDisplay.innerHTML = ajaxRequest.responseText;
					}
				}
				var queryString = "?dropped=" + target + "&dragged=" + file + "&user=" + owner;
				alert(queryString);
				ajaxRequest.open("GET", "/functions/folders/dofolder.php" + queryString, true);
				ajaxRequest.send(null);
				//var timeoutID = setTimeout("window.location.reload(true);", 50);
			}
		}
	});
});