/* $Id: common.js,v 1.210 2007/10/03 04:31:16 shanmugampl Exp $ */
// global variables
notesobject = null;

function openInParent(url, viewFull)
{
	if(viewFull!=null && viewFull)
	{
		window.opener.location.href=url;
		window.close();
	}
	else
	{
		window.location.href=url;
	}

}

function addNotes(url, id)
{
	notesobject = document.getElementById(id);
	var now = new Date();
	var timedURL = url+"&ct="+now.getTime();
	showURLInDialog(timedURL,'width=350px');
}

function updateNotesIcon()
{
	if(notesobject.parentNode.className.indexOf('evenRow') != -1)
	{
		notesobject.parentNode.className="notesicon evenRow";
	}
	else if(notesobject.parentNode.className.indexOf('oddRow') != -1)
	{
		notesobject.parentNode.className="notesicon oddRow";
	}
	else
	{
		notesobject.parentNode.className="notesicon";
	}
	notesobject = null;
}

function selectUser(form, userId)
{
	form.userList.value = userId;
	form.submit();
}

function showOwner()
{
	if(document.WorkOrderForm.assignTo.value == 'Technician')
	{
		var id = document.getElementById('assignTech');
		if (id.style.display == "none")
		{
			eval("id.style.display = 'block';");
		}
		var id1 = document.getElementById('assignQueue');
		if (id1.style.display == "block")
		{
			eval("id1.style.display = 'none';");
		}
	}
	else if(document.WorkOrderForm.assignTo.value == 'Queue')
	{
		var id = document.getElementById('assignTech');
		if (id.style.display == "block")
		{
			eval("id.style.display = 'none';");
		}
		var id1 = document.getElementById('assignQueue');
		if (id1.style.display == "none")
		{
			eval("id1.style.display = 'block';");
		}
	}
	else if(document.WorkOrderForm.assignTo.value == 'None')
	{
		var id = document.getElementById('assignTech');
		if (id.style.display == "block")
		{
			eval("id.style.display = 'none';");
		}
		var id1 = document.getElementById('assignQueue');
		if (id1.style.display == "block")
		{
			eval("id1.style.display = 'none';");
		}
	}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
	if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
		document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);



function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}

var oPrevElement;
// click hover normal
function styleSwap(oElement, sEvent, sOff, sOn) {
	var cssClass;
	if(sEvent == 'click') {
		if(oPrevElement != null) {
			oPrevElement.className = sOff;
		}
		if (oElement) { oElement.className = sOff; }
		oPrevElement = oElement;
	}
	else {

		if (sEvent=='hover') cssClass = sOn;
		else cssClass = sOff;
		if (oPrevElement==null) {
			oElement.className = cssClass;
		}
		else {
			if(oPrevElement.id != oElement.id) {
				oElement.className = cssClass;
			}
		}
	}
}


function loader(did){
	var mid = document.getElementById(did);
	if(readCookie(mid)=="show"){
		eval("mid.style.display = 'block';");

	}else if(readCookie(mid)=="hide"){
		eval("mid.style.display = 'none';");
	}
}

function ShowHide(divId)
{
	var id = document.getElementById(divId);
	if (id.style.display == "none")
	{
		createCookie(id, 'show', 30);
		eval("id.style.display = 'block';");
	}
	else
	{
		createCookie(id, 'hide', 30);
		eval("id.style.display = 'none';");
	}
}

function ShowReqTab(divIdToShow)
{
	var idToShow = document.getElementById(divIdToShow);
	if(divIdToShow=="reqDetails")
	{
		var idToHide = document.getElementById("reqHistory");
		eval("idToHide.style.display = 'none';");
		var idToHide = document.getElementById("resolution");
		eval("idToHide.style.display = 'none';");
	}
	else if(divIdToShow=="resolution")
	{
		var idToHide = document.getElementById("reqDetails");
		eval("idToHide.style.display = 'none';");
		var idToHide = document.getElementById("reqHistory");
		eval("idToHide.style.display = 'none';");
	}
	else if(divIdToShow=="reqHistory")
	{
		var idToHide = document.getElementById("reqDetails");
		eval("idToHide.style.display = 'none';");
		var idToHide = document.getElementById("resolution");
		eval("idToHide.style.display = 'none';");
	}

	eval("idToShow.style.display = 'block';");
}


function ShowProductTab(divIdToShow)
{
	var idToShow = document.getElementById(divIdToShow);
	if(divIdToShow=="productDetails")
	{
		var idToHide = document.getElementById("associatedVendors");
		eval("idToHide.style.display = 'none';");
	}
	else if(divIdToShow=="associatedVendors")
	{
		var idToHide = document.getElementById("productDetails");
		eval("idToHide.style.display = 'none';");
	}
	else if(divIdToShow=="vendorDetails")
	{
		var idToHide = document.getElementById("associatedProducts");
		eval("idToHide.style.display = 'none';");
	}
	else if(divIdToShow=="associatedProducts")
	{
		var idToHide = document.getElementById("vendorDetails");
		eval("idToHide.style.display = 'none';");
	}

	eval("idToShow.style.display = 'block';");
}

function createCookie(name, value, days)
{
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
	var ca = document.cookie.split(';');
	var nameEQ = name + "=";
	for(var i=0; i < ca.length; i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1, c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
	}
	return null;
}

function eraseCookie(name)
{
	createCookie(name, "", -1);
}

function MM_findObj(n, d) { //v4.01
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;}

function checkinteger(order)
{
	var x=order.value;

	var anum=/(^\d+$)|(^\d+\.\d+$)/;
	if (x!=null && x!="" && anum.test(x))
	{
		testresult=true;
		if(x.indexOf(".")>=0)
		{
			testresult=false
		}
		maxVal = Math.max(x,2147483648);
		if(maxVal!=2147483648 || x==maxVal)
		{
			testresult=false;
		}
	}
	else
	{
		testresult=false;
	}
	return (testresult)
}

function checkintegervalue(x)
{
	var anum=/(^\d+$)|(^\d+\.\d+$)/
		if (x!=null && x!="" && anum.test(x))
		{
			testresult=true
				if(x.indexOf(".")>=0)
				{
					testresult=false
				}
			maxVal = Math.max(x,2147483648);
			if(maxVal!=2147483648 || x==maxVal)
			{
				testresult=false
			}
		}
		else
		{
			testresult=false
		}
	return (testresult)
}

function checklong(order)
{
	var x=order.value

		var anum=/(^\d+$)|(^\d+\.\d+$)/
		if (x!=null && x!="" && anum.test(x))
		{
			testresult=true
				if(x.indexOf(".")>=0)
				{
					testresult=false
				}
			maxVal = Math.max(x,9223372036854775808);
			if(maxVal!=9223372036854775808 || x==maxVal)
			{
				testresult=false
			}
		}
		else
		{
			testresult=false
		}
	return (testresult)
}

function checknumber(order)
{
	var x=order.value

		var anum=/(^\d+$)|(^\d+\.\d+$)/
		if (x!=null && x!="" && anum.test(x))
		{
			testresult=true
		}
		else
		{
			alert(document.getElementById('invalidnumber').value)
				testresult=false
		}
	return (testresult)
}

function Show(divId)
{
	var id = document.getElementById(divId);
	if (id.style.display == "none")
	{
		createCookie(id, 'show', 30);
		eval("id.style.display = 'block';");
	}
	else
	{
		createCookie(id, 'hide', 30);
		eval("id.style.display = 'block';");
	}
}

function quickReqValidate(form)
{
	if(trim(form.reqName.value)=="")
	{
		alert(getMessageForKey("sdp.leftpanel.quickcreate.askreqname"));
		form.reqName.focus();
		return false;
	}
	if(trim(form.title.value)=="")
	{
		alert(getMessageForKey("sdp.leftpanel.quickcreate.askreqtitle"));
		form.title.focus();
		return false;
	}

	checkUserExists(form)
		return false;
}

function confirmSubmit(confirmStr)
{
	var agree=confirm(confirmStr);
	if(agree)
	{
		return true ;
	}
	else
	{
		return false ;
	}
}

function loadme()
{
	var e=document.getElementsByTagName("div");
	var temp1 = document.getElementsByName("tabName")[0];
	var temp2 = document.getElementsByName("loggedUserID")[0];
	if(temp1 != null && temp2 != null)
	{
		var module = document.getElementsByName("tabName")[0].value;
		var userID = document.getElementsByName("loggedUserID")[0].value;
		for(var i=0;i<e.length;i++)
		{
			if(e[i].id!=null)
			{
				var bulletObj=MM_findObj("bullet"+e[i].id);
				if(readCookie(userID+module+e[i].id)==e[i].id+"show" )
				{
					eval("e[i].style.display = 'block';");
					if(bulletObj != null)
					{
						bulletObj.src="/images/actionitems_expand.gif";
					}
				}
				if(readCookie(userID+module+e[i].id)==e[i].id+"hide" )
				{
					eval("e[i].style.display = 'none';");
					if(bulletObj != null)
					{
						bulletObj.src="/images/actionitems_collapse.gif";
					}
				}
			}
		}
	}
}

function loadmeadmin()
{
	div1 = document.getElementById('helpcoll');
	div2 = document.getElementById('helpexp');

	var module = document.getElementsByName("tabName")[0].value;
	var userID = document.getElementsByName("loggedUserID")[0].value;
	if(readCookie(userID+module+div1.id)==div1.id+"show" )
	{
		eval("div1.style.display = 'block';");
		eval("div2.style.display = 'none';");
	}
	else if(readCookie(userID+module+div2.id)==div2.id+"show" )
	{
		eval("div1.style.display = 'none';");
		eval("div2.style.display = 'block';");
	}
	else
	{
		eval("div1.style.display = 'block';");
		eval("div2.style.display = 'none';");
		swap2LayerC('helpexp','helpcoll');
	}
}

