
function doPostBack(Task,TaskID)
{
	document.forms[0].task.value = Task;
	document.forms[0].taskid.value = TaskID;
	document.forms[0].submit();
}

function doPostBackParentWithType(Task,TaskID,TopicName,Type)
{
	UpdateDivCSV();
	parent.document.forms[0].task.value = Task;
	parent.document.forms[0].taskid.value = TaskID;
	parent.document.forms[0].TopicName.value = TopicName;
	parent.document.forms[0].TopicType.value = Type;
	//parent.document.forms[0].CSVDivType.value = CSVDivType;
	//parent.document.forms[0].CSVDivTopic.value = CSVDivTopic;
	parent.document.forms[0].submit();
}

function doPostBackParent(Task,TaskID)
{
	parent.document.forms[0].task.value = Task;
	parent.document.forms[0].taskid.value = TaskID;
	parent.document.forms[0].submit();
}
function doDownload(FileNameWithPath)
{
	//var sTest = window.open("","Download",'menubar=yes,width=10,height=10,left=1024,top=768,resizable');
	var sTest = window.open(FileNameWithPath,"Download",'menubar=yes,width=400,height=400,left=10,top=10,resizable');
	sTest.location = FileNameWithPath;
}
function doOpenNewWindow(sFileName)
{
	window.open(sFileName, 'Preview', 'width=1000,height=530,left=8,top=5,status=yes,toolbar=yes,menubar=yes,location=yes,resizable=yes');
}

function findPos(obj) 
{
	//obj = document.getElementById("SELECTED_IMG_ID");
	
	if(obj)
	{
		var curleft = curtop = 0;
		if (obj.offsetParent) {
			curleft = obj.offsetLeft
			curtop = obj.offsetTop
			while (obj = obj.offsetParent) {
				curleft += obj.offsetLeft
				curtop += obj.offsetTop
			}
		}
		
		curtop -= 50;
		
		return curtop;
	}
}

function sstchur_SmartScroller_Scroll(sID)
{
	//alert(sID);
	obj = document.getElementById(sID);
	if(obj)
	{
		var y = findPos(obj);
		var x = 0;
		window.scrollTo(x, y);
	}
}

function doOpenMenu(sID)
{
	location.href = "JIT_TYPE.htm?"+sID;
}

function GetShowHideDivs()
{
	var sSubMenuCnt = document.forms[0].subMenuCnt.value;
	var sTempStr = "";
	
	for(i=0; i<sSubMenuCnt; i++)
	{
		if(document.getElementById("SUB_"+i))
		{
			if(document.getElementById("SUB_"+i).style.display == "block")
			{
				sTempStr += "~"+"SUB_"+i;
			}
		}
	}
	
	return sTempStr;
}


function doShowHide(sID, sMenu)
{
	
	if(sID == "")
	return;
	
	var e = document.getElementById(sID);
	var sSubMenuCnt = document.forms[0].subMenuCnt.value;
	
	if(e)
	{
		var sTemp = e.style.display;
	/*
		for(i=0; i<sSubMenuCnt; i++)
		{
			if(document.getElementById("SUB_"+i))
			{
				if(("SUB_"+i) == sID)
				{
					var sTemp = document.getElementById("SUB_"+i).style.display;
				}
				document.getElementById("SUB_"+i).style.display = "none";
				document.getElementById("SUB_"+i+"_BULLET").innerHTML = "<a href=\"javascript:doShowHide('SUB_"+i+"');\"><img src=\"images/bullet.jpg\" border=\"0\"></a>";
			}
		}
*/
		if(sTemp == "none")
		{
			e.style.display = "block";
			sHTML = "<a href=\"javascript:doShowHide('"+sID+"');\">";
			sHTML += "<img src=\"images/bulletdown.jpg\" id=\"BD\" border=\"0\"></a>";
			document.getElementById(sID+"_BULLET").innerHTML = sHTML;
			//alert(sHTML);
		}
		else
		{
			e.style.display = "none";
			document.getElementById(sID+"_BULLET").innerHTML = "<a href=\"javascript:doShowHide('"+sID+"');\"><img src=\"images/bullet.jpg\" border=\"0\"></a>";	
		}
	}
	
	parent.document.forms[0].SelectedID.value = sID;
	parent.document.forms[0].SelectedMenu.value = sMenu;
	//sstchur_SmartScroller_Scroll(sID);
	UpdateDivCSV();
}


