/* $Id: common.js,v 1.43.2.2.2.3 2010/10/04 09:17:44 sivanand Exp $ */

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") {
			id.style.display = 'block'; //No I18N
		}
		var id1 = document.getElementById('assignQueue');
		if (id1.style.display == "block") {
			id1.style.display = 'none'; //No I18N
		}
	}
	else if(document.WorkOrderForm.assignTo.value == 'Queue') {
		var id = document.getElementById('assignTech');
		if (id.style.display == "block") {
			id.style.display = 'none'; //No I18N
		}
		var id1 = document.getElementById('assignQueue');
		if (id1.style.display == "none") {
			id1.style.display = 'block'; //No I18N
		}
	}
	else if(document.WorkOrderForm.assignTo.value == 'None') {
		var id = document.getElementById('assignTech');
		if (id.style.display == "block") {
			id.style.display = 'none'; //No I18N
		}
		var id1 = document.getElementById('assignQueue');
		if (id1.style.display == "block") {
			id1.style.display = 'none'; //No I18N
		}
	}
}

var oPrevElement;

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"){
		mid.style.display = 'block'; //No I18N

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

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

function Hide(divId) {
	var id = document.getElementById(divId);
    if(!id) { return false; }
	createCookie(id, 'hide', 30); //No I18N
	id.style.display = 'none'; //No I18N
}

function Show(divId) {
    var id = document.getElementById(divId);
	if(!id) { return false; }
	createCookie(id, 'show', 30); //No I18N
	id.style.display = 'block'; //No I18N
}

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); //No I18N
	createCookie(divId2, 'hide', 30); //No I18N
	createCookie(divId3, 'hide', 30); //No I18N
	createCookie(divId4, 'hide', 30); //No I18N
	createCookie(divId5, 'hide', 30); //No I18N
	id1.style.display = 'block'; //No I18N
	id2.style.display = 'none'; //No I18N
	id3.style.display = 'none'; //No I18N
	id4.style.display = 'none'; //No I18N
	id5.style.display = 'none'; //No I18N
	id1.style.height='150px'; //No I18N
	id1.style.overflow='auto'; //No I18N
}

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); //No I18N
	createCookie(divId2, 'hide', 30); //No I18N
	createCookie(divId3, 'hide', 30); //No I18N
	createCookie(divId4, 'hide', 30); //No I18N
	createCookie(divId5, 'hide', 30); //No I18N
	id1.style.display = 'block'; //No I18N
	id2.style.display = 'none'; //No I18N
	id3.style.display = 'none'; //No I18N
	id4.style.display = 'none'; //No I18N
	id5.style.display = 'none'; //No I18N
	id1.style.height='130px'; //No I18N
	id1.style.overflow='auto'; //No I18N
}

function ShowProductTab(divIdToShow) {
	var idToShow = document.getElementById(divIdToShow);
	if(divIdToShow=="productDetails") {
		var idToHide = document.getElementById("associatedVendors");
		if(idToHide != null) {
			idToHide.style.display = 'none'; //No I18N
		}
	}
	else if(divIdToShow=="associatedVendors") {
		var idToHide = document.getElementById("productDetails");
		if(idToHide != null) {
			idToHide.style.display = 'none'; //No I18N
		}
	}
	else if(divIdToShow=="vendorDetails") {
		var idToHide = document.getElementById("associatedProducts");
		if(idToHide != null) {
			idToHide.style.display = 'none'; //No I18N
		}
	}
	else if(divIdToShow=="associatedProducts") {
		var idToHide = document.getElementById("vendorDetails");
		if(idToHide != null) {
			idToHide.style.display = 'none'; //No I18N
		}
	}
	if(idToShow != null) {
		idToShow.style.display = 'block'; //No I18N
	}
}

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(); //No I18N
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var ca = document.cookie.split(';'); //No I18N
	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) {
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		// We are trying to find the document in this case. We send id's only as the first argument. So this check need not be done. Hence commenting
//		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 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]; //No I18N
	var temp2 = document.getElementsByName("loggedUserID")[0]; //No I18N
	if(temp1 != null && temp2 != null) {
		var module = document.getElementsByName("tabName")[0].value; //No I18N
		var userID = document.getElementsByName("loggedUserID")[0].value; //No I18N
		for(var i=0;i<e.length;i++) {
			if(e[i].id!=null) {
				var bulletObj=MM_findObj("bullet"+e[i].id); //No I18N
				if(readCookie(userID+module+e[i].id)==e[i].id+"show" ) {
					e[i].style.display = 'block'; //No I18N
					if(bulletObj != null) {
						bulletObj.src="/images/spacer.gif"; //No I18N
						bulletObj.className="actionitems_expand"; //No I18N
					}
				}
				if(readCookie(userID+module+e[i].id)==e[i].id+"hide" ) {
					e[i].style.display = 'none'; //No I18N
					if(bulletObj != null) {
						bulletObj.src="/images/spacer.gif"; //No I18N
						bulletObj.className="actionitems_collapse"; //No I18N
					}
				}
			}
		}
	}
}

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

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

