// JavaScript Document

function introspect(o) {    
    var tmp = "";
    for(var i in o) {
        //if(i.charAt(i) == "r" || i.charAt(i) == "c")
		eval('o.'+i)
        tmp+=i+':'+eval('o.'+i)+' -- ';                
    }
    alert(tmp);   
}
//	introspect(elm);

var catID=1;
var manufID=0;
var targetID=0;
var packID=0;
var memoryID=0;
var mfgName = 'All Manufacturers';
var packAll = true;
var memAll = true;
var oPackage = new Object();
var oMemory = new Object();


function getTools(){
//	alert('/htdocs/asp/compilers/CompilersSearchResults.asp?loadData=do'+(searchStr!=''?'&srtSrch=do':'')+'&Cat_ID='+catID+'&Manuf_ID='+manufID+'&Target_ID='+(searchStr!=''?searchStr:targetID)+'&Pack_ID='+packID+'&Memory_ID='+memoryID+'&t=abc'+ new Date().getTime());
/*
	console.log('catID: '+catID);
	console.log('manufID: '+manufID);
	console.log('targetID: '+targetID);
	console.log('packID: '+packID);
	console.log('memoryID: '+memoryID);
*/
	iFrame_ToolSerRes.document.location='/htdocs/asp/compilers/CompilersSearchResults.asp?loadData=do'+(searchStr!=''?'&srtSrch=do':'')+'&Cat_ID='+catID+'&Manuf_ID='+manufID+'&Target_ID='+(searchStr!=''?searchStr:targetID)+'&Pack_ID='+packID+'&Memory_ID='+memoryID+'&t=abc'+ new Date().getTime();

}

function getTarget(elm){
	searchStr = '';
	document.getElementById('TargetListBox').className = 'TargetListBoxLoad';
	document.getElementById('TargetListBox').value = 'Loading Data...';
	manufID=elm.value;
	var t = new Date().getTime();
	getXMLdoc('/htdocs/asp/compilers/CompilersXML.asp', 'trgName=get&Cat_ID='+catID+'&Manuf_ID='+manufID+'&t='+t, doTargXML)
	window.frames.iFrame_ToolSerRes.showHideTable('hide');
}


function getPackageX(elmID,elmName){
	searchStr = '';
	targetID=elmID;
	document.getElementById('TargSearchList').style.display = 'none';
	document.getElementById('TargHoldList').style.display = 'none';
	document.getElementById('TargetListBox').value = elmName;
	var t = new Date().getTime();
	getXMLdoc('/htdocs/asp/compilers/CompilersXML.asp', 'trgPack=get&Cat_ID='+catID+'&Manuf_ID='+manufID+'&Target_ID='+targetID+'&t='+t, doPackXML)
//	getXMLdoc('/htdocs/TargetSrchResXML.asp', 'loadData=do&srtSrch=do&Cat_ID='+catID+'&Mfg_ID='+manufID+'&Target_ID='+searchStr+'&SrchSrt='+searchStr+'&t='+t, showData);
	window.frames.iFrame_ToolSerRes.showHideTable('hide');
}
function getMemoryX(elm){
	packID=elm.value;
	var t = new Date().getTime();
	if(searchStr == ''){
		getXMLdoc('/htdocs/asp/compilers/CompilersXML.asp', 'memSize=get&Cat_ID='+catID+'&Manuf_ID='+manufID+'&Target_ID='+targetID+'&Pack_ID='+packID+'&t='+t, doMemoryXML)
	}
	window.frames.iFrame_ToolSerRes.showHideTable('hide');
}

function setMemoryX(elm){
	memoryID=elm.value;
//	iFrame_ToolSerRes.document.location='/htdocs/asp/compilers/CompilersSearchResults.asp?loadData=do&Cat_ID='+catID+'&Manuf_ID='+manufID+'&Target_ID='+targetID+'&Pack_ID='+packID+'&Memory_ID='+memoryID;
	window.frames.iFrame_ToolSerRes.showHideTable('hide');
}

