function thirdMenu(someID,someClass)
{
	document.getElementById(someID).className=someClass;
}

function iconDrop(pstext)
{
     document.getElementById('divIconDrop').innerHTML=pstext;
     document.getElementById('divIconDrop').backGroundColor='#99B3B3';
}

function popSubscribe()
{
	window.open('subscribe06.php','newsletter', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=yes,width=400,height=400');
}

function openReminder(iAllowTrainingContact)
{
	if (iAllowTrainingContact==null)
		iAllowTrainingContact=0;
	
	window.open('cda_reminder.php?at='+iAllowTrainingContact,'reminder','toolbar=0, scrollbars=0, location=0,top=0,left=0,statusbar=0, menubar=0, resizable=no, width=205, height=250');	
}

function chooseContinent()
{
	var stateSelect=document.forms['cvsubmit'].inpState;
	if (stateSelect.length>0 && stateSelect.options[0]!='')
	{
		for (var i=0;i<stateSelect.length;i++)
		{
			stateSelect.options[i].selected=false;	
		}
	}	
	
	var countrySelect=document.forms['cvsubmit'].inpCountrySelect;
	if (countrySelect.length>0 && countrySelect.options[0]!='')
	{
		for (var i=0;i<countrySelect.length;i++)
		{
			countrySelect.options[i].selected=false;	
		}
	}
	
	var thisCont=document.getElementById('inpContinent');

	var thisArrow=document.getElementById('divContinentArrow').style;
	
	if (thisCont.value.indexOf('nywhere')>0)
	{
		thisArrow.visibility='hidden';	
	}
	else
	{
		thisArrow.visibility='visible';
	}
	
	var countryList=document.getElementById('divCountries').style;
	var countryArrow=document.getElementById('divCountryArrow').style;
	var stateList=document.getElementById('divStates').style;
	countryList.visibility='hidden';
	countryArrow.visibility='hidden';
	stateList.visibility='hidden';
}

function chooseCountry()
{
	var stateSelect=document.forms['cvsubmit'].inpState;
	if (stateSelect.length>0 && stateSelect.options[0]!='')
	{
		for (var i=0;i<stateSelect.length;i++)
		{
			stateSelect.options[i].selected=false;	
		}
	}	
	
	var thisCont=document.getElementById('inpContinent');
	var countrySelect=document.forms['cvsubmit'].inpCountrySelect;
	
	var thisArrow=document.getElementById('divCountryArrow').style;
	
	if (countrySelect.options[0].selected==true)
	{
		thisArrow.visibility='hidden';
	}
	else
	{
		var nSelected=0;
		
		for (var i=0;i<countrySelect.length;i++)
		{
			if (countrySelect.options[i].selected==true)
			{
				nSelected=nSelected+1;
			}
		}
		
		if (nSelected>1)
		{
			thisArrow.visibility='hidden';
		}
		else
		{
			thisArrow.visibility='visible';
		}
				
	}
	
	var stateList=document.getElementById('divStates').style;
	stateList.visibility='hidden';
}

function changeLocations()
{
	var stage=document.getElementById('stage');
	
	stage.value=1;
	
	document.forms['stage1'].submit();
}

//adding and removing brands from listing

function addToMyList()
{
	var brandListSelect=document.forms['frmBrands'].brandlist;
	
	for (var i=0;i<brandListSelect.length;i++)
	{
		if (brandListSelect.options[i].selected==true)
		{
			//alert('name: '+brandListSelect.options[i].text+'<br>value: '+brandListSelect.options[i].value);
			addOptionToList(brandListSelect.options[i].text,brandListSelect.options[i].value);
		}
	}
}

function addOptionToList(optionText,optionValue)
{
	//var myBrandSelect=document.forms['frmBrands'].inpMyBrands;
	var myBrandSelect=document.getElementById('inpMyBrands');
	var bIsChosen=false;
	
	if (myBrandSelect.options.length>0)
	{
		for (var i=0;i<myBrandSelect.options.length;i++)
		{
			if (myBrandSelect.options[i].value==optionValue)
			{
				bIsChosen=true;
			}
		} 
	}
	
	if (bIsChosen==false)
	{
		var selectLength=myBrandSelect.options.length;
		
		myBrandSelect.options[selectLength]=new Option(optionText,optionValue);
	}
}

function deleteFromMyList()
{
	//var myBrandSelect=document.forms['frmBrands'].inpMyBrands;
	var myBrandSelect=document.getElementById('inpMyBrands');
	
	alert(myBrandSelect.options.length);
	
	for (var i=0;i<myBrandSelect.options.length;i++)
	{
		if (myBrandSelect.options[i].selected==true)
		{
			alert(myBrandSelect.options[i].text);
			myBrandSelect.options[i]=null;
		}
	}
}

function selectAllNewBrands()
{
	var myBrandSelect=document.getElementById('inpMyBrands');
	for (var i=0;i<myBrandSelect.options.length;i++)
	{
		myBrandSelect.options[i].selected=true;
	}
}

function addNewClass(fromList)
{
	var classSelect=document.getElementById('newclass');
	var classCount=document.getElementById('classes');
	var nextClass=parseInt(classCount.value) + 1;
	var newClass=document.getElementById('class_'+nextClass);

	if (fromList==true)
	{
		for (var i=0;i<classSelect.options.length;i++)
		{
			if (classSelect.options[i].selected==true && classSelect.options[i].value!='')
			{
				newClass.value=classSelect.options[i].value;
				classCount.value=nextClass;		
				document.forms['ceupoints'].submit();
			}
		}
	}
	else
	{	
		newClass.value=document.getElementById('originalcourse').value;
		classCount.value=nextClass;		
		document.forms['ceupoints'].submit();
	}
}

function deleteClass(classNumber)
{
	var classCount=document.getElementById('classes');
	var pastClass=parseInt(classCount.value) - 1;
	
	for (var i=classNumber;i<=classCount.value;i++)
	{
		var n=parseInt(i)+1;		
		var className=document.getElementById('class_'+i);
		var classDate=document.getElementById('classdate_'+i);
		
		if (i==classCount)
		{
			className.value='';
			classDate.value='';
		}
		else
		{
			var nextClassName=document.getElementById('class_'+n);
			var nextClassDate=document.getElementById('classdate_'+n);
			
			className.value=nextClassName.value;
			classDate.value=nextClassDate.value;
		}
	}
	
	classCount.value=pastClass;
	document.forms['ceupoints'].submit();
}

function chooseCEUCategory()
{
	var CEUCat = document.getElementById('classcategory').value;
	
	if (CEUCat!='')
	{
		document.forms['ceupoints'].submit();
	}
}