function toggleSwipe(gName) {

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

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

function swapLayer(showDiv,HideDiv) {
	var showdiv = document.getElementById(showDiv);
	var hidediv = document.getElementById(HideDiv);
	if(showdiv != null) {
		showdiv.style.display = 'block'; //No I18N
	}
	if(hidediv != null) {
		hidediv.style.display = 'none'; //No I18N
	}
}

function onClickSwapLayer(showDiv,HideDiv,swap) {
	if(swap==null || swap==true)
	{
	swapLayer(showDiv,HideDiv);
	}
	var id1 = document.getElementById("success_message");
	if(id1!=null) {
		id1.style.display = 'none'; //No I18N
	}
	var id2 = document.getElementById("error_message");
	if(id2!=null) {
		id2.style.display = 'none'; //No I18N
	}
}

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

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

function checkForUDFNumeric() {
	var num5,num6,num7,num8;
	from =document.getElementsByName("FROM")[0]; //No I18N
	var fromModule = document.getElementById("fromModule");
	if((from!=null && from.value=='INLINE') || (fromModule != null && fromModule.value == "TECH")) {
		num1 = document.getElementsByName("UDF_LONG1")[0]; //No I18N
		num2 = document.getElementsByName("UDF_LONG2")[0]; //No I18N
		num3 = document.getElementsByName("UDF_LONG3")[0]; //No I18N
		num4 = document.getElementsByName("UDF_LONG4")[0]; //No I18N
		num5 = document.getElementsByName("UDF_LONG5")[0]; //No I18N
		num6 = document.getElementsByName("UDF_LONG6")[0]; //No I18N
		num7 = document.getElementsByName("UDF_LONG7")[0]; //No I18N
		num8 = document.getElementsByName("UDF_LONG8")[0]; //No I18N
	}
	else {
		num1 = document.getElementsByName("udfName1")[0]; //No I18N
		num2 = document.getElementsByName("udfName2")[0]; //No I18N
		num3 = document.getElementsByName("udfName11")[0]; //No I18N
		num4 = document.getElementsByName("udfName12")[0]; //No I18N
	}
	if(num1!=null && num1.value!=null && num1.value!='') {
		trimAll(num1);
		if(!checklong(num1)) {
			num1.focus();
			return false;
		}
	}
	if(num2!=null && num2.value!=null && num2.value!='') {
		trimAll(num2);
		if(!checklong(num2)) {
			num2.focus();
			return false;
		}
	}
	if(num3!=null && num3.value!=null && num3.value!='') {
		trimAll(num3);
		if(!checklong(num3)) {
			num3.focus();
			return false;
		}
	}
	if(num4!=null && num4.value!=null && num4.value!='') {
		trimAll(num4);
		if(!checklong(num4)) {
			num4.focus();
			return false;
		}
	}
	if(num5!=null && num5.value!=null && num5.value!='') {
		trimAll(num5);
		if(!checklong(num5)) {
			num5.focus();
			return false;
		}
	}
	if(num6!=null && num6.value!=null && num6.value!='') {
		trimAll(num6);
		if(!checklong(num6)) {
			num6.focus();
			return false;
		}
	}
	if(num7!=null && num7.value!=null && num7.value!='') {
		trimAll(num7);
		if(!checklong(num7)) {
			num7.focus();
			return false;
		}
	}
	if(num8!=null && num8.value!=null && num8.value!='') {
		trimAll(num8);
		if(!checklong(num8)) {
			num8.focus();
			return false;
		}
	}
	return true;
}
function checkForAssetUDFNumeric()
{
	from =document.getElementsByName("FROM")[0]; //No I18N
	if(from!=null && from.value=='INLINE')
	{
		num1 = trimAll(document.getElementsByName("assetUDF_LONG1")[0]); //No I18N
		num2 = trimAll(document.getElementsByName("assetUDF_LONG2")[0]); //No I18N
		num3 = trimAll(document.getElementsByName("assetUDF_LONG3")[0]); //No I18N
		num4 = trimAll(document.getElementsByName("assetUDF_LONG4")[0]); //No I18N
	}
	else
	{
		num1 = document.getElementsByName("assetudfName1")[0]; //No I18N
		num2 = document.getElementsByName("assetudfName2")[0]; //No I18N
		num3 = document.getElementsByName("assetudfName11")[0]; //No I18N
		num4 = document.getElementsByName("assetudfName12")[0]; //No I18N
	}
	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) {
	return isIpAddress(ip);
}

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

function notOperatedForLinux()
{
	alert(getMessageForKey("sdp.admin.setup.ad.notsupported"));
}

function disableForDemo() {
	alert("This feature is disabled for the Online Demo"); //No I18N
	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); //No I18N
	if (selRowObj.style.display == 'none') {
        selRowObj.className = 'show'; //No I18N
		selRowObj.style.display = 'block'; //No I18N
		bulletObj.src="/images/threadcollapse.gif"; //No I18N
	}
	else if(selRowObj.style.display == 'block') {
        selRowObj.className = 'hide'; //No I18N
		selRowObj.style.display = 'none'; //No I18N
		bulletObj.src="/images/threadexpand.gif"; //No I18N
	}
	else if(selRowObj.style.display == '') {
        selRowObj.className = 'show'; //No I18N
		selRowObj.style.display = 'block'; //No I18N
		bulletObj.src="/images/threadcollapse.gif"; //No I18N
	}
}

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