function setTarget(elmID,elmName){
	searchStr = '';
	targetID=elmID;
	document.getElementById('TargSearchList').style.display = 'none';
	document.getElementById('TargHoldList').style.display = 'none';
	document.getElementById('TargetListBox').value = elmName;
	window.frames.iFrame_ToolSerRes.showHideTable('hide');
}

// ---------------------------- AJAX ---------------------------- //

function getXMLdoc(url, param, handler){
		var myAjax = new Ajax.Request(url, {method:'get', parameters:param, onComplete:handler});
}


function getQueryStr(){
//	alert('getQueryStr');
	var Cat_ID;
	var qStr = document.location.search;
	if(qStr!=null&&qStr!=''){
		qStr = qStr.substring(1,qStr.length);
		qStrParts = qStr.split('&');
		for(var i = 0; i < qStrParts.length; i++){
			qStrParts[i] = qStrParts[i].replace("=","='")+"'";
			eval(qStrParts[i]);
		}
		catID = Cat_ID;
	}
	var url = '/htdocs/asp/compilers/CompilersXML.asp';
	var param = 'mnfName=get&Cat_ID='+catID;
	getXMLdoc(url, param, doMfgXML)
//	alert(catID);
}


//////////////////////////////////////// Manufacturer ///////////////////////////////

var manufList, manufListTxt, targHoldList, packList, packListTxt, memoryList, memoryListTxt, targSearchList, targetListBox;

function doMfgXML(req) {
	
	manufList = document.getElementById('manufacturerList');
	manufListTxt = document.getElementById('manufacturerListText');
	targHoldList = document.getElementById('TargHoldList');
	targSearchList = document.getElementById('TargSearchList');
	packList = document.getElementById('PackageList');
	memoryList = document.getElementById('MemoryList');
//	var targListTxt = document.getElementById('TargetListText');
	packListTxt = document.getElementById('PackageListText');
	memoryListTxt = document.getElementById('MemoryListText');
	

	if (req.readyState == 4) {
		if (req.status == 200) {

			response = req.responseXML.documentElement;
		//	alert(response.xml);

			var catData = response.getElementsByTagName('Prod_Cat');
			var manufData = response.getElementsByTagName('Manufacturer');
					
			document.getElementById('ToolCatTxt').innerHTML = catData[0].getAttribute("Cat_Name");
		
			var manufDataLen = manufData.length;
			if(manufDataLen>1){
				manufList.options.length = 0;
				manufList.options[0] = new Option('All', 0);
				for(var i = 0; i < manufDataLen; i++){
					manufList.options[i+1] = new Option(manufData[i].getAttribute("Manuf_Name"), manufData[i].getAttribute("Manuf_ID"));
				}
			}else{
				document.getElementById('manufacturerListText').innerHTML = manufData[0].getAttribute("Manuf_Name");
				document.getElementById('manufacturerList').style.display = 'none';
				document.getElementById('manufacturerListText').style.display = '';
				manufID = manufData[0].getAttribute("Manuf_ID");
			}
			var t = new Date().getTime();
			getXMLdoc('/htdocs/asp/compilers/CompilersXML.asp', 'trgName=get&Cat_ID='+catID+'&Manuf_ID='+manufID+'&t='+t, doTargXML)
			manufList.className = 'manufacturerList';
		}
		req.send(null);
	} else {
		alert("There was a problem retrieving the XML data:\n" + req.statusText);
	}
}




/////////////////////////// Target ///////////////////////////

