function print_r(theObj)
{

  var my_string = "";  

  if(theObj.constructor == Array)
  {
		my_string+="<ul>";
		for(var p in theObj)
		{
		  if(theObj[p].constructor == Array)
		  {
			my_string+="<li>["+p+"] => "+typeof(theObj)+"</li>";
			my_string+="<ul>";
			print_r(theObj[p]);
			my_string+="</ul>";
		  }
		  else
		  {
			my_string+="<li>["+p+"] => "+theObj[p]+"</li>";
		  }
		}

		my_string+="</ul>";
   }


  return my_string;
}




//==================================================================================================
//GET THE GRID AND THE GRID CONTAINER PROPERTIES 
//==================================================================================================
function setGridObjectProperties()
{
	var grid_page = $('grid');  
	var posGrid = getPosition(grid_page);	

	var dim_grid_height = grid_page.scrollHeight; //grid height
	
	
	
	var dim_grid_width = 	grid_page.scrollWidth; //grid width
	var dim_grid_cell_height = dim_grid_height/48;   //grid cell height


	gridObj.dim_grid_height = dim_grid_height;
	gridObj.dim_grid_width = dim_grid_width;
	gridObj.dim_grid_cell_height = dim_grid_cell_height;
	

	gridObj.posGrid = posGrid;	
	gridObj.grid_page = grid_page;
	 
	
	gridObj.grid_visible_id_interval_start = 19;
	gridObj.grid_visible_id_interval_end = 26;
	
	var initial_scroll_top = 18*gridObj.dim_grid_cell_height;	
	gridObj.initial_scroll_top = initial_scroll_top;

	
	var gridcontainer_page = $("gridcontainer");
	gridcontainer_page.scrollTop = initial_scroll_top;

	
	
}
//==================================================================================================
//==================================================================================================

//==================================================================================================
//==================================================================================================

//document.onLoad = setGridObjectProperties;

//==================================================================================================
//==================================================================================================

Number.prototype.NaN0=function(){return isNaN(this)?0:this;}

function getPosition(e){
	var left = 0;
	var top  = 0;
	while (e.offsetParent){
		left += e.offsetLeft + (e.currentStyle?(parseInt(e.currentStyle.borderLeftWidth)).NaN0():0);
		top  += e.offsetTop  + (e.currentStyle?(parseInt(e.currentStyle.borderTopWidth)).NaN0():0);
		e     = e.offsetParent;
	}


	left += e.offsetLeft + (e.currentStyle?(parseInt(e.currentStyle.borderLeftWidth)).NaN0():0);
	top  += e.offsetTop  + (e.currentStyle?(parseInt(e.currentStyle.borderTopWidth)).NaN0():0);

	return {x:left, y:top};

}

//==================================================================================================
//==================================================================================================