function addIt(picklist,tf) {
	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').innerHTML);
	}
}

function removeFromList(listField) {
	// The checks specified for both the alerts will not at all be satisfied
	if ( listField.length == -1) {  // If the list is empty
		alert(document.getElementById('nopicklist').innerHTML);
	} else {
		var selected = listField.selectedIndex;
		if (selected == -1) {
			alert(document.getElementById('choosepicklist').innerHTML);
		} 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);

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

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'); //No I18N
				}
				else {
					selectArow("row"+ e , 'rowoddn'); //No I18N
				}
			}
			else {
				if (toSelectAll) {
					selectArow("row"+e, 'rowHiliteb'); //No I18N
				}
				else {
					selectArow("row"+e, 'rowevenn'); //No I18N
				}
			}
			count = count + 1;
		}
	}
}

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

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

function setSearchTitle(title, val) {
	title=title.replace(/&#39;/g,"'"); //No I18N
	val=val.replace(/&#39;/g,"'"); //No I18N
	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 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(getMessageForKey("sdp.inventory.software.chooseParent"));
	}
	else if(count > 1) {
		alert(getMessageForKey("sdp.inventory.software.chooseOneParent"));
	}
	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'; //No I18N
			var val = opt.innerHTML;
			if (val.indexOf("&nbsp;") != -1) {
				opt.innerHTML = val.substring(18,val.length);
			}
		}
		else {
			opt.className = 'optchild'; //No I18N
			var val = opt.innerHTML;
			if (val.indexOf("&nbsp;") == -1) {
				opt.innerHTML = '&nbsp;&nbsp;&nbsp;' + opt.innerHTML; //No I18N
			}
		}
	}
}

