//Java Script used for the BANDSTAND section at Bharat-Rakshak. 
//Created by Sachin Perinthalakkat .K

//Used by the Music pages to prepare a list of songs to be played in Sequence.
//This method was written by Louis Lau : Real Audio jukebox Visit: http://hkpopsite.virtualave.net
function addTitle(f)
{
	if(f.checked)
	{
		if(this.document.form1.text1.value == "")
		{
			this.document.form1.text1.value = f.name;
		}
		else
		{
			this.document.form1.text1.value = this.document.form1.text1.value + "," + f.name;
		}
	}
	else
	{
		if(confirm("This will erase the whole list. Are you sure?"))
		{	this.document.form1.text1.value = "";
			this.document.form1.reset();
		}else
		{	f.checked = true;
		}
	}
}	//addTitle ends

//validates a Music form, to see whether songs were selected on it.
function validateAll(form)
{
	if(form1.text1.value=="")
	{
		mess = "Please select the tunes from the list. \n";
		mess+="The selection is done by clicking on the check boxes \n";
		mess+="next to the tune name. For listening to a single tune, click \n";
		mess+="on the tune name.";
		alert(mess);
		return false;
	}
	return true;
}//validateAll ends

//checks all the check boxes in the form passed as a parameter. 
function checkAll(form)
{
	var numElements = form.elements.length;
	var tuneList = "";
	//alert("There are "+numElements+" in this form");
	//now loop through the elements and start selecting all the check boxes.
	//Do this only if the element is not a button, a hidden text field
	for(i=0;i<numElements;i++)
	{
		if(form.elements[i].type=="checkbox")
		{
			//alert("I found a checkbox with name:"+form.elements[i].name);
			form.elements[i].checked = true;
			if(tuneList=="")
			{
				tuneList = form.elements[i].name;
			}
			else
			{
				tuneList = tuneList+","+form.elements[i].name;
			}
		}
	}//looping through elements ends
	//set this up in the hidden field, and display the hidden field's contents
	form.text1.value = tuneList;
	//alert(form.text1.value);
	return true;
}//checkAll ends

