// JavaScript Document
var subInd=new Array();
function clearCombo(combo)
{
	if(combo)
	{
		opt=combo.options.length=0;
		return true;
	}
	
	return true;
}

function getSubIndustries(indID)
{
	if(indID!="")
	{
		if(!subInd[indID])
		{
			doAjax("ajax_getdata.php?indID="+indID,"","progress_div","GET","<img src='images/ajax2.gif' alt='processing...'/>","",indID,'industry');
		}	
		else
		{
			addLi(document.getElementById("sindustry_ul"),subInd[indID].split("|"),'sindustry');
		}
	}	
}

function doAjax(strURL,strPostData,strObj,method,strProgressMessage,nTime,indKey,type) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
	www=(window.location.href.toLowerCase().indexOf("//www.")>0)?"http://www.":"http://";
	strURL=strURL.replace("http://",www);
	//updateMessage(strObj,strProgressMessage);
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
	
    self.xmlHttpReq.open(method, strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) 
		{
			//alert(self.xmlHttpReq.responseText);
			if(type == 'industry') {
				subInd[indKey]=self.xmlHttpReq.responseText;
				//hide(strObj);
				//updateMessage(strObj,subInd[indKey]);
				//if (nTime>0) setTimeout("hide('"+strObj+"');",nTime);
				if(subInd[indKey] != "")
				{
					addLi(document.getElementById("sindustry_ul"),subInd[indKey].split("|"),'sindustry');
					//alert(subInd[indKey]);
				}
			}
			
			else if(type == 'sindustry') {
					//alert(self.xmlHttpReq.responseText);
				if(self.xmlHttpReq.responseText != "")
				{
					addLi(document.getElementById("swtype_ul"),self.xmlHttpReq.responseText.split("|"),'swtype');
					//alert(subInd[indKey]);
				}
			}
			
			else if(type == 'swtype') {
					//alert(self.xmlHttpReq.responseText);
				if(self.xmlHttpReq.responseText != "")
				{
					addLi(document.getElementById("sswtype_ul"),self.xmlHttpReq.responseText.split("|"),'sswtype');
					//alert(subInd[indKey]);
				}
			}
			
        }
    }
    self.xmlHttpReq.send(strPostData);
}

function addLi(ulObj,arr,type)
{
	str = "";
	temp = "";
	urlStr = window.location.href;
	urlStr = urlStr[urlStr.length-1] == "#" ? urlStr : urlStr+"#";
	
	for(i=0;i<arr.length;i++)
	{
		temp = arr[i].split("~~");
		str += "<li onclick=\"setValue(this,'"+type+"','"+temp[1]+"');\" value=\""+temp[0]+"\"><a href=\""+urlStr+"\" class=\"link-class\">"+temp[1]+"</a></li>"		
	}
	ulObj.innerHTML += str;
}

function getSwType(sindID)
{
//	clearCombo(document.getElementById("sw_type"));
	//clearCombo(document.getElementById("sw_stype"));
	indID=document.getElementById("industry_id").value;
	
		if(sindID!="")
		{
			doAjax("ajax_getSwType.php?indID="+indID+"&sindID="+sindID,"","progress_div","GET","<img src='images/ajax2.gif' alt='processing...'/>  Loading software types ...","","",'sindustry');
		}	
}

function getSubSwType(swID)
{

	indID=document.getElementById("industry_id").value;
	sindID=document.getElementById("sindustry_id").value;
	
		if(swID!="" && swID > "0")
		{
			doAjax("ajax_getSwType.php?indID="+indID+"&sindID="+sindID+"&swID="+swID,"","progress_div","GET","<img src='images/ajax2.gif' alt='processing...'/>  Loading sub software types ...","","","swtype");
		}	
}

 var hideDropDownsOnClick = function(event) {
   
      var a = Event.element(event);
      if (a.lang == 'dd') { return false; }
      else
	  {
	   	   //hide('industry');
		   //hide('sindustry');
		   hide('swtype');
	   	   //hide('sswtype');
	  }	   
	   return; 
   
   }
   
   Event.observe(document, "click", (hideDropDownsOnClick), true);

  		function showHide(id)
		{
			liFirst = "";
			//alert(document.getElementById(id).style.display);
			if(document.getElementById(id).style.display == 'none')
				document.getElementById(id).style.display = '';
			else
				document.getElementById(id).style.display = 'none';	
		}
		
		function setValue(obj,id,text)
		{
			//alert(obj.value);
			//alert(id);
			document.getElementById(id+"_text").innerHTML=text.length > 25 ? text.substr(0,25)+'...' : text;
			prev = document.getElementById(id+"_id").value;
			document.getElementById(id+"_id").value=obj.value
			if(obj.value > 0)
				document.getElementById(id+"_text").style.fontWeight='bold';
			else
				document.getElementById(id+"_text").style.fontWeight='';
				
			//alert(prev+" -- "+obj.value+" -- "+obj.innerHTML);

			hide(id);
		}