function PNGConvertor(){
	var strGif = "/images/transparentpixel.gif" //No I18N
	var strFilter = "progid:DXImageTransform.Microsoft.AlphaImageLoader" //No I18N
	var arVersion = navigator.appVersion.split("MSIE") //No I18N
	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") {
			//Here the img height and width is hotcoded because it is causing the problem in IE..pratheepv
                        var strNewHTML = "<img style= \" position:relative; height: 166 px; width: 360 px; filter:" + strFilter + "(src=\'" + img.src + "\', sizingMethod=\'image\');\" src=\"" + strGif + "\"  usemap=\"" + img.useMap + "\" border=\"" + img.border + "\">  </img>";
                img.outerHTML = strNewHTML;
		   		i = i-1;
	   		}
		}
	}
}

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

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

/**
* 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,x,y) {
	var reqType = 'progress'; //No I18N
	var image = '/images/processing.gif'; //No I18N
	var cssClass = 'shadow_tip'; //No I18N
	if(type != null && type == "completed") {
		reqType = 'completed'; //No I18N
		image = '/images/processing_done.gif'; //No I18N
	}
	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'; //No I18N
	}
	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/spacer.gif' class='exit1' 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;
		if(y!=null){finalY=y;}
		var finalX = posX - 35;
		if(x!=null){finalX=x;}
		showDialog(outerTable,"position=absolute,closeButton=no,width=250,left=" + finalX + ",top=" + finalY); //No I18N
	}
	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.
	if(document.getElementById('OperationStatus') && key!=null){
		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");
	}
    if(document.getElementById('OperationStatus')) {
        document.getElementById('OperationStatus').innerHTML = getMessageForKey(key);
        if(result) {
            document.getElementById('ProImage').src = "/images/processing_done.gif"; //No I18N
            setTimeout("parent.closeDialog();",1000); //No I18N
        }
        else {
            document.getElementById('ProImage').src = "/images/invalidoperationicon.gif"; //No I18N
        }
    }
}

function showSuccessMessageAndClose( source, value, timeout){
	invokeProgressIndicator(source,value,"completed"); //No I18N
	if(timeout == null) {
		setTimeout("closeDialog();", 2000); //No I18N
	}
	else {
		setTimeout("closeDialog();", timeout); //No I18N
	}
}

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

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

function showProgressAndClose(value, timeout){
	invokeProgressIndicator(null,value,"processing"); //No I18N
	if(timeout == null) {
		setTimeout("closeDialog();", 2000); //No I18N
	}
	else {
		setTimeout("closeDialog();", timeout); //No I18N
	}
}

var attachForm = null;
function constructAttachInfo(formobj) {
	attachForm = formobj;
	var attach = formobj.attach.options;
	var attSize = formobj.attSize.options;
	var description = formobj.att_desc.options;
	var showDesc = parent["Show_Att_Desc"]; //No I18N
	if(showDesc == null) {
		showDesc = true;
	}
	var content = "<br><table cellspacing='1' width='100%' cellpadding='4' border='0' bgcolor='#cccccc' id='AttDet'><tr class='bluebg' style='color:#000000;'><td>" + getMessageForKey("sdp.common.file") + "</td>";
	if(showDesc) {
		content = content.concat("<td>" + getMessageForKey("sdp.common.desc") + "</td>"); //No I18N
	}
	content = content.concat("<td width='75px'>" + getMessageForKey("sdp.common.attachment.size") + "</td><td width='30px'>&nbsp;</td></tr>");
	var spanObj = document.getElementsByTagName("span");
	for(var cnt = 0; cnt < spanObj.length; cnt++) {
		var spanId = spanObj[cnt].id;
		if(spanId != null && spanId.indexOf("ATT_ID") >= 0) {
			if(spanObj[cnt].getAttribute("isdeleted") == "false") {
				fs = parseInt(spanObj[cnt].getAttribute("attsize"));
				var suf = "B"; //No I18N
				if(fs > 1024) {
					fs = parseInt(fs / 1024);
					suf = "KB"; //No I18N
				}
				if(fs > 1024) {
					fs = parseInt(fs / 1024);
					suf = "MB"; //No I18N
				}
				content = content.concat("<tr id='whitebg'><td style=\"background: rgb(255, 255, 255) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;\" bgcolor=\"#ffffff\">" + spanObj[cnt].getAttribute("attname") + "</td>");
				if(showDesc) {
					content = content.concat("<td style=\"background: rgb(255, 255, 255) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;\" bgcolor=\"#ffffff\">" + spanObj[cnt].innerHTML + "</td>");
				}
				content = content.concat("<td style=\"background: rgb(255, 255, 255) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;\" bgcolor=\"#ffffff\">" + fs + " " + suf + "</td><td style=\"background: rgb(255, 255, 255) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;\" bgcolor=\"#ffffff\"><a href='javascript:void(0)' onClick='deleteFile(" + spanObj[cnt].getAttribute("attid") +  ", \"Existing\")'><img src='/images/deleteicon.gif' border='0'></a></td></tr>");
			}
		}
	}

	for(var cnt = 0; cnt < formobj.attSize.options.length; cnt++) {
		var fs = formobj.attSize.options[cnt].value;
		var suf = "B"; //No I18N
		if(fs > 1024) {
			fs = parseInt(fs / 1024);
			suf = "KB"; //No I18N
		}
		if(fs > 1024) {
			fs = parseInt(fs / 1024);
			suf = "MB";//No I18N
		}
		if(formobj.attach.options[cnt].value != "") {
			content = content.concat("<tr id='whitebg'><td style=\"background: rgb(255, 255, 255) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;\" bgcolor=\"#ffffff\">" + formobj.attach.options[cnt].value + "</td>");
			if(showDesc) {
				content = content.concat("<td style=\"background: rgb(255, 255, 255) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;\" bgcolor=\"#ffffff\">" + checkNullValue(formobj,cnt) + "</td>");
			}
			content = content.concat("<td style=\"background: rgb(255, 255, 255) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;\" bgcolor=\"#ffffff\">" + fs + " " + suf + "</td><td style=\"background: rgb(255, 255, 255) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;\" bgcolor=\"#ffffff\"><a href='javascript:void(0)' onClick='deleteFile(" + cnt + ")'><img src='/images/deleteicon.gif' border='0'></a></td></tr>");
		}
	}
	content = content.concat("</table>");
	document.getElementById("displayAttachments").innerHTML = content;
}

function checkNullValue(formobj, cnt) {
	if( formobj.att_desc.options.length > 0 ) {
		return formobj.att_desc.options[cnt].value;
	}
	return "";
}

function deleteFile(fileIndex, existing) {
	if( document.getElementById("deletealert") != null ) {
		if(confirm(document.getElementById("deletealert").innerHTML)) {
			if(existing == null ) {
				attachForm.attach.options[fileIndex] = null;
				attachForm.attPath.options[fileIndex] = null;
				attachForm.attSize.options[fileIndex] = null;
				attachForm.att_desc.options[fileIndex] = null;
			}
			else {
				document.getElementById("ATT_ID_" + fileIndex).setAttribute("isdeleted", true); //No I18N
				attachForm.toBeDeleted.options[attachForm.toBeDeleted.options.length] = new Option(fileIndex, fileIndex, true, false);
				attachForm.toBeDeleted.options[attachForm.toBeDeleted.options.length-1].selected = true;
			}
			constructAttachInfo(attachForm);
		}
	}
	else {
		if(existing == null ) {
			attachForm.attach.options[fileIndex] = null;
			attachForm.attPath.options[fileIndex] = null;
			attachForm.attSize.options[fileIndex] = null;
			attachForm.att_desc.options[fileIndex] = null;
		}
		else {
			document.getElementById("ATT_ID_" + fileIndex).setAttribute("isdeleted", true); //No I18N
			attachForm.toBeDeleted.options[attachForm.toBeDeleted.options.length] = new Option(fileIndex, fileIndex, true, false);
			attachForm.toBeDeleted.options[attachForm.toBeDeleted.options.length-1].selected = true;
		}
		constructAttachInfo(attachForm);
	}
}

function invokeFileAttachment(module) {
	var url = "/common/FileAttachment.jsp?type=new&module="+module; //No I18N
	showURLInDialog(url + "&" + (new Date()).getTime(), "closeButton=no,position=relative"); //No I18N
}

function createMCSearchRow(referenceId, uniqueId) {
	var mainRowTr = document.getElementById(referenceId + "_MainRow");
	// null check added because in some places these methods can be called without the main view being invoked.
	if(mainRowTr != null) {
		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, rowCount) {
	// null check added because in some places these methods can be called without the main view being invoked.
	if(document.getElementById(uniqueId + '_Navig') != null) {
		if(parent.document.getElementById(uniqueId + '_NAV') == null){
			document.getElementById(uniqueId + '_NAV').innerHTML = document.getElementById(uniqueId + '_Navig').innerHTML;
			if(document.getElementById(uniqueId + '_NAV_BOT') != null) {
				document.getElementById(uniqueId + '_NAV_BOT').innerHTML = document.getElementById(uniqueId + '_Navig').innerHTML;
			}
		}
		else {
			parent.document.getElementById(uniqueId + '_NAV').innerHTML = document.getElementById(uniqueId + '_Navig').innerHTML;
			if(parent.document.getElementById(uniqueId + '_NAV_BOT') != null) {
				parent.document.getElementById(uniqueId + '_NAV_BOT').innerHTML = document.getElementById(uniqueId + '_Navig').innerHTML;
			}
			if(parent.document.getElementById(uniqueId + '_BOT') != null) {
				if(rowCount > 15) {
					parent.document.getElementById(uniqueId + '_BOT').className = "";
				}
				else {
					parent.document.getElementById(uniqueId + '_BOT').className = "hide"; //No I18N
				}
			}
		}
	}
}

function getSelectedCheckBoxes(form) {
	var selectedVals = new Array();
	var elems = form.elements;
	for(var i = 0; i < elems.length; i++) {
		if(elems[i].type == "checkbox" && elems[i].name == "checkbox") {
			if(elems[i].checked) {
				selectedVals[selectedVals.length] = elems[i].value;
			}
		}
	}
	return selectedVals;
}

/*
* Function for clearing the form text element(s) value
* @param formName - form name for the text field to be cleared
* @author Murugesn K
*/
function clearFormValues( formName ) {
	var form_length = document.forms.length;
	if( form_length > 0 ) {
		try {
			for( i=0; i<form_length; i++ ) {
				if( document.forms[i].name == formName ) {
					var elements = document.forms[i].elements;
					var length = elements.length;
					var element_type;
					var element_name;
					for( j=0; j<length; j++ ) {
                        element_type = elements[j].type;
						if( element_type == 'text' || element_type == 'textarea') {
							elements[j].value = "";
							if(elements[j].getAttribute("default") != null) {
								elements[j].value = elements[j].getAttribute("default");
							}
                        }
                        else if(elements[j].nodeName == "SELECT" && elements[j].options.length > 0){
                            elements[j].value = elements[j].options[0].value;
							if(elements[j].getAttribute("default") != null) {
								elements[j].value = elements[j].getAttribute("default");
							}
                        }
                        else if(elements[j].nodeName == "INPUT") {
                            if(elements[j].checked) { elements[j].checked = false; }    // checkbox and radio buttons
                        }
					}
				}
			}
		}
		catch(e) {
			alert( "[ " + formName + "] : " + e.message); //No I18N
		}
	}
	else {
		alert('clearFormValues() : No form(s) found!!!');
	}
}


