ie = navigator.appName.indexOf("Microsoft") != -1;
ns = navigator.appName.indexOf("Netscape") != -1;

function openscreenwindow (url) {
 fenster=window.open(url, "fenster1", "width=850,align=center height=650,status=no,scrollbars=yes,resizable=yes");
 fenster.focus();
}

function roll_over(img_name, img_src) {
	document[img_name].src = img_src;
}


function openlookup (url) {
 fenster=window.open("http://www.spotterpix.de/popup.php?action=lookup", "fenster1", "width=650,align=center,height=300,status=no,scrollbars=yes,resizable=no");
 fenster.focus();
}

function openedit (id) {
 fenster=window.open("http://www.spotterpix.de/popup.php?action=sc_up_edit&id="+id, "fenster1", "width=650,align=center,height=575,status=no,scrollbars=yes,resizable=no");
 fenster.focus();
}

function add_album (id) {
 fenster=window.open("http://www.spotterpix.de/popup.php?action=add_album&tag="+id, "fenster2", "width=450,align=center,height=110,status=no,scrollbars=no,resizable=no,location=no");
 fenster.focus();
}

function openupairport (url) {
 fenster=window.open("http://www.spotterpix.de/popup.php?action=sc_up_airport&tag="+url, "fenster2", "width=450,align=center,height=165,status=no,scrollbars=no,resizable=no,location=no");
 fenster.focus();
}

function openupairline (url) {
 fenster=window.open("http://www.spotterpix.de/popup.php?action=sc_up_airline&tag="+url, "fenster2", "width=450,align=center,height=130,status=no,scrollbars=no,resizable=no,location=no");
 fenster.focus();
}

function openupaircraft (url) {
 fenster=window.open("http://www.spotterpix.de/popup.php?action=sc_up_aircraft&tag="+url, "fenster2", "width=450,align=center,height=130,status=no,scrollbars=no,resizable=no,location=no");
 fenster.focus();
}

function iata(flughafen) {
	top.window.opener.document.uploadform['iata'].value = flughafen;
	window.close();
}

function addsmilie(smilie) {
	document.commentform.kommentar.value =
	document.commentform.kommentar.value + smilie;
}

function addavatar(avatar) {
	document.avatarurl.avatar.value =
	document.avatarurl.avatar.value = avatar;
}

function checkFormularSearch()
{

 if(document.searchform.aircraft_id.value == "")
  {
   alert("Bitte wählen Sie einen Flugzeugtypen aus!");
   document.searchform.aircraft_id.focus();
   return false;
  }

 if(document.searchform.airline_id.value == "")
  {
   alert("Bitte wählen Sie eine Fluggesellschaft aus!");
   document.searchform.airline_id.focus();
   return false;
  }
 
 if(document.searchform.airport_id.value == "")
  {
   alert("Bitte wählen Sie einen Flughafen aus!");
   document.searchform.airport_id.focus();
   return false;
  }

}

function checkFormularUpload()
{

  if(document.uploadform.bild.value == "")
   {
   alert("Bitte wählen Sie ein Bild aus!");
   document.uploadform.bild.focus();
   return false;
  }
 
 if(document.uploadform.fotograf.value == "")
  {
   alert("Bitte geben Sie Ihren Namen ein!");
   document.uploadform.fotograf.focus();
   return false;
  }

 if(document.uploadform.fotografmail.value == "")
  {
   alert("Bitte geben Sie Ihre E-Mail-Adresse ein!");
   document.uploadform.fotografmail.focus();
   return false;
  }
      if(document.uploadform.fotografmail.value.indexOf('@') == -1)
  {
   alert("Keine gueltige E-Mail-Adresse!");
   document.uploadform.fotografmail.focus();
   return false;
  }

 if(document.uploadform.lfzreg.value == "")
  {
   alert("Bitte geben Sie die Registrierung ein!");
   document.uploadform.lfzreg.focus();
   return false;
  }

 if(document.uploadform.flughafen.value == "")
  {
   alert("Bitte tragen Sie einen Flughafen ein!");
   document.uploadform.flughafen.focus();
   return false;
  }

 if(document.uploadform.airline_id.value == "")
  {
   alert("Bitte wählen Sie eine Fluggesellschaft aus!");
   document.uploadform.airline_id.focus();
   return false;
  }

 if(document.uploadform.actype_id.value == "")
  {
   alert("Bitte wählen Sie einen Flugzeugtypen aus!");
   document.uploadform.actype_id.focus();
   return false;
  }

 if(document.uploadform.agree.checked == false)
  {
   alert("Bitte akzeptieren Sie die Regeln, um fortzufahren.");
   document.uploadform.agree.focus();
   return false;
  }
  
 if(document.uploadform.submitbutton.disabled == false)
  {
   document.uploadform.submitbutton.disabled = true;
  }  

}

function checkFormularScreening()
{
 if(document.screenform.aktion.value == "0")
  {
   alert("Bitte eine Aktion auswählen!");
   document.screenform.aktion.focus();
   return false;
  }
}

function checkFormularRegister()
{
 if(document.registerform.name.value == "")
  {
   alert("Bitte geben Sie Ihren Namen ein!");
   document.registerform.name.focus();
   return false;
  }
 if(document.registerform.nickname.value == "")
  {
   alert("Bitte geben Sie Ihre gewünschte Login-ID an!");
   document.registerform.nickname.focus();
   return false;
}
 if(document.registerform.pwd.value == "")
  {
   alert("Bitte geben Sie Ihr Passwort an!");
   document.registerform.pwd.focus();
   return false;
  }
 if(document.registerform.pwdwdh.value == "")
  {
   alert("Bitte geben Sie Ihr Wiederholungspasswort an!");
   document.registerform.pwdwdh.focus();
   return false;
  }
 if(document.registerform.email.value == "")
  {
   alert("Bitte geben Sie Ihre E-Mail-Adresse ein!");
   document.registerform.email.focus();
   return false;
  }
      if(document.registerform.email.value.indexOf('@') == -1)
  {
   alert("Keine gueltige E-Mail-Adresse!");
   document.registerform.email.focus();
   return false;

  }
}

