function SurveyEntries_ShowComments(o,surveyID,entryID,guidQ)
{
	try
	{
		event.cancelBubble= true;
		event.returnValue = false;
	}catch(e){}
	var args= new Function();
	args.surveyID = surveyID;
	args.entryID = entryID;
	args.guidQ = guidQ;
	//if (window.showModalDialog("/Panels/ShowComments/default.htm?surveyID="+surveyID+"&entryID="+entryID+"&guidQ="+guidQ, args, 'dialogWidth:65em; dialogHeight:55em; center:yes; edge:raised; resizable:yes; scroll:auto; status:yes;'))
	if (window.showModalDialog("/Panels/ShowComments/default.htm", args, 'dialogWidth:65em; dialogHeight:55em; center:yes; edge:raised; resizable:yes; scroll:auto; status:yes;'))
	{
	}
	return false;
}
//-------------------------------------------------------------
function SurveyEntries_OnMouseOverRow(o)
{
	var tr=o;while(tr.tagName!="TR")tr=tr.parentNode;//Element;
	for(var i1=0; i1<tr.cells.length; i1++)
	{
		var td=tr.cells[i1];
		if(tr.s1_color==null)
		{
			tr.s1_color = td.style.color;
			tr.s1_backgroundColor = td.style.backgroundColor;
		}
		td.style.color='red';
		td.style.backgroundColor='#fafad2';
	}
}
function SurveyEntries_OnMouseOutRow(o)
{
	var tr=o;while(tr.tagName!="TR")tr=tr.parentNode;//Element;
	for(var i1=0; i1<tr.cells.length; i1++)
	{
		var td=tr.cells[i1];
		if(tr.s1_color!=null)
		{
			td.style.color = tr.s1_color;
			td.style.backgroundColor = tr.s1_backgroundColor;
		}
	}
}
//-------------------------------------------------------------
function SurveyEntries_NoClick(o)
{
	event.returnValue = false;
	event.cancelBubble = true;
	return false;
}