var requestOne;
var ajax_request_id;
/*
* Function for calling ajax request
* @param url - request URL
* @param params - request parameter(s)
* @param requestID - to identify the ajax request
* author Murugesan K
*/
function callAjaxRequest(url, params, requestID) {
	ajax_request_id = requestID;
	requestOne = getXMLHttpRequest();
	if(requestOne)
	{
		try
		{
			requestOne.open("POST", url, true); //No I18N
			requestOne.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8"); //No I18N
			requestOne.setRequestHeader("Content-length", params.length); //No I18N
			requestOne.onreadystatechange = updateAjaxRequest;
			requestOne.send(params);
		}
		catch(e)
		{
			alert("Error while sending the request : " + e.message);
		}
	}
}

/*
* Function for calling sjax request [ Synchronous AJAX ]
* @param url - request URL
* @param params - request parameter(s)
* author Murugesan K
*/
var srequestOne;
function callSjaxRequest(url, params) {
	srequestOne = getXMLHttpRequest();
	if(srequestOne)
	{
		try
		{
			srequestOne.open("POST", url, false); //No I18N
			srequestOne.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8"); //No I18N
			srequestOne.setRequestHeader("Content-length", params.length); //No I18N
			srequestOne.send(params);
			return srequestOne;
		}
		catch(e)
		{
			alert("Error while sending the request : " + e.message);
		}
	}
}