function doShowHide_NEW(sID, sMenu)
{
	
	var e = document.getElementById(sID);
	var sSubMenuCnt = document.forms[0].subMenuCnt.value;
	
	if(e)
	{
		/*
		for(i=0; i<sSubMenuCnt; i++)
		{
		
			if(document.getElementById("SUB_"+i))
			{
				if(("SUB_"+i) == sID)
				{
					var sTemp = document.getElementById("SUB_"+i).style.display;
				}
				
				document.getElementById("SUB_"+i).style.display = "none";
				document.getElementById("SUB_"+i+"_BULLET").innerHTML = "<a href=\"javascript:doShowHide('SUB_"+i+"');\"><img src=\"images/bullet.jpg\" border=\"0\"></a>";
			}
		}
		*/

		if(e.style.display == "none")
		{
			e.style.display = "block";
			document.getElementById(sID+"_BULLET").innerHTML = "<a href=\"javascript:doShowHide('"+sID+"');\"><img src=\"images/bulletdown.jpg\" border=\"0\"></a>";
		}
		else
		{
			e.style.display = "none";
			document.getElementById(sID+"_BULLET").innerHTML = "<a href=\"javascript:doShowHide('"+sID+"');\"><img src=\"images/bullet.jpg\" id=\"b2\" name=\"b2\" border=\"0\"></a>";	
		}
	}
	
	
	parent.document.forms[0].SelectedID.value = sID;
	parent.document.forms[0].SelectedMenu.value = sMenu;
	//sstchur_SmartScroller_Scroll(sID);
	//alert(sID);
	//InitialiseScrollbar();
	
	UpdateDivCSV();
	
}

function UpdateDivCSV()
{
	sTempCSV = GetShowHideDivs();
	
	if(document.forms[0].TabType.value == "Type")
	{
		parent.document.forms[0].CSVDivType.value = sTempCSV;
	}
	else
	{
		parent.document.forms[0].CSVDivTopic.value = sTempCSV;		
	}
}

function InitLeftFrame()
{
	//InitialiseScrollbar();
	sID = parent.document.forms[0].SelectedID.value;
	sMenu = parent.document.forms[0].SelectedMenu.value;
	//alert((sID + " - " + sMenu));
	//if(sID != "")
	//doShowHide(sID, sMenu);
	
	doHideSelectedDivs()
	
	//sArr = CSVDiv.split("~");
	//alert(sArr.length);
	sstchur_SmartScroller_Scroll('SELECTED_IMG_ID');
	
	
	//CHANGE for AdunctCentral
	//Check if the call is external
	//isExternalCall = document.forms[0].ExternalCall.value;
	sResource = document.forms[0].ExternalResource.value;
	if(sResource != "")
	{
		sResource = document.forms[0].ExternalResource.value;
		sDivID = document.getElementById(sResource).innerHTML;
		//alert(sDivID);
		//Collapse the selected menu
		doShowHide(sDivID);
		//Scroll till the selected menu
		sstchur_SmartScroller_Scroll('BD');
	}
	document.forms[0].ExternalResource.value = "";
	//END
}

function doHideSelectedDivs()
{
	//var CSVDiv = parent.document.forms[0].CSVDiv.value;
	if(document.forms[0].TabType.value == "Type")
	{
		CSVDiv = parent.document.forms[0].CSVDivType.value;
	}
	else
	{
		CSVDiv = parent.document.forms[0].CSVDivTopic.value;		
	}

	arrDiv = CSVDiv.split("~");
	if(arrDiv.length>1)
	{
		for(i=1; i<arrDiv.length; i++)
		{
			doShow(arrDiv[i]);
		}
	}
	
}

b1 = new Image(22,22);
b1.src="images/bullet.jpg";  

b2 = new Image(22,22);
b2.src="images/bullet.jpg";  

function doHide(sID)
{
	var e = document.getElementById(sID);
	
	e.style.display = "none";
	document.getElementById(sID+"_BULLET").innerHTML = "<a href=\"javascript:doShowHide('"+sID+"');\"><img src=\"images/bullet.jpg\" id=\"b1\" name=\"b1\" border=\"0\"></a>";	
}