//-------------------------------------------------------------
//function SurveyEntries_OnClick(o)
//{
//alert(o.c_onclick);
//	eval(o.c_onclick);
//}
//-------------------------------------------------------------
function SurveyEntries_OnMouseUp(o)
{
	if (window.event.button == 2)
	{
		SurveyEntries_CallContextMenu(window.event.srcElement,'SurveyEntry');
	}
	else if (event.button == 1)
	{
//alert(1);
//		var tr	= td;	while(tr.tagName!="TR")tr=tr.parentNode;
//		eval(tr.getAttribute("c_onclick"));
//		event.returnValue = false;
//		event.cancelBubble = true;
//		return false;
	}
}
//--------------------------------------------------
function SurveyEntries_GetSpan4Menu(clientID,token)
{
	var panXml = document.getElementById(clientID + "_panXmls");
	var arr	= panXml.getElementsByTagName("SPAN");
	for(var j=0; j<arr.length; j++)
	{
		if (arr[j].getAttribute("ref") == token)
		{
			return arr[j];
		}
	}
	return null;
}
//--------------------------------------------------
function SurveyEntries_CallContextMenu(o,what,onlyRightButton)
{
	try
	{
		if (onlyRightButton==true && event.button!=2)
			return;
	
		event.returnValue = false;
		event.cancelBubble = true;
	}
	catch(e){}

	var td	= o;	while(td.tagName!="TD"){td=td.parentNode;}
	var tr	= td;	while(tr.tagName!="TR")tr=tr.parentNode;
	var p			= SurveyEntries_GetPanel(o);
	var clientID	= p.getAttribute("c_clientID");
	var panXml		= document.getElementById(clientID + "_panXmls");
	//var span2 = SurveyEntries_GetSpan4Menu(clientID,what);
	var arr = panXml.getElementsByTagName("XML");
	var xmlDoc		= arr[0].XMLDocument.documentElement;//children[0].XMLDocument.documentElement;
	var xmlCust		= arr[1].XMLDocument.documentElement;//children[1].XMLDocument.documentElement;
	var xNode		= xmlDoc.selectSingleNode("//ContextMenus/Caller[@ref='" + what + "']").cloneNode(true);
	
	clickedTag = o;
	
	try
	{
		try{xNode.selectSingleNode("Item[@guid='ViewEdit']").setAttribute("disabled",	tr.c_perm_Edit=="y"?"n":"y");}catch(e){}
		try{xNode.selectSingleNode("Item[@guid='ChangeStatus_InProcess']").setAttribute("disabled",		tr.c_perm_ChStatus=="y"?"n":"y");}catch(e){}
		try{xNode.selectSingleNode("Item[@guid='Print']").setAttribute("disabled",		tr.c_perm_View=="y"?"n":"y");}catch(e){}
		try{xNode.selectSingleNode("Item[@guid='Delete']").setAttribute("disabled",		tr.c_perm_Delete=="y"?"n":"y");}catch(e){}
		try{xNode.selectSingleNode("Item[@guid='SetPerm']").setAttribute("disabled",	tr.c_perm_SetPerm=="y"?"n":"y");}catch(e){}
		try{xNode.selectSingleNode("Item[@guid='ColumnHeader_ResetSorting']").setAttribute("disabled",	o.c_sort=="y"?"n":"y");}catch(e){}
		
		try{xNode.selectSingleNode("Item[@guid='PrintAll']").setAttribute("disabled",		p.c_isPublished=="y"?"n":"y");}catch(e){}
		try{xNode.selectSingleNode("Item[@guid='PrintVisible']").setAttribute("disabled",	p.c_isPublished=="y"?"n":"y");}catch(e){}
		try{xNode.selectSingleNode("Item[@guid='SetColumns']").setAttribute("disabled",		p.c_isPublished=="y"?"n":"y");}catch(e){}
		try{xNode.selectSingleNode("Item[@guid='SetSortByColumns']").setAttribute("disabled",p.c_isPublished=="y"?"n":"y");}catch(e){}
		
		try
		{
			var hid	= document.getElementById(clientID+"_hidView_SearchBar");
			var src = "/images/23x22/Search_" + (hid.value=="y"?"On":"Off") + ".gif";
			try{xNode.selectSingleNode("Item[@guid='ViewSearchBar']").setAttribute("icon",src);}catch(e){}
		}catch(e){}
		try
		{
			var arr = xmlCust.selectNodes("R");
			if (what=="ShowReports" && arr.length > 0)
			{
				var x = __AddXmlNode(xNode,"","Item");
				x.setAttribute("text","-");
				
				for(var i1=0; i1<arr.length; i1++)
				{
					x = __AddXmlNode(xNode,"","Item");
					x.setAttribute("text", arr[i1].getAttribute("name"));
					x.setAttribute("guid", "Report_Custom_"+arr[i1].getAttribute("repID"));
					x.setAttribute("disabled", "n");
					x.setAttribute("icon", "/images/23x22/Report1.gif");
				}
			}
		}
		catch(e){}

		//...set references to Popup objects
		try{ td._Popup.hide();}catch(e){} 
		td._Popup = window.createPopup();
		td._RootPopup = td._Popup;
		td._path = '';
		
		eval("Menu_ShowContextMenu(0, 19, xmlDoc, xNode, td, 'SurveyEntries_ContextMenuSelected');");
		//eval("Menu_ShowContextMenu(0, 19, span2, td, 'SurveyEntries_ContextMenuSelected');");
	}
	catch(e)
	{
alert(e.message);
	}
}
//--------------------------------------------------
function SurveyEntries_ContextMenuSelected(cmd)
{
	var o			= clickedTag;
	var p			= SurveyEntries_GetPanel(o);
	var td	= o;	while(td.tagName!="TD"){td=td.parentNode;}
	var tr	= td;	while(tr.tagName!="TR")tr=tr.parentNode;
	var clientID	= p.getAttribute("c_clientID");
//	var appPath		= p.c_appPath;
//	var tbl			= o;while(tbl.c_token!="ItemTable")tbl=tbl.parentNode;
//	var tr			= tbl.rows[0];
	var hidID		= document.getElementById(clientID+"_hidID");
	var hidCmd		= document.getElementById(clientID+"_hidCommand");
	var hidValue	= document.getElementById(clientID+"_hidValue");
	var lb			= document.getElementById(clientID+"_lbCommand");
	var doCmd		= false;
	var itemID		= tr.getAttribute("c_ItemID");

	hidCmd.value	= cmd;
	hidID.value		= itemID;

	if (cmd=="ViewEdit")// || cmd=="PrintAll" || cmd=="PrintVisible")
	{
		doCmd = true;
	}
	else if (cmd=="Print")
	{
		SurveyEntries_PrintEntry(o,itemID);
	}
	/*
	else if (cmd=="SetColumns")
	{
		var args = new Function();
		args.SurveyID = document.getElementById(clientID+'_hidSurveyID').value;
		args.xmlColumns = document.getElementById(clientID+'_hidSetColumns').value;
		if (window.showModalDialog("/Panels/SelectSurveyColumns/default.htm", args, "dialogWidth:770px; dialogHeight:600px; center:yes; edge:raised; resizable:yes; scroll:yes; status:yes;"))
		{
			document.getElementById(clientID+'_hidParam1').value	= args.xmlColumns;
			doCmd = true;
		}
	}
	else if (cmd=="SetSortByColumns")
	{
		var args = new Function();
		args.xmlColumns = document.getElementById(clientID+'_hidSetColumns').value;
		if (window.showModalDialog("/Panels/SetSortBy/default.htm", args, "dialogWidth:770px; dialogHeight:600px; center:yes; edge:raised; resizable:yes; scroll:yes; status:yes;"))
		{
			document.getElementById(clientID+'_hidParam1').value	= args.xmlSortByColumns;
			doCmd = true;
		}
	}
	*/
	else if (cmd=="Delete" || cmd=="ChangeStatus_InProcess")
	{
		SurveyEntries_AskFor(o,cmd);
	}
	else if (cmd=="SetPerm")
	{
		var args = new Function();
		args.FullItemID = tr.c_FullItemID;
		args.ModuleToken = "SurveyEntry";
		tr.s_backgroundColor = tr.style.backgroundColor;
		tr.style.backgroundColor = "yellow";
		//tr.runtimeStyle.backgroundColor = "yellow";
		if (window.showModalDialog("/Panels/SetPermissions/default.htm", args, 'dialogWidth:70em; dialogHeight:55em; center:yes; edge:raised; resizable:yes; scroll:no; status:yes;'))
		{
			hidValue.value	= args.xmlSecurity;
			doCmd = true;
		}
		tr.style.backgroundColor = tr.s_backgroundColor;
		//tr.runtimeStyle.backgroundColor = "";
/*
return;
		//...
		var fn = tbl.c_appPath + "Security/default.htm";
		var url = fn + "?ItemID="+tbl.c_ItemID + "&ModuleID="+tbl.c_ModuleID + "&IsFolder=n";// + "&time="+dt.getTime();
		var args = new Function();
		tr.runtimeStyle.backgroundColor = "yellow";
		if (window.showModalDialog(url, args, 'dialogWidth:780px; dialogHeight:600px; center:yes; edge:raised; scroll:no; status:no;'))
		{
			hidValue.value = args.xmlPerms;
			doCmd = true;
		}
		tr.runtimeStyle.backgroundColor = "";
		*/
	}
	else if (cmd=="ViewSearchBar")
	{
		var hid	= document.getElementById(clientID+"_hidView_SearchBar");
		var pan = document.getElementById(clientID+"_panSearchBar");
		pan.style.display = hid.value != "y" ? "inline" : "none";
		hid.value = hid.value != "y" ? "y" : "n";
	}
	/*
	else if (cmd.indexOf("Report_") != -1)
	{
		if (cmd=="Report_QuestionTotals")	SurveyEntries_CallReport( o, "QuestionTotals", -1);
		else if (cmd=="Report_Pivot")		SurveyEntries_CallReport( o, "PivotTable", -1);
		else if (cmd=="Report_Trend")		SurveyEntries_CallReport( o, "TrendReport", -1);
		else if (cmd.indexOf("Report_Custom_") != -1)
		{
			var repID = cmd.substr("Report_Custom_".length);
			SurveyEntries_CallReport( o, "CustomReport", repID);
		}
	}
	*/
	else if (cmd.indexOf("ExportTo")!=-1)
	{
		doCmd = true;
		//SurveyEntries_ExportTo(o,cmd);
	}
	else if (cmd=="ColumnHeader_ResetSorting")
	{
		hidValue.value = o.c_guid;
		doCmd = true;
	}
	
	if (doCmd)
		try{lb.click();}catch(e){alert(e.message);}
}
//-------------------------------------------------------------
function SurveyEntries_ClickMenu(sender, args) 
{
	var cmd = args.get_item().get_value();
// g_global.GetParentObject(sender.get_element()).ExecCommand_Begin(args.get_item().get_value()); 
}
//-------------------------------------------------------------
function SurveyEntries_SearchBar(o,clientID)
{
	try
	{
		var hid	= document.getElementById(clientID+"_hidView_SearchBar");
		var pan = document.getElementById(clientID+"_panSearchBar");
		pan.style.display = hid.value != "y" ? "inline" : "none";
		hid.value = hid.value != "y" ? "y" : "n";
//		var arr = o.getElementsByTagName("SPAN");
//		arr[0].innerHTML = (hid.value=="y"?"Hide Search":"Search");
	}
	catch(e){}
}
/*
function SurveyEntries_SearchBar(o)
{
	try
	{
		var p			= SurveyEntries_GetPanel(o);
		var clientID	= p.getAttribute("c_clientID");
		var hid	= document.getElementById(clientID+"_hidView_SearchBar");
		var pan = document.getElementById(clientID+"_panSearchBar");
		pan.style.display = hid.value != "y" ? "inline" : "none";
		hid.value = hid.value != "y" ? "y" : "n";
		var arr = o.getElementsByTagName("SPAN");
		arr[0].innerHTML = (hid.value=="y"?"Hide Search":"Search");
	}
	catch(e){}
}
*/
//-------------------------------------------------------------
function SurveyEntries_FilterRows(o,clientID)
{
	var args = new Function();
	args.SurveyID = document.getElementById(clientID+'_hidSurveyID').value;
	//args.xmlRowFilters = document.getElementById(clientID+'_hidRowFilter').value;
	args.xmlColumns = document.getElementById(clientID+'_hidSetColumns').value;
	if (window.showModalDialog("/Panels/RowFilters/default.htm", args, "dialogWidth:770px; dialogHeight:600px; center:yes; edge:raised; resizable:no; scroll:no; status:yes;"))
	{
		document.getElementById(clientID+'_hidCommand').value	= "RowFilters";
		document.getElementById(clientID+'_hidParam1').value	= args.xmlColumns; //xmlRowFilters;
		document.getElementById(clientID+'_lbCommand').click();
	}
}
//-------------------------------------------------------------
function SurveyEntries_Report(o,clientID,cmd)
{
	var repType,repID;
	if (cmd=="Report_QuestionTotals"){	repType = "QuestionTotals"; repID=-1;	}
	else if (cmd=="Report_Pivot"){		repType = "PivotTable";		repID=-1;	}
	else if (cmd=="Report_Trend"){		repType = "TrendReport";	repID=-1;	}
	else if (cmd.indexOf("Report_Custom_") != -1)
	{	
		repType = "CustomReport"; 
		repID	= cmd.substr("Report_Custom_".length);
	}
	
	var url		= "/Reports/ReportViewer/default.htm";
	var args	= new Function();
	args.Mode			= "New";
	args.ReportType		= repType;
	args.ReportID		= repID;
	args.SelectorParams	= document.getElementById(clientID+"_hidSelectorParams").value;
	window.showModalDialog(url, args, 'dialogWidth:65em; dialogHeight:50em; center:yes; edge:raised; scroll:no; status:yes; resizable:yes;');
}