/*
* Function for handling ajax response
* This function will invoke the ajaxRequestOnSuccess function if the ajax request success else it will
* invoke the ajaxRequestOnFailure
* User(s) have to implement these functions and it will give the two parameter(s) one will contain respose object
* and other will contain you ajax request identification number
* @author Murugesan K
*/
function updateAjaxRequest() {
	// only if req shows "loaded"
	try {
		if (requestOne.readyState == 4) {
			if (requestOne.status == 200) {
				ajaxRequestOnSuccess(requestOne, ajax_request_id);
			}
			else {
				ajaxRequestOnFailure(requestOne, ajax_request_id);
			}
		}
	}
	catch(e) {
		alert("Error while fetching ajax response : " + e.message);
	}
}

/*
* Function used for validating input fields
* @param control - Object of the input element
* @param comparevalue - value to be compared with the input element
* @param datatype - data type of the input element
* @param errorMsg - error message to be thrown in case of invalid data in input field
* @author Murugesan K
* @sample isValidData(document.sampleform.egelement,'','string', 'Invalid input')
*
*/
function isValidData(control, comparevalue, datatype, errorMsg) {
	var isvalid = true;
	if(trim(control.value) == comparevalue || trim(control.value) == null) {
		showErrorMessage(control, errorMsg);
		return false;
	}
	if( datatype == 'integer' ) {
		isvalid = isInteger(trim(control.value));
	}
	else if( datatype == 'pinteger' ) {
		isvalid = isPositiveInteger(trim(control.value));
	}
	else if( datatype == 'double' ) {
		isvalid = isDouble(trim(control.value));
	}
	if( isvalid == false ) {
		showErrorMessage(control, errorMsg);
	}
	return isvalid;
}
/*
* Function used to display the error message and set the focus to error element
* @param control - Element object
* @param errorMsg - message to be displayed
*/
function showErrorMessage(control, errorMsg) {
	alert(errorMsg);
	control.focus();
	if( control.type !='select-one' && control.type !='select-multiple' && control.id != undefined && control.id != '' ) {
		new Effect.ScrollTo(control.id);
		control.select();
	}
}