function Browser() 
{
  var ua, s, i;

  this.isIE    = false;
  this.isNS    = false;
  this.version = null;

  ua = navigator.userAgent;
  
  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Opera";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

//==================================================================================================
//==================================================================================================


function dragStart(event, id)
{

  var el;
  var x, y;
  
  var start_event_on_grid = true;  
 

  //alert(nr_conferences);
  //alert(conferences_array.length+1);
  

   
  //if( (nr_conferences == 1) || ( (nr_conferences+1)  == (conferences_array.length)) )
  /*
  if(nr_conferences)
  {
  	
	if(nr_conferences_start != nr_conferences)
	{
		start_event_on_grid = false;
		return false;
	}
  	
  }
  */


  if(start_event_on_grid)
  {
  
	  dragObj = new Object();
	  dragObj.cursorStartY = 0;
		
	  // If an element id was given, find it. Otherwise use the element being
	  // clicked on.
	
	  if (id)
	    dragObj.elNode = document.getElementById(id);
	
	  else {
	    if (browser.isIE)
	      dragObj.elNode = window.event.srcElement;
	    if (browser.isNS)
	      dragObj.elNode = event.target;
	
	    // If this is a text node, use its parent element.
	
	    if (dragObj.elNode.nodeType == 3)
	      dragObj.elNode = dragObj.elNode.parentNode;
	  }
	
	  // Get cursor position with respect to the page.
	
	  if (browser.isIE) {
	    x = window.event.clientX + document.documentElement.scrollLeft
	      + document.body.scrollLeft;
	    y = window.event.clientY + document.documentElement.scrollTop
	      + document.body.scrollTop;
	  }
	  if (browser.isNS) {
	    x = event.clientX + window.scrollX;
	    y = event.clientY + window.scrollY;
	  }
	
	  // Save starting positions of cursor and element.
	
	  dragObj.cursorStartX = x;
	  dragObj.cursorStartY = y;
	  dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
	  dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);
	
	  dragObj.elStartLeft = 0;
	  dragObj.elStartTop  = 0;
	
	  // Update element's z-index.	  

	
	  
	  //SET elNode properties-----------------------------------------------------------------------	
	  if (!browser.isIE)
	  {
	  	dragObj.elNode.style.zIndex = dragObj.zIndex;    
	  }
	  dragObj.elNode.style.backgroundColor="#fed116";
	
	  try{dragObj.elNode.style.mozOpacity= 0.65;}catch(err){ }
	  try{dragObj.elNode.style.filter="alpha(opacity=65)";}catch(e){alert(e);}
	  try{dragObj.elNode.style.opacity=0.65;}catch(err){} 
	  
	
	  dragObj.elNode.style.width = '100%';
	  dragObj.elNode.style.left = '2px'; 
	
	 
	  //---------------------------------------------------------------------------------------------
	
	 	
	  var gridcontainer_page = $("gridcontainer");
	  var scroll_top = gridcontainer_page.scrollTop; //grid scroll
	
	  var pos_start = y - gridObj.posGrid.y + scroll_top;
	  pos_start = Math.floor(pos_start/gridObj.dim_grid_cell_height) * gridObj.dim_grid_cell_height;  //position start for the conference div
	
	  var id_interval_start = pos_start/gridObj.dim_grid_cell_height+1; //interval id start for conference
	
	  //$("id_interval_start").value = id_interval_start; 
	
	  //SET elNode properties-----------------------------------------------------------------------	
	  dragObj.elNode.style.height= gridObj.dim_grid_cell_height;
	  dragObj.elNode.style.top =  pos_start; 
	  dragObj.elNode.style.display='block';	
	  //---------------------------------------------------------------------------------------------
	
	
	 
	  dragObj.pos_start = pos_start;
	  dragObj.cursorStartY = pos_start - scroll_top + gridObj.posGrid.y;
	  dragObj.cursorStartYOriginal = y;
	  dragObj.id_interval_start = id_interval_start;  
	  dragObj.scroll_top = scroll_top; //scroll top of the grid
	
	  //SET SCROLLING VARIABLES-----------------------------------------------------------------------------------
	  gridObj.grid_visible_id_interval_start = Math.ceil(scroll_top/gridObj.dim_grid_cell_height)+1;
	  gridObj.grid_visible_id_interval_end =  gridObj.grid_visible_id_interval_start+7;	  
	  gridObj.initial_scroll_top = scroll_top;
	  //----------------------------------------------------------------------------------------------------------
	  
	
	 //$("mouse_pos_x").innerHTML =  gridObj.grid_visible_id_interval_start+"||"+gridObj.grid_visible_id_interval_end;
	  
	  // Capture mousemove and mouseup events on the page.
	
	  if (browser.isIE)
	  {
	     document.attachEvent("onmousemove", dragGo);
	     document.attachEvent("onmouseup",   dragStop);
	     window.event.cancelBubble = true;
	     window.event.returnValue = false;
	
	  }
	  if (browser.isNS)
	  {
	     document.addEventListener("mousemove", dragGo,   true);
	     document.addEventListener("mouseup",   dragStop, true);
	     event.preventDefault();
	
	  }
	  
  }// if(start_event_on_grid)


}

//==================================================================================================
//==================================================================================================


