/******************* File Comments **************************
Filename:		cscombo.js
Description:	This file populates comboboxes with all
	known countries (as of 03/26/2003).  When the user
	selects a country the state combobox will be populated
	with the states associated with the country selected.
Compatibility:
	MSIE 4, 5, 6
	Netscape 4.7, 6, 7
	WebTV
	Opera	
Usage:		I generally have this command executed just before
	the closing < / body > tag.  Also in the onChange event
	of the Country combobox.
Warnings:	There is a bug in IE that requires the focus to 
	be shifted any other control on the form or the defaults
	will be off by one.  There is a fix within the code however 
	if causes focus to be sent to either the country or state
	combobox.  Quick fix would be to add a *.focus();
	event to fire to a textbox on the form.

Example 1:
	...page...
	< SCRIPT >
		FillCountry(document.myform.Country, document.myform.State, 'USA');
		FillState(document.myform.Country, document.myform.State, 'Florida');
		document.myform.Title.focus();
	< / SCRIPT >
	< / body >
	< / html >
	...end...
Example 2:
	 onChange="FillState(document.myform.Country, document.myform.State, 'Florida')"

This file was created by Brian Reeves  (ketapillar'ayat'hotmail.com)
Open Source feel free to take.  I do appreciate feedback as
well.  BTW vote at www.planet-source-code.com thanks.

Created:	@12/01/2002		brian
Modified:	3/26/2003		brian
	Modified so that the whole contents work by passing the
	comboboxes to the function.  Also changed the coding so
	that it resides in a script include.  No longer requires
	minimal ASP.
*************************************************************/

/******************* FillCountry() Comments *****************
This function needs to be called first to populate the country
combobox.  

Created:	@12/01/2002		brian
Modified:	3/26/2003		brian
	Modified to allow the passing of combo's instead of hard
	coding them.  Also created the default capabilities of
	passing a default country to be selected.

Example:  FillCountry(NameOfCountryCombo, NameOfStateCombo, DefaultCountry)
*************************************************************/

function FillCountry(cboCountry, cboState, sDefaultCountry)
{
	var sDefaultCountry, sDefault, sCountry
		
	cboCountry.options.length=0
	for(i=0;i<sCountryString.split("|").length;i++){
		sCountry = sCountryString.split("|")[i];

		if (sDefaultCountry == sCountry) 
		{
			sDefault=true;
			if (navigator.appName=="Microsoft Internet Explorer"){
			cboState.focus();
			}
		}
		else {sDefault=false;}
		
		if (sDefault) 
		{
			cboCountry.options[i]=new Option(sCountry,sCountry,sDefault,sDefault);
		}
		else 
		{
			cboCountry.options[i]=new Option(sCountryString.split("|")[i]);
		}
	}
	//alert(document.getElementById('country').value);
}
if (navigator.appName=="Netscape"){
isNav=true
}

/******************* FillState() Comments *******************
This function needs to be called after the FillCountry() to
populate the State combobox.  Also from the onChange of the
country combobox.

Created:	@12/01/2002		brian
Modified:	3/26/2003		brian
	Modified to allow the passing of combo's instead of hard
	coding them.  Also created the default capabilities of
	passing a default country to be selected.

Example:  FillState(NameOfCountryCombo, NameOfStateCombo, DefaultState)
*************************************************************/
function FillState(cboCountry, cboState, sDefaultState){
	var sDefaultState, sState, sDefault
		
	cboState.options.length=0
	for(i=0;i<sStateArray[cboCountry.selectedIndex].split("|").length;i++){
		sState = sStateArray[cboCountry.selectedIndex].split("|")[i];
		
		if(sDefaultState == sState) {
			sDefault=true;
			if (navigator.appName=="Microsoft Internet Explorer"){cboState.focus();}
		} 
		else {sDefault=false;}
		
		if(sDefault) {cboState.options[i]=new Option(sState,sState,sDefault,sDefault)}
		else {cboState.options[i]=new Option(sState,sState);}
	}	
		enableField()
		document.myform.Versions.value= '';
		document.myform.Versions.disabled=true;
		document.myform.Versions.removeItemAt(1);
}

function FillVersions(cboState, cboVersions, sDefaultVersions)
{
	var sDefaultVersions, sVersions, sDefault
		
	cboVersions.options.length=0;
	if(document.getElementById('Country').value == "Purchased" && document.getElementById('State').value == "Project Planner - PE Lite"||document.getElementById('Country').value == "Trial" && document.getElementById('State').value == "Project Planner - PE Lite" )
   {
	  for(i=0;i<sVersionsArray1[cboState.selectedIndex].split("|").length;i++)
	   {				
		sVersions = sVersionsArray1[cboState.selectedIndex].split("|")[i];	
		 if(sDefaultVersions == sVersions)
		 {
			sDefault=true;
			if (navigator.appName=="Microsoft Internet Explorer")
			{
				//cboVersions.focus();
			}
		} 
		else 
		{
			sDefault=false;
		}
		
		if(sDefault) 
		{
			cboVersions.options[i]=new Option(sVersions,sVersions,sDefault,sDefault)
		}
		else
		{
			cboVersions.options[i]=new Option(sVersions,sVersions);
		}
	}	
   }
	else
	{
			for(i=0;i<sVersionsArray[cboState.selectedIndex].split("|").length;i++)
	  {				
		sVersions = sVersionsArray[cboState.selectedIndex].split("|")[i];	
		 if(sDefaultVersions == sVersions)
		 {
			sDefault=true;
			if (navigator.appName=="Microsoft Internet Explorer")
			{
				//cboVersions.focus();
			}
		} 
		else 
		
		{
			sDefault=false;
		}
		
		if(sDefault) 
		{
			cboVersions.options[i]=new Option(sVersions,sVersions,sDefault,sDefault)
		}
		else
		{
			cboVersions.options[i]=new Option(sVersions,sVersions);
		}
	}	
 }
   enableField()
  

}
/*
function FillVersions1(cboCountry, cboVersions, sDefaultVersions){
	var sDefaultVersions, sVersions, sDefault
		
	cboVersions.options.length=0
	for(i=0;i<sVersionsArray1[cboCountry.selectedIndex].split("|").length;i++){
		sVersions = sVersionsArray1[cboCountry.selectedIndex].split("|")[i];
		
		if(sDefaultVersions == sVersions) {
			sDefault=true;
			if (navigator.appName=="Microsoft Internet Explorer"){cboVersions.focus();}
		} 
		else {sDefault=false;}
		
		if(sDefault) {cboVersions.options[i]=new Option(sVersions,sVersions,sDefault,sDefault)}
		else {cboVersions.options[i]=new Option(sVersions,sVersions);}
	}	
		
}

*/