/*
* Function for constructing parameter name & value(s) for the requested form
* @param formName - request parameter(s) to be constructed for the form name
* @return this will return the chain of param name & value pair
*/
function constructParameters( formName ) {
	var params = "";
	try {
		var elements_list = formName.elements;
		var length = elements_list.length;
		var element_type;
		for( i=0; i<length; i++ ) {
			element_type = elements_list[i].type;
		if( element_type == 'textarea' || element_type == 'text' || element_type == 'select-one' || element_type == 'password' || (element_type == 'hidden' && elements_list[i].name.indexOf("UDF_DATE") >= 0)) {

				params += "&" + elements_list[i].name + "=" + encodeURIComponent(elements_list[i].value); //No I18N
			}
			else if( element_type == 'checkbox' && elements_list[i].checked ) {
				params += "&" + elements_list[i].name + "=" + encodeURIComponent(elements_list[i].value); //No I18N
			}
			else if( element_type == 'select-multiple' ) {
				var size = elements_list[i].options.length;
				for( j=0 ;j<size; j++ ) {
					if( elements_list[i].options[j].selected) {
						params += "&" + elements_list[i].name + "=" + encodeURIComponent(elements_list[i].options[j].value); //No I18N
					}
				}
			}
			else if( element_type == 'radio' )
			{
				if(elements_list[i].checked)
				{
					params += "&" + elements_list[i].name + "=" + encodeURIComponent(elements_list[i].value); //No I18N
				}
			}

		}
	}
	catch(e) {
		alert( "Error while constructing request parameter : " + e.message );
	}
	return params;
}