function dragGo(event) {

  var x, y;
  
  var positionX, positionY;

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Move drag element by the same amount the cursor has moved.
  positionX = (dragObj.elStartLeft + x - dragObj.cursorStartX);
  positionY = (dragObj.elStartTop  + y - dragObj.cursorStartY);

  
   

  if(positionY >= 0)	
  {
	   var nr_cell_grow =  Math.ceil(positionY/ gridObj.dim_grid_cell_height); 
	   var height_conference =  nr_cell_grow*gridObj.dim_grid_cell_height;

	   dragObj.elNode.style.height  = height_conference;	   
	   dragObj.elNode.style.top =  dragObj.pos_start;

	   var id_interval_end = dragObj.id_interval_start + nr_cell_grow; //interval id end

	   var pos_end = dragObj.pos_start + nr_cell_grow*gridObj.dim_grid_cell_height; //end position for the conference
	   
	   
	   
	   

	   var dif_pos_end = id_interval_end  - gridObj.grid_visible_id_interval_end;		   
	   var gridcontainer_page = $("gridcontainer");
  	   if(dif_pos_end >= 1)
  	   {
  			gridcontainer_page.scrollTop =  dragObj.scroll_top + (gridObj.dim_grid_cell_height*dif_pos_end);
  			//gridObj.grid_visible_id_interval_end ++;
  	   }		
	 
  	 // $("mouse_pos_y").innerHTML = dif_pos_end+"||"+gridObj.grid_visible_id_interval_end;

  }
  else
  {
	   positionYPos = Math.abs(positionY);	

	   var nr_cell_grow =  Math.ceil(positionYPos/ gridObj.dim_grid_cell_height); 	   
	   nr_cell_grow ++ ;
		
	  
	   
       var height_conference = nr_cell_grow*gridObj.dim_grid_cell_height;

       dragObj.elNode.style.height  = height_conference;

	   if(nr_cell_grow > 1)
	   {
            dragObj.elNode.style.top =  dragObj.pos_start -	(nr_cell_grow-1)*gridObj.dim_grid_cell_height;
	   }

	   var id_interval_end = dragObj.id_interval_start - nr_cell_grow; //interval id end

	   var pos_end = dragObj.pos_start - nr_cell_grow*gridObj.dim_grid_cell_height; //end position for the conference
	   
	   var dif_pos_end = id_interval_end   - gridObj.grid_visible_id_interval_start;	
	   
	    
	    var gridcontainer_page = $("gridcontainer");
  	    if(dif_pos_end < 0)
  	    {  	    	
  			gridcontainer_page.scrollTop =  dragObj.scroll_top + (dif_pos_end*gridObj.dim_grid_cell_height);
  	    }		
	   
  }
  
     
 

  dragObj.id_interval_end = id_interval_end;
  dragObj.pos_end = pos_end;
  dragObj.height_conference = height_conference;
  
  
  $("user_conf_time_af").innerHTML = day_intervals_array[dragObj.id_interval_start]+" - "+day_intervals_array[dragObj.id_interval_end];
  
  
  
  //user_conf_time_af
  

  //$('id_interval_end').value = id_interval_end;
  //$("mouse_pos_x").innerHTML = nr_cell_grow;
  //$("mouse_pos_y").innerHTML = positionY+"|"+dragObj.elStartTop;
 
  
  
  /*	
   //LAST POSITION---------------------------------------------------------
  if(dragObj.id_interval_end == 49)
  {
	 // dragObj.id_interval_end = 1;
  }
  //-----------------------------------------------------------------------
  */
  
     
  
  //STOP AT THE END OF GRID------------------------------------------------------------------------------------------------------
   
  if (browser.isIE)
  {
	 window.event.cancelBubble = true;
	 window.event.returnValue = false;

	 if( (id_interval_end > 48) && (positionY >= (gridObj.dim_grid_cell_height-1) ) )
	 {
		 dragStop(window.event);
	 }
  }
  if (browser.isNS)
  {
	     event.preventDefault();
	           	 	
	    
		 if( (id_interval_end > 48) && (positionY >= (gridObj.dim_grid_cell_height-1) ) )
		 {
			 dragStop(event);
		 }
  }
  
  
 // $("mouse_pos_x").innerHTML = "id_interval_end = "+id_interval_end+"||"+"positionY="+positionY;   
   
  //-----------------------------------------------------------------------------------------------------------------------------

  
  
  //set the indicators length
  
  if(positionX<0)
  {
      positionX=0;
  }
  
  if(positionY<0)
  {
      positionY=0;
  } 
 
 

 


}