/*
//-------------------------------------------------------------
function SurveyEntries_CallReport(o,reportType,reportID)
{
	var p		= SurveyEntries_GetPanel(o);
	var clientID= p.getAttribute("c_clientID");
	var url		= "/Reports/ReportViewer/default.htm";
	var args	= new Function();
	args.Mode			= "New";
	args.ReportType		= reportType;
	args.ReportID		= reportID;
	args.SelectorParams	= document.getElementById(clientID+"_hidSelectorParams").value;
	window.showModalDialog(url, args, 'dialogWidth:65em; dialogHeight:50em; center:yes; edge:raised; scroll:no; status:yes; resizable:yes;');
}
//-------------------------------------------------------------
function __________________________SurveyEntries_ExportTo(o,cmd)
{
	var p	= SurveyEntries_GetPanel(o);
	var clientID = p.c_clientID;
	var url = "/Reports/ExportTo/default.htm";
	var key = document.getElementById(p.c_clientID+"_hidSelectorKey").value;
	window.open("/Reports/ExportTo.aspx?mode=" + cmd + "&key=" + key);
}
function ________________SurveyEntries_ExportTo(clientID,cmd,sessionKey)
{
	//var key = document.getElementById(c_clientID+"_hidSelectorKey").value;
	window.open("/Reports/ExportTo.aspx?mode=" + cmd + "&key=" + sessionKey);
}
*/
//-------------------------------------------------------------
/*
function SurveyEntries_Delete(o)
{
	var p = SurveyEntries_GetPanel(o);
	var clientID = p.getAttribute("c_clientID");
	var tr=o;while(tr.tagName!='TR')tr=tr.parentNode;

	window.event.cancelBubble=true;
	window.event.returnValue=false;

	tr.setAttribute("s_backgroundColor",tr.style.backgroundColor);
	tr.style.backgroundColor='yellow';
	if (confirm("Do you want to delete selected item?"))
	{
		return true;
	}
	tr.style.backgroundColor = tr.getAttribute("s_backgroundColor");
	return false;
}
*/
//-------------------------------------------------------------
function SurveyEntries_AskFor(o,what)
{
	var p = SurveyEntries_GetPanel(o);
	var clientID = p.getAttribute("c_clientID");
	var tr=o;while(tr.tagName!='TR')tr=tr.parentNode;
	var ss = "";

	if (what=="Delete")
		ss = "Do you want to delete selected item?";
	else if (what=="ChangeStatus_InProcess")
		ss = "Do you want to reset complete survey entry and set it's status to 'In-Process'?";
	else
		return false;
		
	tr.setAttribute("s_backgroundColor",tr.style.backgroundColor);
	tr.style.backgroundColor='yellow';
	if (confirm(ss))
	{
		document.getElementById(clientID+"_hidID").value = tr.c_ItemID;
		document.getElementById(clientID+"_hidCommand").value = what;
		try{document.getElementById(clientID+"_lbCommand").click();}catch(e){alert(e.message);}
	}
	else
	{
		tr.style.backgroundColor = tr.getAttribute("s_backgroundColor");
		event.cancelBubble=true;
		event.returnValue=false;
	}
	return false;
}
//-------------------------------------------------------------
function SurveyEntries_ArrangeIFrame(win,iframeID)
{
	//var fr = document.getElementById(clientID+"_frTakeSurvey");
	//var hh = fr.
//	var b = win.document.body;
//	var fr = document.getElementById(iframeID);
	/*
//alert(fr.outerHTML);
alert(b.offsetHeight + "    " + b.offsetWidth + "\n" + 
b.clientHeight + "    " + b.clientWidth + "\n" + 
b.scrollHeight + "    " + b.scrollWidth + "\n");
	fr.style.width = 700;
	fr.style.height= 300;

	fr.style.width = b.scrollHeight;
	fr.style.height= b.scrollWidth;
	*/
}
//-------------------------------------------------------------
function SurveyEntries_OpenSurvey(appPath,params)
{
	var ss = params!=null ? params : "";
	var url = "/Survey/TakeSurvey.aspx?" + ss;

	var retVal = window.showModalDialog(url, null, 'dialogWidth:70em; dialogHeight:55em; center:yes; edge:raised; resizable:yes; scroll:no; status:yes;');
	return retVal==true;
	
//	window.open(url, "_blank", "width=800px,height=600px,location=yes,menubar=yes,toolbar=yes,resizable=yes");
//	return false;// retVal==true;
}
//-------------------------------------------------------------
function SurveyEntries_GetPanel(o)
{
	var p=o;while(p.getAttribute("c_token")!="ListItems")p=p.parentNode;
	return p;
}