function deleteAttachment(link,id) {
	if(confirm(document.getElementById("deletealert").innerHTML)) {
		document.getElementById(id).parentNode.removeChild(document.getElementById(id));
		document.getElementById("hiddenFrame").src = link;
		if(document.getElementById("attachmentList") != null && document.getElementById("attachmentList").rows != null && document.getElementById("attachmentList").rows.length == 0) {
			document.getElementById("attachRow").parentNode.removeChild(document.getElementById("attachRow"));
		}
		else if (document.getElementById("attachments") != null && document.getElementById("attachments").rows != null && document.getElementById("attachments").rows.length == 0){
			document.getElementById("attachRow").parentNode.removeChild(document.getElementById("attachRow"));
		}
	}
}

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"; //No I18N
						}
						node.onmouseout=function() {
							this.className=this.className.replace(" over", ""); //No I18N
						}
					}
				}
			}
		}
	}
}
window.onload=startList;
function closeAttachment(formVal,val,vv,size,module)
{
    top.window.opener.assignVal(formVal,val,unescape(vv),size,module);
    window.close();
}
function validateAttach()
{
	var str=document.form1.filePath.value;
    if((str=="")||(str.charAt(str.length-1)=="/"))
    {
        return false;
    }
    else
    {
        document.form1.filename.value=str;
    }
    return true;
}
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/AECommonDef.jsp?TYPE=" + type+"&forwardTo="+commonList; //No I18N
	for(var i = 0; i < selVals.length; i++) {
		url = url + "&COMMONID=" + selVals[i]; //No I18N
	}
	frames["CONF_FRAME"].location.href = url; //No I18N
	invokeProgressIndicator('DeleteStage','sdp.common.delete'); //No I18N
	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;
}


function showConfForm(commonList) {
	window.frames['CONF_FRAME'].location.href = "/setup/AECommonDefForm.jsp?forwardTo="+commonList; //No I18N
}

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'); //No I18N
}


/**
 * When we get the value as a responseXML through ajax, then &lt; and &gt; have to be replaced to < and > before setting them to the form
 */

function escapeForStrutsForm(value) {
	if(value != null) {
		value = value.replace(/&lt;/g,"<"); // No I18N
		value = value.replace(/&gt;/g,">"); // No I18N
	}
	return value;
}
function replaceAllStringOccurences(Source,stringToFind,stringToReplace){
	var temp = Source;

    	var index = temp.indexOf(stringToFind);

        while(index != -1){

            temp = temp.replace(stringToFind,stringToReplace);

            index = temp.indexOf(stringToFind);

        }

        return temp;

}
function setSiteName(from,to)
{
	to.innerHTML=getSiteName(from);
}
function setAccount(obj)
{
	obj.innerHTML=getAccountName();
}
function getAccountId()
{
	var k=document.getElementById("__persistentAccountId__select");
	return k.value;

}
function setAccountId(id)
{
    var k=document.getElementById("__persistentAccountId__select");
    if(k != null) {
        for(var i=0;i<k.options.length;i++)
        {
            if(k.options[i].value==id)
            {
                k.selectedIndex=i;
                return;
            }
        }
    }
}
function getSiteName(fromObj)
{
     	var arr=fromObj.options[fromObj.selectedIndex].innerHTML+"";
	var str= arr.split(",");
	return str[str.length-1];
}
function getAccountName()
{
    	var k=document.getElementById("__persistentAccountId__select");
	return k.options[k.selectedIndex].innerHTML;
}
