// JavaScript Document
var XML_HTTP=create_XML_Object();

function create_XML_Object()
{
	var xml;
	
	try
	{
		xml=new XMLHttpRequest();
	}
	catch(e)
	{
		try
		{
			xml=new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(e)
		{
			alert("Your broswer does not support ActiveX Object");
			xml=false;
		}
	}
	return xml;
}


function get_pos(obj)
{
	
	try
	{
		document.getElementById(obj).attachEvent("onmouseover",popup_pic);
		document.getElementById(obj).attachEvent("onmouseout",close_popup);
	}
	catch(e)
	{
		try
		{
			document.getElementById(obj).addEventListener("mouseover",popup_pic,true);
			document.getElementById(obj).addEventListener("mouseout",close_popup,true);
		}
		catch(e)
		{}
	}

}

//	function to make popup in the search result page when mouseover the images
function popup_pic(event)
{
		var obj_id;
		
		try
		{
			obj_id=event.srcElement.id;
			var img_X=window.event.x+document.body.scrollLeft;
			var img_Y=window.event.y+document.body.scrollTop;
		}
		catch(e)
		{
			try
			{
				obj_id=event.target.id;
				var img_X=event.pageX;
				var img_Y=event.pageY;
			}
			catch(e){}
		}

		var new_popup=document.createElement("div");
		new_popup.className="popup_div";
		new_popup.id="img_popup";

		new_popup.style.left=(img_X-(-5))+"px";
		new_popup.style.top=(img_Y-(-5))+"px";
		
		new_popup.innerHTML="<img src='create_thumb1.php?file_id="+ obj_id +"' />";
		document.body.appendChild(new_popup);
}



//	function to close the popup div in the search page
function close_popup()
{
	if(document.getElementById("img_popup"))
	{
		var obj=document.getElementById("img_popup");
		obj.parentNode.removeChild(obj);
	}
}

//		function to display the profile enlarge image in a popup
function popup_pro_img(user_id)
{
		img_bg=document.createElement("div");
		img_bg.className="popup_pro_img";
		img_bg.id="div_popup_img";
		img_bg.style.height=window.screen.height;
		document.getElementById("template-show").appendChild(img_bg);

		img_div=document.createElement("div");
		img_div.className="popup_img_div";
		img_div.id="popup_img_div";
		
	try
	{
		img_bg.attachEvent("onclick",close_popup_img);
	}
	catch(e)
	{
		try
		{
			img_bg.addEventListener("click",close_popup_img,true);
		}
		catch(e)
		{}
	}
	
	img_div.innerHTML="<center><img src='create_thumb1.php?file_id="+user_id+"' ><br/><a href='javascript:void(0);' onclick='close_popup_img();'>Close</a></center>";
		document.getElementById("template-show").appendChild(img_div);

}

//	function to close the 2 divs in the profile page display the popup
function close_popup_img()
{
		document.getElementById("div_popup_img").parentNode.removeChild(document.getElementById("div_popup_img"));
		document.getElementById("popup_img_div").parentNode.removeChild(document.getElementById("popup_img_div"));
}