﻿// Show pop for assigning a ticket
// img = image which calls the function
function ShowTicketOptions(td)
{
    var divTopicOptions = document.getElementById("divTopicOptions");

	var tdTemp = td;
	
	// Find out the absolute postion of image
	var posLeft = 0;
	var posTop = 0;
	
	do 
	{
		posLeft += tdTemp.offsetLeft;
		posTop += tdTemp.offsetTop;
	} 
	while (tdTemp = tdTemp.offsetParent);

	// If position was not changed, close popup
	if(divTopicOptions.style.display == "")
	{
		divTopicOptions.style.display = "none";
	}
	else
	{
	    posLeft += -53;
	    posTop += 25;
	
		divTopicOptions.style.display = "";
		divTopicOptions.style.left = (posLeft + "px");
		divTopicOptions.style.top = (posTop + "px");
		
//		// Write ticket id into hidden field, to assign on server site
//		document.getElementById(idExt + "hiddenPostText").value = img.id.substring(img.id.lastIndexOf('_') + 1);
	}
	
//	var divPopup;
//	
//	if(type.toLowerCase() == 'assign')
//	{
//		// Get assign popup div and set position
//		divPopup = document.getElementById(idExt + 'div_popup');
//		posLeft += -108;
//	}
//	else if(type.toLowerCase() == 'close')
//	{
//		// Get close popup div and set position
//		divPopup = document.getElementById('div_close');
//		posLeft += -254;
//	}
//	else
//	{
//		// If no type was selected do nothing
//		return;
//	}
//	
//	// If position was not changed, close popup
//	if(divPopup.style.top == (posTop + "px") && divPopup.style.display == "")
//	{
//		divPopup.style.display = "none"
//	}
//	else
//	{
//		divPopup.style.display = "";
//		divPopup.style.left = (posLeft + "px");
//		divPopup.style.top = (posTop + "px");
//		
//		// Write ticket id into hidden field, to assign on server site
//		document.getElementById(idExt + "hiddenPostText").value = img.id.substring(img.id.lastIndexOf('_') + 1);
//	}
}
