////////////////////////////////////////////////////////////////
//
// wScript.js für die Anwendung Download-Bereich
// erstellt durch Scholl Communications AG, 77694 Kehl, www.scholl.de
// erstellt mit Weblication® Content Management Server, www.weblication.de
//
////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////
//
// Anzupassende Variablen:
//
// Aktiviert den Cachemodus (0 = aus, 1 = ein).
var cacheMode = 0;
//
//erscheint wenn ein Pflichtfeld nicht ausgefüllt wurde
var messageObligation = " ist ein Pflichtfeld!\n"; 
////////////////////////////////////////////////////////////////

function openDownloadWin(filename){
  winDownload = window.open('/Elstar-deutsch/downloads_1/download.php' + '?filename=' + filename, 'downloadWin', 'width=300, height=150, resizable=no, scrollbars=no');
  window.setTimeout("writeDownloadString()", 2000);
  centerPopup(winDownload, 300, 150);
}

function writeDownloadString(){
  winDownload.document.write('<html>\n<head>\n');
  winDownload.document.write('<title>Download</title>\n');
  winDownload.document.write('</head>\n');
  winDownload.document.write('<body>\n');
  winDownload.document.write('<div class=\'elementSpacer\'>&nbsp;</div>');
  winDownload.document.write('<div style=\'width:95%;text-align:center\'>\n');
  winDownload.document.write('<span class=\'text\'>herunterladen</span>\n<br />\n<br />\n');
  winDownload.document.write('<a href=\'javascript:self.close();\' style=\'text-decoration:none;\'>schliessen</a>\n');
  winDownload.document.write('</div>\n');
  winDownload.document.write('</body>\n');
  winDownload.document.write('</html>');  
}

function centerPopup(winName, width, height){
   var xValue = (screen.width / 2) - (width / 2);
   var yValue = (screen.height / 2) - (height / 2);
   
   winName.moveTo(xValue, yValue);
   winName.focus();
}


////////////////////////////////////////////////////////////////
//
// Beschreibung: Oeffnet das Fenster zur Dateiauswahl
//
////////////////////////////////////////////////////////////////

function openWin(){
  var win = window.open('/cgi-bin/wDir.cgi?path=<!--PRC:ENV name="dirInclude"-->', 'dirWin', 'width=700, height=700, scrollbars=yes');
}


////////////////////////////////////////////////////////////////
//
// Beschreibung: Sendet das Formular
// 
// Parameter: form = Formular, das gesendet werden soll.
//
////////////////////////////////////////////////////////////////

function submitForm(frmUploadFileDownload){

  var checkfiledest = document.frmUploadFileDownload.filedest.value;
  var filedest = checkfiledest.match(/[FILETYPEDEST]/);

  var checkfile = document.frmUploadFileDownload.file.value;
  var fileType  = checkfile.replace(/.+\.([^\.]+)$/, '$1');
	
	// Prueft, in welches Zielverzeichnis die ausgewaehlte Datei hochgeladen werden soll:

  if(fileType == "xls"){
    //alert('xls');
    checkfiledest = checkfiledest.replace(/FILETYPEDEST/,"xls");
    document.frmUploadFileDownload.filedest.value = checkfiledest;
  }    
  else if(fileType == "pdf"){
    //alert('pdf');
    checkfiledest = checkfiledest.replace(/FILETYPEDEST/,"pdf");
    document.frmUploadFileDownload.filedest.value = checkfiledest;
  }
  else if(fileType == "doc"){
    //alert('doc');
    checkfiledest = checkfiledest.replace(/FILETYPEDEST/,"doc");
    document.frmUploadFileDownload.filedest.value = checkfiledest;
  }
	else{
		alert('Dieser Dateityp wird nicht unterstützt!\nWählen Sie eine andere Datei aus!\n');
		 return false;
	}
	
	if(document.getElementsByName("frmUploadFileDownload")[0].file.value == ""){
		alert('Bitte wählen Sie noch eine Datei aus!');
		  document.frmUploadFileDownload.file.focus();
	}
	else{
		document.getElementsByName("frmUploadFileDownload")[0].submit();
	}
  
	if(document.getElementsByName("frmUploadFileDownload")[0].headline.value == ""){
		alert('Bitte geben Sie eine Überschrift an!');
		  document.frmUploadFileDownload.headline.focus();
	}
	else{
	  var headlineBefore = document.getElementsByName("frmUploadFileDownload")[0].headline.value;
	  var headline = headlineBefore.replace(/"/g, " ");
	  var headline = headlineBefore.replace(/'/g, " ");
		document.getElementsByName("frmUploadFileDownload")[0].submit();
	}
}





////////////////////////////////////////////////////////////////
//
// Beschreibung: Blendet Container aus bzw. ein
//
////////////////////////////////////////////////////////////////

function wToggleSettings(){
  element = document.getElementById('settings');
  if(element.style.display == 'block'){
     element.style.display = 'none';
     document.getElementById('toggleBar').firstChild.nodeValue = "Uploadmaske öffnen";
  }
  else{
    element.style.display = 'block';
    document.getElementById('toggleBar').firstChild.nodeValue = "Uploadmaske schliessen";
  }                      
}


