var xmlHttp; var descriptionxmlHttpII; var descriptionxmlHttpIII; var image_infoxmlHttp; var display_comment_xmlHttp; var delete_comment_xmlHttp;
var display_image_on_list_xmlHttp; var rotate_xmlHttp; var description_history_xmlHttp; var exif_xmlHttp; var refresh_xmlHttp; var big_xmlHttp;
var validate_user_js_xmlHttp; var comments_matrix_view_xmlHttp; var populate_matrix_div_with_elements_xmlHttp; var change_view_xmlHttp; var display_enlarge_xmlHttp; var load_description_history; var matrix_thumb_width, matrix_thumb_height;
var sitepath; var continue_with_matrix_loading; continue_with_matrix_loading = false; var number_of_images; var descriptionxmlHttp; var tab_xmlHttp; var change_status_xmlHttp; var wccc_xmlHttp; var ftp_xmlHttp;
var sitepath; var continue_with_matrix_loading; continue_with_matrix_loading = false; var number_of_images; var descriptionxmlHttp;
var image_id_xmlHttp; var orig2_start_number_of_images; var ftp_uploads;
var desc_text_only; var ignore_old_ftp; var global_do_action;
desc_text_only = 0;

function GetXmlHttpObject_multi(variable_name)
{
	try
	{
		variable_name=new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			variable_name=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			variable_name=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return variable_name;
}

function change_status_popup_ajax(t_id, new_status)
{
	change_status_xmlHttp = null;
	change_status_xmlHttp = GetXmlHttpObject_multi(change_status_xmlHttp);
	if (change_status_xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	image_id = t_id;
	var url = siteaddress + "update_status_image.php?image_id=" + t_id + "&new_status=" + new_status
	url=url+"&sid="+Math.random();
	change_status_xmlHttp.onreadystatechange=update_single_status_ajax
	change_status_xmlHttp.open("GET",url,true)
	change_status_xmlHttp.send(null)
}

function update_single_status_ajax()
{ 
	if (change_status_xmlHttp.readyState==4 || change_status_xmlHttp.readyState=="complete")
	{
     		continue_with_matrix_loading = false;
		load_display_status(image_id);
	}
}
///////////////////////////////
function check_ftp_alarms_folder_specific(the_folder_id, orig_start_number_of_images, cont_loading)
{
	if (ignore_old_ftp==1)
	{
		ftp_uploads=0;
	}
	if (ftp_uploads == 0)	
	{
		parent.location.reload();
	}
	else
	{
		if (cont_loading == 0)
		{
			try
			{
				document.getElementById("refresh_change_id").innerHTML = "<img src='"+siteaddressroot+"_images/Menu/check_for_new_disable.png' title='Set Auto Refresh' style='border:0;'>";
			}
			catch (e)
			{
				document.getElementById("refresh_change_id_matrix").innerHTML = "<img src='"+siteaddressroot+"_images/Menu/manual_refresh_disable.png' title='Set Auto Refresh' style='border:0;'>";
			}
		}
		orig2_start_number_of_images = orig_start_number_of_images;
		orig2_start_number_of_images_continue = cont_loading;
		ftp_xmlHttp = null;
		ftp_xmlHttp = GetXmlHttpObject_multi(ftp_xmlHttp);
		if (ftp_xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		}
		var url = siteaddressroot + "checkftp.php?user=1&folder_id="+the_folder_id+"&f_id="+Math.random();
		ftp_xmlHttp.onreadystatechange=check_new_ftp_results
		ftp_xmlHttp.open("GET",url,true)
		ftp_xmlHttp.send(null)
	}
}

function check_new_ftp_results()
{
	if (ftp_xmlHttp.readyState==4 || ftp_xmlHttp.readyState=="complete")
	{
		if (orig2_start_number_of_images_continue == 0)
		{
			parent.location.reload();
		}
		else if (orig2_start_number_of_images_continue == 1)
		{
			response_text = ftp_xmlHttp.responseText;
			getting_refresh = response_text.split("@@@@@@@@@@");
			if (getting_refresh[1] == "1")
			{
				parent.location.reload();
			}
			else
			{
				start_timer2(orig2_start_number_of_images);
			}
		}
	}
}

function start_timer(start_number_of_images, client_account_type, the_folder_id)
{
	if (client_account_type == 1 && ignore_old_ftp==0)
	{
		check_ftp_alarms_folder_specific(the_folder_id, start_number_of_images, 1)
	}
	else
	{
		start_timer2(start_number_of_images);
	}
}

function start_timer2(start_number_of_images)
{
	number_of_images = 0;
	number_of_images = start_number_of_images;
	refresh_xmlHttp = null;
	refresh_xmlHttp = GetXmlHttpObject_multi(refresh_xmlHttp);
	if (refresh_xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	var url = siteaddress + "auto_refresh.php"
	refresh_xmlHttp.onreadystatechange=check_page_refresh
	refresh_xmlHttp.open("GET",url,true)
	refresh_xmlHttp.send(null)
}

function check_page_refresh()
{ 
	if (refresh_xmlHttp.readyState==4 || refresh_xmlHttp.readyState=="complete")
	{
		if (number_of_images == refresh_xmlHttp.responseText)
		{
			//alert("the same : " + number_of_images + " : " + refresh_xmlHttp.responseText);
		}
		else
		{
			parent.location.reload();
		}
	}
}

function set_page_number_open_gallery(page_index_number)
{
	try
	{
	}
	catch (e)
	{
		document.write("spacer");
	}
	set_page_xmlHttp = null;
	set_page_xmlHttp = GetXmlHttpObject_multi(set_page_xmlHttp);

	if (set_page_xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	
	var url = siteaddress + "set_open_gallery_page_index.php?"
	url=url+"pageindex=" + page_index_number;
	set_page_xmlHttp.onreadystatechange=set_page_number
	set_page_xmlHttp.open("GET",url,true)
	set_page_xmlHttp.send(null)
}

function set_page_number()
{
	if (set_page_xmlHttp.readyState==4 || set_page_xmlHttp.readyState=="complete")
	{
		parent.location.reload();
	} 
}

function populate_popup_with_elements()
{
	populate_matrix_div_with_elements_xmlHttp = null;
	populate_matrix_div_with_elements_xmlHttp = GetXmlHttpObject_multi(populate_matrix_div_with_elements_xmlHttp);

	if (populate_matrix_div_with_elements_xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	
	var url = siteaddress + "get_matrix_popup_elements.php?"
	url=url+"image_id=" + image_id;
	url=url+"&sid="+Math.random();

	populate_matrix_div_with_elements_xmlHttp.onreadystatechange=display_elements_matrix_popup_div
	populate_matrix_div_with_elements_xmlHttp.open("GET",url,true)
	populate_matrix_div_with_elements_xmlHttp.send(null)
}

function display_elements_matrix_popup_div()
{ 
	if (populate_matrix_div_with_elements_xmlHttp.readyState==4 || populate_matrix_div_with_elements_xmlHttp.readyState=="complete")
	{
		try
		{
			document.getElementById("image_popup_ID2").innerHTML = populate_matrix_div_with_elements_xmlHttp.responseText;
		}
		catch (e)
		{
		}
		if (continue_with_matrix_loading == true)
		{
			load_popup_image(image_id);
		}
	} 
}

function display_all_comments_matrix_view(image_id)
{
	comments_matrix_view_xmlHttp = null;
	comments_matrix_view_xmlHttp = GetXmlHttpObject_multi(comments_matrix_view_xmlHttp);

	if (comments_matrix_view_xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	
	var url = siteaddress + "get_comments_matrix_view.php?"
	url=url+"image_id=" + image_id;
	url=url+"&sid="+Math.random();

	comments_matrix_view_xmlHttp.onreadystatechange=display_comments_matrix_view_result
	comments_matrix_view_xmlHttp.open("GET",url,true)
	comments_matrix_view_xmlHttp.send(null)
}

function display_comments_matrix_view_result()
{ 
	if (comments_matrix_view_xmlHttp.readyState==4 || comments_matrix_view_xmlHttp.readyState=="complete")
	{
		document.getElementById("image_popup_ID2").innerHTML = comments_matrix_view_xmlHttp.responseText;
	} 
}

function clear_all_search(clear_variables)
{
	if (clear_variables == false)
	{
		parent.location.reload();
	}
	else if (clear_variables == true)
	{
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
		alert ("Browser does not support HTTP Request")
		return
		}
		var url= siteaddress + "clear_all_search.php"
		url=url+"?sid="+Math.random()
		xmlHttp.onreadystatechange=clear_all_search_variables
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}
}

function clear_all_search_variables()
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		parent.location.reload();
	} 
}

function GetXmlHttpObject_validate_user_js()
{
	var validate_user_js_xmlHttp;
	try
	{
		validate_user_js_xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			validate_user_js_xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			validate_user_js_xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return validate_user_js_xmlHttp;
}

function check_for_valid_user()
{
	validate_user_js_xmlHttp=GetXmlHttpObject_validate_user_js()
	if (validate_user_js_xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	
	var url = siteaddress + "get_captcha.php?"
	url=url+"sid="+Math.random();
	validate_user_js_xmlHttp.onreadystatechange=get_validate_user_display
	validate_user_js_xmlHttp.open("GET",url,true)
	validate_user_js_xmlHttp.send(null)
}

function get_validate_user_display()
{
	if (validate_user_js_xmlHttp.readyState==4 || validate_user_js_xmlHttp.readyState=="complete")
	{
		document.getElementById("check_valid_user").innerHTML=validate_user_js_xmlHttp.responseText;
	} 
}

function set_site_javascript_address(s_address)
{
	siteaddress = s_address;
}

function flip_or_mirror_image(do_action, image_id)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	
	var url = siteaddress + "flip_or_mirror.php?image_id=" + image_id
	url=url+"&action="+do_action;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=flip_mirror_browser_action
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function flip_mirror_browser_action()
{
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  {
	//alert(xmlHttp.responseText);
	//frmsites.submit();
	parent.location.reload();
  }
}

function move_copy_images(do_action, image_id_array, folder_id)
{
	if (is_matrix_view == 0 && do_action!="copy")
	{
		display_loader_for_image();
	}
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	
	array_count = image_id_array.length;
	if (array_count > 0)
	{
		if (do_action == "move")
		{
			var url = "move_image.php?folder_id=" + folder_id;
		}
		else if (do_action == "copy")
		{
			var url = "copy_image.php?folder_id=" + folder_id;
		}
		else if (do_action == "delete")	
		{
			var url = "multi_delete.php?folder_id=" + folder_id;
		}
		else if (do_action == "change_status")
		{
			var url = "update_status_image.php?new_status=" + folder_id;
		}	
		var image_attach = "";
		for (a_counter = 0; a_counter < array_count;a_counter++)
		{
			image_attach = image_attach + image_id_array[a_counter] + ":";
		}
		url = url + "&image_id=" + image_attach;
		url=url+"&sid="+Math.random();
		url = siteaddress + url;
		global_do_action=do_action;
	}
	else
	{
		alert("No images was selected");
	}
	xmlHttp.onreadystatechange=moved_files
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function moved_files()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		if (global_do_action=="copy")
		{
			alert("Done");
		}
		else
		{
			parent.location.reload();
		}  
	}
}

function Get_filter_variables_XmlHttpObject()
{
	var filter_variables_xmlHttp;
	try
	{
		filter_variables_xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			filter_variables_xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			filter_variables_xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return filter_variables_xmlHttp;
}

function save_filter_variables(selected_filter, selected_flag_filter, selected_acknowledge_filter)
{
	filter_variables_xmlHttp=Get_filter_variables_XmlHttpObject()
	if (filter_variables_xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	var url= siteaddress + "set_filter_variables.php?"
	url=url+selected_filter+selected_flag_filter+selected_acknowledge_filter;
	filter_variables_xmlHttp.onreadystatechange=set_filter_variables
	filter_variables_xmlHttp.open("GET",url,true)
	filter_variables_xmlHttp.send(null)
}
function set_filter_variables()
{
	if (filter_variables_xmlHttp.readyState==4 || filter_variables_xmlHttp.readyState=="complete")
	{
		parent.location.reload();
	}
}

/*/////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////*/

function load_classic_big_img()
{
	big_xmlHttp = null;
	big_xmlHttp = GetXmlHttpObject_multi(big_xmlHttp);
	if (big_xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	var url= siteaddress + "display_classic_img_back.php?"
	url=url+"&sid="+Math.random()
	big_xmlHttp.onreadystatechange=display_big_classic_image_result
	big_xmlHttp.open("GET",url,true)
	big_xmlHttp.send(null)
}

function display_big_classic_image_result()
{
	if (big_xmlHttp.readyState==4 || big_xmlHttp.readyState=="complete")
	{
		ttl_response_pre = big_xmlHttp.responseText;
		ttl_response_post = ttl_response_pre.split("@@@");
		response_width = ttl_response_post[0];
		response_height = ttl_response_post[1];
		if (is_matrix_view == 0)
		{
			after_new_height = 275;
			after_new_width = 375;
		}
		else if (is_matrix_view == 1)
		{
			after_new_height = (275 * 1.2);
			after_new_width = (375 * 1.2);
		}
		temp_img_load = siteaddress + "getImage.php?imageid=" + image_id + "&height="+after_new_height+"&width="+after_new_width+"&quality=100&f_id=" + Math.random();
		
		new_inner_html = "<table style='background-image: url(" + temp_img_load + ");background-repeat: no-repeat;background-position: top;' align='center' height='"+response_height+"px' width='" + response_width + "px' border='0' cellpadding='0' cellspacing='0'><tr valign='bottom'><td align='left'>";
		if (can_show_gps_icon == 1)
		{
			gps_pic = siteaddressroot + "_images/earth_gps.png";
			a_href = siteaddressroot + "maps/exif.php?image_id=" + image_id + "&maptype=1&pointer=1";
			new_inner_html = new_inner_html + "<a href='" + a_href + "'><img src='" + gps_pic + "' border='0' title='Click for GPS mapping'></a>";
		}
		can_show_gps_icon = 0;
		new_inner_html = new_inner_html + "</td></tr></table>";
		if (is_matrix_view == 0)
		{
			document.getElementById("display_image_id").innerHTML = new_inner_html;
			can_change_image_id = 1;
		}
		else if (is_matrix_view == 1)
		{
			document.getElementById("image_popup").innerHTML=new_inner_html;
		}
	}
}

function rotate_image_and_thumbnail(temp_image_id, degrees)
{
	temp_img_load = siteaddress + "images/loadingAnimation.gif";
	new_preload_inner_html = "<table><tr><td><br><br><br><br><br><img src='" + temp_img_load + "'><br><br><br><br><br></td></tr></table>";
	if (is_matrix_view == 0)
	{
		document.getElementById("display_image_id").innerHTML = new_preload_inner_html;
	}
	else if (is_matrix_view == 1)
	{
		document.getElementById("image_popup").innerHTML=new_preload_inner_html;
	}
	image_id = temp_image_id;
	rotate_xmlHttp = null;
	rotate_xmlHttp = GetXmlHttpObject_multi(rotate_xmlHttp);
  	if (rotate_xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	var url= siteaddress + "rotate.php?"
	url=url+"image_id="+image_id
	if (degrees == 'flip')
	{
		url=url+"&flip=1";
	}
	else if (degrees == 'flop')
	{
		url=url+"&flop=1";
	}
	else
	{
		url=url+"&angle="+degrees;
	}
	url=url+"&sid="+Math.random()
	rotate_xmlHttp.onreadystatechange=rotate_result_state_change
	rotate_xmlHttp.open("GET",url,true)
	rotate_xmlHttp.send(null)
}

function rotate_result_state_change()
{ 
	if (rotate_xmlHttp.readyState==4 || rotate_xmlHttp.readyState=="complete")
	{ 
		if (is_matrix_view == 0)
		{
			new_thumb_img = siteaddress + "getImage.php?imageid=" + image_id + "&thumb=true&f_id=" + Math.random();
			try{
			document.getElementById("image_popup_id_" + image_id).src = new_thumb_img;}
			catch (e) {}
			load_classic_big_img();
		}
		else if (is_matrix_view == 1)
		{
			new_thumb_img = siteaddress + "getImage.php?imageid=" + image_id;
			new_thumb_img = new_thumb_img + "&width=" + matrix_thumb_width + "&height=" + matrix_thumb_height + "&quality=100";
			new_thumb_img = new_thumb_img + "&f_id=" + Math.random();
			try{
				document.getElementById("image_popup_id_" + image_id).src = new_thumb_img;
			}
			catch (e) {}
			load_classic_big_img();
		}
	}
}

/*////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////*/

function get_description_matrix_view(image_id)
{
	descriptionxmlHttp = null;
	descriptionxmlHttp = GetXmlHttpObject_multi(descriptionxmlHttp);
	if (descriptionxmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	var url= siteaddress + "getdescription_matrix_view.php"
	url=url+"?sid="+Math.random()
	descriptionxmlHttp.onreadystatechange=description_load_matrix
	descriptionxmlHttp.open("GET",url,true)
	descriptionxmlHttp.send(null)
}

function description_load_matrix()
{
	if (descriptionxmlHttp.readyState==4 || descriptionxmlHttp.readyState=="complete")
	{ 
		document.getElementById('txt_description_ID').value = descriptionxmlHttp.responseText;
	} 
}

function GetXmlHttpObjectforExif()
{
	var exif_xmlHttp=null;
	try
	{
		exif_xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			exif_xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			exif_xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return exif_xmlHttp;
}

function load_description_area(image_id)
{
	descriptionxmlHttpIII = null;
	descriptionxmlHttpIII = GetXmlHttpObject_multi(descriptionxmlHttpIII);

	if (descriptionxmlHttpIII==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	}
	var url= siteaddress + "getdescription.php"
	url=url+"?desc_only="+desc_text_only+"&sid="+Math.random()
	descriptionxmlHttpIII.onreadystatechange=description_load
	descriptionxmlHttpIII.open("GET",url,true)
	descriptionxmlHttpIII.send(null)
}

function description_load()
{
	if (descriptionxmlHttpIII.readyState==4 || descriptionxmlHttpIII.readyState=="complete")
	{
		try{
			document.getElementById("descriptionOutput").innerHTML=descriptionxmlHttpIII.responseText;
			if (desc_text_only == 1)
			{
				desc_text_only = 0;
				document.getElementById("titlebuttons").style.visibility = "visible";
				focus_element("txt_description_ID");
			}
		}
		catch (e)
		{}

		try{
			if (continue_with_matrix_loading == true)
			{
				load_comment_grid_only(image_id);
			}
		}
		catch (e){
		}
	} 
}

function description_history_GetXmlHttpObject()
{
	var description_history_xmlHttp=null;
	try
	{
		description_history_xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			description_history_xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			description_history_xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return description_history_xmlHttp;
}

function populateDescriptionHistory()
 { 
	description_history_xmlHttp=description_history_GetXmlHttpObject()
	if (description_history_xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	var url= siteaddress + "getdescriptionhistory.php"
	url=url+"?sid="+Math.random()
	description_history_xmlHttp.onreadystatechange=description_history_stateChanged 
	description_history_xmlHttp.open("GET",url,true)
	description_history_xmlHttp.send(null)
 }

function description_history_stateChanged()
 { 
	if (description_history_xmlHttp.readyState==4 || description_history_xmlHttp.readyState=="complete")
  	{ 
		try
		{
  			document.getElementById("descriptionOutputHistory").innerHTML=description_history_xmlHttp.responseText 
		}
		catch (e)
		{
			//asdas
		}

		try
		{
			if (is_from_open_gallery == true)
			{
				try
				{display_loading_dialogue('none');}
				catch (e){/*if error goes here*/}
				image_popup(true);
			}
		}
		catch (e)
		{/*is_from_open_gallery was not defined*/;}

		try
		{if (continue_with_matrix_loading == true)
		 {
			display_loading_dialogue("none");
			image_popup(true);
		 }
		}
		catch (e){;}
	}
 }

/*///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////*/
	function load_popup_info(image_id)
	{
		image_infoxmlHttp=Get_image_info_XmlHttpObject()
		if (image_infoxmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		}
		var url= siteaddress + "get_image_info.php"
		url=url+"?image_id="+image_id
		url=url+"&sid="+Math.random()
		image_infoxmlHttp.onreadystatechange=get_image_info
		image_infoxmlHttp.open("GET",url,true)
		image_infoxmlHttp.send(null)
	}
	
	function display_enlarge_image_for_matrix(image_id_to_use)
	{
		display_enlarge_xmlHttp=Get_image_info_XmlHttpObject()
		if (display_enlarge_xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		}
		var url= siteaddress + "get_enlarge_display.php"
		url=url+"?image_id="+image_id_to_use
		url=url+"&sid="+Math.random()
		display_enlarge_xmlHttp.onreadystatechange=display_enlarge_or_not
		display_enlarge_xmlHttp.open("GET",url,true)
		display_enlarge_xmlHttp.send(null)
	}

	function display_enlarge_or_not()
	{
		if (display_enlarge_xmlHttp.readyState==4 || display_enlarge_xmlHttp.readyState=="complete")
		{
			try{
				document.getElementById("image_real_size_popup_id").innerHTML = display_enlarge_xmlHttp.responseText;
			}
			catch (e){
				//result
			}

			try{
				if (continue_with_matrix_loading == true){
					load_description_area(image_id);
				}
			}
			catch (e){
				//asdasd
			}
		}
	}

	function get_image_info()
	{ 
		if (image_infoxmlHttp.readyState==4 || image_infoxmlHttp.readyState=="complete")
		{
			try{
				document.getElementById("get_image_info").innerHTML=image_infoxmlHttp.responseText
			}
			catch (e){
			/*asdasd*/}

			try{
				if (continue_with_matrix_loading == true){
					display_enlarge_image_for_matrix(image_id);}
			}
			catch (e)
			{}
		} 
	}
	
	function Get_image_info_XmlHttpObject()
	{
		var image_infoxmlHttp=null;
		try
		{
			// Firefox, Opera 8.0+, Safari
			image_infoxmlHttp=new XMLHttpRequest();
		}
		catch (e)
		{
				// Internet Explorer
			try
			{
				image_infoxmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e)
			{
				image_infoxmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
		return image_infoxmlHttp;
	}
/*///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////*/

function load_display_status(image_id)
{
	app_system_xmlHttp=app_system_GetXmlHttpObject()
	if (app_system_xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	var url= siteaddress + "app_system.php"
	url=url+"?image_id="+image_id
	url=url+"&sid="+Math.random()
	app_system_xmlHttp.onreadystatechange=get_app_system
	app_system_xmlHttp.open("GET",url,true)
	app_system_xmlHttp.send(null)
}

function get_app_system()
{ 
	if (app_system_xmlHttp.readyState==4 || app_system_xmlHttp.readyState=="complete")
	{ 
		try
		{
			document.getElementById("display_status").innerHTML=app_system_xmlHttp.responseText
		}
		catch (e)
		{
			//asdasd
		}
		try
		{
			if (continue_with_matrix_loading == true)
			{
				populateDescriptionHistory();
			}
			//alert(app_system_xmlHttp.responseText);
			//<div id="display_status">
		}
		catch (e)
		{
			//asdas
		}
	} 
}

function app_system_GetXmlHttpObject()
{
	var app_system_xmlHttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		app_system_xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			app_system_xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			app_system_xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return app_system_xmlHttp;
}

function load_popup_image(image_id)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	var url= siteaddress + "get_image_popup.php"
	url=url+"?image_id="+image_id
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=get_popup_image
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
 }

function get_popup_image()
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		try
		{
			document.getElementById("image_popup").innerHTML=xmlHttp.responseText
		}
		catch (e)
		{
			//asdad
		}
		try
		{
			if (continue_with_matrix_loading == true)
			{
				load_popup_info(image_id);
			}
		}
		catch(e)
		{
			//asdasdasd
		}
	} 
}

/*/////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////*/

function GetXmlHttpObjectforDescriptionII()
{
	var descriptionxmlHttpII=null;
	try
	{
	// Firefox, Opera 8.0+, Safari
		descriptionxmlHttpII=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			descriptionxmlHttpII=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			descriptionxmlHttpII=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return descriptionxmlHttpII;
} 

function addDescription(image_id, descrip, folder_id)
 { 
	descriptionxmlHttpII=GetXmlHttpObjectforDescriptionII()
	if (descriptionxmlHttpII==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	}
	var url= siteaddress + "setdescription.php"
	url=url+"?image_id="+image_id
	redzeb_check = descrip.split("&");
	if (redzeb_check.length > 1)
	{
		descrip = "";
		//alert(redzeb_check.length + " : " + descrip);
		for (keep_count = 0; keep_count < redzeb_check.length; keep_count++)
		{
			//alert(keep_count + " : " + redzeb_check[keep_count]);
			if (keep_count == 0)
			{
				descrip = redzeb_check[keep_count];
			}
			else
			{
				descrip = descrip + "redzebra_replace" + redzeb_check[keep_count];
			}
		}
	}
	url=url+"&description="+descrip
	url=url+"&folder_id="+folder_id
	url=url+"&sid="+Math.random()
	descriptionxmlHttpII.onreadystatechange=description_stateChanged 
	descriptionxmlHttpII.open("GET",url,true)
	descriptionxmlHttpII.send(null)
 }

function description_stateChanged()
{ 
	if (descriptionxmlHttpII.readyState==4 || descriptionxmlHttpII.readyState=="complete")
	{ 
		//alert(descriptionxmlHttpII.responseText);
		//document.getElementById("txt_description_ID").innerHTML=descriptionxmlHttpII.responseText
		populateDescriptionHistory(); 
	}
}

/*/////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////*/

/*/////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////*/

	function Get_image_on_list_XmlHttpObject()
	{
		var display_image_on_list_xmlHttp=null;
		try
		{
			// Firefox, Opera 8.0+, Safari
			display_image_on_list_xmlHttp=new XMLHttpRequest();
		}
		catch (e)
		{
			// Internet Explorer
			try
			{
				display_image_on_list_xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e)
			{
				display_image_on_list_xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
		return display_image_on_list_xmlHttp;
	} 

	function display_image_on_list(image_id)
	{
		display_image_on_list_xmlHttp=Get_image_on_list_XmlHttpObject()
		if (display_image_on_list_xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		}
		var url= siteaddress + "display_image.php?image_id=" + image_id
		url=url+"&sid="+Math.random()
		display_image_on_list_xmlHttp.onreadystatechange=display_image_on_list_response
		display_image_on_list_xmlHttp.open("GET",url,true)
		display_image_on_list_xmlHttp.send(null)
	}

	function display_image_on_list_response()
	{ 
		if (display_image_on_list_xmlHttp.readyState==4 || display_image_on_list_xmlHttp.readyState=="complete")
		{ 
			document.getElementById("image_or_comment").innerHTML=display_image_on_list_xmlHttp.responseText
		} 
	}	

	function display_comments(image_id, display_thumb_image)
	{
		display_comment_xmlHttp=Get_display_comment_XmlHttpObject()
		if (display_comment_xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		}
		var url= siteaddress + "get_just_comment.php?image_id=" + image_id
		url=url+"&image_thumb="+ display_thumb_image
		url=url+"&sid="+Math.random()
		display_comment_xmlHttp.onreadystatechange=display_comment_grid
		display_comment_xmlHttp.open("GET",url,true)
		display_comment_xmlHttp.send(null)
	}

	function display_comment_grid()
	{ 
		if (display_comment_xmlHttp.readyState==4 || display_comment_xmlHttp.readyState=="complete")
		{ 
			document.getElementById("image_or_comment").innerHTML=display_comment_xmlHttp.responseText
		} 
	}	

	function Get__comment_print_XmlHttpObject()
	{
		var get_comment_print_xmlHttp=null;
		try
		{
			// Firefox, Opera 8.0+, Safari
			get_comment_print_xmlHttp=new XMLHttpRequest();
		}
		catch (e)
		{
			// Internet Explorer
			try
			{
				get_comment_print_xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e)
			{
				get_comment_print_xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
		return get_comment_print_xmlHttp;
	} 

	function load_comment_print(image_id)
	{
		get_comment_print_xmlHttp=Get__comment_print_XmlHttpObject()
		if (get_comment_print_xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		}
		var url= siteaddress + "getcommentprint.php"
		url=url+"?image_id="+image_id
		url=url+"&sid="+Math.random()
		get_comment_print_xmlHttp.onreadystatechange=get_comment_print
		get_comment_print_xmlHttp.open("GET",url,true)
		get_comment_print_xmlHttp.send(null)
	}

	function get_comment_print()
	{ 
		if (get_comment_print_xmlHttp.readyState==4 || get_comment_print_xmlHttp.readyState=="complete")
		{ 
			try
			{
				document.getElementById("comment_print").innerHTML=get_comment_print_xmlHttp.responseText
			}
			catch (e)
			{
				//asdasd
			}

			try
			{
				if (continue_with_matrix_loading == true)
				{
					load_display_status(image_id);
				}
			}
			catch (e)
			{
				//asdasd
			}
		} 
	}

	function load_comment_delete(comment_id)
	{ 
		delete_comment_xmlHttp=Get_delete_comment_XmlHttpObject()
		if (delete_comment_xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		}
		var url= siteaddress + "get_delete_comment.php"
		url=url+"?comment_id="+comment_id
		url=url+"&sid="+Math.random()
		delete_comment_xmlHttp.onreadystatechange=comment_delete
		delete_comment_xmlHttp.open("GET",url,true)
		delete_comment_xmlHttp.send(null)
	}
	
	function Get_delete_comment_XmlHttpObject()
	{
		var delete_comment_xmlHttp=null;
		try
		{
			// Firefox, Opera 8.0+, Safari
			delete_comment_xmlHttp=new XMLHttpRequest();
		}
		catch (e)
		{
			// Internet Explorer
			try
			{
				delete_comment_xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e)
			{
				delete_comment_xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
		return delete_comment_xmlHttp;
	} 

	function comment_delete()
	{ 
		if (delete_comment_xmlHttp.readyState==4 || delete_comment_xmlHttp.readyState=="complete")
		{ 
			try
			{
				document.getElementById("commentOutput").innerHTML=delete_comment_xmlHttp.responseText
				//classic view
			}
			catch (e)
			{
				try
				{
					document.getElementById("matrix_view_comment_grid").innerHTML=delete_comment_xmlHttp.responseText
					//matrix view popup - comment view
				}
				catch (e)
				{
					try
					{
						document.getElementById("commentgridonly").innerHTML=delete_comment_xmlHttp.responseText
						//matrix view popup - image view
					}
					catch (e)
					{
						//oops, somewhere refreshing the wrong comment grid, but his should not happen anymore
					}
				}
			}
		} 
	}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	function load_comment_not_adding(image_id)
	{ 
		display_comment_xmlHttp=Get_display_comment_XmlHttpObject()
		if (display_comment_xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		}
		var url= siteaddress + "get_just_comment.php"
		url=url+"?image_id="+image_id
		url=url+"&sid="+Math.random()
		display_comment_xmlHttp.onreadystatechange=comment_not_adding_stateChanged
		display_comment_xmlHttp.open("GET",url,true)
		display_comment_xmlHttp.send(null)
	}

	function load_comment_grid_only(image_id)
	{ 
		display_comment_xmlHttp=Get_display_comment_XmlHttpObject()
		if (display_comment_xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		}
		var url= siteaddress + "commentsgrid.php"
		url=url+"?image_id="+image_id
		url=url+"&sid="+Math.random()
		////commentgridonly
		display_comment_xmlHttp.onreadystatechange=comment_grid_only
		display_comment_xmlHttp.open("GET",url,true)
		display_comment_xmlHttp.send(null)
	}
	
	function comment_grid_only()
	{ 
		if (display_comment_xmlHttp.readyState==4 || display_comment_xmlHttp.readyState=="complete")
		{
			try
			{
				document.getElementById("commentgridonly").innerHTML=display_comment_xmlHttp.responseText
			}
			catch (e)
			{
				//asdasd
			}

			try
			{
				if (continue_with_matrix_loading == true)
				{
					load_comment_print(image_id);
				}
			}
			catch (e)
			{
				//asdasd
			}
		} 
	}

	function Get_display_comment_XmlHttpObject()
	{
		var display_comment_xmlHttp=null;
		try
		{
			// Firefox, Opera 8.0+, Safari
			display_comment_xmlHttp=new XMLHttpRequest();
		}
		catch (e)
		{
			// Internet Explorer
			try
			{
				display_comment_xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e)
			{
				display_comment_xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
		return display_comment_xmlHttp;
	} 

	function comment_not_adding_stateChanged()
	{ 
		if (display_comment_xmlHttp.readyState==4 || display_comment_xmlHttp.readyState=="complete")
		{ 
			document.getElementById("commentOutput").innerHTML=display_comment_xmlHttp.responseText
		} 
	}


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function add_matrix_Comment(image_id, comments, folder_id)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	var url= siteaddress + "getcomment.php"
	url=url+"?image_id="+image_id
	url=url+"&comments="+comments
	url=url+"&folder_id="+folder_id
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=matrix_comment_stateChanged
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function matrix_comment_stateChanged()
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  	{ 
		 try
  		{
  			document.getElementById("commentgridonly").innerHTML=xmlHttp.responseText
  		}
 		catch (e)
  		{
			try
			{
				display_all_comments_matrix()
			}
			catch (e)
			{
				//////////////////
			}
		}
    	}
}

function addComment(image_id, comments, folder_id)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	tempstring=comments;
	post_split_string=tempstring.split("\n");
	post_split_string_count=post_split_string.length;
	if (post_split_string_count>0)
	{
		tempstring="";
		for (loop_counter=0;loop_counter<post_split_string_count;loop_counter++)
		{
			if (loop_counter!=0)
				tempstring=tempstring+"\\n";
			tempstring=tempstring+post_split_string[loop_counter];
		}
	} 
	var url= siteaddress + "getcomment.php"
	url=url+"?image_id="+image_id
	url=url+"&comments="+tempstring
	url=url+"&folder_id="+folder_id
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=comment_stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function comment_stateChanged()
 { 
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  { 
    document.getElementById("commentOutput").innerHTML=xmlHttp.responseText
  } 
 }

function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 // Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
} 