function doTargXML(req) {
	
	
	searchStr = '';
	document.getElementById('TargetListBox').className = 'TargetListBoxLoad';
	targSearchList.style.display = 'none';
	targHoldList.style.display = 'none';
	
/*	
	packList.className = 'PackageListLoad';
	packList.options.length = 0;
	packList.options[0] = new Option('Loading Data...',0);
	packList.style.display = '';
	packListTxt.style.display = 'none';

	memoryList.className = 'MemoryListLoad';
	memoryList.options.length = 0;
	memoryList.options[0] = new Option('Loading Data...',0);
	memoryList.style.display = '';
	memoryListTxt.style.display = 'none';
*/
	targetID = 0;
//	packID=0;
	
//	memoryID=0;
	
	if (req.readyState == 4) {
		if (req.status == 200) {
			response = req.responseXML.documentElement;
		//	alert(response.xml);

			var catData = response.getElementsByTagName('Prod_Cat');
			var targData = response.getElementsByTagName('Target');
			
			mfgName = catData[0].getAttribute("MfgName");
			var targDataLen = targData.length;
			document.getElementById('targetTotalNum').innerHTML = targDataLen;
			
			var TargDropList = document.getElementById('TargetDropDownList');
			while (TargDropList.firstChild){
				TargDropList.removeChild(TargDropList.firstChild);	
			}
//			if(targDataLen>1){

			if(manufID!=0){
			//	document.getElementById('TargetListBox').value = 'All';
		
				if(targDataLen==1){
					document.getElementById('TargetListBox').value = targData[0].getAttribute("Targ_Name");
					targetID = targData[0].getAttribute("Targ_ID");
					document.getElementById('ListMenuBtn').style.display = 'none';
					document.getElementById('TargetListBox').style.width = 177+'px';
				}else{
					for(var i = -1; i < targDataLen; i++){
			
						var li_Targ = document.createElement('li');
						var aNode = document.createElement('a');
						if(i==-1){
						//	aNode.href = 'JavaScript:;';
							aNode.href = 'JavaScript:setTarget("0","All");';
							eNameText = document.createTextNode("All");
						}else{
							aNode.href = 'JavaScript:setTarget("'+targData[i].getAttribute("Targ_ID")+'","'+targData[i].getAttribute("Targ_Name")+'");';
						//	aNode.href = 'JavaScript:getPackage("'+targData[i].getAttribute("Targ_ID")+'","'+targData[i].getAttribute("Targ_Name")+'");';
							eNameText = document.createTextNode(targData[i].getAttribute("Targ_Name"));
						}
						aNode.appendChild(eNameText);
						li_Targ.appendChild(aNode);
						TargDropList.appendChild(li_Targ);
					}
			
					document.getElementById('ListMenuBtn').style.display = '';
					document.getElementById('TargetListBox').style.width = 160+'px';
					document.getElementById('TargetListBox').value = 'All';
					
				}
		
			}else{
				document.getElementById('TargetListBox').value = targData[0].getAttribute("Targ_Name");
				document.getElementById('TargetListBox').value = 'Enter MCU pattern or select Mfg.';
				document.getElementById('ListMenuBtn').style.display = 'none';
				document.getElementById('TargetListBox').style.width = 177+'px';
				
			//	document.getElementById('TargetListText').innerHTML = targData[0].getAttribute("Targ_Name");
			//	document.getElementById('TargetList').style.display = 'none';
			//	document.getElementById('TargetListText').style.display = '';
			//	targetID = targData[0].getAttribute("Targ_ID");
			//	loadXMLDoc('pack','/htdocs/asp/compilers/CompilersXML.asp?trgPack=get&Cat_ID='+catID+'&Manuf_ID='+manufID+'&Target_ID='+targetID);
			}
	//		alert('trgPack=get&Cat_ID='+catID+'&Manuf_ID='+manufID+'&Target_ID='+targetID);
			var t = new Date().getTime();
	//		getXMLdoc('/htdocs/asp/compilers/CompilersXML.asp', 'trgPack=get&Cat_ID='+catID+'&Manuf_ID='+manufID+'&Target_ID='+targetID+'&t='+t, doPackXML)

			targHoldList.style.display = '';

			document.getElementById('TargetDropDownList').style.width = Math.max(162, document.getElementById('TargetDropDownList').clientWidth)+'px';
		

			document.getElementById('TargHoldList').style.width = document.getElementById('TargetDropDownList').clientWidth + 20+'px';
			document.getElementById('TargHoldList').style.height = Math.max(0,Math.min(200,(document.getElementById('TargetDropDownList').clientHeight)))+'px';
			targHoldList.style.display = 'none';
			document.getElementById('TargetListBox').className = 'TargetListBox';
		}
		req.send(null);
		} else {
		alert("There was a problem retrieving the XML data:\n" + req.statusText);
	}
}



