function doSearch() {
	document.forms['srch'].a.value="search";
	document.forms['srch'].submit();
};

function rowHiLite(obj) {
	obj.style.backgroundColor = "#ffffff";
};

function rowLoLite(obj) {
	obj.style.backgroundColor = "#e3d7f4";
};

function showArtist(name) {
	document.forms['srch'].art.value = name;
	document.forms['srch'].sng.value = "";
	doSearch();
};

function updateDetails(url) {
	document.getElementById('songdet').innerHTML = "Querying...";
	// create new script element, set its relative URL, and load it
	script = document.createElement('script');
	// this next step requests the URL & therefor loads it
	script.src = url;
	document.getElementsByTagName('head')[0].appendChild(script);
};


function updateComparison() {
	document.getElementById('pkgdet').innerHTML = "Querying...";
	// create new script element, set its relative URL, and load it
	script = document.createElement('script');
	// get values for the url from the form -> pkgcomp.php?pkg1=000&pkg2=000
	url = 'pkgcomp.php?pkg1=' + document.forms['comp'].pkg1.value + '&pkg2=' + document.forms['comp'].pkg2.value;
	// this next step requests the URL & therefor loads it
	script.src = url;
	document.getElementsByTagName('head')[0].appendChild(script);
};

function updateSong(songId) {
	/*
	*/
	url = 'updatesong.php?id=' + songId + '&s=' + document.forms['songupdate'].st.value + '&d=' + document.forms['songupdate'].dt.value + '&n1=' + document.forms['songupdate'].n1.value + '&n2=' + document.forms['songupdate'].n2.value + '&r=' + document.forms['songupdate'].rp.value;
	document.getElementById('songdet').innerHTML = "Updating...";
	script = document.createElement('script');
	script.src = url;
	document.getElementsByTagName('head')[0].appendChild(script);
};

function showDiv(divName) {
	var theDiv = document.getElementById(divName);
	theDiv.style.visibility = 'visible';
	theDiv.style.display = '';
	posDiv(divName);
};

function getScrollingPosition() {
	var position = [0, 0];
	if (typeof window.pageYOffset != 'undefined')	{
		position = [window.pageXOffset, window.pageYOffset];
	} else if (typeof document.documentElement.scrollTop != 'undefined' && document.documentElement.scrollTop > 0) {
		position = [document.documentElement.scrollLeft, document.documentElement.scrollTop];
	} else if (typeof document.body.scrollTop != 'undefined') 	{
		position = [document.body.scrollLeft, document.body.scrollTop];
	};
	return position;
};

function posDiv(divName) {
	var theDiv = document.getElementById(divName);
	var w = 0;
	var h = 0;
	if (navigator.appName.indexOf('Microsoft') != -1) {
		w = document.body.clientWidth;
		h = document.body.clientHeight;
	} else {
		w = window.innerWidth;
		h = window.innerHeight;
	};
	var scrollpos = getScrollingPosition();
	theDiv.style.left = (w - 400)/2;
	//theDiv.style.top = (h - 300)/2 + scrollpos[1];
	theDiv.style.top = 100 + scrollpos[1];
};

function hideDiv(divName) {
	var theDiv = document.getElementById(divName);
	theDiv.style.visibility = 'hidden';
	theDiv.style.display = 'none';
};

function showPkg(id) {
	hideDiv('popup');
	document.location="http://www.unstableovine.net/singstardb/?pkg=" + id + "&a=pack";
};

function listPkg() {
	hideDiv('popup');
	document.location="http://www.unstableovine.net/singstardb/?a=packlist";
};

function keyUp(e) {
	if (e.keyCode == 13) {
		doSearch();
	};
};