function toggleSwipe(gName)
{
	var selRowObj = document.getElementById(gName);
	var module = document.getElementsByName("tabName")[0].value;
	var userID = document.getElementsByName("loggedUserID")[0].value;
	var bulletObj=MM_findObj("bullet"+gName);
	if (selRowObj.style.display == 'none')
	{
		eval("selRowObj.style.display = 'block';");
		bulletObj.src="/images/actionitems_expand.gif";
	}
	else if(selRowObj.style.display == 'block')
	{
		eval("selRowObj.style.display = 'none';");
		bulletObj.src="/images/actionitems_collapse.gif";
	}
	else if(selRowObj.style.display == '')
	{
		eval("selRowObj.style.display = 'none';");
		bulletObj.src="/images/actionitems_collapse.gif";
	}
	setMinLeftPanelHeight();
}

function toggleSwipe1(gName)
{
	var selRowObj = document.getElementById(gName);
	var module = document.getElementsByName("tabName")[0].value;
	var userID = document.getElementsByName("loggedUserID")[0].value;
	if (selRowObj.style.display == 'none')
	{
		eval("selRowObj.style.display = 'block';");
	}
	else if(selRowObj.style.display == 'block')
	{
		eval("selRowObj.style.display = 'none';");
	}
	else if(selRowObj.style.display == '')
	{
		eval("selRowObj.style.display = 'none';");
	}
}

function swapLayer(showDiv,HideDiv)
{
	var showdiv = document.getElementById(showDiv);
	var hidediv = document.getElementById(HideDiv);
	eval("showdiv.style.display = 'block';");
	eval("hidediv.style.display = 'none';");
}

function onClickSwapLayer(showDiv,HideDiv)
{
	swapLayer(showDiv,HideDiv);
	var id1 = document.getElementById("success_message");
	if(id1!=null)
	{
		eval("id1.style.display = 'none';");
	}

	var id2 = document.getElementById("error_message");
	if(id2!=null)
	{
		eval("id2.style.display = 'none';");
	}
}

function swap2Layer(toShow,toHide)
{
	var idToShow = document.getElementById(toShow);
	var idToHide = document.getElementById(toHide);
	eval("idToShow.style.display = 'block';");
	eval("idToHide.style.display = 'none';");
}

function swapLayer3(toShow,toHide1,toHide2)
{
	swap2Layer(toShow,toHide1);
	var idToHide2 = document.getElementById(toHide2);
	eval("idToHide2.style.display = 'none';");
}

function swapLayer4(toShow,toHide1,toHide2,toHide3)
{
	swap2Layer(toShow,toHide1);
	var idToHide2 = document.getElementById(toHide2);
	eval("idToHide2.style.display = 'none';");
	var idToHide3 = document.getElementById(toHide3);
	eval("idToHide3.style.display = 'none';");

	var module = document.getElementsByName("tabName")[0].value;
	var userID = document.getElementsByName("loggedUserID")[0].value;

	createCookie(userID+module+toShow, toShow+'show', 30);
	createCookie(userID+module+toHide1, toHide1+'hide', 30);
	createCookie(userID+module+toHide2, toHide2+'hide', 30);
	createCookie(userID+module+toHide3, toHide3+'hide', 30);
}

function swap2LayerC(showDiv,HideDiv)
{
	var showdiv = document.getElementById(showDiv);
	var hidediv = document.getElementById(HideDiv);
	var module = document.getElementsByName("tabName")[0].value;
	var userID = document.getElementsByName("loggedUserID")[0].value;
	if(showdiv!=null && showdiv!='')
	{
		eval("showdiv.style.display = 'block';");
	}
	if(hidediv!=null && hidediv!='')
	{
		eval("hidediv.style.display = 'none';");
	}
	createCookie(userID+module+showDiv, showDiv+'show', 30);
	createCookie(userID+module+HideDiv, HideDiv+'hide', 30);
}

function trimAll(str)
{
	//check for all spaces
	var objRegExp =/^(\s*)$/;
	if (objRegExp.test(str))
	{
		str = str.replace(objRegExp,'');
		if (str.length == 0)
			return str;
	}

	//  check for leading and trailling spaces
	objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
	if(objRegExp.test(str))
	{
		str = str.replace(objRegExp, '$2');
	}
	return str;
}

function beforePOCancel()
{
	if(window.confirm(document.getElementById("confirmMsg").value))
	{
		return true;
	}
	else
	{
		return false;
	}
}

function checkForUDFNumeric()
{
	from =document.getElementsByName("FROM")[0];
	if(from!=null && from.value=='INLINE')
	{
		num1 = trimAll(document.getElementsByName("UDF_LONG1")[0]);
		num2 = trimAll(document.getElementsByName("UDF_LONG2")[0]);
		num3 = trimAll(document.getElementsByName("UDF_LONG3")[0]);
		num4 = trimAll(document.getElementsByName("UDF_LONG4")[0]);
	}
	else
	{
		num1 = document.getElementsByName("udfName1")[0];
		num2 = document.getElementsByName("udfName2")[0];
		num3 = document.getElementsByName("udfName11")[0];
		num4 = document.getElementsByName("udfName12")[0];
	}
	if(num1!=null && num1.value!=null && num1.value!='')
	{
		if(!checklong(num1))
		{
			num1.focus();
			return false;
		}
	}

	if(num2!=null && num2.value!=null && num2.value!='')
	{
		if(!checklong(num2))
		{
			num2.focus();
			return false;
		}
	}

	if(num3!=null && num3.value!=null && num3.value!='')
	{
		if(!checklong(num3))
		{
			num3.focus();
			return false;
		}
	}

	if(num4!=null && num4.value!=null && num4.value!='')
	{
		if(!checklong(num4))
		{
			num4.focus();
			return false;
		}
	}

	return true;
}

function validateIP(ip)
{
	val = trimAll(ip.value);
	if(val.indexOf(".")>0)
	{
		val1 = val.substring(0,val.indexOf("."));
		if(checkintegervalue(val1))
		{
			max2 = Math.max(val1,256);
			if(max2!=256 || val1==max2)
			{
				ip.focus();
				return false;
			}
		}
		else
		{
			ip.focus();
			return false;
		}
		val = val.substring(val.indexOf(".")+1,val.length);
		if(val.indexOf(".")>0)
		{
			val1 = val.substring(0,val.indexOf("."));
			if(checkintegervalue(val1))
			{
				max2 = Math.max(val1,256);
				if(max2!=256 || val1==max2)
				{
					ip.focus();
					return false;
				}
			}
			else
			{
				ip.focus();
				return false;
			}
			val = val.substring(val.indexOf(".")+1,val.length);
			if(val.indexOf(".")>0)
			{
				val1 = val.substring(0,val.indexOf("."));
				if(checkintegervalue(val1))
				{
					max2 = Math.max(val1,256);
					if(max2!=256 || val1==max2)
					{
						ip.focus();
						return false;
					}
				}
				else
				{
					ip.focus();
					return false;
				}
				val = val.substring(val.indexOf(".")+1,val.length);
				if(checkintegervalue(val))
				{
					max2 = Math.max(val,256);
					if(max2!=256 || val==max2)
					{
						ip.focus();
						return false;
					}
				}
				else
				{
					ip.focus();
					return false;
				}
			}
			else
			{
				ip.focus();
				return false;
			}
		}
		else
		{
			ip.focus();
			return false;
		}
	}
	else
	{
		ip.focus();
		return false;
	}
	return true;
}

function checkForIntegerZero(order)
{
	var x=order.value;
	if(!checkinteger(order))
	{
		return false;
	}
	for(var i=0; i < x.length; i++)
	{
		y = x.charAt(i);
		if(y=='0')
		{
			x = x.substring(i+1,x.length);
			i--;
			if(i<0 && x.length==0)
			{
				break;
			}
		}
		else
		{
			break;
		}
	}
	order.value=x;
	if(x==null || x=='')
	{
		return false;
	}
	else
	{
		return true;
	}
}

function ruleSelection(oElement, val)
{
	ele1 = document.getElementById('operatorID'+val);
	ele2 = document.getElementById('rowTextID'+val);
	alert(" ruleSelection ")
		sOff = 'rowselected';
	textC = 'formStyleTextSel';
	if(oElement)
	{
		oElement.className = sOff;
	}
	if(ele1)
	{
		ele1.className = textC;
	}
	if(ele2)
	{
		ele2.className = textC;
	}
}


function openWindow(theURL,winName,features,w,h) { //v2.0

	LeftPosition=(screen.width)?(screen.width-w)/2:100;
	TopPosition=(screen.height)?(screen.height-h)/2:100;
	features = features + ',top='+TopPosition+',left='+LeftPosition;
	window.open(theURL,winName,features);
}


function disableForDemo()
{
	alert("This feature is disabled for the Online Demo");
	return false;
}

function formChoose(labelId, onclass, offclass)
{
	var id = document.getElementById(labelId);
	var e=document.getElementsByTagName("label");
	for(var i=0;i<e.length;i++)
	{
		if(e[i].id!=null)
		{
			var bulletObj=MM_findObj(e[i].id);
			bulletObj.className= offclass;

		}
	}

	id.className = onclass ;
}


