// JavaScript Document


// Admin PopUp

function adminPop(url, name)
{
 var width  = 600;
 var height = 600;
 var left   = (screen.width  - width)/2;
 var top    = (screen.height - height)/2;
 var params = 'width='+width+', height='+height;
 params += ', top='+top+', left='+left;
 params += ', directories=no';
 params += ', location=no';
 params += ', menubar=no';
 params += ', resizable=yes';
 params += ', scrollbars=yes';
 params += ', status=no';
 params += ', toolbar=no';
 newwin=window.open(url,'adminPop', params);
 if (window.focus) {newwin.focus()}
 return false;
}

function winPop(url,name,width,height)
{
 var left   = (screen.width  - width)/4;
 var top    = (screen.height - height)/4;
 var params = 'width='+width+', height='+height;
 params += ', top='+top+', left='+left;
 params += ', directories=no';
 params += ', location=no';
 params += ', menubar=no';
 params += ', resizable=yes';
 params += ', scrollbars=yes';
 params += ', status=no';
 params += ', toolbar=no';
 newwin=window.open(url,name, params);
 if (window.focus) {newwin.focus()}
 return false;
}

function replaceAndClose(url)
{
	opener.location.replace(url);
	self.close();	
}


function submitForm() {
//make sure hidden and iframe values are in sync before submitting form
//updateRTE('newText'); //use this when syncing only 1 rich text editor ("rtel" is name of editor)
updateRTEs(); //uncomment and call this line instead if there are multiple rich text editors inside the form
//alert(document.addTrackInfo.trackInfo.value) //alert submitted value
return true; //Set to false to disable form submission, for easy debugging.
}

function getValueByName(name) {
//make sure hidden and iframe values are in sync before submitting form
//updateRTE('newText'); //use this when syncing only 1 rich text editor ("rtel" is name of editor)
updateRTEs(); //uncomment and call this line instead if there are multiple rich text editors inside the form
var theValue = frames[name].document.body.innerHTML;

//var theValue = document.getElementById(name).contentWindow;
//alert(theValue);
return theValue;//alert submitted value
}

function makeInput(id,type,name)
{	
	var Output = '<input type="' + type + '" value="" name="' + name + '" id="' + name + '" maxlength="100";" />';
	document.getElementById(id).innerHTML = Output;
	document.getElementById(name).focus();
}
function deleteInput(id)
{
	document.getElementById(id).innerHTML = '';
}

function addValue(idTO,idFROM)
{
	document.getElementById(idTO).value = document.getElementById(idFROM).value;
}

function showEdit(element,id)
{
	var Output = ' <a href="../pop.php?a=14&artistId=' + id +'" class="minilink">Edit Artist</a>';
	
	if(id > 0)
	document.getElementById(element).innerHTML = Output;
}
function hideEdit(element,id)
{
	document.getElementById(element).innerHTML = '';
}


function showDiv(id)
{
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}
function hideDiv(id)
{
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function replaceDiv(id, replaceId) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(replaceId).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.replaceId.display = 'none';
		}
		else { // IE 4
			document.all.replaceId.style.display = 'none';
		}
	}
}

<!-- Adding an image to the TET EDIT window
function AddImage(imgSrc){
	var html = '<img src="' + imgSrc + '" width="' + document.form.width.value +'" heigth="auto" />';
	
	if(document.form.width.value == '' || document.form.width.value == ' ' || document.form.width.value == '  ' || document.form.width.value == '   '){
		var width = false;
	}
	else{
		var width = true;
	}
	
	if(width){
		window.opener.insertHTML(html);
		window.close();
	}
	else{
		alert('You need to fill in a width for your picture.');
	}
}

