/** --- Abhängige Funktionen (Masken, usw.) ---------------------------------------> **/

/* NOSC-spezifische Funktionen */

/* SYMBOLS */
function symbol_updatemask_showFileDialogForm(e,cb){
	if(cb.checked==true){
		e.innerHTML="<br>Klicken Sie auf <strong>Durchsuchen</strong><br><input name=\"image_update\" type=\"hidden\" value=\"true\"><br><label for=\"img\">Bild* (aktualisieren):</label><br><input type=\"file\" id=\"img\" name=\"img\">";	
	}else e.innerHTML="";
	
}

function symbol_mask_onSubmit(){
	if((document.symbol.name.value=='' || document.symbol.name.value.length==0)
		|| (document.symbol.alt.value=='' || document.symbol.alt.value.length==0)
		|| (document.symbol.img && document.symbol.img.value.length==0)
		|| (document.symbol.description=='' || document.symbol.description.value.length==0)){
		alert("Bitte füllen Sie die mit einem * gekennzeichneten Felder aus!");
		document.symbol.name.focus();
		return false;
	}else return true;
}

function symbolcat_mask_onSubmit(){
	if((document.symbolcat.name.value=='' || document.symbolcat.name.value.length==0)
		|| (document.symbolcat.title.value=='' || document.symbolcat.title.value.length==0)
		|| (document.symbolcat.descr=='' || document.symbolcat.descr.value.length==0)){
		alert("Bitte füllen Sie die mit einem * gekennzeichneten Felder aus!");
		document.symbolcat.name.focus();
		return false;
	}else return true;
}

function symbolcat_delete_dataset(base_url,s,w,sid,name,id){
	check = confirm("Wollen Sie den Datensatz "+name+" wirklich löschen?");
	if(check == true){
		self.location.href=base_url+"?s="+s+"&w="+w+"&id="+id+"&"+sid;
	}
}

/* PROVINCE */
function province_mask_onSubmit(){
	if(document.province.name.value=='' || document.province.name.value.length==0){
		alert("Bitte geben Sie einen Namen ein!");
		document.province.name.focus();
		return false;
	}else return true;
}

function province_delete_dataset(base_url,s,w,sid,name,id){
	check = confirm("Wollen Sie den Datensatz "+name+" wirklich löschen?");
	if(check == true){
		self.location.href=base_url+"?s="+s+"&w="+w+"&id="+id+"&"+sid;
	}
}

/* DISTRICT */
function district_insertmask_showFileDialogForm(e,cb){
	if(cb.checked==true){
		e.innerHTML="<br>Klicken Sie auf <strong>Durchsuchen</strong><br><br><label for=\"img\">Bild*:</label><br><input type=\"file\" id=\"img\" name=\"img\">";	
	}else e.innerHTML="";
	
}

function district_updatemask_showFileDialogForm(e,cb){
	if(cb.checked==true){
		e.innerHTML="<br>Klicken Sie auf <strong>Durchsuchen</strong><br><br><label for=\"img\">Bild* (aktualisieren):</label><br><input type=\"file\" id=\"img\" name=\"img\">";	
	}else e.innerHTML="";
	
}

function district_delete_dataset(base_url,s,w,sid,name,id){
	check = confirm("Wollen Sie den Datensatz "+name+" wirklich löschen?");
	if(check == true){
		self.location.href=base_url+"?s="+s+"&w="+w+"&id="+id+"&"+sid;
	}
}

function district_mask_onSubmit(){
	if(document.district.name.value=='' || document.district.name.value.length==0
		|| (document.district.img && document.district.img.value.length==0)){
		alert("Bitte füllen Sie die mit einem * gekennzeichneten Felder aus!");
		document.district.name.focus();
		return false;
	}else return true;
}

/* COUNTRY */
function country_delete_dataset(base_url,s,w,sid,name,id){
	check = confirm("Wollen Sie den Datensatz "+name+" wirklich löschen?");
	if(check == true){
		self.location.href=base_url+"?s="+s+"&w="+w+"&id="+id+"&"+sid;
	}
}

function country_mask_onSubmit(){
	if((document.country.name.value=='' || document.country.name.value.length==0)
		|| (document.country.int_char_code.value=='' || document.country.int_char_code.value.length==0)
		|| (document.country.int_area_code.value=='' || document.country.int_area_code.value.length==0)){
		alert("Bitte füllen Sie alle Felder aus!");
		document.country.int_area_code.focus();
		return false;
	}else return true;
}

/* LANGUAGE */
function language_mask_onSubmit(){
	if((document.language.name.value=='' || document.language.name.value.length==0)
		|| (document.language.int_language_code.value=='' || document.language.int_language_code.value.length==0)
		|| (document.language.img && document.language.img.value.length==0)
		){
		alert("Bitte füllen Sie alle Felder aus!");
		document.language.name.focus();
		return false;
	}else return true;
}

function language_insertmask_showFileDialogForm(e,cb){
	if(cb.checked==true){
		e.innerHTML="<br>Klicken Sie auf <strong>Durchsuchen</strong><br><label for=\"img\">Bild*:</label><br><input type=\"file\" id=\"img\" name=\"img\">";	
	}else e.innerHTML="";
	
}