function selectRow(elementId, onclass, offclass)
{
	var eid = document.getElementById(elementId);
	var e=document.getElementsByTagName("tr");
	for(var i=0;i<e.length;i++)
	{
		if(eid[i].id!=null)
		{
			var eObj=MM_findObj(eid[i].id);
			eObj.className= offclass;

		}
	}

	eid.className = onclass ;

}


function threadShowhide(gName)
{
	var selRowObj = document.getElementById(gName);
	var bulletObj=MM_findObj("bullet"+gName);
	if (selRowObj.style.display == 'none')
	{
		eval("selRowObj.style.display = 'block';");
		bulletObj.src="/images/threadcollapse.gif";
	}
	else if(selRowObj.style.display == 'block')
	{
		eval("selRowObj.style.display = 'none';");
		bulletObj.src="/images/threadexpand.gif";
	}
	else if(selRowObj.style.display == '')
	{
		eval("selRowObj.style.display = 'block';");
		bulletObj.src="/images/threadcollapse.gif";
	}
}


function threadinit()
{
	window.name="main";
	var e=document.getElementsByTagName("div");
	var module = document.getElementsByName("tabName")[0].value;
	for(var i=0;i<e.length;i++)
	{
		if(e[i].id!=null)
		{
			var bulletObj=MM_findObj("bullet"+e[i].id);
			if(readCookie(module+e[i].id)==e[i].id+"show" )
			{
				eval("e[i].style.display = 'block';");
				bulletObj.src="/images/threadcollapse.gif";
			}
			if(readCookie(module+e[i].id)==e[i].id+"hide" )
			{
				eval("e[i].style.display = 'none';");
				bulletObj.src="/images/threadexpand.gif";
			}
		}
	}
}



function copyListValues(formName,from,to)
{
	fromList = eval('document.'+formName+'.'+ from);
	toList = eval('document.'+formName+'.'+ to);

	if (toList.options.length > 0 && toList.options[0].value == '0')
	{
		toList.options.length = 0;
	}
	var sel = false;
	for (i=0;i<fromList.options.length;i++)
	{
		var current = fromList.options[i];
		if (current.selected)
		{
			sel = true;
			if (current.value == '0')
			{
				alert (document.getElementById('invalidselection').value);
				return;
			}
			txt = current.text;
			val = current.value;
			len = toList.length;
			var present = false;
			for (role=0;role<len;role++)
			{
				if(current.value == toList.options[role].value)
				{
					present = true;
					break;
				}
				else
				{
					continue;
				}
			}
			if(!present)
			{
				toList.options[toList.length] = new Option(txt,val);
			}
			fromList.options[i] = null;
			i--;
		}
	}
	if (!sel) alert (document.getElementById('noselection').value);
}
function addIt(picklist,tf)
{
	/* uncomment this to see what it is adding as it is adding it */
	/* alert(picklist.picklist1.options.length+"\n"+picklist.t1.value+"\n"+picklist.t0.value); */
	if(tf.value == "")
	{
		alert(getMessageForKey("sdp.admin.udf.emptystringjerror"));
		return false;
	}

	var NI = picklist.options.length++;
	picklist.options[NI]= new Option(tf.value, tf.value, true, false);
	tf.value = "";
	return true;
}

function deSelect(picklist)
{
	if(picklist.selectedIndex>=0)
		picklist.selectedIndex = -1;
	else
		alert(document.getElementById('noselection').value);
}


function removeFromList(listField) {
	if ( listField.length == -1) {  // If the list is empty
		alert(document.getElementById('nopicklist').value);
	} else {
		var selected = listField.selectedIndex;
		if (selected == -1) {
			alert(document.getElementById('choosepicklist').value);
		} else {  // Build arrays with the text and values to remain
			var replaceTextArray = new Array(listField.length-1);
			var replaceValueArray = new Array(listField.length-1);
			for (var i = 0; i < listField.length; i++) {
				// Put everything except the selected one into the array
				if ( i < selected) { replaceTextArray[i] = listField.options[i].text; }
				if ( i > selected ) { replaceTextArray[i-1] = listField.options[i].text; }
				if ( i < selected) { replaceValueArray[i] = listField.options[i].value; }
				if ( i > selected ) { replaceValueArray[i-1] = listField.options[i].value; }
			}
			listField.length = replaceTextArray.length;  // Shorten the input list
			for (i = 0; i < replaceTextArray.length; i++) { // Put the array back into the list
				listField.options[i].value = replaceValueArray[i];
				listField.options[i].text = replaceTextArray[i];
			}
		} // Ends the check to make sure something was selected
	} // Ends the check for there being none in the list
}


function chooseType(toShow,toHide1,toHide2)
{
	var idToShow = document.getElementById(toShow);
	var idToHide1 = document.getElementById(toHide1);
	var idToHide2 = document.getElementById(toHide2);

	eval("idToShow.style.display = 'block';");
	eval("idToHide1.style.display = 'none';");
	eval("idToHide2.style.display = 'none';");
	var module = document.getElementsByName("tabName")[0].value;
}

function selectArowAlone(elementId, onclass, offclass)
{
	var eid = document.getElementById(elementId);
	var eObj=MM_findObj(eid.id);
	if(eObj.className==onclass)
		eObj.className=offclass;
	else
		eObj.className=onclass;
}



function selectArowAndCheck(string,elementId, onclass, offclass,quantity)
{
	var eid = document.getElementById(elementId);
	var roweid = document.getElementById("row"+elementId);
	var eObj=MM_findObj(roweid.id);

	if (string.indexOf("quanedit") == -1)
	{
		eid.checked = true;
		eObj.className=onclass;
	}
	else
	{
		eid.checked = false;
		eObj.className=offclass;
		document.getElementById("QuanOf"+elementId).value=quantity;
	}
}

function checkAll(thisForm, checkBoxCompName)
{
	toSelectAll = false;
	if(thisForm.CheckAllItems.checked)
	{
		toSelectAll = true;
	}
	var count =0;
	for(var i=0; i<thisForm.elements.length; i++)
	{
		if(thisForm.elements[i].type == checkBoxCompName)
		{
			thisForm.elements[i].checked = toSelectAll;
			var e = thisForm.elements[i].getAttribute("id");
			if(e  == "RememberMe327")
			{
				continue;
			}
			if (count%2 == 0)
			{
				if (toSelectAll)
				{
					selectArow("row"+ e , 'rowHiliteb');
				}
				else
				{
					selectArow("row"+ e , 'rowoddn');
				}
			}
			else
			{
				if (toSelectAll)
				{
					selectArow("row"+e, 'rowHiliteb');
				}
				else
				{
					selectArow("row"+e, 'rowevenn');
				}
			}
			count = count + 1;
		}
	}
}

function selectArow(elementId, onclass)
{
	var eid = document.getElementById(elementId);
	var eObj=MM_findObj(eid.id);
	eObj.className=onclass;
}


function checkValue(thisForm,quanAvailable,elementId,itemName)
{
	var eid = document.getElementById(elementId);
	var eidVal = eid.value;
	if (eidVal == 0)
	{
		alert(document.getElementById('zeroitems').value);
		eid.value = quanAvailable;
		eid.focus();
	}
	var quantityAvailable = parseInt(quanAvailable);
	if (eidVal > quantityAvailable)
	{
        var text1, text2, text3;
        if($('excessquantity1')) {
            text1 = $('excessquantity1').value;     // I18Ned
        }
        else {                                      // Fail safe
            text1 = "Only ";
        }
        if($('excessquantity1')) {
            text2 = $('excessquantity2').value;
        }
        else {
            text2 = " of the item ";
        }
        if($('excessquantity1')) {
            text3 = $('excessquantity3').value;
		}
        else {
            text3 = " are yet to be received.";
        }
        alert(text1 +" "+quanAvailable+" "+text2+" "+itemName+" "+text3);
		eid.value = quanAvailable;
		eid.focus();
	}

}

// I18N functions
function loadMessageForKeys(keysList) {
	var xmlHttp = getXMLHttpRequest();
	var url = "/jsp/FetchMessage.jsp?";
	for(var i=0; i<keysList.length; i++) {
		url = url + "KEY=" + keysList[i] + "&";
	}
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState == 4) {
			var newObj = document.createElement("DIV");
			if(browser_ie){
				newObj.style.display = "none";
			}
			else if (browser_nn4 || browser_nn6){
				newObj.setAttribute("style","display:none;");
			}
			document.body.appendChild(newObj);
			newObj.innerHTML = xmlHttp.responseText;
		}
	}
	xmlHttp.send(null);
}

function getMessageForKey(key) {
	var divObj = document.getElementById(key);
	if(divObj != null) {
		return divObj.innerHTML;
	}
	return key;
}

function showAll(elementId, elementName)
{
	var elements = document.getElementsByTagName(elementName);
	var isFirst = true;
	var firstId = null;
	for(var i=0; i<elements.length; i++) {
		if(elements[i].id != null && elements[i].id.indexOf(elementId) >= 0 ){
			if(isFirst) {
				isFirst = false;
				firstId = elements[i];
			}
			var selRowObj = elements[i];
			var gName = elements[i].id;
			var bulletObj=MM_findObj("bullet"+gName);
			selRowObj.className = "show";
			selRowObj.style.display = "block";
			if(bulletObj != null){
				bulletObj.src="/images/threadcollapse.gif";
			}
		}
	}
	new Effect.ScrollTo(firstId);
}