//////////////////////// Package ///////////////////////

var arrAllPack = new Array();

function addNewPackX(type, packID) {
  this.Type=type;
  this.PackID=packID;
}
function sortPackTypeX(a, b) {
    var x = a.Type.toLowerCase();
    var y = b.Type.toLowerCase();
    return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}


function doPackXMLX(req) {
//	alert('doPackXML');
	arrAllPack = new Array();

	packList.options[0] = new Option('Loading Data...',0);
	packList.style.display = '';
	packListTxt.style.display = 'none';
	packID=0;
	memoryID=0;

	
	memoryList.className = 'MemoryListLoad';
	memoryList.options.length = 0;
	memoryList.options[0] = new Option('Loading Data...',0);
	memoryList.style.display = '';
	memoryListTxt.style.display = 'none';

		if (req.readyState == 4) {
			if (req.status == 200) {
				response = req.responseXML.documentElement;
			//	alert(response.xml);

				var packData = response.getElementsByTagName('Package');
				var packDataLen = packData.length;
				if(packDataLen>1){
					
					packList.options.length = 0;
					packList.options[0] = new Option('All', 0);
					
					var o = new Object();
					for(var i=0; i<packDataLen; i++){
						eval('o.pack'+packData[i].getAttribute("Pack_ID")+'={name:\"'+packData[i].getAttribute("Pack_Name")+'\", value:\"'+packData[i].getAttribute('Pack_ID')+'\"}');
						if(packAll){
							eval('oPackage.pack'+packData[i].getAttribute("Pack_ID")+'={name:\"'+packData[i].getAttribute("Pack_Name")+'\", value:\"'+packData[i].getAttribute('Pack_ID')+'\"}');
						}
						
					}
					packAll = false;
					
					var num = 0;
					for(var property in o){
						var oName  = eval('o.'+property+'.name')
						var oValue = eval('o.'+property+'.value')
						arrAllPack[arrAllPack.length++] = new addNewPack((oName=='None'?' On-chip Debug ':oName), oValue);
					//	packList.options[num+1] = new Option(oName, oValue);
						num++; 
					}
				//	alert('JB01: '+num);
					arrAllPack.sort(sortPackType);
					for(var i = 0; i < arrAllPack.length; i++){
						packList.options[i+1] = new Option(arrAllPack[i].Type, arrAllPack[i].PackID);
					}
					if(num==1){
						document.getElementById('PackageListText').innerHTML = arrAllPack[0].Type; // packData[0].getAttribute("Pack_Name");
						document.getElementById('PackageList').style.display = 'none';
						document.getElementById('PackageListText').style.display = '';
						packID = packData[0].getAttribute("Pack_ID");
					}
				}else{
				//	alert('JB02 - else');
					document.getElementById('PackageListText').innerHTML = packData[0].getAttribute("Pack_Name")=='None'?' On-chip Debug ':packData[0].getAttribute("Pack_Name");
					document.getElementById('PackageList').style.display = 'none';
					document.getElementById('PackageListText').style.display = '';
					packID = packData[0].getAttribute("Pack_ID");
					

				}
				packList.className = 'PackageList';
				var t = new Date().getTime();
				getXMLdoc('/htdocs/asp/compilers/CompilersXML.asp', 'memSize=get&Cat_ID='+catID+'&Manuf_ID='+manufID+'&Target_ID='+targetID+'&Pack_ID='+packID+'&t='+t, doMemoryXML)

			}
		req.send(null);
		} else {
		alert("There was a problem retrieving the XML data:\n" + req.statusText);
	}
}