//-------------------------------------------------------------
function SurveyEntries_SetColumns(o,clientID)
{
	var args = new Function();
	args.SurveyID = document.getElementById(clientID+'_hidSurveyID').value;
	args.xmlColumns = document.getElementById(clientID+'_hidSetColumns').value;
	if (window.showModalDialog("/Panels/SelectSurveyColumns/default.htm", args, "dialogWidth:770px; dialogHeight:600px; center:yes; edge:raised; resizable:yes; scroll:yes; status:yes;"))
	{
		document.getElementById(clientID+'_hidCommand').value	= "SetColumns";
		document.getElementById(clientID+'_hidParam1').value	= args.xmlColumns;
		document.getElementById(clientID+'_lbCommand').click();
	}
}
//-------------------------------------------------------------
function SurveyEntries_SetSortByColumns(o,clientID)
{
	var args = new Function();
	args.xmlColumns = document.getElementById(clientID+'_hidSetColumns').value;
	if (window.showModalDialog("/Panels/SetSortBy/default.htm", args, "dialogWidth:770px; dialogHeight:600px; center:yes; edge:raised; resizable:yes; scroll:yes; status:yes;"))
	{
		document.getElementById(clientID+'_hidCommand').value	= "SetSortByColumns";
		document.getElementById(clientID+'_hidParam1').value	= args.xmlSortByColumns;
		document.getElementById(clientID+'_lbCommand').click();
	}
}