function doShow(sID)
{
	var e = document.getElementById(sID);
	
	e.style.display = "block";
	document.getElementById(sID+"_BULLET").innerHTML = "<a href=\"javascript:doShowHide('"+sID+"');\"><img src=\"images/bullet.jpg\" id=\"b1\" name=\"b1\" border=\"0\"></a>";	
}

function doHighlight(sID)
{
	var e = document.getElementById(sID+"_BULLET");
	e.innerHTML = "<img src='images/bullet-black-topspace.jpg' >";
}

function doRemoveHighlight(sID)
{
	var e = document.getElementById(sID+"_BULLET");
	e.innerHTML = "&nbsp;";
}


function doDisplayData()
{
	/*
	var sQuery = location.search.substr(1);

	if(sQuery!="")
	{
		var sDesc = document.getElementById(sQuery+"_DESC").innerHTML;
	
		document.getElementById(sQuery+"_TD").innerHTML = sDesc;
		document.getElementById(sQuery+"_BULLET").innerHTML = "<img src='images/bullet-black-topspace.jpg' >";

		var arrID = sQuery.split("_");
		sID = arrID[0]+"_"+arrID[1];

		var sType = document.getElementById(sID+"_TYPE").innerHTML;
		document.getElementById("CONTENT_ID").innerHTML = ActivityData(sType, sDesc);

		document.getElementById(sID+"_BULLET").innerHTML = "<a href=\"javascript:doShowHide('"+sID+"');\"><img src=\"images/bulletdown.jpg\" border=\"0\"></a>";
		document.getElementById(sID).style.display = "block"
	}
	else
	{
		document.getElementById("CONTENT_ID").innerHTML = InitText();
	}
	
	if(document.getElementById("MeasureHeight").offsetHeight > 320 && document.getElementById("ImplementHeight").offsetHeight < document.getElementById("MeasureHeight").offsetHeight)
	{
		document.getElementById("ImplementHeight").style.height = document.getElementById("MeasureHeight").offsetHeight;
	}*/
}



/*
function sstchur_SmartScroller_GetCoords()
		{
			var scrollX, scrollY;
		      
			if (document.all)
			{
				if (!document.documentElement.scrollLeft)
					scrollX = document.body.scrollLeft;
				else
					scrollX = document.documentElement.scrollLeft;
		               
				if (!document.documentElement.scrollTop)
					scrollY = document.body.scrollTop;
				else
					scrollY = document.documentElement.scrollTop;
			}   
			else
			{
				scrollX = window.pageXOffset;
				scrollY = window.pageYOffset;
			}
		   
			parent.parent.HiddenFrame.document.forms[0].xCoordHolder.value = scrollX;
			parent.parent.HiddenFrame.document.forms[0].yCoordHolder.value = scrollY;
		}

		function sstchur_SmartScroller_Scroll()
		{
			//var x = parent.parent.HiddenFrame.document.forms[0].xCoordHolder.value;
			//var y = parent.parent.HiddenFrame.document.forms[0].yCoordHolder.value;
			//window.scrollTo(x, y);
			//alert("Y = "+y);
			
			obj = document.getElementById("SELECTED_IMG_ID");
			if(obj)
			{
				var y = findPos(obj);
				var x = 0;
				window.scrollTo(x, y);
			}
		}
				
		window.onload = sstchur_SmartScroller_Scroll;
		//window.onscroll = sstchur_SmartScroller_GetCoords;
		//window.onkeypress = sstchur_SmartScroller_GetCoords;
		//window.onclick = sstchur_SmartScroller_GetCoords;
				

		function findPos(obj) 
		{
			obj = document.getElementById("SELECTED_IMG_ID");
			
			
			if(obj)
			{
				var curleft = curtop = 0;
				if (obj.offsetParent) {
					curleft = obj.offsetLeft
					curtop = obj.offsetTop
					while (obj = obj.offsetParent) {
						curleft += obj.offsetLeft
						curtop += obj.offsetTop
					}
				}
				
				curtop -= 275;
				return curtop;
			}
		}
*/
