//-- --------------------------------------------------------------------
//
//      AUTHOR :  Roman Zhovtulya
//
// JavaScript Library for Database Lab website
// --------------------------------------------------------------------
//
//      Versions :
//
//      date         version         By whoom and what was done
// --------------------------------------------------------------------
//      20.10.2002    V 1.0	     Roman, optimizing
//      
//                                  
//     
//
// --------------------------------------------------------------------

//function that closes the current window:

function closewindow()
{
   window.close();
}


//function that checkes user input:

function ValidForm(theForm)
{
  if (theForm.team_name.value == "")
  {
    alert("Please enter the team name!");
    theForm.team_name.focus();
    return (false);
  }

  if (theForm.student1.value == "")
  {
    alert("Please enter the name of the 1st member!");
    theForm.student1.focus();
    return (false);
  }

  if (theForm.student2.value == "")
  {
    alert("Please enter the name of the 2nd member!");
    theForm.student2.focus();
    return (false);
  }

}


// function to check whether the "name" input box is filled out at file upload in iLearning

function validFormUploadFile(theForm)
{
  if (theForm.dbFileName.value == "")
  {
    alert("Please put the file name");
    theForm.dbFileName.focus();
    return (false);
  }


}



//function that refreshes the target window to the location (LocString) provided
// (used for automatic refresh when select box value is changed):


function popUpNav(LocString,wTarget) 
{
	if (LocString != "") {
		wTarget.location.href = LocString;
	}
}






//function opens a window based on the provided information:

function openwindow (url, w, h, name) 
{

//window.open(url,name,'toolbar=no,resizable=yes,directories=no,status=no,scrollbars=yes,resize=no,menubar=no,width='+w+',height='+h);

child = window.open(url,name,'toolbar=no,resizable=yes,directories=no,status=no,scrollbars=yes,resize=no,menubar=no,width='+w+',height='+h);


}






// new function used to open a window in CMS editor in such a way that it would later be possible to close it and reload the parent page in Mozilla as well

function openwindowNew(url, w, h, name) 
{
child = window.open(url,name,'toolbar=no,resizable=yes,directories=no,status=no,scrollbars=yes,resize=no,menubar=no,width='+w+',height='+h);
}


function closeChild(elementNameToUpdate, elementValueToUpdate) {

child.close();
 
 parent.location.reload();

}




// function for closing the child window from within the child windowype=educationFHO&editType=ins
// (for administration "edit data" scrips):

// additional functionality to pass the element name and the new value to the parent
// window (used for informing the "list.jsp" element of the new id of the element 
// (in case there is a nested insert (e.g. during inserting the "educationFHO" (first level) we need to insert a new thesis)))

function endNow(elementNameToUpdate, elementValueToUpdate) 
{
 var urlToUpdateTo="";
if(opener.location.href.indexOf("?")>0)
   urlToUpdateTo=opener.location.href+'&'+elementNameToUpdate+'='+elementValueToUpdate;
else
   urlToUpdateTo=opener.location.href+'?'+elementNameToUpdate+'='+elementValueToUpdate;
opener.location.href=urlToUpdateTo;

window.close();

}






// function for loading the URL content into the parent window (used in FHO Portal search engine):

function loadIntoParent(url) {
 opener.location.href=url;
}



//function used in voting:

        function poll24_submit() 
        { 

		if (document.poll_form24.choice[0].checked) {var c2=1;} 

		else if (document.poll_form24.choice[1].checked) {var c2=2;} 

		else if (document.poll_form24.choice[2].checked) {var c2=3;} 
		else if (document.poll_form24.choice[3].checked) {var c2=4;} 
		


		else {alert("Please make your choice"); var c2=0;} 

		if (c2!=0){ myWin = open("presentation/components/vote.jsp?choice="+c2, "displayWindow", "width=450,height=450,status=no,toolbar=no,menubar=no");} 

        }







function checkUserNameAvailability(userNameIn, url, w, h, name)
{

child = window.open(url+'&userName='+userNameIn, name,'toolbar=no,resizable=yes,directories=no,status=no,scrollbars=yes,resize=no,menubar=no,width='+w+',height='+h);

}

function captchaReload(captchaImg)
{
    document.getElementById(captchaImg).src = document.getElementById(captchaImg).src + '#';
}