function hideAll(elementId, elementName)
{
	var elements = document.getElementsByTagName(elementName);
	for(var i=0; i<elements.length; i++) {
		if(elements[i].id != null && elements[i].id.indexOf(elementId) >= 0 ){
			var selRowObj = elements[i];
			var gName = elements[i].id;
			var bulletObj=MM_findObj("bullet"+gName);
			selRowObj.className = "hide";
			selRowObj.style.display = "none";
			if(bulletObj != null){
				bulletObj.src="/images/threadexpand.gif";
			}
		}
	}
}

var mcTableKeys = new Array('sdp.leftpanel.search.title','sdp.leftpanel.search.go');

function setSearchTitle(title, val) {
	for(var i=0; i<document.forms.length;i++) {
		var formObj = document.forms[i];
		for(var j=0; j<formObj.elements.length;j++) {
			var element = formObj.elements[j];
			if(element.name == "searchSubmit") {
				element.title= title;
				element.value= val;
			}
		}
	}
}

function historyShowhide(gName)
{
	var selRowObj = document.getElementById("HIST_" + gName);
	var textC = document.getElementById("HTC_" + gName);
	var textE = document.getElementById("HTE_" + gName);
	if (selRowObj.className == 'hide')
	{
		selRowObj.className = 'show';
		textC.className = 'show';
		textE.className = 'hide';
	}
	else if(selRowObj.className == 'show')
	{
		selRowObj.className = 'hide';
		textC.className = 'hide';
		textE.className = 'show';
	}
	else if(selRowObj.className == '')
	{
		selRowObj.className = 'show';
		textC.className = 'show';
		textE.className = 'hide';
	}
}

function historyShowhideAsset(prefix,gName)
{
	var selRowObj = document.getElementById(prefix+ "HIST_" + gName);
	var text = document.getElementById(prefix + "HT_" + gName);
	if (selRowObj.className == 'hide')
	{
		selRowObj.className = 'show';
		text.innerHTML = "<img src='\\images\\threadcollapse.gif'>";
	}
	else if(selRowObj.className == 'show')
	{
		selRowObj.className = 'hide';
		text.innerHTML = "<img src='\\images\\threadexpand.gif'>";
	}
	else if(selRowObj.className == '')
	{
		selRowObj.className = 'show';
		text.innerHTML = "<img src='\\images\\threadcollapse.gif'>";
	}
}

function loadChineseStyle(win) {
	var xmlHttp = getXMLHttpRequest();
	var url = "/jsp/LoadStyle.jsp?";
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState == 4) {
			var elems = win.document.getElementsByTagName("link");
			if(xmlHttp.responseText.indexOf("style") >= 0) {
				for(var i=0; i<elems.length;i++) {
					var linkEl = elems[i];
					if(linkEl.href.indexOf('/style/style.css') >= 0) {
						linkEl.href = xmlHttp.responseText;
					}
				}
			}
		}
	}
	xmlHttp.send(null);
}

function getXMLHttpRequest(){
	var xmlhttp=false;
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (E) {
			xmlhttp = false;
		}
	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}
function accordion(toShow,toHide1,toHide2)
{
	var idToShow = document.getElementById(toShow);
	var idToHide1 = document.getElementById(toHide1);
	var idToHide2 = document.getElementById(toHide2);

	eval("idToShow.style.display = 'block';");
	eval("idToShow.style.overflow = 'auto';");

	eval("idToHide1.style.display = 'none';");
	eval("idToHide2.style.display = 'none';");
}



function accordionState()
{
	window.name="main";
	var e=document.getElementsByTagName("div");
	var module = document.getElementsByName("module")[0].value;
	for(var i=0;i<e.length;i++)
	{
		if(e[i].id!=null)
		{
			if(readCookie(module+e[i].id)==e[i].id+"show" )
			{
				eval("e[i].style.display = 'block';");
				eval("e[i].style.height = '300px';");
				eval("e[i].style.overflow = 'auto';");
			}
			if(readCookie(module+e[i].id)==e[i].id+"hide" )
			{
				eval("e[i].style.display = 'none';");
			}
		}
	}
}

function constructActionBar() {
	if (document.all&&document.getElementById) {
		var ulelems = document.getElementsByTagName("ul");
		for(var k=0; k<ulelems.length; k++) {
			if(ulelems[k].id == 'nav') {
				navRoot = ulelems[k];
				for (i=0; i<navRoot.childNodes.length; i++) {
					node = navRoot.childNodes[i];
					if (node.nodeName=="LI") {
						node.onmouseover=function() {
							this.className+=" over";
						}
						node.onmouseout=function() {
							this.className=this.className.replace(" over", "");
						}
					}
				}
			}
		}
	}
}

function checkApprovalForm(formObj) {
	var mailIds = trimAll(formObj.TO.value);
	if(mailIds == "" || mailIds == null)
	{
		alert(getMessageForKey("sdp.emailcheck.mailjserror"));
		formObj.TO.focus();
		return false;
	}
	if(mailIds.indexOf(";") > 0) {
		mailIds = mailIds.replace(/\;/g,",");
		formObj.TO.value = mailIds;
	}
	var mails = mailIds.split(",");
	for(var i = 0; i < mails.length; i++) {
		var index1 = trimAll(mails[i]).indexOf("@");
		var index2 = trimAll(mails[i]).indexOf(".");
		if(index1 < 0 || index2 < 0) {
			alert(getMessageForKey("sdp.emailcheck.invalidmailjserror"));
			formObj.TO.focus();
			return false;
		}
	}

	var sub = formObj.SUBJECT.value;
	if(trimAll(sub) == "") {
		alert(getMessageForKey("sdp.common.mail.jsSubErr"));
		return false;
	}
	var apprDesc = parent['editor'].getHTML();
	if(apprDesc.indexOf("$ApprovalLink") < 0) {
		alert(getMessageForKey("sdp.approve.linkerror"));
		return false;
	}
	formObj.DESCRIPTION.value = parent["editor"].getHTML();
	formObj.submit();
	return true;
}

function changeNotificationTab(id, id1, id2, params){
	document.getElementById(id).className = "show";
	document.getElementById(id + "_tab").className = "subtabon";
	document.getElementById(id1).className = "hide";
	document.getElementById(id1 + "_tab").className = "subtaboff";
	document.getElementById(id2).className = "hide";
	document.getElementById(id2 + "_tab").className = "subtaboff";
	if(id == "problem") {
		window.frames['NotFrame'].location.href = "/setup/ProblemNotifications.jsp";
	}
	if(id == "change") {
		window.frames['NotFrame'].location.href = "/setup/ChangeNotifications.jsp";
	}
}

/**
 * Used to switch the selection in a checkbox by using a nearby image. Any
 * linked enabling or disabling can also be done. The field to be enabled
 * should be specified using the notType argument. The constraint here is that
 * the image should have an id like <fieldName>_IMG.
 * The parents to be chosen while selecting a child
 * should be specified as an array to the linkedParentsToOpen argument and the
 * childs to be closed while closing a parent should be specified using the
 * linkedChildsToClose argument.
 *
 * @notType	DOM id of the field Name to be checked/unchecked
 * @linkedParentsToOpen	array of DOM id of the parents to be checked along with the current child.
 * @linkedChildsToClose	array of DOM id of the childs to be unchecked along with the current parent.
 *
 * for onclick event. No onChange event for checkbox in IE*/
function changeNotificationSelection(notType, linkedParentsToOpen, linkedChildsToClose) {
	//alert("changeNotificationSelection");
	//alert("checked:"+$(notType).checked);
	if(document.getElementById(notType) != null && document.getElementById(notType).checked) {
		document.getElementById(notType).checked = false;
		document.getElementById(notType+"_IMG").src = "/images/checked_no.gif";
		if(linkedChildsToClose != null) {
			for(var i=0; i<linkedChildsToClose.length; i++) {
				document.getElementById(linkedChildsToClose[i]).checked = false;
				document.getElementById(linkedChildsToClose[i]+"_IMG").src = "/images/checked_no.gif";
			}
		}
	}
	else {
		document.getElementById(notType).checked = true;
		document.getElementById(notType+"_IMG").src = "/images/checked_yes.gif";
		if(linkedParentsToOpen != null) {
			for(var i=0; i<linkedParentsToOpen.length; i++) {
				document.getElementById(linkedParentsToOpen[i]).checked = true;
				document.getElementById(linkedParentsToOpen[i]+"_IMG").src = "/images/checked_yes.gif";
			}
		}
	}
}

/*
 * This method is similar to the previous one but works directly on checkboxes
 *
 * fieldID                  -   DOM ID of the checkbox being operated upon
 * parentFieldsToCheck      -   array od DOM IDs of checkboxes to check
 * childFieldsToUncheck     -   array od DOM IDs of checkboxes to uncheck
 */
function setGroupSelection(fieldID, parentFieldsToCheck, childFieldsToUncheck) {
	if($(fieldID) != null && $(fieldID).checked) {
		$(fieldID).checked = true;
		if(parentFieldsToCheck != null) {
			for(var i=0; i<parentFieldsToCheck.length; i++) {
				$(parentFieldsToCheck[i]).checked = true;
			}
		}
	}
	else {
		$(fieldID).checked = false;
		if(childFieldsToUncheck != null) {
			for(var i=0; i<childFieldsToUncheck.length; i++) {
				$(childFieldsToUncheck[i]).checked = false;
			}
		}
	}
}


var oldCategoryId = null;
var oldSubCategoryId = null;
var catItemId = null;