//////////////////////// Memory ///////////////////////

function doMemoryXMLX(req) {
	
//	alert('doMemoryXML');
	
	memoryList.className = 'MemoryListLoad';
	memoryList.options.length = 0;
	memoryList.options[0] = new Option('Loading Data...',0);
	memoryList.style.display = '';
	memoryListTxt.style.display = 'none';
	memoryID=0;

	if (req.readyState == 4) {
		if (req.status == 200) {
			response = req.responseXML.documentElement;
		//	alert(response.xml);

			var memoryData = response.getElementsByTagName('Memory');
			
			var memoryDataLen = memoryData.length;
			
			if(memoryDataLen>1){
				memoryList.options.length = 0;
				memoryList.options[0] = new Option('All', 0);
				
				var o = new Object();
				for(var i=0; i<memoryDataLen; i++){
					eval('o.memory'+memoryData[i].getAttribute("Mem_ID")+'={name:\"'+memoryData[i].getAttribute("Men_Name")+'\", value:\"'+memoryData[i].getAttribute('Mem_ID')+'\"}');
					if(memAll){
						eval('oMemory.memory'+memoryData[i].getAttribute("Mem_ID")+'={name:\"'+memoryData[i].getAttribute("Men_Name")+'\", value:\"'+memoryData[i].getAttribute('Mem_ID')+'\"}');
					}
				}
				memAll = false;
				var num = 0;
				for(var property in o){
					var oName  = eval('o.'+property+'.name')
					var oValue = eval('o.'+property+'.value')
					memoryList.options[num+1] = new Option((oName=='None'?'On-chip Debug ':oName), oValue);
					num++;
				}
				if(num==1){
					document.getElementById('MemoryListText').innerHTML = memoryData[0].getAttribute("Men_Name")=='None'?' On-chip Debug ':memoryData[0].getAttribute("Men_Name");
					document.getElementById('MemoryList').style.display = 'none';
					document.getElementById('MemoryListText').style.display = '';
					memoryID = memoryData[0].getAttribute("Mem_ID");
				//	alert('01 - targetID:'+targetID+'  ::  packID:'+packID);
//					var url = '/htdocs/asp/compilers/CompilersSearchResults.asp?loadData=do&Cat_ID='+catID+'&Manuf_ID='+manufID+'&Target_ID='+targetID+'&Pack_ID='+packID+'&Memory_ID='+memoryID;
//					if(targetID!=''&&packID!='') window.frames['iFrame_ToolSerRes'].location = url; 
				}
			}else{
				document.getElementById('MemoryListText').innerHTML = memoryData[0].getAttribute("Men_Name")=='None'?' On-chip Debug ':memoryData[0].getAttribute("Men_Name");
				document.getElementById('MemoryList').style.display = 'none';
				document.getElementById('MemoryListText').style.display = '';
				memoryID = memoryData[0].getAttribute("Mem_ID");
			//	alert('02 - targetID:'+targetID+'  ::  packID:'+packID);
//				var t = new Date().getTime();
//				var url = '/htdocs/asp/compilers/CompilersSearchResults.asp?loadData=do&Cat_ID='+catID+'&Manuf_ID='+manufID+'&Target_ID='+targetID+'&Pack_ID='+packID+'&Memory_ID='+memoryID+'&t='+t;
//				if(targetID!=''&&packID!='') window.frames['iFrame_ToolSerRes'].location = url; 

			}
			memoryList.className = 'MemoryList';

		}
		req.send(null);
		} else {
		alert("There was a problem retrieving the XML data:\n" + req.statusText);
	}
}



////////////////////////////////////////////////////    Search    ////////////////////////////////////////

function changeClass(elm){
	document.getElementById(elm).className = 'TargetListBoxLoad';
}

var strLoadAllPacks = true;