//==================================================================================================
//==================================================================================================


function dragStop(event)
{

  // Stop capturing mousemove and mouseup events.

  if (browser.isIE) {
    document.detachEvent("onmousemove", dragGo);
    document.detachEvent("onmouseup",   dragStop);
  }
  if (browser.isNS) {
    document.removeEventListener("mousemove", dragGo,   true);
    document.removeEventListener("mouseup",   dragStop, true);
  }


   
	

	//-------------------------------------------------------------------------------------
	//IF WE CREATE A SINGLE INTERVAL CONFERENCE THEN WE DON;T HAVE DRAGGO SO THE DRAGOBJ PROPERTIES MUST BE SET HERE
	//-------------------------------------------------------------------------------------
	
	if(!dragObj.id_interval_end)
	{
		/*
		if(dragObj.id_interval_start == 48)
		{
			dragObj.id_interval_end = 1;
		}
		else
		{		
			
		}
		*/
		
		dragObj.id_interval_end = dragObj.id_interval_start+1;
	}
	
	

	if(!dragObj.pos_end)
	{
		dragObj.pos_end = dragObj.pos_start + gridObj.dim_grid_cell_height;
	}

	if(!dragObj.height_conference)
	{
		dragObj.height_conference = gridObj.dim_grid_cell_height;
	}
	//-------------------------------------------------------------------------------------
	//-------------------------------------------------------------------------------------
	
	//alert(dragObj.id_interval_start);
	//alert(dragObj.id_interval_end);
	

  //---------------------------------------------------------------------------------------------------------
  //SET THE OVERLAY DETAILS	
  //---------------------------------------------------------------------------------------------------------
 

  if(page_name_value == "index.php") 
  {
  		$("day_interval_start_id").value = dragObj.id_interval_start;
  		$("day_interval_end_id").value = dragObj.id_interval_end;
  		
  		$("user_conf_time_af").innerHTML = day_intervals_array[dragObj.id_interval_start]+" - "+day_intervals_array[dragObj.id_interval_end];	
  		
  		 		
  }
  else
  {

   
	   if(page_name_value=="test_divs.php")		
	   {
	  	
		   $("interval_selected_af").innerHTML = day_intervals_array[dragObj.id_interval_start]+" - "+day_intervals_array[dragObj.id_interval_end];  
		  	
		  	var overlay_pos_x = 0;
		  	var overlay_pos_y = 0;
		
		  	overlay_pos_y = dragObj.pos_start  + 50 -  dragObj.scroll_top + gridObj.posGrid.y;  
		  	overlay_pos_x = Math.floor(gridObj.dim_grid_width/2) + gridObj.posGrid.x;
		
		  	//alert(overlay_pos_x +" "+ overlay_pos_y);
		
		  	$("overlay_user_pick_time").style.position = 'absolute';
		  	$("overlay_user_pick_time").style.zIndex   = 32099;
		  	$("overlay_user_pick_time").style.left = overlay_pos_x;
		  	$("overlay_user_pick_time").style.top = overlay_pos_y;
		
		  	Element.show('overlay_main_page'); 
		  	$("overlay_user_pick_time").style.display = "block";
		  	
	   }
  	
  	
  	
  }

  	//---------------------------------------------------------------------------------------------------------
	//--------------------------------------------------------------------------------------------------------- 
    

}//dragStop(event)

//==================================================================================================
//==================================================================================================

//==================================================================================================
//FUNCTION CLOSE OVERLAY FOR TIME PICKER
//==================================================================================================
function close_overlay_time_picker()
{
	dragObj.elNode.style.display = "none";
	

	Element.hide('overlay_main_page');
	Element.hide('overlay_user_pick_time');

	dragObj = new Object();


}
//==================================================================================================
//==================================================================================================

//==================================================================================================
//FUNCTION CREATE DRAGGABLE ELEMENT FOR A CONFERENCE DIV 
//==================================================================================================

