
//var xmlDoc = null;
//var isIE = 1;

function isBrowserIE()
{
	var nav=navigator.userAgent;
	if (nav.indexOf("MSIE")>-1)
	{ 
		isIE=1;
	}
	else 
	{ 
		isIE=0;
	}
	return isIE;
}

function findSpecialists(specialityId) 
{

	while (document.customerForm.SpecCat.options.length) 
		document.customerForm.SpecCat.options[0] = null;
	option = new Option("select a category...","");
	document.customerForm.SpecCat.options[document.customerForm.SpecCat.options.length] = option;

	if (xmlDoc==null)
	{
		try
		{
			if (isIE==1) //Internet Explorer
			{
				xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
			}
			else //Firefox, Opera etc
			{
				xmlDoc=document.implementation.createDocument("","",null);
			}
			xmlDoc.async=false;
			xmlDoc.load("trades.xml");
		}
		catch(e)
		{
			alert(e.message);
			return;
		}
	}

	var myXML, myNodes, specNodes;
	var display="";
	myNodes=xmlDoc.getElementsByTagName("trades")[0].childNodes;

	//Specialities
	for (var i=0; i<myNodes.length; i++) 
	{
		if (myNodes[i].nodeName != "#text" && myNodes[i].getAttribute("value") == specialityId)
		{
			specNodes=myNodes[i].getElementsByTagName("option");
			   for (var k=0; k<specNodes.length; k++) 
				{
					var theText=(isIE?specNodes[k].text:specNodes[k].textContent);
					option = new Option(theText, specNodes[k].getAttribute("value"));
					document.customerForm.SpecCat.options[document.customerForm.SpecCat.options.length] = option;
				}
		}
	}
}

function initialTradesSelect(isToRefreshSpecialities) 
{
	isIE = isBrowserIE();

	while (document.customerForm.TradeCat.options.length) 
		document.customerForm.TradeCat.options[0] = null;
	option = new Option("select a trade...","");
	document.customerForm.TradeCat.options[document.customerForm.TradeCat.options.length] = option;

	if (isToRefreshSpecialities==1)
	{
		while (document.customerForm.SpecCat.options.length) 
			document.customerForm.SpecCat.options[0] = null;
		option = new Option("select a category...","");
		document.customerForm.SpecCat.options[document.customerForm.SpecCat.options.length] = option;
	}
	
	if (xmlDoc==null)
	{
		try
		{
			if (isIE==1) //Internet Explorer
			{
				xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
			}
			else //Firefox, Opera etc
			{
				xmlDoc=document.implementation.createDocument("","",null);
			}
			xmlDoc.async=false;
			xmlDoc.load("trades.xml");
		}
		catch(e)
		{
			alert(e.message);
			return;
		}
	}

   var myXML, myNodes, specNodes;
   var display="";
   try
   {
		myNodes=xmlDoc.getElementsByTagName("trades")[0].childNodes;
   }
		catch (e)
   {
		alert(e.message);
		return;
   }

   //Trades
   for (var i=0; i<myNodes.length; i++) 
   {
      if (myNodes[i].nodeName != "#text" && myNodes[i].getAttribute("value") != "0")
	  {
			option = new Option(myNodes[i].getAttribute("descr"), myNodes[i].getAttribute("value"));
			document.customerForm.TradeCat.options[document.customerForm.TradeCat.options.length] = option;
	  }
   }
}

function copyDropDownList(selectElement,targetSelectElement)
{
	while (document.customerForm.TradeCat2.options.length) 
		document.customerForm.TradeCat2.options[0] = null;
	
	var length=document.customerForm.TradeCat.options.length;
	var i,option;
	for (i=0;i<length;i++)
	{
		option = new Option(document.customerForm.TradeCat.options[i].text,
			document.customerForm.TradeCat.options[i].value); //descr then code/value
		document.customerForm.TradeCat2.options[document.customerForm.TradeCat2.options.length] = option;
	}
	
	document.customerForm.TradeCat.options[0].text="select a primary trade...";
	document.customerForm.TradeCat2.options[0].text="select a secondary trade...";
}

function preloadImages()
{
	if (document.images)
	{
		pic1=new Image(780,580); 
		pic1.src="pic/fpBGmiddle.jpg"; 
		pic2=new Image(780,580); 
		pic2.src="pic/spBGMiddle.jpg";  
		pic3=new Image(390,290); 
		pic3.src="pic/fpFormLeft.gif"; 
		pic4=new Image(128,60); 
		pic4.src="pic/fpFormRight.gif";		
		pic5=new Image(150,1700); 
		pic5.src="pic/fpBGedges.jpg";		
	}
}