//-------------------------------------------------------------
function SurveyEntries_RestoreSorting(o,clientID)
{
	document.getElementById(clientID+'_hidCommand').value	= "RestoreSorting";
	document.getElementById(clientID+'_lbCommand').click();
}
//-------------------------------------------------------------
function SurveyEntries_PrintEntry(o,itemID)
{
	var p = SurveyEntries_GetPanel(o);
	var clientID = p.getAttribute("c_clientID");
	
	if (itemID==null)
	{
		var tr=o;while(tr.tagName!='TR')tr=tr.parentNode;
		itemID = tr.getAttribute("c_ItemID");
		//itemID=o.getAttribute("c_id");
	}
	
	$get(clientID+'_hidValue').value	= p.getAttribute("c_surveyID")+":"+itemID;
	$get(clientID+'_hidCommand').value	= "PrintEntry";
	eval( unescape( $get(clientID+'_lbCommand').href ) );
	
//	var args = new Function();
//	args.SurveyID	= p.c_surveyID;
//	args.ItemID		= itemID; //o.c_id;

//	var url = "/Survey/Entries/PrintEntry/default.htm";
//	window.showModalDialog(url, args, 'dialogWidth:770px; dialogHeight:600px; center:yes; edge:raised; scroll:yes; resizable:yes; status:yes;');
}
function SurveyEntries_PrintEntry_End(url)
{
	var ww = window.screen.availWidth - 100;
	var hh = window.screen.availHeight - 100;
	if (window.showModalDialog)
	{
		var args = new Function();
		if (window.showModalDialog(url, args, "dialogWidth:"+ww+"px; dialogHeight:"+hh+"px; center:yes; edge:raised; resizable:yes; scroll:yes; status:yes;"))
		{
//			var prm = Sys.WebForms.PageRequestManager.getInstance();
//			prm._doPostBack(clientID+"_upView", '');
		}
	}
	else
	{
		window.open(url, "_blank", "width="+ww+"px,height="+hh+"px,location=no,menubar=no,toolbar=no,resizable=yes");
	}
}
//-------------------------------------------------------------
function SurveyEntries_DeleteEntry(o)
{
	if (SurveyEntries_AskFor(o,"Delete"))
	{
		var tr=o;while(tr.tagName!='TR')tr=tr.parentNode;
		$get(clientID+"_hidValue").value = tr.getAttribute("c_FullItemID");
		$get(clientID+"_hidCommand").value = "DeleteEntry";
		eval( unescape( $get(clientID+'_lbCommand').href ) );
	}
}
//-------------------------------------------------------------
function SurveyEntries_PrintList(o,clientID,scope)
{
	document.getElementById(clientID+"_hidCommand").value = scope;
	//document.getElementById(clientID+"_lbCommand").click();
	eval( unescape( $get(clientID+'_lbCommand').href ) );
}
//-------------------------------------------------------------
function SurveyEntries_OpenPrintList()
{
	var url = "/Panels/Print/default.htm";
	//window.open(url, "_blank", "height=600,width=770,location=no,menubar=yes,toolbar=yes,resizable=yes");
	window.showModalDialog(url, null, 'dialogWidth:770px; dialogHeight:600px; center:yes; edge:raised; scroll:yes; status:yes; resizable:yes;');
}
//-------------------------------------------------------------
function SurveyEntries_ExportTo()
{
	var url = "/Panels/Export/default.aspx";
	window.open(url, "_blank", "height=600,width=770,location=no,menubar=yes,toolbar=yes,resizable=yes");
	//window.showModalDialog(url, null, 'dialogWidth:770px; dialogHeight:600px; center:yes; edge:raised; scroll:yes; status:yes; resizable:yes;');
}
//-------------------------------------------------------------
function SurveyEntries_SelectSurvey(o)
{
	var p = SurveyEntries_GetPanel(o);
	var clientID = p.c_clientID;
	var args = new Function();
	args.allowedSurveys = document.getElementById(clientID+'_hidAllowedSurveys').value;
	if (window.showModalDialog("/Panels/SelectSurvey/default.htm", args, 'dialogWidth:750px; dialogHeight:600px; center:yes; edge:raised; scroll:no; status:no; resizable:yes;'))
	{
		document.all(clientID+'_hidID').value = args.SurveyID;
		return true;
	}
	return false;
}
//-------------------------------------------------------------
function SurveyEntries_AllowedSurveys(o,clientID)
{
	var args = new Function();
	args.selectedItemIDs = document.getElementById(clientID+'_hidAllowedSurveys').value;
	if (window.showModalDialog("/Panels/SelectSurveys/default.htm", args, "dialogWidth:770px; dialogHeight:600px; center:yes; edge:raised; resizable:yes; scroll:yes; status:yes;"))
	{
		document.getElementById(clientID+'_hidCommand').value	= "AllowedSurveys";
		document.getElementById(clientID+'_hidAllowedSurveys').value	= args.selectedItemIDs;
		//document.getElementById(clientID+'_lbCommand').click();
		eval( unescape( $get(clientID+'_lbCommand').href ) );
	}
}
//-------------------------------------------------------------
function SurveyEntries_AccessibleGroups(o,clientID)
{
	var args = new Function();
	args.selectedItemIDs = document.getElementById(clientID+'_hidAccessibleGroups').value;
//alert(args.selectedItemIDs);
	if (window.showModalDialog("/Panels/SelectGroups/default.htm", args, "dialogWidth:770px; dialogHeight:600px; center:yes; edge:raised; resizable:yes; scroll:yes; status:yes;"))
	{
//alert(args.selectedItemIDs);
		document.getElementById(clientID+'_hidCommand').value	= "AccessibleGroups";
		document.getElementById(clientID+'_hidAccessibleGroups').value	= args.selectedItemIDs;
		//document.getElementById(clientID+'_lbCommand').click();
		eval( unescape( $get(clientID+'_lbCommand').href ) );
	}
}
//-------------------------------------------------------------
function SurveyEntries_CallUploader(o,clientID)
{
/*
	var args = new Function();
	args.SurveyID = document.getElementById(clientID+"_hidSurveyID").value;
	if (window.showModalDialog("/Survey/UploadData/default.htm", args, 'dialogWidth:70em; dialogHeight:55em; center:yes; edge:raised; resizable:yes; scroll:no; status:yes;'))
	{
		document.all(clientID+"_hidCommand").value	= "Refresh";
		//document.all(clientID+"_lbCommand").click();
		eval( unescape( $get(clientID+'_lbCommand').href ) );
	}
	*/
	
	var args = new Function();
	args.callerObject = this;
	args.callback = "args.callerObject.ProfileChanged(args);";
	//var url = "/Panels/Chat/PrintMessage.aspx";
	//var url = "/Survey/UploadData/UploadWizard.aspx?surveyID="+$get(clientID+"_hidSurveyID").value;
	var url = "/Survey/UploadData/default.aspx?surveyID="+$get(clientID+"_hidSurveyID").value;
	var win = g_global.OpenWindow(url,args,950,600,"<b>Upload Survey Data</b>");
	
	
}
//-------------------------------------------------------------
function SurveyEntries_DownloadDictionary(o,clientID,scope)
{
//	var args = new Function();
//	args.SurveyID = document.getElementById(clientID+"_hidSurveyID").value;
//	args.xmlColumns = document.getElementById(clientID+'_hidSetColumns').value;
//	window.showModalDialog("/Panels/SurveyDictionary/default.htm", args, 'dialogWidth:70em; dialogHeight:55em; center:yes; edge:raised; resizable:yes; scroll:no; status:yes;');

	var surveyID = document.getElementById(clientID+"_hidSurveyID").value;
	var url = "/Panels/SurveyDictionary/Sheet1.aspx?surveyID="+surveyID;
	window.open(url, "_blank", "height=600,width=770,location=no,menubar=yes,toolbar=yes,resizable=yes");

}
//-------------------------------------------------------------
function SurveyEntries_ViewDictionary(o,clientID)
{
//	var args = new Function();
//	args.SurveyID = document.getElementById(clientID+"_hidSurveyID").value;
//	args.xmlColumns = document.getElementById(clientID+'_hidSetColumns').value;
//	window.showModalDialog("/Panels/SurveyDictionary/default.htm", args, 'dialogWidth:70em; dialogHeight:55em; center:yes; edge:raised; resizable:yes; scroll:no; status:yes;');

	var surveyID = document.getElementById(clientID+"_hidSurveyID").value;
	var url = "/Panels/ViewDictionary/default.aspx?surveyID="+surveyID;
	//var url = "/Panels/SurveyDictionary/Sheet1.aspx?surveyID="+surveyID;
	window.open(url); 
	//, "_blank", "height=600,width=770,location=no, menubar=yes, toolbar=yes, resizable=yes, scrollbars=yes");
}
//-------------------------------------------------------------
function SurveyEntries_DownloadStructure(o,clientID)
{
	var surveyID = document.getElementById(clientID+"_hidSurveyID").value;
	var url = "/Panels/SurveyStructure/SurveyXmlStructure.aspx?surveyID="+surveyID;
	window.open(url);//, "_blank", "height=600,width=700,location=no,menubar=yes,toolbar=yes,resizable=yes;");
}
//-------------------------------------------------------------
function SurveyEntries_DownloadData(cacheKey,surveyID)
{
	var url = "/Panels/DownloadData/Sheet1.aspx?surveyID="+surveyID+"&cacheKey="+cacheKey;
	window.open(url, "_blank", "height=600,width=770,location=no,menubar=yes,toolbar=yes,resizable=yes,scrollable=yes");
}
//-------------------------------------------------------------
function SurveyEntries_SetWidth(o)
{
//alert(o.outerHTML);
	if (document.body.scrollWidth > document.body.offsetWidth)
	{
		return document.body.offsetWidth + "px";
	}
	else
	{
		return "100%";
	}
//alert("clientWidth = " + document.body.clientWidth + "\n" +
//"offsetWidth = " + document.body.offsetWidth + "\n" +
//"scrollWidth = " + document.body.scrollWidth + "\n" +
//"style.width = " + document.body.style.width + "\n");
}
//-------------------------------------------------------------
function SurveyEntries_DefineWhoCanDelete(o,clientID)
{
	var args = new Function();
	args.mode = "WhoCanDelete";
	args.value = document.getElementById(clientID+'_hidWhoCanDelete').value;
	if (window.showModalDialog("/Panels/SurveyEntriesProps/default.htm", args, "dialogWidth:770px; dialogHeight:600px; center:yes; edge:raised; resizable:yes; scroll:yes; status:yes;"))
	{
		document.getElementById(clientID+'_hidCommand').value	= "WhoCanDelete";
		document.getElementById(clientID+'_hidWhoCanDelete').value	= args.value;
		//document.getElementById(clientID+'_lbCommand').click();
		eval( unescape( $get(clientID+'_lbCommand').href ) );
	}
}
//-------------------------------------------------------------
function SurveyEntries_SetSurveyProperties(o,clientID)
{
	var args = new Function();
	args.SurveyID = document.getElementById(clientID+'_hidSurveyID').value;
//	args.xmlColumns = document.getElementById(clientID+'_hidSetColumns').value;
	if (window.showModalDialog("/Panels/SetSurveyProperties/default.htm", args, "dialogWidth:820px; dialogHeight:600px; center:yes; edge:raised; resizable:yes; scroll:no; status:yes;"))
	{
//		document.getElementById(clientID+'_hidCommand').value	= "WhoCanDelete";
//		document.getElementById(clientID+'_hidWhoCanDelete').value	= args.value;
//		document.getElementById(clientID+'_lbCommand').click();
	}
}
//-------------------------------------------------------------
function SurveyEntries_GetCheckedItems(clientID)
{
	var arr = $get(clientID+"_dList").rows;
	var ss = "";
	for(var j=1; j<arr.length; j++)
	{
		var tr = arr[j];
		try
		{
			var cb = tr.cells[0].getElementsByTagName("input")[0];
			if (cb.type=="checkbox" && cb.checked)
			{
				ss+=(ss==""?"":",") + tr.getAttribute("c_FullItemID");
			}
		}
		catch(e){}
	}
	return ss;
}
//-------------------------------------------------------------
function SurveyEntries_DeleteChecked(clientID)
{
	var ss = SurveyEntries_GetCheckedItems(clientID);
	
	if (ss=="")
	{
		alert("No entries checked");
	}
	else
	{
		var cnt = ss.split(",").length;
		if (confirm("Do you want to delete " + cnt + " checked item"+(cnt==1?"":"s")+"?"))
		{
			$get(clientID+'_hidCommand').value	= "DeleteChecked";
			$get(clientID+'_hidValue').value	= ss;
			eval( unescape( $get(clientID+'_lbCommand').href ) );
		}
//alert(ss);
	}
}

//-------------------------------------------------------------
function SurveyEntries_EmailEntry(o)
{
	var p = SurveyEntries_GetPanel(o);
	var clientID = p.getAttribute("c_clientID");
	var tr=o;while(tr.tagName!='TR')tr=tr.parentNode;
	var itemID = tr.getAttribute("c_ItemID");
	
	$get(clientID+'_hidValue').value	= p.getAttribute("c_surveyID")+":"+itemID;
	$get(clientID+'_hidCommand').value	= "EmailEntry";
	eval( unescape( $get(clientID+'_lbCommand').href ) );
}
function SurveyEntries_EmailEntry_End(url)
{
	var ww = window.screen.availWidth - 100;
	var hh = window.screen.availHeight - 100;
	if (window.showModalDialog)
	{
		var args = new Function();
		if (window.showModalDialog(url, args, "dialogWidth:"+ww+"px; dialogHeight:"+hh+"px; center:yes; edge:raised; resizable:yes; scroll:yes; status:yes;"))
		{
		}
	}
	else
	{
		window.open(url, "_blank", "width="+ww+"px,height="+hh+"px,location=no,menubar=no,toolbar=no,resizable=yes");
	}
}