function enableField() {

if(document.myform.Country.selectedIndex ==3)

document.myform.Versions.disabled=true;
else if (document.myform.Country.selectedIndex ==2)
//document.myform.Versions.selectedIndex=3;
document.myform.Versions.disabled=false;
else
{
document.myform.Versions.disabled=false;
}

}



var sCountryString = "|Purchased|Trial|Free Utilities"
		
var sStateArray = new Array()
sStateArray[0]=""
sStateArray[1]="|SmartWorks - PE|SmartWorks - HO|SmartWorks - SO|SmartWorks - Mini|SmartWorks - Prof|SmartWorks - Entp|Projekt Planner - Deutsch|Project Planner - PE Lite|Project Planner - PE|Project Planner - HO|Project Planner - SO|Project Planner - Mini|Project Planner - Prof|Project Planner - Entp|Meeting Manager - HO|Meeting Manager - SO|Meeting Manager - Mini|Smart Tracker - Mini|Smart Tracker - Prof|Smart Tracker - Entp"
sStateArray[2]="|SmartWorks - PE|SmartWorks - Entp|Project Planner - PE|Project Planner - Entp|Projekt Planner - Deutsch"
sStateArray[3]="|MPP2PPR Converter|PP Reader - English|PP Reader - Deutsch"
sStateArray[4]="|Project Planner - PE Lite"


var sVersionsArray = new Array()

sVersionsArray[0]=""
sVersionsArray[1]="|Ver4.5|Ver4.7|Ver4.8|Ver4.9"
sVersionsArray[2]="Ver4.9"
sVersionsArray[3]=""
sVersionsArray[4]="|Ver4.5|Ver4.7|Ver4.8"
/*
sVersionsArray[3]="|Ver4.0|Ver4.5|Ver4.7|Ver4.8"
sVersionsArray[4]="|Ver4.0|Ver4.5|Ver4.7|Ver4.8"
sVersionsArray[5]="|Ver4.0|Ver4.5|Ver4.7|Ver4.8"
sVersionsArray[6]="|Ver4.0|Ver4.5|Ver4.7|Ver4.8"
sVersionsArray[7]="|Ver4.8"
sVersionsArray[8]="|Ver4.8"
sVersionsArray[9]="|Ver4.0|Ver4.5|Ver4.7|Ver4.8"
sVersionsArray[10]="|Ver4.0|Ver4.5|Ver4.7|Ver4.8"
sVersionsArray[11]="|Ver4.0|Ver4.5|Ver4.7|Ver4.8"
sVersionsArray[12]="|Ver4.0|Ver4.5|Ver4.7|Ver4.8"
sVersionsArray[13]="|Ver4.0|Ver4.5|Ver4.7|Ver4.8"
sVersionsArray[14]="|Ver4.0|Ver4.5|Ver4.7|Ver4.8"
sVersionsArray[15]="|Ver4.0|Ver4.5|Ver4.7|Ver4.8"
sVersionsArray[16]="|Ver4.0|Ver4.5|Ver4.7|Ver4.8"
sVersionsArray[17]="|Ver4.0|Ver4.5|Ver4.7|Ver4.8"
sVersionsArray[18]="|Ver4.0|Ver4.5|Ver4.7|Ver4.8"
sVersionsArray[19]="|Ver4.0|Ver4.5|Ver4.7|Ver4.8"
sVersionsArray[20]="|Ver4.0|Ver4.5|Ver4.7|Ver4.8"
*/

var sVersionsArray1 = new Array()
sVersionsArray1[0]=""
sVersionsArray1[1]="|Ver4.5|Ver4.7|Ver4.8"
sVersionsArray1[2]="|Ver4.8|Ver4.9"
sVersionsArray1[3]=""
sVersionsArray[4]="|Ver4.5|Ver4.7|Ver4.8"

var sVersionsArray2 = new Array()
sVersionsArray1[0]=""
sVersionsArray1[1]="|Ver4.5|Ver4.7|Ver4.8"
sVersionsArray1[2]="|Ver4.8|Ver4.9"
sVersionsArray1[3]=""
sVersionsArray[4]="|Ver4.5|Ver4.7|Ver4.8"


