var ev= jQuery.noConflict();

/****************************** SAVE & UPDATE ***************************************/

function add_event(event_date,event_name,event_description,event_type,user_id)

{

	if((event_name!="")&&(event_type!=""))

	{

		ev("#new_event_div").html('<img src="images/ajax-loader.gif"> Loading...');

		ev.ajax({

		type: "GET",

		url: "events/events_db.php",

		data: "event_date="+event_date+"&event_name="+event_name+"&event_description="+event_description+"&event_type="+event_type+"&user_id="+user_id+"&action=add_event_name",

		success: function(msg){ev("#new_event_div").html(msg);}

		});

	}

	else

	{

		valid = true;

		if(document.new_event_form.event_name.value=="")

		{

			alert('Please Enter Event Name');

			document.new_event_form.event_name.focus();

			return false;

		}

		if(document.new_event_form.event_type.value=="")

		{

			alert('Please Enter Event type');

			document.new_event_form.event_type.focus();

			return false;

		}

	}

}



/*************************** load edit form ********************************************/

function edit_load_event(event_date,user_id)

{

		ev("#load_event").html('<img src="images/ajax-loader.gif"> Loading...');

		ev.ajax({

		type: "GET",

		url: "events/events_edit_name.php",

		data: "event_date="+event_date+"&user_id="+user_id,

		success: function(msg){ev("#load_event").html(msg);}

		});

}



function load_event_details(event_date,user_id,event_id)

{

		ev("#load_other_fileds").html('<img src="images/ajax-loader.gif"> Loading...');

		ev.ajax({

		type: "GET",

		url: "events/events_edit_details.php",

		data: "event_date="+event_date+"&user_id="+user_id+"&event_id="+event_id,

		success: function(msg){ev("#load_other_fileds").html(msg);}

		});

}



/****************************** remove event files *******************************/

function delete_event_picture(user_id,type,event_id,picture)

{alert(user_id);alert(type);alert(event_id);alert(picture);

		ev("#event_preview").html('<img src="images/ajax-loader.gif"> Loading...');

		ev.ajax({

		type: "GET",

		url: "events/events_db.php",

		data: "type="+type+"&user_id="+user_id+"&event_id="+event_id+"&picture="+picture+"&action=delete_event_picture",

		success: function(msg){ev("#event_preview").html(msg);}

		});

}

function delete_event_video(user_id,type,event_id,picture)

{

		ev("#event_preview").html('<img src="images/ajax-loader.gif"> Loading...');

		ev.ajax({

		type: "GET",

		url: "events/events_db.php",

		data: "type="+type+"&user_id="+user_id+"&event_id="+event_id+"&picture="+picture+"&action=delete_event_video",

		success: function(msg){ev("#event_preview").html(msg);}

		});

}

/**************** show event details **************************/

function show_events(event_date,user_id)

{

		ev("#show_events_div").html('<img src="images/ajax-loader.gif"> Loading...');

		ev.ajax({

		type: "GET",

		url: "events/show_events.php",

		data: "event_date="+event_date+"&user_id="+user_id+"&action=show_events",

		success: function(msg){ev("#show_events_div").html(msg);}

		});

}

/****************************** MOVE PICTURE ALBUM TO TRASH ***************************************/

function move_events_to_trash(user_id,event_id,event_date)

{

		ev("#show_events_div").html('<img src="images/ajax-loader.gif"> Loading...');

		ev.ajax({

		type: "GET",

		url: "events/events_db.php",

		data: "user_id="+user_id+"&event_id="+event_id+"&event_date="+event_date+"&action=move_trash_event",

		success: function(msg){ev("#show_events_div").html(msg);}

		});

}