function loadAllPacksX(){
//	alert(loadAllPacks);
	packList.className = 'PackageListLoad';
	packList.options.length = 0;
	packList.options[0] = new Option('All', 0);
	
	var arrAllPack = new Array();
	var num = 0;
	for(var property in oPackage){
		var oName  = eval('oPackage.'+property+'.name')
		var oValue = eval('oPackage.'+property+'.value')
		arrAllPack[arrAllPack.length++] = new addNewPack((oName=='None'?' On-chip Debug':oName), oValue);
	}
	arrAllPack.sort(sortPackType);
	for(var i = 0; i < arrAllPack.length; i++){
		packList.options[i+1] = new Option(arrAllPack[i].Type, arrAllPack[i].PackID);
	}
	packList.className = 'PackageList';
	strLoadAllPacks = false;
}

var strLoadAllMemory = true;

function loadAllMemoryX(){
	memoryList.className = 'MemoryListLoad';
	memoryList.options.length = 0;
	memoryList.options[0] = new Option('All', 0);
	memoryList.style.display = '';
	memoryListTxt.style.display = 'none';
	
	var num = 0;
	for(var property in oMemory){
		var oName  = eval('oMemory.'+property+'.name')
		var oValue = eval('oMemory.'+property+'.value')
		if(oValue!=7){
			memoryList.options[num+1] = new Option((oName=='None'?'On-chip Debug ':oName), oValue);
			num++;
		}
	}
	memoryList.className = 'MemoryList';
	strLoadAllMemory = false;
}