function create_dragable_object_with_scriptaculous(conference_div_id_name, conference_id)
{
	//alert(gridObj.dim_grid_cell_height);
	
	var my_drag = new Draggable(conference_div_id_name,	
	
	{ snap:[0, gridObj.dim_grid_cell_height], constraint:'vertical', change: funciton_drag_on_change, revert:function_drag_on_drop, zindex:10000 }
	
	);

	conferences_array[conference_id]["my_drag"] = my_drag;

}
//==================================================================================================
//==================================================================================================

//==================================================================================================
//FUNCITON SET Z-INDEX FOR A CONFERENCE DIV
//==================================================================================================

function set_zIndex_for_conference_div(conference_id)
{
	var z_index = 1000;
	
	z_index = conferences_array[conference_id]["id_interval_start"] * 20 + 1000;

	//alert(conference_id+" "+z_index);
	
	conferences_array[conference_id]["element"].style.zIndex = z_index;
}

//==================================================================================================
//==================================================================================================



//==================================================================================================
//FUNCTION CREATE CONFERENCE ON PAGE AND UPDATING THE CONFERENCE ARRAY
//==================================================================================================

function create_conference_interval_content(pos_start_var, pos_end_var, id_interval_start_var, id_interval_end_var, height_conference_var, content_conference_title, color_conf, icon_left)
{
	var nr_conferences_page = conferences_array.length;			

		

	var conference_id = "conference_"+nr_conferences_page;
	var conference_start_id = "conferencestart_"+nr_conferences_page;
	var conference_height_id = "conferenceheight_"+nr_conferences_page;
	
	content_conference_title_html = "";
	if(content_conference_title)
	{
		content_conference_title_html = content_conference_title;
	}
	
	

	var conference_container = document.createElement('div');	
	conference_container.id = conference_id;
	conference_container.className = 'chip';
	
	//alert(id_interval_start_var);
	//alert(pos_start_var);
	
	
	
	//---------------------------------------------------------------------------------------------------------
	//CREATE CONFERENCE DIV ON PAGE
	//---------------------------------------------------------------------------------------------------------
    
    conference_container.style.position = 'absolute';
	conference_container.style.zIndex = '20';
 	conference_container.style.top = pos_start_var;
	conference_container.style.left = "2px";
	conference_container.style.height = height_conference_var;
	conference_container.style.width = "100%";

	conference_container.style.backgroundColor = "#668cd9";	
	
	function_on_mouse_down = "";
	if(page_name_value=="test_divs.php")	
	{
		function_on_mouse_down = "dragStartResize(event, '"+conference_id+"')";
	}

//<div class="t1" style="background-color: rgb(41, 82, 163);">&nbsp;</div><div class="t2" style="background-color: rgb(41, 82, 163);">&nbsp;</div>
//<div class="b2" style="border-color: rgb(41, 82, 163); background-color: rgb(102, 140, 217);">&nbsp;</div><div class="b1" style="background-color: rgb(41, 82, 163);">&nbsp;</div>

	/*
	if(icon_left)
	{
		var content_icon = icon_left;
	}
	else
	{
		var content_icon = '<img src="'+dir_value+'/images/icons/alarm_white.gif" height="7" width="9">';
	}
	*/
	
	var content_icon = '<img src="'+dir_value+'/images/icons/alarm_white.gif" height="7" width="9">';
	
	if(color_conf)
	{
		var content_background_color = color_conf;
	}
	else
	{
		var content_background_color = "rgb(102, 140, 217);";
	}
	
	//alert(content_icon);
	
	conference_container.innerHTML='<div class="chipbody edit" style="background-color:'+content_background_color+' "><dl id="'+conference_height_id+'" style="border-color: rgb(41, 82, 163); height: '+height_conference_var+'"><dt style="background-color: rgb(41, 82, 163);">  <b unselectable="on"><span class="timelabel" id="'+conference_start_id+'">'+day_intervals_array[id_interval_start_var]+'</span> '+content_icon+'</b></dt><dd><div><span style="cursor: pointer;color:#ffffff">'+content_conference_title_html+' </span></div></dd><dd class="resize" height="5" unselectable="on"  onmousedown="'+function_on_mouse_down+'"></dd> </dl></div>';

	

	gridObj.grid_page.appendChild(conference_container);
	//---------------------------------------------------------------------------------------------------------
	//---------------------------------------------------------------------------------------------------------

		
	//---------------------------------------------------------------------------------------------------------
	//UPDATING CONFERENCE ARRAY IN PAGE
	//---------------------------------------------------------------------------------------------------------
	conferences_array[nr_conferences_page] = new Array();

	conferences_array[nr_conferences_page]["element"] = conference_container;		
	conferences_array[nr_conferences_page]["element_time"] = $(conference_start_id);
	conferences_array[nr_conferences_page]["element_content"] = $(conference_height_id);

	
	conferences_array[nr_conferences_page]["pos_start"] = pos_start_var;	
	conferences_array[nr_conferences_page]["pos_end"] = pos_end_var;
	conferences_array[nr_conferences_page]["id_interval_start"] = id_interval_start_var;
	conferences_array[nr_conferences_page]["id_interval_end"] = id_interval_end_var;
	conferences_array[nr_conferences_page]["height_conference"] = height_conference_var;
	
	//---------------------------------------------------------------------------------------------------------
	//---------------------------------------------------------------------------------------------------------

	//---------------------------------------------------------------------------------------------------------
	//CREATING DRAGABLE ELEMENT
	//---------------------------------------------------------------------------------------------------------
	if(page_name_value=="test_divs.php")	
	{				
		create_dragable_object_with_scriptaculous(conference_id, nr_conferences_page);
	}
	//---------------------------------------------------------------------------------------------------------
	//---------------------------------------------------------------------------------------------------------	

	//if(nr_conferences == 0)
	//{
		nr_conferences = nr_conferences +1;
	//}
		
}



