function getObj(id) {
	return document.getElementById(id);
}

function checkGenre(obj) {
	var val = obj.options[obj.selectedIndex].value;
	var box = getObj("genre_other_box");
	if(val==0) {
		box.style.display = "block";
	} else {
		box.style.display = "none";
	}
	return false;
}
function checkArtist(obj) {
	var val = obj.options[obj.selectedIndex].value;
	var box = getObj("artist_other_box");
	if(val==0) {
		box.style.display = "block";
	} else {
		box.style.display = "none";
	}
	return false;
}
function checkAlbum(obj) {
	var val = obj.options[obj.selectedIndex].value;
	var box = getObj("album_other_box");
	if(val==0) {
		box.style.display = "block";
	} else {
		box.style.display = "none";
	}
	return false;
}
function toggleCPlaylist() {
	var box = getObj("create_playlist_box");
	if(box.style.display == "block") {
		box.style.display = "none";
	} else {
		box.style.display = "block";
	}
	return void(0);
}
function addMozillaPanel(url) {
	if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")) {
		window.sidebar.addPanel ("Community Music Player ",url,"");
	} else {
        var rv = window.confirm ("Music Player Sidebar requires a compatible browser. Do you want to upgrade?");
        if (rv)
			document.location.href = "http://www.getfirefox.com";
    }
}
function toggleCheckboxes(obj) {
	var boo = obj.checked;
	var list = obj.form;
	for(var i=0;i<list.length;i++) {
		if(list[i].type == "checkbox" && list[i] != obj)
			list[i].checked = boo;
	}
}
function proccessUpload() {
	var size = Math.round(132 / 2);
	var obj = getObj("upload-bar");
	var darkness = getObj("upload-blankout");
	darkness.style.display = "block";
	obj.style.display = "block";
	var width = (window.innerWidth) ? window.innerWidth : document.body.clientWidth;
	var height = (window.innerHeight) ? window.innerHeight : document.body.clientHeight;
	obj.style.top = (Math.round(height/2) - size) + "px";
	obj.style.right = (Math.round(width/2) - size) + "px";
	return true;
}
var emailchr = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_@.";
function res(t,v){
	var w = "";
	for (i=0; i < t.value.length; i++) {
		x = t.value.charAt(i);
		if (v.indexOf(x,0) != -1)
			w += x;
	}
	t.value = w;
}

function openPlayer(url) {
	window.open(
		url,
		'CMPlayer',
		'status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=0,width=350,height=175'
	);
	return void(0);
}
function togglePlaylister(obj) {
	var but = getObj('submitButton');
	var playl = getObj('playlist');
	if(obj.options[obj.selectedIndex].value == 'addToPlaylist') {
		playl.style.display='inline';
		but.value = "Add To Playlist";
	} else {
		playl.style.display='none';
		but.value = "Delete Selected";
	}
}
function actionCheck() {
	var act = getObj('action');
	if(act.value == "action") {
		alert("Please Select an Action");
		return false;
	} else if(act.value == "delete") {
		return confirm("Are you sure you want to delete the selected songs");
	} else {
		return true;
	}
}
function searchJump(obj,page) {
	var p = getObj('p');
	p.value = page;
	obj.form.submit();
}