function getTargetInfo(str){
	
/*
	packID=0;
	memoryID=0;
	loadAllPacks();
	loadAllMemory();
	
	packList.style.display = '';
	packListTxt.style.display = 'none';
	packList.options.length = 0;
	packList.options[0] = new Option('All',0);

	packList.className = 'PackageListLoad';
	packList.options[0] = new Option('Loading Data...',0);
*/
//	memoryList.className = 'MemoryListLoad';
/*
	memoryList.options.length = 0;
	memoryList.options[0] = new Option('All',0);
	memoryList.style.display = '';
	memoryListTxt.style.display = 'none';
	targetID = 0;
	packID=0;
	memoryID=0;
*/



//	document.getElementById('manufacturerList').selectedIndex = 0;

	document.getElementById('TargetListBox').className = 'TargetListBoxLoad';
	
	searchStr = str.replace(/'/g, "''");
//	searchStr = str.replace(/*/,'');
//	alert(searchStr);
	
	var t =  new Date().getTime();
	if(searchStr.length>1&&searchStr!=null&&searchStr!=''){

		getXMLdoc('/htdocs/asp/compilers/CompilersXML.asp', 'trgStr=get&Cat_ID='+catID+'&Manuf_ID='+manufID+'&SrchSrt='+searchStr+'&t='+t, showData);
		
//		searchAjax.doGet('/htdocs/TargetSrchResXML.asp?loadData=do&Cat_ID='+catID+'&Mfg_ID='+manufID+'&SrchSrt='+elm, showData, 'xml');
	}else{
		document.getElementById('targetTotalNum').innerHTML = 0;
		var TargDropList = document.getElementById('TargetSearchDropDownList');
		while (TargDropList.firstChild){
			TargDropList.removeChild(TargDropList.firstChild);	
		}
		var li_Targ = document.createElement('li');
		var aNode = document.createElement('a');
//		aNode.href = 'JavaScript:getPackage("'+srchStr[i].getAttribute("targ_id")+'","'+srchStr[i].getAttribute("targ_name")+'");';
		eNameText = document.createTextNode(searchStr.length=1?'Enter 2 or more characters':'No Match '+(searchStr!=null&&searchStr!=''?'for '+searchStr:''));
		aNode.appendChild(eNameText);
		li_Targ.appendChild(aNode);
		TargDropList.appendChild(li_Targ);
		document.getElementById('TargSearchList').style.display = '';


		document.getElementById('TargetSearchDropDownList').style.width = Math.max(162, document.getElementById('TargetSearchDropDownList').clientWidth)+'px';
		document.getElementById('TargSearchList').style.width = document.getElementById('TargetSearchDropDownList').clientWidth + 20+'px';
		document.getElementById('TargSearchList').style.height = Math.max(0,Math.min(200,(document.getElementById('TargetSearchDropDownList').clientHeight)))+'px';
		document.getElementById('TargetListBox').className = 'TargetListBox';

	}
}

var showData = function(req){
	
	if (req.readyState == 4) {
		if (req.status == 200) {
		
			response = req.responseXML.documentElement;
		//	alert(response.xml);
		
			var srchStr = response.getElementsByTagName('srchStr');
			var srchStrLen = srchStr.length;
		//	alert(srchStrLen);
			
			document.getElementById('targetTotalNum').innerHTML = srchStrLen;
			document.getElementById('TargHoldList').style.display = 'none';
			document.getElementById('TargSearchList').style.display = '';
			var TargDropList = document.getElementById('TargetSearchDropDownList');
		//	alert(TargDropList.firstChild);
			while (TargDropList.firstChild){
				TargDropList.removeChild(TargDropList.firstChild);	
			}
			if(srchStrLen==0){
				var li_Targ = document.createElement('li');
				var aNode = document.createElement('a');
				aNode.href = 'JavaScript:;';
				eNameText = document.createTextNode('No match for "'+searchStr+'" in selected Mfg.'); // document.createTextNode(srchStr[i].getAttribute("targ_name"));
				aNode.appendChild(eNameText);
				li_Targ.appendChild(aNode);
				TargDropList.appendChild(li_Targ);
/*		
*/				
			}else{
				for(var i = 0; i < srchStrLen; i++){
					
					var li_Targ = document.createElement('li');
					var aNode = document.createElement('a');
					aNode.href = 'JavaScript:setTarget("'+srchStr[i].getAttribute("targ_id")+'","'+srchStr[i].getAttribute("targ_name")+'");';
					
			//		JavaScript:setTarget("16","AT91RM9200");
					
			//		getTarget
			//		aNode.href = 'JavaScript:getPackage("'+srchStr[i].getAttribute("targ_id")+'","'+srchStr[i].getAttribute("targ_name")+'");';
					eNameText = document.createTextNode(srchStr[i].getAttribute("targ_name"));
					aNode.appendChild(eNameText);
					li_Targ.appendChild(aNode);
					TargDropList.appendChild(li_Targ);
				}
			}
			document.getElementById('TargSearchList').style.display = '';
			document.getElementById('TargetSearchDropDownList').style.width = Math.max(162, document.getElementById('TargetSearchDropDownList').clientWidth)+'px';
			document.getElementById('TargSearchList').style.width = document.getElementById('TargetSearchDropDownList').clientWidth + 20+'px';
			document.getElementById('TargSearchList').style.height = Math.max(0,Math.min(200,(document.getElementById('TargetSearchDropDownList').clientHeight)))+'px';
			document.getElementById('TargetListBox').className = 'TargetListBox';
		}
	}
	document.getElementById('TargetListBox').className = 'TargetListBox';
}



function theList(elm){
	this.elm = elm;
	this.showListNow = true;
	var self = this;
	
	this.showList = function(){
		if(self.showListNow){
			var listElm = document.getElementById(elm);
			listElm.style.display = '';
		}
		setTimeout(self.hideList, 2000);
	}
	this.hideList = function(){
		if(!self.showListNow){
			document.getElementById(self.elm).style.display= 'none';
		}
	}
	this.hideNow = function(){
		document.getElementById(self.elm).style.display= 'none';
		self.showListNow = false;
	}
}

var doSrchList = new theList('TargSearchList');
var doHoldList = new theList('TargHoldList');


var toolSelected = false;
var submitted = false;
function submitForm(){    
	if(submitted){
		alert('Please wait... ');
	}else{
		document.forms[0].submit();
		submitted = true;
	}
}