function submitFormAlbum()
{
	var msg = '';
	var answer = true;
	
	if(document.album.name.value == ''){
		msg = 'Enter an album name \n'; 	
		answer = false;
	}
	if(document.album.bandNameINT.value == 0){
		msg = msg + 'Enter a band name \n'; 	
		answer = false;
	}
	if(document.album.time.value == ''){
		msg = msg + "Enter album time \n"; 	
		answer = false;
	}
	if(document.album.cat.value == ''){
		msg = msg + "Enter catalog number \n"; 	
		answer = false;
	}
	if(document.album.releaseDate.value == ''){
		msg = msg + "Enter the release date \n"; 	
		answer = false;
	}
	if(document.album.image.value == ''){
		msg = msg + "Choose an album cover \n"; 	
		answer = false;
	}
	if(document.album.howMany.value == 0){
		msg = msg + "Choose personnel \n"; 	
		answer = false;
	}
	if(!answer) alert(msg);
	
	return answer;
	
}
function submitFormArtist()
{
	var msg = '';
	var answer = true;
	
	if(document.addArtistInfo.artistName.value == ''){
		msg = 'Enter a name \n'; 	
		answer = false;
	}
	if(!answer) alert(msg);
	
	return answer;
}

function submitFormUploadPics()
{
	var msg = '';
	var answer = true;
	
	if(document.upload.upFile.value == ''){
		msg = 'Pick a file \n'; 	
		answer = false;
	}
	if(!answer) alert(msg);
	
	return answer;
}

function submitFormTrack()
{
	var msg = '';
	var answer = true;
	
	if(document.addTrackInfo.name.value == ''){
		msg = 'Enter a name \n'; 	
		answer = false;
	}
	if(document.addTrackInfo.artist.value == 0){
		msg = 'Pick an artist \n'; 	
		answer = false;
	}
	if(!answer) alert(msg);
	
	return answer;
}

function changeImage(newImage)
{
	if (document.getElementById){
	opener.document.getElementById('image').value = newImage;
	opener.document.getElementById('edit').submit();
	self.close();
	}
}

function moveDiv(id,screenWidth, screenHeight) {
	if (document.getElementById) { // DOM3 = IE5, NS6
		//var divWidth = document.getElementById(id).style.width;
		//var divHeight = document.getElementById(id).style.height;
		document.getElementById(id).style.left = screenWidth / 2 - 200;
		document.getElementById(id).style.top = screenHeight / 2 - 150;
	}
		else {
			if (document.layers) { // Netscape 4
				document.id.style.left = screen.width / 2 -100 + document.body.scrollLeft;
				document.id.style.top = screen.height / 2 -140 + document.body.scrollTop;
			}
			else { // IE 4
				document.all.id.style.top = screen.height / 2 -140 + document.body.scrollTop;
				document.all.id.style.left = screen.width / 2 -100 + document.body.scrollLeft;
			}
		}	
	// Show the DIV
	showDiv(id);

}

function isVisibleDiv(id){
	var returnVal = '';
	
	if (document.getElementById) { // DOM3 = IE5, NS6
		if(document.getElementById(id).style.display == 'block')
			returnVal = true;
		else
			returnVal = false;
	}
		else {
			if (document.layers) { // Netscape 4
				if(document.id.style.display == 'block')
					returnVal = true;
				else
					returnVal = false;
			}
			else { // IE 4
				if(document.all.id.style.display == 'block')
					returnVal = true;
				else
					returnVal = false;
			}
			
		}
	return returnVal;
}

function readReview(id){
	
	// CLose down all other reviews currently being read
	for(var c = 1;c < 2000; c++){
		if(isVisibleDiv('readReview' + c))
			hideDiv('readReview' + c);
	}
	
	moveDiv(id);
}

function setViewCart(queryString){
	document.location.replace('setViewCart.php?' + queryString);
}	

function help(id,msg) {
		if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).innerHTML = msg; 
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.innerHTML(msg); 
		}
		else { // IE 4
			document.all.id.innerHTML(msg); 
		}
	}
	
	
	showDiv(id);
}

function writeDays(tot,inputId){
	var days;
	var dayId = 'day' + inputId;
	
	
	for(var i = 01; i <= tot; i++){
	
		if(i < 10)
			days = days + '<option value="0' + i + '" id="day0' + i + '_' + inputId + '">0' + i + '</option><br />';
		else
			days = days + '<option value="' + i + '" id="day' + i + '_' + inputId + '">' + i + '</option><br />';
	}
	
	// Insert inte the day select
	document.getElementById(dayId).innerHTML = days;
}


//-->
