function AddSrcToDest(source,destin){
	locsrc = document.getElementById(source);
	locdest = document.getElementById(destin);

    if (locsrc.selectedIndex != -1){	
		var localready = 0;
	
		//Check To See If It's allready in the list
		for (var check=0; check <= (locdest.options.length); check++){
			if (locdest.options[check] != null){
				if (locdest.options[check].value == locsrc.options[locsrc.selectedIndex].value){
					localready = 1;
				}
			}
		}
		
		if (localready == 1){
			alert('Item '+locsrc.options[locsrc.selectedIndex].text+' is already on the list');
		}else{
			
			if ((locStart+1) <= locLimit){
				loclen = locdest.options.length++;
				locdest.options[loclen].value = locsrc.options[locsrc.selectedIndex].value;
				locdest.options[loclen].text = locsrc.options[locsrc.selectedIndex].text;
				locStart++;
				updateRemain(1);
			}else{
				alert('You have reached your Desired Location limit');
			}
		}
	}
}

function AddSrcToSect(source1,source2,destin){
	src1 = document.getElementById(source1);
	src2 = document.getElementById(source2);
	dest = document.getElementById(destin);

    if (src1.selectedIndex != -1 && src2.selectedIndex != -1){	
		var already = 0;
	
		//Check To See If It's allready in the list
		for (var check=0; check <= (dest.options.length); check++){
			if (dest.options[check] != null){
				if (dest.options[check].value == src2.options[src2.selectedIndex].value){
					already = 1;
				}
			}
		}
		
		if (already == 1){
			if (src2.options[src2.selectedIndex].value == '') {
				alert('Item '+src1.options[src1.selectedIndex].text+' is already on the list');
			} else {
				alert('Item '+src1.options[src1.selectedIndex].text+' -> '+src2.options[src2.selectedIndex].text+' is already on the list');
			}
		}else{
			
			if ((secStart+1) <= secLimit){
				newslot = dest.options.length++;
				if (src2.options[src2.selectedIndex].value == '') {
					dest.options[newslot].value = src1.options[src1.selectedIndex].value;
					dest.options[newslot].text = src1.options[src1.selectedIndex].text;
				} else {
					dest.options[newslot].value = src2.options[src2.selectedIndex].value;
					dest.options[newslot].text = src1.options[src1.selectedIndex].text+' -> '+src2.options[src2.selectedIndex].text;
				}
				secStart++;
				updateRemain(0);
			}else{
				alert('You have reached your sector limit');
			}
		}
	}
}

function AddLangToDest(source,destin){
	langsrc = document.getElementById(source);
	langdest = document.getElementById(destin);

    if (langsrc.selectedIndex != -1){	
		var langalready = 0;
	
		//Check To See If It's allready in the list
		for (var check=0; check <= (langdest.options.length); check++){
			if (langdest.options[check] != null){
				if (langdest.options[check].value == langsrc.options[langsrc.selectedIndex].value){
					langalready = 1;
				}
			}
		}
		
		if (langalready == 1){
			alert('Item '+langsrc.options[langsrc.selectedIndex].text+' is already on the list');
		} else {
			
			if (langsrc.options[langsrc.selectedIndex].value != ''){
				langlen = langdest.options.length++;
				langdest.options[langlen].value = langsrc.options[langsrc.selectedIndex].value;
				langdest.options[langlen].text = langsrc.options[langsrc.selectedIndex].text;
			}else{
				alert('You cannot add the item you have selected');
			}
		}
	}
}

function SelectAll(destin){
	//src = document.getElementById(source);
	dest = document.getElementById(destin);
	destlen = dest.options.length;
	for (var loop = 0; loop <= destlen; loop++){
		if (dest.options[loop] != null){
			dest.options[loop].selected = true;
		}
	}
	//window.document.forms[0].submit();
}

function RemoveItem(type,destin){
	dest = document.getElementById(destin);
	
	//Are They any to selected if not don't remove any
	do {
		for (var check=0; check <= (dest.options.length); check++){
			if (dest.options[check] != null){
				if (dest.options[check].selected == true){
					dest.options[check] = null;
					if (type == 1) {
						locStart--;
						updateRemain(1);
					}
					if (type == 0) {
						secStart--;
						updateRemain(0);
					}
				}
			}
		}
	} while(nomorechecked(destin));
}

function nomorechecked(object){
	dest = document.getElementById(object);
	
	var found;
	found = false;
	for (var check=0; check <= (dest.options.length); check++){
		if (dest.options[check] != null){
			if (dest.options[check].selected == true){
				found = true;
			}
		}
	}
	
	if (found){
		return true
	}else{
		return false
	}
}