function populateCategory(catObj,subCatObj,itemObj, catId, subCatId, itemId) {
	oldCategoryId = catId;
	oldSubCategoryId = subCatId;
	catItemId = itemId;
	var catRows = parent["CAT_LIST"];
	for(var categoryId in catRows) {
		var catName = catRows[categoryId];
		catObj.options[catObj.options.length] = new Option(catName, categoryId, true, false);
		if(catId != null && catId == categoryId) {
			catObj.options[catObj.options.length - 1].selected = true;
		}
	}
	if(subCatId != null )
	{
		populateSubCategory(catObj,subCatObj,itemObj, catId, subCatId, itemId);
	}
}

function populateSubCategory(catObj,subCatObj,itemObj, catId, subCatId, itemId) {
	if(subCatObj == null || subCatObj.options == null)
	{
		return;
	}
	var catId = catObj.value;
	for(var j = 0; j < subCatObj.options.length; j++) {
		if(subCatObj.options[j].value != "0" && subCatObj.options[j].value != "-1") {
			subCatObj.options[j] = null;
			j--;
		}
	}
	var itemObj = itemObj;
	if(itemObj != null && itemObj.options != null)
	{
		for(var j = 0; j < itemObj.options.length; j++) {
			if(itemObj.options[j].value != "0" && itemObj.options[j].value != "-1") {
				itemObj.options[j] = null;
				j--;
			}
		}
	}

	if(catId == "0") {
		for(var j = 0; j < subCatObj.options.length; j++) {
			if(subCatObj.options[j].value == "0") {
				subCatObj.options[j].selected = true;
			}
		}
		if(itemObj != null && itemObj.options != null)
		{
			for(var j = 0; j < itemObj.options.length; j++) {
				if(itemObj.options[j].value == "0") {
					itemObj.options[j].selected = true;
				}
			}
		}
		return;
	}
	var catRows = parent["CAT_" + catId];
	if(catRows == null) {
		var xmlHttp = getXMLHttpRequest();
		if(subCatId == "undefined" || subCatId == "" || subCatId == null || subCatId == "null") {
			xmlHttp.open("GET", "/workorder/GetCSIList.jsp?TYPE=SUBCAT&CATEGORYID=" + catId + "&Time=" + new Date(), true);
		}
		else {
			xmlHttp.open("GET", "/workorder/GetCSIList.jsp?TYPE=SUBCAT&CATEGORYID=" + catId + "&SUBCATEGORYID=" + subCatId + "&Time=" + new Date(), true);
		}
		xmlHttp.onreadystatechange = function() {
			if (xmlHttp.readyState == 4) {
				var catDiv = document.getElementById("SUBCAT_DIV");
				if (catDiv  == null) {
					catDiv = document.createElement("DIV");
					catDiv.id = "SUBCAT_DIV";
					document.body.appendChild(catDiv);
				}
				catDiv.innerHTML = xmlHttp.responseText;
				var scripts = catDiv.getElementsByTagName("script");
				for(var i=0; i<scripts.length; i++) {
					eval(scripts[i].innerHTML);
				}
				catRows = parent["CAT_" + catId];
				populateCSIList(subCatObj, catRows, subCatId);
				if(itemId != null)
				{
					populateItem(catObj,subCatObj,itemObj, catId, subCatId, itemId);
				}
			}
		}
		xmlHttp.send(null);
	}
	else {
		populateCSIList(subCatObj, catRows, subCatId);
		if(itemId != null)
		{
			populateItem(catObj,subCatObj,itemObj, catId, subCatId, itemId);
		}
	}
}

	function populateItem(catObj,subCatObj,itemObj, catId, subCatId, itemId) {
		if(itemObj == null || itemObj.options == null)
		{
			return;
		}
		var subCatId = subCatObj.value;
		for(var j = 0; j < itemObj.options.length; j++) {
			if(itemObj.options[j].value != "0" && itemObj.options[j].value != "-1") {
				itemObj.options[j] = null;
				j--;
			}
		}
		if(subCatId == "0") {
			for(var j = 0; j < itemObj.options.length; j++) {
				if(itemObj.options[j].value == "0") {
					itemObj.options[j].selected = true;
				}
			}
			return;
		}
		var subCatRows = parent["SUBCAT_" + subCatId];
		if(subCatRows == null) {
			var xmlHttp = getXMLHttpRequest();
			if(itemId == "undefined" || itemId == "" || itemId == null || itemId == "null") {
				xmlHttp.open("GET", "/workorder/GetCSIList.jsp?TYPE=ITEM&SUBCATEGORYID=" + subCatId + "&Time=" + new Date(), true);
			}
			else {
				xmlHttp.open("GET", "/workorder/GetCSIList.jsp?TYPE=ITEM&SUBCATEGORYID=" + subCatId + "&ITEMID=" + itemId + "&Time=" + new Date(), true);
			}
			xmlHttp.onreadystatechange = function() {
				if (xmlHttp.readyState == 4) {
					var itemDiv = document.getElementById("ITEM_DIV");
					if (itemDiv  == null) {
						itemDiv = document.createElement("DIV");
						itemDiv.id = "ITEM_DIV";
						document.body.appendChild(itemDiv);
					}
					itemDiv.innerHTML = xmlHttp.responseText;
					var scripts = itemDiv.getElementsByTagName("script");
					for(var i=0; i<scripts.length; i++) {
						eval(scripts[i].innerHTML);
					}
					subCatRows = parent["SUBCAT_" + subCatId];
					populateCSIList(itemObj, subCatRows, itemId);
				}
			}
			xmlHttp.send(null);
		}
		else {
			populateCSIList(itemObj, subCatRows, itemId);
		}
	}

function populateCSIList(selObj, rows, checkId) {
	for(var i in rows) {
		var catName = rows[i];
		selObj.options[selObj.options.length] = new Option(catName, i, true, false);
	}
	var options = selObj.options;
	for(var k=0; k<options.length;k++) {
		var val = options[k].value;
		if(val == checkId) {
			selObj.options[k].selected = true;
		}
	}
}

function highlight(divClass) {
	$$(divClass).each( function(e) { e.visualEffect('highlight',{duration:3,startcolor:"#48FF48",endcolor:"#E5EDE6"}) })
}

function confBulkOperation(type,commonList) {
	var formObj = document.ConfListForm;
	var selVals = getSelectedCheckBoxes(document.ConfListForm);
	if(selVals.length == 0) {
		alert(getMessageForKey("sdp.admin.common.deletemess"));
		return;
	}
	if(type == "DELETE") {
		var result = confirm(getMessageForKey("sdp.admin.common.deleteconfmess"));
		if(!result) {
			return;
		}
	}
	var url = "/setup/CommonDef.jsp?TYPE=" + type+"&forwardTo="+commonList;
	for(var i = 0; i < selVals.length; i++) {
		url = url + "&COMMONID=" + selVals[i];
	}
	frames["CONF_FRAME"].location.href = url;
	invokeProgressIndicator('DeleteStage','sdp.common.delete');
	return;
}

function validateConfForm(formObj) {
	var name = formObj.NAME.value;
	if(trimAll(name) == "") {
		alert(getMessageForKey("sdp.jserror.name"));
		formObj.NAME.value="";
		formObj.NAME.focus();
		return false;
	}
	formObj.NAME.value=trimAll(name);
	return true;//handleStateForForm(formObj);
}

function showConfForm(commonList) {
	window.frames['CONF_FRAME'].location.href = "/setup/CommonDefForm.jsp?forwardTo="+commonList;
}
// TASKS RELATED METHODES STARTS HERE
function updateTaskDetailsView(selObj)
{

	var val = selObj.value;
	var reqParams = "";
	var prevParams = getState('ShowTaskDetails','_D_RP');
	if(prevParams != null) {
		reqParams = prevParams + "&TYPE=" + val+"&CHANGED=true";
	}
	else {
		reqParams = prevParams;
	}
	updateState('ShowTaskDetails','_D_RP',reqParams);
	refreshSubView('ShowTaskDetails');
	selectTaskView(selObj,selObj.value);
}

function selectTaskView(selObj, type) {
	var options =  selObj.options;
	for(var i=0; i<options.length;i++) {
		if(options[i].value == type) {
			options[i].selected = true;

		}
	}
}

function taskDetailsOperation(type,frameName,view) {

	var formObj = document.TaskDetailsForm;
	var selVals = getSelectedCheckBoxes(document.TaskDetailsForm);
	if(selVals.length == 0) {
		if(type == "DELETE"){
			alert("Select atleast one task to delete");
			return;
		}
		else {
			alert("Select atleast one task to close");
			return;
		}
	}
	if(type == "DELETE") {
		var result = confirm("Are you sure to delete selected task(s)");
		if(!result) {
			return;
		}
	}
	var url = "/tasks/TaskListBulkOperation.jsp?TYPE=" + type;
	for(var i = 0; i < selVals.length; i++) {
		url = url + "&TASKID=" + selVals[i];
	}
	if(view != null){
		url = url+"&VIEW="+view;
	}
	if (frameName != null)
	{
		frames[frameName].location.href = url;
	}
	else
	{
		frames["TaskFrame"].location.href = url;
	}
	showDialog("<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td class='actiontooltipbg'><table border='0' cellspacing='0' cellpadding='0'><tr><td><img id='ProImage' src='../images/processing.gif' hspace='6' vspace='6'></td><td id='OperationStatus' class='tooltip_working'>Please wait...</td></tr></table></td></tr></table>","position=relative,closeButton=no,left=-60,top=-75,srcElement=" + type);

}
// TASKS RELATED METHODS ENDS HERE