function checkFormularComments()
{
  if(document.commentform.kommentar.value == "")
   {
   alert("Please insert a comment! It is not allowed to submit a empty commentform. Thank You!");
   document.commentform.kommentar.focus();
   return false;
  }
}

function PopupScreeningPic(sPicURL) {
     window.open( "upload_popup.php?"+sPicURL, "","resizable=1,HEIGHT=200,WIDTH=200");
   } 

function hide_pn(id) {
    
    document.getElementById(id).style.display = 'none';
    document.getElementById("table_"+id).style.display = 'inline';   
}

function hide_upload(id) {
	document.getElementById("upload_"+id).style.display = 'none';
	document.getElementById("upload_hide_arrow_"+id).style.display = 'none';
	document.getElementById("upload_show_arrow_"+id).style.display = 'inline';
}

function show_upload(id) {
	document.getElementById("upload_"+id).style.display = 'inline';
	document.getElementById("upload_hide_arrow_"+id).style.display = 'inline';
	document.getElementById("upload_show_arrow_"+id).style.display = 'none';
}


function checkFormularUploadStep1() {
   
    document.getElementById("upload_form").style.display = 'none';
    document.getElementById("upload_status").style.display = 'inline';   
}

function confirmChangeRights() {
   return confirm("Wollen Sie die Zugriffsrechte wirklich ändern?");
}

function changeRights(id,id2) {
	if(confirmChangeRights(true)) {

		var inputId = document.createElement("INPUT");
		inputId.type = "hidden";
		inputId.value = id;
		inputId.name = "id";
		inputId.id = "id";
		document.getElementById("hiddenForm").appendChild(inputId);

		var inputId = document.createElement("INPUT");
		inputId.type = "hidden";
		inputId.value = id2;
		inputId.name = "id";
		inputId.id = "id";
		document.getElementById("hiddenForm").appendChild(inputId);

	
	}
} 

function changeBGColor() {
	document.getElementById('sc_table').style.backgroundColor = "darkblue";
}

function del_pn(aktion, id) {
	if(confirm_pn(true)) {

		var inputAktion = document.createElement("INPUT");
		inputAktion.type = "hidden";
		inputAktion.value = aktion;
		inputAktion.name = "aktion";
		inputAktion.id = "aktion";
		document.getElementById("hiddenForm").appendChild(inputAktion);
	
		var inputId = document.createElement("INPUT");
		inputId.type = "hidden";
		inputId.value = id;
		inputId.name = "id";
		inputId.id = "id";
		document.getElementById("hiddenForm").appendChild(inputId);
		document.getElementById("hiddenForm").submit();
	}
} 

function del_upload(id) {
	if(confirm_del_upload(true)) {

		var inputId = document.createElement("INPUT");
		inputId.type = "hidden";
		inputId.value = id;
		inputId.name = "id";
		inputId.id = "id";
		document.getElementById("hiddenForm").appendChild(inputId);

	
	}
} 

function confirm_pn() {
   return confirm("Bist du Dir sicher, dass du die Nachricht(en) löschen willst?");
}

function confirm_pn_dir() {
   return confirm("Soll der Ordner inklusiver aller Nachrichten wirklich entfernt werden?");
}

function del_pn_dir(id) {
  if(confirm_pn_dir(true)) {
    	var inputId = document.createElement("INPUT");
    	inputId.type = "hidden";
    	inputId.value = id;
    	inputId.name = "box_id";
    	inputId.id = "box_id";
    	document.getElementById("hiddenForm").appendChild(inputId);
    	document.getElementById("hiddenForm").submit();
  }
}   

function checkFormularPNSend()
{
 if(document.pn_send_form.pn_to.value == "" && document.pn_send_form.pn_member.value == "0") {
  {
   alert("Bitte geben Sie einen Empfänger ein!");
   document.pn_send_form.pn_to.focus();
   return false;
  }

}

 if(document.pn_send_form.betreff.value == "")
  {
   alert("Bitte geben Sie einen Betreff ein!");
   document.pn_send_form.betreff.focus();
   return false;
  }
 if(document.pn_send_form.text.value == "")
  {
   alert("Bitte geben Sie eine Nachricht ein!");
   document.pn_send_form.text.focus();
   return false;
  }
}

function cur_ins(field, startTag, endTag, offset) {
 field.focus();
 if (document.getSelection) { 
   selStart = field.selectionStart;
   selEnd = field.selectionEnd;
   text = field.value.substring(selStart, selEnd);
   field.value = field.value.substring(0, selStart) + startTag + text + endTag + field.value.substring(selEnd);
   if (text.length > 0) {
     if (offset != 0) {
       field.selectionStart = selStart + startTag.length + text.length - offset;
     } else {
       field.selectionStart = selStart + startTag.length + text.length + endTag.length;
     }
   } else {
      field.selectionStart = selStart + startTag.length;
   }
   field.selectionEnd = field.selectionStart;
 } else 
 if (document.selection) {
     marker = document.selection.createRange();
     text = marker.text;
     marker.text = startTag+text+endTag;
     marker = document.selection.createRange();
     if (text.length > 0) {
       if (offset != 0) {
         marker.move('character', startTag.length + text.length - offset);
       } else {
         marker.move('character', startTag.length + text.length + endTag.length + offset);
       }
     } else {
       marker.move('character', -(endTag.length));
     }
     marker.select();
  }
}
 