//-- --------------------------------------------------------------------
//
//      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 for closing the edit window and refreshing the parent
// (in administration "edit data" scrips):

function closeChild() {

child.close();
 
 self.location.reload();
}



// function for closing the child window from within the child window
// (for administration "edit data" scrips):

function endNow() {
 opener.location.href="JavaScript:closeChild()";
}






// 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 for implementation of fading of front images:

var exit=1

function clearname(value){
if (document.javaclear1.name.value == value)
	document.javaclear1.name.value = "";
}
function clearemail(value){
if (document.javaclear1.email.value == value)
	document.javaclear1.email.value = "";
}

cogdistFadeObjects = new Object();
cogdistFadeTimers = new Object();

function cogdistFade(object, destOp, rate, delta) {
if (!document.all)
  return
if (object != "[object]") {
  setTimeout("cogdistFade("+object+","+destOp+","+rate+","+delta+")",0);
  return;
}

clearTimeout(cogdistFadeTimers[object.sourceIndex]);
diff = destOp-object.filters.alpha.opacity;
direction = 1;
if (object.filters.alpha.opacity > destOp) {
  direction = -1;
}

delta=Math.min(direction*diff,delta);
object.filters.alpha.opacity+=direction*delta;
if (object.filters.alpha.opacity != destOp) {
  cogdistFadeObjects[object.sourceIndex]=object;
  cogdistFadeTimers[object.sourceIndex]=setTimeout("cogdistFade(cogdistFadeObjects["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);
}
}

function check() {
  var ext = document.f.image.value;
  ext = ext.substring(ext.length-3,ext.length);
  ext = ext.toLowerCase();
  if(ext != 'jpg') {
    alert('You selected a .'+ext+
          ' file; please select a .jpg file instead!');
    return false; }
    else
    return true; 
}




/* This script is constructing a loader button using the XMLHttpRequest object, 
     a very basic element of AJAX technology */

var stateTOC;

function ajaxLoader(url, contId, boxId) 
{  
    // Setting the button's status to 'OFF' and do not display any content on that state.
      if (stateTOC == 'ON') 
      {
        stateTOC ='OFF'
        document.getElementById(boxId).style.display = "none";
      }
      
    
    // Setting the button's status to 'ON' and load/display content. 
      else 
      {
        stateTOC = 'ON'
        document.getElementById(boxId).style.display = "inline";
            var XMLHttpRequestObject = false;
            
           // For Mozilla Browser create the request object
            if (window.XMLHttpRequest) 
            {
                XMLHttpRequestObject = new XMLHttpRequest();
            } 
            
           // for Internet Explorer
            else if (window.ActiveXObject) 
            {
                XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
            }
          
            if(XMLHttpRequestObject) 
            {
                var obj = document.getElementById(contId);
                XMLHttpRequestObject.open("GET", url, true);
                XMLHttpRequestObject.onreadystatechange = function()
                {
                   if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) 
                   {
                       obj.innerHTML = XMLHttpRequestObject.responseText;
                   }
                }
            
              XMLHttpRequestObject.send(null);
            }
      }
}