var css_browser_selector = function() {
	var
		ua=navigator.userAgent.toLowerCase(),
		is=function(t){ return ua.indexOf(t) != -1; },
		h=document.getElementsByTagName('html')[0],
		b=(!(/opera|webtv/i.test(ua))&&/msie (\d)/.test(ua))?('ie ie'+RegExp.$1):is('gecko/')? 'gecko':is('opera/9')?'opera opera9':/opera (\d)/.test(ua)?'opera opera'+RegExp.$1:is('konqueror')?'konqueror':is('applewebkit/')?'webkit safari':is('mozilla/')?'gecko':'',
											 os=(is('x11')||is('linux'))?' linux':is('mac')?' mac':is('win')?' win':'';
	var c=b+os+' js';
	h.className += h.className?' '+c:c;
}();


function showMenuInDialog(holder, source) {
	var holderObj = document.getElementById(holder);
	var posX = findPosX(holderObj);
	var posY = findPosY(holderObj);
	var finalY = posY + holderObj.offsetHeight - document.body.scrollTop;
	showDialog(document.getElementById(source).innerHTML, 'position=absolute,closeButton=no,closeOnBodyClick=yes,left=' + posX + ',top=' + finalY);
}

function displayReminders(holder) {
	var holderObj = document.getElementById(holder);
	var posX = findPosX(holderObj);
	var posY = findPosY(holderObj);
	var finalX = posX + holderObj.offsetWidth - 331;
	showURLInDialog('/jsp/Reminder.jsp','closeButton=no,position=absolute,closeOnBodyClick=yes,left='+finalX+',top='+posY);
}


function displayRoboQuestion(holder, questionPage, params) {
	var holderObj = document.getElementById(holder);
	var posX = findPosX(holderObj);
	var posY = findPosY(holderObj);
	var finalX = posX + holderObj.offsetWidth - 375;
	if(params == null)
	{
		showURLInDialog('/jsp/'+questionPage+'.jsp','position=absolute,width=400,left='+finalX+',top='+posY);
	}
	else
	{
		showURLInDialog('/jsp/'+questionPage+'.jsp?'+params,'position=absolute,width=400,left='+finalX+',top='+posY);
	}
}

/**
 * Invokes a progress indicator near the element specified by the source
 * attribute. The text to be displayed can be passed using the key attribute.
 * If not passed, this defaults to a string 'Processing. Please Wait', else the
 * i18ned values will be fetched using the getMessageForKey method. If source is passed
 * _____________________________
 * |                           |
 * --  -------------------------
 *   \/
 *
 * @source	the element id near which the indicator should be displayed.
 * @key		the key of the key to be displayed.
 * @type	progress | completed where for progress a processing image will
 * 		be dislpayed and for completed a tick image will be displayed.
 * @image	the url of the image that should be displayed. The url should
 * 		be relative to the context.
 */
function invokeProgressIndicator(source, key, type, imageUrl, showCloseButton) {
	var reqType = 'progress';
	var image = '/images/processing.gif';
	var cssClass = 'shadow_tip';
	if(type != null && type == "completed") {
		reqType = 'completed';
		image = '/images/processing_done.gif';
	}
	if(key == null) {
		// The key to be shown is not passed. Kindly pass it.
		// TODO: This should be removed during the release
		//alert("The key to be shown is not passed. Kindly pass it.");
	}
	if(source == null) {
		cssClass = 'shadow_ct';
	}
	if(imageUrl != null) {
		if(imageUrl == "no") {
			image = null;
		}
		else {
			image = imageUrl;
		}
	}
    if(showCloseButton != null && (showCloseButton == "no" || showCloseButton == false || showCloseButton =="false")) {
        showCloseButton = false;
    }
    else {
        showCloseButton = true;
    }

	var outerTable = "<table width='100%' border=0 cellspacing=0 cellpadding=0 id=Actions_tool_tip><tr><td width=18 height=6 class=top_lt></td><td class=top_ct colspan=2></td><td class='top_ct'>";
    if(showCloseButton == true) {
        outerTable = outerTable + "<a href='javascript:void(0);' onclick='closeDialog();'><img id=closeImg border=0 style=\"position:absolute; margin-left:-6px;\" src='/images/exit1.gif' hspace=6 vspace=6 ></a>";
    }
    outerTable = outerTable + "</td><td width=6 class=top_rt></td></tr><tr><td width=18 class=center_lt></td><td class=actions_color colspan=3>";

	var innerTable = "<table border=0 cellspacing=0 cellpadding=0><tr><td>";
	if(image != null) {
		innerTable = innerTable.concat("<img id=ProImage src='");
		innerTable = innerTable.concat(image);
		innerTable = innerTable.concat("' hspace=6 vspace=6>");
	}
	innerTable = innerTable.concat("</td><td id='OperationStatus' class=tooltip_working>&nbsp;</td></tr></table>");
	outerTable = outerTable.concat(innerTable);
	outerTable = outerTable.concat("</td><td class=center_rt>&nbsp;</td></tr><tr><td width=18 height=25 class=bottom_lt></td><td width=35 class=");
	outerTable = outerTable.concat(cssClass);
	outerTable = outerTable.concat("></td><td width='200' class=shadow_ct>&nbsp;</td><td width=7 class=shadow_lt></td><td width=6 class=bottom_rt></td></tr></table>");
	if(source != null) {
		var holderObj = document.getElementById(source);
		var posX = findPosX(holderObj);
		var posY = findPosY(holderObj);
		var finalY = posY - 40 - document.body.scrollTop;
		var finalX = posX - 35;
		showDialog(outerTable,"position=absolute,closeButton=no,width=250,left=" + finalX + ",top=" + finalY);
	}
	else {
		showDialog(outerTable,"position=absmiddle,closeButton=no,width=250");
	}
	// The Key is not set to the td while constructing itself, so that any
	// problems due to ' and " could be avoided while assigning then.
	document.getElementById('OperationStatus').innerHTML= getMessageForKey(key);
}

/**
 * Closes the progress indicator, after checking whether the operation is a
 * success or failure which should be indicated by the result parameter. The
 * text to be displayed can be specified through the key parameter. The
 * indicator will be closed after a time gap of 1sec.
 *
 * @key		The i18n key for the key.
 * @result	true | false [true]
 */
function closeProgressIndicator(key, result) {
	if(result == null) {
		result = true;
	}
	if(key == null) {
		// The key should be passed. Should be removed later.
		//alert("No key is specified while closing the indicator");
	}
	document.getElementById('OperationStatus').innerHTML = getMessageForKey(key);
	if(result) {
		document.getElementById('ProImage').src = "/images/processing_done.gif";
		setTimeout("parent.closeDialog();",1000);
	}
	else {
		document.getElementById('ProImage').src = "/images/invalidoperationicon.gif";
	}
}


var reqToProKeys = new Array('sdp.common.processing','sdp.common.processcomp');
var udfErrorKeys = new Array('sdp.jserror.requestcustomfields');

function selectRemDate( value ){
	var len = document.CUDTask.REMDATE.options.length;
	for( var i=0 ; i<len ; i++){
		var opt = document.CUDTask.REMDATE.options[i];
		if( opt.value == value){
			opt.selected = true;
		}
	}
}

function selectStatus( value ){
	var len = document.CUDTask.STATUSID.options.length;
	for( var i=0 ; i<len ; i++){
		var opt = document.CUDTask.STATUSID.options[i];
		if( opt.value == value){
			opt.selected = true;
		}
	}
}

function showMessageAndClose( value, timeout){
	invokeProgressIndicator(null,value,"completed");
	if(timeout == null)
	{
		setTimeout("closeDialog();", 2000);
	}
	else
	{
		setTimeout("closeDialog();", timeout);
	}
}

function showAttachedMessageAndClose(holder, value, timeout, imgUrl){
	invokeProgressIndicator(holder, value, "completed", imgUrl);
    if(timeout != null && timeout != 0) {
        setTimeout("closeDialog();",timeout);
    }
}

function showFailureMessageAndClose(value, timeout){
	invokeProgressIndicator(null, value, "completed", '/images/invalidoperationicon.gif');
	if(timeout == null)
	{
		setTimeout("closeDialog();", 2000);
	}
	else
	{
		setTimeout("closeDialog();", timeout);
	}
}

function showSiteForm() {
	window.frames['SITE_FRAME'].location.href = "/SiteDefForm.do";
}

function siteBulkOperation(type) {
	var formObj = document.SiteListForm;
	var selVals = getSelectedCheckBoxes(document.SiteListForm);
	if(selVals.length == 0) {
		alert(getMessageForKey("sdp.setup.site.selectone"));
		return;
	}
	if(type == "DELETE") {
		var result = confirm(getMessageForKey("sdp.setup.site.confirm"));
		if(!result) {
			return;
		}
	}
	var url = "/SiteDefForm.do?TYPE=" + type;
	for(var i = 0; i < selVals.length; i++) {
		url = url + "&SITEID=" + selVals[i];
	}
	frames["SITE_FRAME"].location.href = url;
	invokeProgressIndicator('DeleteSite', "sdp.common.processing");
	return;
}

function TimeTick()
{
	time = time+1000;
	if(rTimer) {
		clearTimeout(rTimer);
	}
	rTimer = setTimeout('TimeTick()', 1000);
}

function updateClock()
{
	var date = new Date();
	date.setTime(time);
	var min = date.getMinutes();
	var hrs = date.getHours();
	var sec = date.getSeconds();
	if(min <= 9) {
		min = "0" + min;
	}
	if(hrs <= 9) {
		hrs = "0" + hrs;
	}
	if(sec <= 9) {
		sec = "0" + sec;
	}
	document.getElementById('Timer').innerHTML=date.getDate() + " " + monthMap[date.getMonth()] + " " + date.getFullYear() + ", "+ hrs+" : "+ min + " : "+sec;
	if(uTimer)
	{
		clearTimeout(uTimer);
	}
	uTimer = setTimeout('updateClock()', 1000);
}