function language_delete_dataset(base_url,s,w,sid,name,id){
	check = confirm("Wollen Sie den Datensatz "+name+" wirklich löschen?");
	if(check == true){
		self.location.href=base_url+"?s="+s+"&w="+w+"&id="+id+"&"+sid;
	}
}

/* USER */
function user_delete_dataset(base_url,s,w,sid,name,id){
	check = confirm("Wollen Sie den Datensatz "+name+" wirklich löschen?");
	if(check == true){
		self.location.href=base_url+"?s="+s+"&w="+w+"&id="+id+"&"+sid;
	}
}

function user_mask_onSubmit(){
  return true;
}

/** --- BACKEND-spezifische Funktionen ------------------------------------------> **/
function toggleAccommodationProperties(cb,id,cap_sess_value,fcap_sess_value){
	e = document.getElementById("accommodationproperties_"+id);
	if(cb.checked==true){
		e.innerHTML = "<br><label for=\"accommodationcapacity_"+id+"\" class=\"form_label\" style=\"margin-left: 25px; font-weight:bold; font-size:0.8em;\">Anzahl der Wohnpl&auml;tze insgesamt: </label>\n<input type=\"text\" name=\"accommodationcapacity_"+id+"\" id=\"accommodationcapacity_"+id+"\" value=\""+cap_sess_value+"\" size=\"4\" maxlength=\"10\" class=\"form_textfield_std\"><br>\n<label for=\"accommodationfreecapacity_"+id+"\" class=\"form_label\" style=\"margin-left: 25px; font-weight:bold; font-size:0.8em;\">Freie Pl&auml;tze: </label>\n<input type=\"text\" name=\"accommodationfreecapacity_"+id+"\" id=\"accommodationfreecapacity_"+id+"\" value=\""+fcap_sess_value+"\" size=\"4\" maxlength=\"10\" class=\"form_textfield_std\">";
	}else e.innerHTML="&nbsp;";
}

function confirmDelete(url){
	result = confirm('Möchten Sie den Datensatz tatsächlich löschen?');
	if(result != false) self.location.href=url;
}

function showDetails(id){
	//sid = <? echo SID; ?>;
	//details = window.open("detail.php?id="+id,"detail_window","width=550,height=400,resizable=yes,scrollbars=yes");
	details = window.open("http://www.atempo.at/nueva/app/index.php?action=view&ignore_offline=1&id="+id,"detail_window","width=550,height=450,resizable=yes,scrollbars=yes,menubar=yes");
	details.focus();
}

/** --- Unabhängige Funktionen --------------------------------------------------> **/

function form_jumpMenu(targ,selObj,restore){ 
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
	
	if(document.getElementById("facility_index_area") != null){
		e = document.getElementById("facility_index_area");
		e.innerHTML = "<br><span class=\"small_content\" style=\"font-weight:bold; color:#8CA8BD\">lade Liste ...</span>\n";
	}
}

function openTaskManager(userID, sid){
	taskWindow = window.open('taskmanager.php','nueva_online_task_manager','dependent=yes,height=450,width=500,scrollbars=yes');
}

function validateNumeric(o,label){
	if(!Number(o.value)){
		alert("Der Eingabewert von "+label+" ist ungültig! Sie müssen einen numerischen Wert mit max 11 Stellen eingeben.");
		o.value='';
		o.focus();
	}
}

function setFocusToFirstFormElement(form_id,elem_id){
	if(document.forms[form_id].elements[elem_id]) document.forms[form_id].elements[elem_id].focus();
}

function validateTextLength(o,len){
	if(o.value.length>len){
		alert("Sie haben die maximale Zeichenzahl erreicht! Es sind maximal "+len+" Zeichen erlaubt. Kürzen Sie Ihren Text.");
		return false;
	}
}

function showPic(imgSrc){
	//alert(imgSrc);
	picwin = window.open("../includes/showPic.php?src="+imgSrc,"PictureViewer","height=400,width=400,scrollbars=yes,resizable=yes");
	picwin.focus();
}

function exportCSV(facility_id){
	exportWin = window.open("../includes/exportCSV.php?id="+facility_id,"CSVExport","height=120,width=300,scrollbars=yes,resizable=yes");
	exportWin.focus();
}

function exportViewCSV(facility_ids){
	exportWin = window.open("../includes/exportCSV.php?ids="+facility_ids,"CSVExport","height=120,width=300,scrollbars=yes,resizable=yes");
	exportWin.focus();
}

function movieFullScreen(id){
  win = window.open("","Fullscreen","left=0,top=0,height=" + screen.availHeight + ",width=" + screen.availWidth + ",location=no,menubar=no,resizable=no,scrollbars=no,status=no");
  win.document.write("<html><head><title></title><style>body{background-color:#333;}</style></head><body><p><object type='application/x-shockwave-flash' data='http://83.64.150.247/nueva/vdo_player/vdo_service.php?id="+id+"&fullScreenButton=2' width='100%' height='100%'>  <param name='movie' value='http://83.64.150.247/nueva/vdo_player/vdo_service.php?id="+id+"&fullScreenButton=2' />  <param name='quality' value='high' />  </object> </p></body></html>");
}
