function displayArchDirFiles(table_to_display){
    for (var i=0; i<10; i++){
    var thisEleName='table_Episode_00'+i;
    var thisElement=document.getElementById(thisEleName);
      if (thisElement != null){
         thisElement.style.display='none';
      }
    }

    for (var i=10; i<100; i++){
      var thisEleNameTens='table_Episode_0'+i;
      var thisElementTens=document.getElementById(thisEleNameTens);
      if (thisElementTens != null){
         thisElementTens.style.display='none';
      }
    }
    document.getElementById(table_to_display).style.display='';
}


/*
* This scripts informs user about the size of the text area he is entering 
* and prevents entering long messages(>1000 chars) 
*/
function doTextAreaKeyUp(ele){
	if (ele.value.length>=1000)
	{
		alert ("your message length has reached the limit, submit it" );
	}
	else{
		var totalLeft = 1001-ele.value.length+' chars left)' ;
		var totalCharleft = '('+totalLeft; 
		document.getElementById('charCounter').innerHTML=totalCharleft ;
	}
  }
/**
 * called with menu mouseover event
 * @param elem
 * @return
 */
function doMenuMouseOver(tdId){
	 var ele = document.getElementById(tdId);
	 ele.style.color='#66ccff';
	 ele.style.cursor='pointer';
	 
}

/**
* called with menu mouseout event
* @param elem
* @return
*/
function doMenuMouseOut(tdId){
	var ele = document.getElementById(tdId);
	ele.style.color='#0000ff';
	ele.style.cursor='arrow';
	
}

/**
* called with menu selection event
* @param elem
* @return
*/

function doMenuSelect(target1, target2){
        submitRequestToServer(target1+".php", target1+".php");
}

function sendCommentsToServer(){
	var messageText = "Thank you "+document.forms[0].contactUserName.value+ " for your comments. "+
	"\nWe highly appreciate it.";
	alert(messageText);
	//clearContactUsForm();
	submitRequestToServer("contactus.php", "contactus.php");
	
}

function clearContactUsForm(){
	
	var nameToClear =document.forms[0].contactUserName;
	nameToClear.value='';
	nameToClear.focus();
	document.forms[0].contactUserEmail.value='';
	document.forms[0].contactSubject.value='';
	document.forms[0].contactMessageText.value='';	
}


function displaySigninFields(){
	document.getElementById("userNameRow").style.display='';
	document.getElementById("passwordRow").style.display='';
	document.getElementById("submitButtonRow").style.display='';
}

/*
*this function submits request to server to save the contents entered by user
*/
function submitToGuestbook(){
  	document.forms[0].feedbackSubmitName.value=document.forms[0].feedbackName.value;	
	document.forms[0].feedbackSubmitContent.value=document.forms[0].feedbackComment.value;	
        
    submitRequestToServer("guestbook.php", "guestbook.php");
}

/**
 * submits the login request to the server
 * @return
 */
function submitLogin(){
       document.forms[0].currentUserEmail.value=document.forms[0].loginEmail.value;
       document.forms[0].currentUserPassword.value=document.forms[0].loginPassword.value;
       document.forms[0].inputPageFormName.value=document.forms[0].name;
       submitRequestToServer("accon", "accon");	
}

function submitRequestToServer(targetPage, submitToAction ){
	document.forms[0].menuText.value=targetPage;
	document.forms[0].action=submitToAction;
	document.forms[0].submit();
}

function doRegister(){
	submitRequestToServer("register", "AppDispatcherServlet");
}

function uploadMovie(){
	submitRequestToServer("uploadMovieFile", "AppDispatcherServlet");
}

function doOnload(decTD){
	
	var tdtoDecorate =document.getElementById(decTD);
	tdtoDecorate.bgColor="#ffffff";
}

function playProgram(){
	var playerId = document.forms[0].moviePlayerList.value;
	document.getElementById("mplayer1").style.display='none';
	document.getElementById("mplayer2").style.display='none';
	document.getElementById("mplayer3").style.display='none';
	document.getElementById("mplayer4").style.display='none';
	var playerCode = "m"+playerId;
	var eleSelect = document.getElementById(playerCode);
	eleSelect.style.display='';
	
	
}

function logoutUser(){
	submitRequestToServer("userLogout", "AppDispatcherServlet");	
}


function showRegisterPage(){
	submitRequestToServer("register", "register");	
}

function checkForValidName(elem){
  var thisElementValue=elem.value;
  if (thisElementValue.length <3 ){
    alert("please enter a valid name");
  }
}

function checkForValidEmail(elem){
  var thisElementValue=elem.value;
  if (thisElementValue.length <4 ){
    alert("please enter a valid email");
  }
}

function checkForValidSubject(elem){
  var thisElementValue=elem.value;
  if (thisElementValue.length <2 ){
    alert("please enter a valid Subject");
  }
}

function doUserRegister(){
    document.forms[0].currentUserEmail.value=document.forms[0].regEmailId.value;
    document.forms[0].currentUserPassword.value=document.forms[0].regPassword.value;
    document.forms[0].inputPageFormName.value=document.forms[0].name;
    document.forms[0].currentUserName.value=document.forms[0].regUserName.value;
    document.forms[0].currentUserPasswordHint.value=document.forms[0].regPasswordHint.value;
    document.forms[0].currentUserAddress.value=document.forms[0].regAddress.value;
    document.forms[0].currentUserCity.value=document.forms[0].regCity.value;
    document.forms[0].currentUserState.value=document.forms[0].regState.value;
    document.forms[0].currentUserZip.value=document.forms[0].regZipCode.value;
    document.forms[0].currentUserCountry.value=document.forms[0].regCountry.value;
   submitRequestToServer("userreg", "userreg");  
}



function clearUserRegister(){
    document.forms[0].regEmailId.value='';
    document.forms[0].regPassword.value='';
    document.forms[0].regUserName.value='';
    document.forms[0].regPasswordHint.value=''
    document.forms[0].regAddress.value='';
    document.forms[0].regCity.value='';
    document.forms[0].regState.value='';
    document.forms[0].regZipCode.value='';
    document.forms[0].regCountry.value='';
}

function playCurrentProgram(progId){
    document.forms[0].programToPlay.value=progId;
    submitRequestToServer("video", "video");     
} 