if(parent["TimeSet"] == null) {
	time = 0;
	var rTimer,uTimer;
	var monthMap = new Object();
	parent["TimeSet"] = "true";
}

function displayClock(curTime) {
	time = curTime;
	monthMap["0"] = "Jan";
	monthMap["1"] = "Feb";
	monthMap["2"] = "Mar";
	monthMap["3"] = "Apr";
	monthMap["4"] = "May";
	monthMap["5"] = "Jun";
	monthMap["6"] = "Jul";
	monthMap["7"] = "Aug";
	monthMap["8"] = "Sep";
	monthMap["9"] = "Oct";
	monthMap["10"] = "Nov";
	monthMap["11"] = "Dec";
	TimeTick();
	updateClock();
}

// Methods for Keep me signed in. Moved from Header.jspf file
// Start
function signedIn()
{
	var sso = null;
	sso = getCookie("singlesignon");
	if(sso!=null)
	{
		var expDate = new Date();
		expDate.setTime(expDate.getTime()+(24*60*60*1000*365));
		var sin="true";
		document.cookie="signedin= "+ sin +";expires= "+((expDate).toGMTString());
	}
}

function preLogout(ssostatus)
{
	deleteCookie("singlesignon");
	deleteCookie("username");
	deleteCookie("password");
	deleteCookie("signedin");
	if( ssostatus == 'true' )
	{
		window.location="jsp/Logout.jsp?ssostatus=true";
	}
	else
	{
		window.location="jsp/Logout.jsp";
	}
}
// End

//Method for converting the long date value to time in seconds.
//start

function reminderDateCheck(formObj)
{
	var date1Value = formObj.date1.value;
	var time1Value = formObj.time1.value;
	var date2Value = formObj.date2.value;

	if(date1Value != "")
	{
		var dt = new Date();
		var tmp = date1Value.split("-");
		var tmp1 = time1Value.split(" ");
		var tmp2 = tmp1[0].split(":");
		dt.setYear(tmp[0]);
		dt.setMonth(tmp[1]-1);
		dt.setDate(tmp[2]);
		dt.setHours(tmp2[0]);
		dt.setMinutes(tmp2[1]);
		dt.setSeconds(0);
		dt.getTime();
		if( dt.getTime() < serverdt.getTime()){
			alert(getMessageForKey("sdp.reminder.currenttimeerr"));
			return false;
		}
		if(date2Value != "0"){
			var datedt = dt.getTime() - date2Value;
			if( datedt < serverdt.getTime()){
				alert(getMessageForKey("sdp.reminder.remtimeerr"));
				return false;
			}
		}
	}
	return true;
}
//End

function showCABForm() {
	window.frames['CAB_FRAME'].location.href = "/setup/CABDefForm.jsp?";
}


function submitGlobalViewForm(formObj) {
	var selObj = formObj.VIEW;
	var count = _viewObjects.length;
	for(var i = 0; i < count; i++){
		var curObj = _viewObjects[i];
		if(curObj[2] == 'true'){
			selObj.options[selObj.options.length] = new Option(curObj[0], curObj[0], true, false);
			selObj.options[selObj.options.length - 1].selected = true;
		}
	}
	formObj.submit();
}

function ShowAndHide(divId1,divId2,divId3,divId4,divId5)
{
	var id1 = document.getElementById(divId1);
	var id2 = document.getElementById(divId2);
	var id3 = document.getElementById(divId3);
	var id4 = document.getElementById(divId4);
	var id5 = document.getElementById(divId5);
	createCookie(divId1, 'show', 30);
	createCookie(divId2, 'hide', 30);
	createCookie(divId3, 'hide', 30);
	createCookie(divId4, 'hide', 30);
	createCookie(divId5, 'hide', 30);
	eval("id1.style.display = 'block';");
	eval("id2.style.display = 'none';");
	eval("id3.style.display = 'none';");
	eval("id4.style.display = 'none';");
	eval("id5.style.display = 'none';");
	eval("id1.style.height='150px';");
	eval("id1.style.overflow='auto';");
}

function ShowAndHideBasedOnCookie(divId1,divId2,divId3,divId4,divId5)
{
	var id1 = document.getElementById(divId1);
	var id2 = document.getElementById(divId2);
	var id3 = document.getElementById(divId3);
	var id4 = document.getElementById(divId4);
	var id5 = document.getElementById(divId5);

	createCookie(divId1, 'show', 30);
	createCookie(divId2, 'hide', 30);
	createCookie(divId3, 'hide', 30);
	createCookie(divId4, 'hide', 30);
	createCookie(divId5, 'hide', 30);
	eval("id1.style.display = 'block';");
	eval("id2.style.display = 'none';");
	eval("id3.style.display = 'none';");
	eval("id4.style.display = 'none';");
	eval("id5.style.display = 'none';");
	eval("id1.style.height='130px';");
	eval("id1.style.overflow='auto';");
}

function Hide(divId)
{
	var id = document.getElementById(divId);
	createCookie(id, 'hide', 30);
	eval("id.style.display = 'none';");
}


function Show(divId)
{
	var id = document.getElementById(divId);
	createCookie(id, 'show', 30);
	eval("id.style.display = 'block';");
}


startList = function()
{
	if (document.all&&document.getElementById) {
		var ulelems = document.getElementsByTagName("ul");
		for(var k=0; k<ulelems.length; k++) {
			if(ulelems[k].id == 'nav') {
				navRoot = ulelems[k];
				for (i=0; i<navRoot.childNodes.length; i++) {
					node = navRoot.childNodes[i];
					if (node.nodeName=="LI") {
						node.onmouseover=function() {
							this.className+=" over";
						}
						node.onmouseout=function() {
							this.className=this.className.replace(" over", "");
						}
					}
				}
			}
		}
	}
}

function showMenuAsDialog(holder, source) {
	var reqX = findPosX(document.getElementById(holder));
	var reqY = findPosY(document.getElementById(holder));
	var offsetWidth = document.getElementById(holder).offsetHeight
    showDialog(document.getElementById(source).innerHTML,'position=absolute,closeButton=no,closeOnBodyClick=yes,srcElement=CreateNew_PH,left=' + (reqX-document.body.scrollLeft) + ',top=' + (reqY+ offsetWidth-document.body.scrollTop));
}

function showMenuAsDialogForQuickLink(holder, source) {
	document.onmousemove = capturePosForQuickLink;

	var reqX = findPosX(document.getElementById(holder))-540;
	var reqY = findPosY(document.getElementById(holder))+12;
	var offsetWidth = document.getElementById(holder).offsetHeight;
	showDialog(document.getElementById(source).innerHTML,'position=absolute,closeButton=no,srcElement=CreateNew_PH,left=' + (reqX-document.body.scrollLeft) + ',top=' + (reqY+ offsetWidth-document.body.scrollTop));
	setTimeout("closeMenusDialogForQuickLink('" + source + "')", 1000);
}



var xpositionForQuickLink,ypositionForQuickLink;

function capturePosForQuickLink(eForQuickLink) {
    if (window.ActiveXObject)
    {
        xpositionForQuickLink = window.event.clientX;
        ypositionForQuickLink = window.event.clientY;
    }
    else
    {
        xpositionForQuickLink = eForQuickLink.pageX;
        ypositionForQuickLink = eForQuickLink.pageY;
    }
}


function closeMenusDialogForQuickLink(source)
{
	var dialogElement = document.getElementById("_DIALOG_LAYER");

	var reqX = findPosX(dialogElement) + 305;
	var reqY = findPosY(dialogElement) - 20;
	var offsetHeight = dialogElement.offsetHeight - 10 ;
	var offsetWidth = dialogElement.offsetWidth - 325 ;

	if (window.ActiveXObject) { }

	var reqEndX = reqX + offsetWidth;
	var reqEndY = reqY + offsetHeight;

	if(xpositionForQuickLink < reqEndX && xpositionForQuickLink > reqX && ypositionForQuickLink < reqEndY && ypositionForQuickLink > (reqY-20)) {
		setTimeout("closeMenusDialogForQuickLink('" + source + "')", 1000);
	}
	else {
		closeDialog();
	}

}

function handleSoftware(source,destination,operation,direction)
{
	var len = source.length;
	var isSelected = false;

	for (i=0; i<len; i++) {
		opt = source.options[i];
		if (opt.selected) {
			isSelected = true;
		}
	}

	if (! isSelected) {
		alert("Kindly select an option to move");
		return false;
	}
	if (operation == 'update') {
		updateLists(source,destination);
	}
	else {
		moveUp(source);
	}

	var destlen = document.ProductDefForm.associatedSoftwareList.length;

	for (j=0;j<destlen; j++)
	{
		opt = document.ProductDefForm.associatedSoftwareList.options[j];
		if (j == 0)
		{
			opt.className = 'optparent';
			var val = opt.innerHTML;
			if (val.indexOf("&nbsp;") != -1)
			{
				opt.innerHTML = val.substring(18,val.length);
			}
		}
		else
		{
			opt.className = 'optchild';
			var val = opt.innerHTML;
			if (val.indexOf("&nbsp;") == -1)
			{
				opt.innerHTML = '&nbsp;&nbsp;&nbsp;' + opt.innerHTML;
			}
		}
	}

	var manSWLen = document.ProductDefForm.softwareList.length;
	if (direction == '2to1')
	{
		for (k=0;k<manSWLen;k++)
		{
			opt = document.ProductDefForm.softwareList.options[k];
			opt.className = 'optchild';
			value = opt.innerHTML;
			if (value.indexOf("&nbsp;") != -1) {
				value = value.substring(18,value.length);
			}
			opt.innerHTML = value;
		}
	}
	return true;
}