function create_conference_interval()
{	
		
	create_conference_interval_content(dragObj.pos_start, dragObj.pos_end, dragObj.id_interval_start, dragObj.id_interval_end, dragObj.height_conference); 
	
	/*
	//ADD STOP EVENT ACTION ----------------------------------------------------------------------------
	 switch(page_name_value)
	 {
	 	case "user_inv_add_details.php":
	 		var nr_conferences_page = conferences_array.length;	
	 		set_action_end_event_select_conference_start_end_time(nr_conferences_page-1, conferences_array);
	 	break;
	 }
	 //--------------------------------------------------------------------------------------------------	 
	 
	 */

	//OVERLAPPING MECHANISM 
	set_conferences_array_order();
		
	//CLOSE THE OVERLAY
	close_overlay_time_picker();

}

//==================================================================================================
//==================================================================================================



//==================================================================================================
//FUNCTION WHEN A CONFERENCE IS DRAGGED USED WITH SCRIPTACULOUS EVENT
//==================================================================================================
function funciton_drag_on_change(my_drag_obj)
{
	
	
	
	var conference_div_id = my_drag_obj.element;
	var conference_div_id_name = conference_div_id.id;		
    var comp =  conference_div_id_name.split("_"); 
	var conference_id = comp[1];
	
	var gridcontainer_page = $("gridcontainer");
	var scroll_top = gridcontainer_page.scrollTop; //grid scroll
	
	var conferencePos = getPosition(conference_div_id);	
	
	posGridYPos = Math.abs(gridObj.posGrid.y);
		
	var conference_pos_start = Math.floor( (conferencePos.y - gridObj.posGrid.y )/gridObj.dim_grid_cell_height) * gridObj.dim_grid_cell_height;	
	
	
		
	
	var conference_pos_end = conference_pos_start + conferences_array[conference_id]["height_conference"]; 
	
	var id_interval_start = conference_pos_start/gridObj.dim_grid_cell_height+1;
	var id_interval_end = conference_pos_end/gridObj.dim_grid_cell_height+1;


	conferences_array[conference_id]["pos_start"] = conference_pos_start;
	conferences_array[conference_id]["pos_end"] = conference_pos_end;
	conferences_array[conference_id]["id_interval_start"] = id_interval_start;
	conferences_array[conference_id]["id_interval_end"] = id_interval_end;
	
	//SET Z INDEX
	//set_zIndex_for_conference_div(conference_div_id_name, conference_id);

	
	conferences_array[conference_id]["element_time"].innerHTML = day_intervals_array[id_interval_start]+" - "+day_intervals_array[id_interval_end];
	
}


