function uploadCheck() {
	if(document.getElementById('screenshot').value == "") {
		alert('You need to choose a picture to upload');
		return false;
	} else {
		return true;
	}	
}

function ofForw(id) {
	for(var i=0; i < document.forms["leftList"].length; i++) {
		moveDualList(document.forms["leftList"].elements[i], document.getElementById('ny_div_'+id));
	}
}

function ofBack(id) {
	for(var j=0; j < document.forms["rightList"].length; j++) {
		if(document.forms["rightList"].elements[j] != 'submit_form') {
			if(document.forms["rightList"].elements[j].type != 'hidden') {
				moveDualList(document.forms["rightList"].elements[j], document.getElementById('div_'+id));
			}
		}
	}
}

function onSub() {
	for(var j=0; j < document.forms["rightList"].length; j++) {
		if(document.forms["rightList"].elements[j].id != 'submit_form') {
			if(document.forms["rightList"].elements[j].type != 'hidden') {
				var temp = '';
				for(var h=0; h < document.forms["rightList"].elements[j].options.length; h++) {
					temp = temp + document.forms["rightList"].elements[j].options[h].value;
					if(h+1 != document.forms["rightList"].elements[j].options.length) temp = temp + ':';
				}
				document.getElementById(document.forms["rightList"].elements[j].id+'_hidden').value = document.getElementById(document.forms["rightList"].elements[j].id+'_hidden').value + temp;
			}
		}
	}
	return true;
}

function compareOptionValues(a, b) { 

  	// Radix 10: for numeric values
	// Radix 36: for alphanumeric values
  	
	var sA = parseInt( a.value, 36 );  
  	var sB = parseInt( b.value, 36 );  
  	return sA - sB;
}


function compareOptionText(a, b) { 
  	
	// Radix 10: for numeric values
  	// Radix 36: for alphanumeric values

  	var sA = parseInt( a.text, 36 );  
  	var sB = parseInt( b.text, 36 );  

  	return sA - sB;
}

function moveDualList(srcList, destList) {
  	if(srcList.selectedIndex == -1)  {
		return;
	}

	newDestList = new Array(destList.options.length);
	
	varlen = 0;

  	for(len = 0; len < destList.options.length; len++) {
    	if(destList.options[ len ] != null) {
      		newDestList[ len ] = new Option(destList.options[ len ].text, destList.options[ len ].value, destList.options[ len ].defaultSelected, destList.options[ len ].selected);
    	}
  	}

  	for(var i = 0; i < srcList.options.length; i++) { 
		if(srcList.options[i] != null && srcList.options[i].selected == true) {
       		newDestList[ len ] = new Option(srcList.options[i].text, srcList.options[i].value, srcList.options[i].defaultSelected, srcList.options[i].selected);
       		len++;
    	}
  	}

  	newDestList.sort(compareOptionValues);   // BY VALUES

  	//newDestList.sort(compareOptionText);   // BY TEXT
  
    for(var j = 0; j < newDestList.length; j++) {
    	if(newDestList[ j ] != null ) {
			destList.options[ j ] = newDestList[ j ];
			destList.options[ j ].selected = false;
		}
 	}
	
 	for(var i = srcList.options.length - 1; i >= 0; i--) {
    	if(srcList.options[i] != null && srcList.options[i].selected == true) {
       		srcList.options[i] = null;
    	}
  	}
}