function chooseParent(source)
{
	var len = source.length;
	var isSelected = false;
	var count = 0;
	var selectVal;

	for (i=0; i<len; i++)
	{
		opt = source.options[i];
		if (opt.selected)
		{
			selectVal = i;
			isSelected = true;
			count = ++count;
		}
	}

	if(!isSelected) {
		alert('Kindly select a Parent software');
	}
	else if(count > 1) {
		alert('Please select one Parent software');
	}
	else {
		for(i=selectVal; i>0; i--) {
			moveUp(source);
		}
	}

	var destlen = source.length;

	for (j=0;j<destlen; j++)
	{
		opt = source.options[j];
		if (j == 0)
		{
			opt.className = 'optparent';
			var val = opt.innerHTML;
			if (val.indexOf("&nbsp;") != -1) {
				opt.innerHTML = val.substring(18,val.length);
			}
		}
		else
		{
			opt.className = 'optchild';
			var val = opt.innerHTML;
			if (val.indexOf("&nbsp;") == -1) {
				opt.innerHTML = '&nbsp;&nbsp;&nbsp;' + opt.innerHTML;
			}
		}
	}
}

function PNGConvertor(){
	var strGif = "/images/transparentpixel.gif"
    var strFilter = "progid:DXImageTransform.Microsoft.AlphaImageLoader";
	var arVersion = navigator.appVersion.split("MSIE");
	var version = parseFloat(arVersion[1]);

	if ((version >= 5.5) && (document.body.filters))
	{
		for(var i=0; i<document.images.length; i++)
		{
			var img = document.images[i];
			var imgName = img.src.toUpperCase();

			if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
			{
				var strNewHTML = "<img style= \" position:relative; height:" + img.height + "px; width: " + img.width + "px; filter:" + strFilter + "(src=\'" + img.src + "\', sizingMethod=\'image\');\" src=\"" + strGif + "\"  usemap=\"" + img.useMap + "\" border=\"" + img.border + "\">  </img>";
				img.outerHTML = strNewHTML;
				i = i-1;
			}
		}
	}
}


function historyShowhideAsset(prefix,gName)
{
	var selRowObj = document.getElementById(prefix+ "HIST_" + gName);
	var text = document.getElementById(prefix + "HT_" + gName);
	if (selRowObj.className == 'hide')
	{
		selRowObj.className = 'show';
		text.innerHTML = "<img src='\\images\\threadcollapse.gif'>";
	}
	else if(selRowObj.className == 'show')
	{
		selRowObj.className = 'hide';
		text.innerHTML = "<img src='\\images\\threadexpand.gif'>";
	}
	else if(selRowObj.className == '')
	{
		selRowObj.className = 'show';
		text.innerHTML = "<img src='\\images\\threadcollapse.gif'>";
	}
}

function showLeftNav(state) {
	var url="/jsp/getLeftNav.jsp?LeftNav=" + state;
	stateChanged(state);
	if(parent["toBeShown"] != null) {
		parent.checkAndLoadTypes();
	}
	window.open(url, "SDPHeaderFrame");
}

function stateChanged(status) {
	if(status == 'Open') {
		document.getElementById('LeftOpen').style.display = 'none';
		document.getElementById('Left-Section').style.display = 'block';
	}
	else {
		document.getElementById('Left-Section').style.display = 'none';
		document.getElementById('LeftOpen').style.display = 'block';
	}
}

/* This function will call SelectWOAssetView in a new window
 * adding the username parameter from the document
 * the user parameter can be userID or userName (will be taken care of in the server)
 * the user parameter will be null when called from the new/edit workorder page
 * the user parameter has to be provided when called from workorder details page
 */
function showWOAssets(user)
{
    if(user == null) {
        // if no user is provided, we will try to fetch it from the page (in case new workorder and esit workorder pages)
        var requester = $('reqSearch');
        //console.debug("reqSearch",requester);
        if(requester != null)   user = requester.value;
    }
    //console.debug("user",user);
    if(user != null && user != "") {
        //alert('/workorder/SelectWOAsset.jsp?user='+user+'&');
        NewWindow('/SelectWOAssetView.cc?command=userasset&itemId='+user+'&','SelectWOAsset','500','500','yes','center');
    }
    else {
        //alert('Please enter the Requester name before selecting assets');
        NewWindow('/SelectWOAssetView.cc?command=assettype&itemId=0&','SelectWOAsset','500','500','yes','center');
    }
}

/**
 * This function will take the error object and display it in a useful manner depending upon the browser, to the user
 * It can also take an optional function name to display in which function it was called (error happened)
 * It also takes custom message as an optional third parameter
 */
function showError(errorObject, funcName, userMessage)
{
    var msg = "";

    if(errorObject == null || errorObject.name == null) {
        // no error object supplied
        if(funcName != null) {
            msg += "UnSpecified Error occured in function "+funcName;
            if(userMessage != null) {
                msg += "\nMessage: "+userMessage;
            }
        }
        else {
            msg += "UnSpecified Error occured ";
        }
        alert(msg);
        return;
    }

    if(funcName != null) {
        msg += "Error in function "+funcName+"\n";
    }

    if(is_gecko) {
        msg += errorObject.name+" [Line:"+errorObject.lineNumber+"]: "+errorObject.message;
        /* if(showStack != null && showStack == true) {
            msg += "\n Stack Trace: "+errorObject.stack;
        } */
    }
    else if(is_ie) {
        msg += errorObject.name+": "+errorObject.message;     //" ErrNo: "+errorObject.number+
    }
    else {
        msg += errorObject.name+": "+errorObject.message;
    }

    if(userMessage != null) {
        msg += "\nMessage: "+userMessage;
    }

    // TODO: a dialog element can be displayed instead of an alert
    alert(msg);
}

/**
 * This function will show a tooltip next to the element whose element has been passed.
 */
function showToolTip(toolTipText, elementID)
{
  //var tooltip =  "<div id=\"msg"+elementID+"\" style=\"position: absolute; left: 333px; top: 389px; opacity: 0.985062;\"><table cellspacing=\"0\" class=\"completeMessage\"><tbody><tr><td class=\"caTopLeft\"/><td colspan=\"2\" class=\"caTopCenter\"/><td class=\"caTopRight\"/></tr><tr><td class=\"caMiddleLeft\"/><td class=\"caMessage\"> "+toolTipText+" </td><td class=\"caClose\"><button id=\"normalbubbletooltip_close\" class=\"caCloseButton\"/></td><td class=\"caMiddleRight\"/></tr><tr><td class=\"caBottomLeft\"/><td colspan=\"2\" class=\"caBottomCenter\"></td><td class=\"caBottomRight\"/></tr></tbody></table></div>";
  //showDialog(tooltip, 'position=relative, closeButton=no, closeOnEscKey=yes, width=250, srcElement='+elementID);

  invokeProgressIndicator(elementID, toolTipText, 'completed', 'no', 'no');
}


// Used in Header.jspf
function getSDPQuote() {
	window.open("http://www.manageengine.com/products/service-desk/get-quote.html", "GetQuote");
}

// Used in Req Quick Create
function loadScript(url) {
	if (document.layers) {
		window.location.href = url;
	}
	else if (document.getElementById) {
		var script = document.createElement('script');
		script.defer = true;
		script.src = url;
		document.getElementsByTagName('head')[0].appendChild(script);
	}
}

function createMCSearchRow(referenceId, uniqueId) {
	var mainRowTr = document.getElementById(referenceId + "_MainRow");
	var mainRowTds = mainRowTr.getElementsByTagName("th");
	var mainLastCell = mainRowTds[mainRowTds.length - 1];

	var searchRowTr = document.getElementById(referenceId + "_SearchRow");
	if(searchRowTr != null) {
		var searchRowTds = searchRowTr.getElementsByTagName("th");
		var searchLastCell = searchRowTds[searchRowTds.length - 1];

		var doc = document.getElementById("ACT_BTN_" + uniqueId);
		var elements = doc.getElementsByTagName("div");
		var mainCellData  = "<table width='100%' valign='top' cellspacing=0 cellpadding=0><tr><td nowrap>" + mainLastCell.innerHTML + "</td>";
		for(var i=0; i< elements.length; i++) {
			if(elements[i].id == "Div1") {
				searchLastCell.innerHTML = "<table width='100%'><tr><td width='90%'>" + searchLastCell.innerHTML + "</td><td align='right'>" + elements[i].innerHTML + "</td></tr></table>";
			}
			else {
				mainCellData = mainCellData + "<td align='right' valign='top' width='5px' nowrap>" + elements[i].innerHTML + "</td>";
			}
		}
		mainLastCell.innerHTML = mainCellData + "</tr></table>"
	}
}

function loadMCNavigator(uniqueId) {
	if(parent.document.getElementById(uniqueId + '_NAV') == null){
		document.getElementById(uniqueId + '_NAV').innerHTML = document.getElementById(uniqueId + '_Navig').innerHTML;
	}
	else {
		parent.document.getElementById(uniqueId + '_NAV').innerHTML = document.getElementById(uniqueId + '_Navig').innerHTML;
	}
}