function function_drag_on_drop(conference_id_object)
{	
	$("mouse_pos_x").innerHTML = "drop"; 
	var conference_div_id_name = conference_id_object.id;		
    var comp =  conference_div_id_name.split("_"); 
	var conference_id = comp[1];	
	
	set_zIndex_for_conference_div(conference_id);
	
	/*
     //ADD STOP EVENT ACTION ----------------------------------------------------------------------------
	 switch(page_name_value)
	 {
	 	case "user_inv_add_details.php":
	 		set_action_end_event_select_conference_start_end_time(conference_id, conferences_array);
	 	break;
	 }
	 //--------------------------------------------------------------------------------------------------	 
	 
	*/
		
	set_conferences_array_order(); 

	
}

//==================================================================================================
//==================================================================================================
//==================================================================================================
//==================================================================================================

//==================================================================================================
//RESIZE ACTIONS
//==================================================================================================

function dragStartResize(event, conference_div_id_name)
{
   resizeObj = new Object();
   
   resizeObj.conference_div_id_name = conference_div_id_name;

   var comp =  conference_div_id_name.split("_"); 
   var conference_id = comp[1];
   resizeObj.conference_id = conference_id; //the id from the array of conferences

   resizeObj.elNode = conferences_array[conference_id]["element"];

    var gridcontainer_page = $("gridcontainer");
    var scroll_top = gridcontainer_page.scrollTop; //grid scroll

	resizeObj.scroll_top = scroll_top;

   //-------------------------------------------------------------------------------------------------------- 	
   //DESTROY MY DRAG FROM SCRIPTACULOUS
   var my_drag = conferences_array[resizeObj.conference_id]["my_drag"];
   my_drag.destroy();
   //-------------------------------------------------------------------------------------------------------- 

   //$('mouse_pos_x').innerHTML =  conferences_array[conference_id]["pos_start"] +" "+conferences_array[conference_id]["pos_end"];
   //$('mouse_pos_y').innerHTML =  conferences_array[conference_id]["id_interval_start"]+" "+conferences_array[conference_id]["id_interval_end"];  
   

   if (browser.isIE)
   {
		 document.attachEvent("onmousemove", dragGoResize);
		 document.attachEvent("onmouseup",   dragStopResize);
		 window.event.cancelBubble = true;
		 window.event.returnValue = false;
		

   }
   if (browser.isNS)
   {
		 document.addEventListener("mousemove", dragGoResize,   true);
		 document.addEventListener("mouseup",   dragStopResize, true);
		 event.preventDefault();
   }

    try{ window.event.stopPropagation(); } catch(err){ }
	try{ event.stopPropagation(); } catch(err){ }

	

}

//---------------------------------------------------------------------------------------------------------

