function inputclass() {
	for (var j=0;j<document.forms.length;j++) {
		for (var i=0;i<document.forms[j].elements.length;i++) {
			document.forms[j][i].className=document.forms[j][i].type
		}
	}
}

function normalize(s) {
	var ret
	ret=decodeURI(s)
	ret=ret.replace('https://sonic.dnsalias.net/Warez/Audioz/FLACz/','')
	return ret
}

function clickedQuality() {
	with(document.forms[0]) {
		unit[0].checked=true
		quality.disabled=false
		max_bitrate.disabled=true
	}
}

function clickedBitrate() {
	with(document.forms[0]) {
		unit[1].checked=true
		quality.disabled=true
		max_bitrate.disabled=false
		max_bitrate.focus()
	}
}

function clickedAdd() {
	var s=normalize(document.forms[0].path.value) // because of "with"
	with(document.forms[0]) {
		if(path.value.length) {
			playlist.options.add(new Option(s),playlist.selectedIndex)
			path.value=''
			//changedPath();
			//alert(playlist.size)
			if(playlist.options.length==1) playlist.size=2
			else playlist.size=playlist.options.length
			//if(playlist.selectedIndex==-1) playlist.selectedIndex=0
			//document.getElementById('rowPlaylist').style.display='block'
			playlist.style.display='block'
			changedPlaylist()
		}
	}
}

function clickedRemove() {
	with(document.forms[0]) {
		var i=playlist.selectedIndex
		playlist.remove(i)
		if(playlist.options.length > 1) playlist.size=playlist.options.length
		//else document.getElementById('rowPlaylist').style.display='none'
		if(playlist.options.length == 0) playlist.style.display='none'
		if(i==playlist.options.length) i=playlist.options.length-1
		playlist.selectedIndex=i
		changedPlaylist()
	}
}

function move(dir) {
	var _dir=dir // because of "with"
	with(document.forms[0]) {
		var i=playlist.selectedIndex
		var t=playlist.options[i+_dir].text
		playlist.options[i+_dir].text=playlist.options[playlist.options.selectedIndex].text
		playlist.options[playlist.options.selectedIndex].text=t
		playlist.selectedIndex=i+_dir
		changedPlaylist()
	}
}

function changedPlaylist() {
	with(document.forms[0]) {
		if(playlist.selectedIndex != -1) {
			remove.disabled=false
			if(playlist.selectedIndex < 1) up.disabled=true
			else up.disabled=false
			if(playlist.selectedIndex >= playlist.options.length-1) down.disabled=true
			else down.disabled=false
		} else {
			remove.disabled=true
			up.disabled=true
			down.disabled=true
		}
	}
}

/*function changedPath() {
	with(document.forms[0]) {
		if(path.value.length!=0) add.disabled=false
		else add.disabled=true
	}
}*/

function submitted() {
	var s=normalize(document.forms[0].path.value) // because of "with"
	with(document.forms[0]) {
		path.value=s
		for(var i=0;i<playlist.options.length;i++) playlist.options[i].selected=true
	}
}

