function add_screenshot_div(){
  var ni = document.getElementById('screenshots_list');
  var numi = document.getElementById('sc_int');
  var num = (document.getElementById('sc_int').value -1)+ 2;
  numi.value = num;
  var newdiv = document.createElement('li');
  var divIdName = 'sc'+num;
  newdiv.setAttribute('id',divIdName);
  newdiv.innerHTML = "<input type='button' name=''  value='X' onclick=\"remove_screenshot_div('"+divIdName+"')\" /> Title<br /><input name='"+divIdName+"_title' maxlength='30' type='text' style='width: 500px;' /> <br />File<br /><input name='"+divIdName+"_file' type='file' size='50' style='width: 500px;' /> <br />Description<br /><textarea name='"+divIdName+"_description' rows='1' cols='25' style='width: 500px;'></textarea><br />";
  ni.appendChild(newdiv);
}

function remove_screenshot_div(divNum) {
  var d = document.getElementById('screenshots_list');
  var olddiv = document.getElementById(divNum);
  d.removeChild(olddiv);
}

function trim(sString){
	while (sString.substring(0,1) == ' '){
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' '){
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}

function set_upload(){
	$('upload_button').value = 'Uploading...';
	$('upload_img').style.display = 'block';
}

function rate(set_id, your_rating){
	new Ajax.Updater('rating', '/shots/rate/'+set_id+'/'+your_rating+'?ajax=true');
}

function add_to_favourites(set_id){
	new Ajax.Updater('favourites', '/user/favourites/add/'+set_id+'?ajax=true');
}