function dragGoResize(event)
{

	resizeObj.elNode.style.top = conferences_array[resizeObj.conference_id]["pos_start"];

	//GET MOUSE POSITION
	if (browser.isIE)
	{
		x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
		y = window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
	}
	if (browser.isNS)
	{
		x = event.clientX + window.scrollX;
		y = event.clientY + window.scrollY;
	}

	

	
	var positionY = y -  conferences_array[resizeObj.conference_id]["pos_end"] + resizeObj.scroll_top - gridObj.posGrid.y;
	
	

	//$('id_interval_start').value = gridObj.posGrid.y;
	//$('id_interval_end').value = y;

	if(positionY > 0)
	{
		
		positionY = Math.floor(positionY/gridObj.dim_grid_cell_height)*gridObj.dim_grid_cell_height;

		var height_conference = conferences_array[resizeObj.conference_id]["height_conference"] + positionY;

		var nr_cell_grow = positionY/gridObj.dim_grid_cell_height;


		resizeObj.elNode.style.height =  height_conference;

		//$('mouse_pos_x').innerHTML = height_conference
	
		conferences_array[resizeObj.conference_id]["pos_end"] = conferences_array[resizeObj.conference_id]["pos_end"] + positionY;	
		conferences_array[resizeObj.conference_id]["height_conference"] = height_conference;
		conferences_array[resizeObj.conference_id]["id_interval_end"] = conferences_array[resizeObj.conference_id]["id_interval_end"] + nr_cell_grow;

		conferences_array[resizeObj.conference_id]["element_content"].style.height = height_conference;

	}
	else
	{
		  positionYPos = Math.abs(positionY);
		  var positionYPos =  Math.ceil(positionYPos/ gridObj.dim_grid_cell_height)*gridObj.dim_grid_cell_height; 	   
			
          var height_conference = conferences_array[resizeObj.conference_id]["height_conference"] - positionYPos;

     	  var nr_cell_grow = positionYPos/gridObj.dim_grid_cell_height;

		 if(height_conference >= gridObj.dim_grid_cell_height)
		 {
			 
			resizeObj.elNode.style.height =  height_conference;			
			conferences_array[resizeObj.conference_id]["pos_end"] = conferences_array[resizeObj.conference_id]["pos_end"] - positionYPos;	
	   	    conferences_array[resizeObj.conference_id]["height_conference"] = height_conference;
    		conferences_array[resizeObj.conference_id]["id_interval_end"] = conferences_array[resizeObj.conference_id]["id_interval_end"] - nr_cell_grow;

			conferences_array[resizeObj.conference_id]["element_content"].style.height = height_conference;

		 } 

	}
	
	//set_zIndex_for_conference_div( resizeObj.conference_div_id_name, resizeObj.conference_id);
	

	 conferences_array[resizeObj.conference_id]["element_time"].innerHTML = day_intervals_array[conferences_array[resizeObj.conference_id]["id_interval_start"]]+" - "+day_intervals_array[conferences_array[resizeObj.conference_id]["id_interval_end"]];
	
	 //$("mouse_pos_x").innerHTML = positionY;
     //$("mouse_pos_y").innerHTML = height_conference;

	 if (browser.isIE)
	 {
		 window.event.cancelBubble = true;
		 window.event.returnValue = false;

		 if(conferences_array[resizeObj.conference_id]["id_interval_end"] >= 48)
		 {
			 dragStopResize(window.event);
		 }
	  }
	  if (browser.isNS)
	  {
			event.preventDefault();
			 if( (conferences_array[resizeObj.conference_id]["id_interval_end"] >= 48) )
			 {
				 dragStopResize(event);
			 }
	  }

}
	
//---------------------------------------------------------------------------------------------------------

function dragStopResize(event)
{


  //alert(resizeObj.elNode.style.zIndex);	

  // Stop capturing mousemove and mouseup events.
  if (browser.isIE)
  {
	  document.detachEvent("onmousemove", dragGoResize);
	  document.detachEvent("onmouseup",   dragStopResize);
  }

  if (browser.isNS)
  {
      document.removeEventListener("mousemove", dragGoResize,   true);
      document.removeEventListener("mouseup",   dragStopResize, true);
  }
  
  
  //---------------------------------------------------------------------------------------------------------
  //CREATING DRAGABLE ELEMENT
  //---------------------------------------------------------------------------------------------------------
  create_dragable_object_with_scriptaculous(resizeObj.conference_div_id_name,  resizeObj.conference_id);
  //---------------------------------------------------------------------------------------------------------
  //---------------------------------------------------------------------------------------------------------	
  
  
  //OVERLAPPING MECHANISM	
  set_conferences_array_order();
  
  
  	/*
     //ADD STOP EVENT ACTION ----------------------------------------------------------------------------
	 switch(page_name_value)
	 {
	 	case "user_inv_add_details.php":
	 		set_action_end_event_select_conference_start_end_time(resizeObj.conference_id, conferences_array);
	 	break;
	 }
	 //--------------------------------------------------------------------------------------------------
	 
	*/
  

  resizeObj = new Object();
  

}

//---------------------------------------------------------------------------------------------------------

//==================================================================================================
//==================================================================================================
