testAlert = function(a) {
alert(a);
}

popup = function (url,width,height) {
 fenster = window.open(url, "Popupfenster", "width="+width+",height="+height+",resizable=no,toolbar=no,status=no'");
 fenster.focus();
 return false;
}
pause = function (milliseconds) {
	var dt = new Date();
	while ((new Date()) - dt <= milliseconds) { /* Do nothing */ }
}

// Ajax updater für prototype.js 
ajaxUpdater = function(id,url) {    new Ajax.Updater(id,url,{asynchronous:true, evalScripts:true, encoding:'iso-8859-1'});   }   

// correctly handle PNG transparency in Win IE 5.5 & 6.
function correctPNG() 
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (version < 8.0) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    
}
var browserName=navigator.appName;
if (browserName=="Microsoft Internet Explorer")
 {
	window.attachEvent("onload", correctPNG);
}
// nach anlegen eines neuen produktes
disableNeu = function (){
	document.getElementById("neu").checked = false;
}
// nur produkte ohne uppercontainer im Hintergrund neu laden
updateOnlyProdukte = function(){
	ajaxUpdater('produkte','./produkte.php?produktreload=1');
}
// produkte im Hintergrund neu laden
updateProdukte = function(){
	ajaxUpdater('reload','./produkte.php?inc=1');
}
// Features im Hintergrund neu laden
updateFeatures = function (produktid){
	ajaxUpdater('features','./produkte.features.php?inc=1&p=' + produktid);
}

checkAddfolder = function(){
	if(document.getElementById("addfolder").checked == false){
		document.getElementById("addfolderName").value = '';
	} else if(document.getElementById("addfolder").checked == true){
		if(document.getElementById("addfolderName").value == ''){		  
			if(document.getElementById("projektname").value == ''){
			  	document.getElementById("addfolderName").value = 'Name angeben!';
			  }else{
			  	document.getElementById("addfolderName").value = document.getElementById("projektname").value;
			  }		  
		}
	}
}
// Fügt das gewählte Bild in Vorschau und Editor ein
updatebild = function(path,filename){
      	var src = '<IMG id="previewbild" SRC="' + path + filename + '" WIDTH="236" style="display:block;cursor:pointer;" VSPACE="0" HSPACE="0" BORDER="0">';
      	$('bild').update(src);
      	$('previewbild').update(src);
      	$('imagename').value = filename; // filename in hidden field
}// Fügt das gewählte Bild in Vorschau und Editor ein
sendImage = function(path,filename){
      	var src = '<IMG id="previewbild" SRC="' + path + filename + '" WIDTH="236" style="display:block;cursor:pointer;" VSPACE="0" HSPACE="0" BORDER="0">';
      	$('bild').update(src);
      	//$('previewbild').update(src);
      	$('projektfilename').value = filename; // filename in hidden field
      	$('saveprojektimage').show();
}
// Fügt das gewählte Bild in Vorschau und Editor ein
removebild = function(){
      	var src = '<IMG id="previewbild" SRC="./images/blind.gif" WIDTH="236" HEIGHT="77" style="display:block;cursor:pointer;" VSPACE="0" HSPACE="0" BORDER="0">';
      	$('bild').update(src);
      	//$('previewbild').update(src);
      	$('filename').value = ''; // filename in hidden field
}
resetImage = function(path){
				var filename = $('originprojektfilename').value;
      	var src = '<IMG id="previewbild" SRC="' + path + filename + '" WIDTH="236" style="display:block;cursor:pointer;" VSPACE="0" HSPACE="0" BORDER="0">';
      	$('bild').update(src);
      	//$('previewbild').update(src);
      	$('projektfilename').value = filename; // filename in hidden field
      	
}
checknewfolder = function  () {
  if (document.uploadform.direktlink.selectedIndex == 1)
  	{
      	$('newfolderinput').show(); 
      	}else{
      	$('newfolderinput').hide(); 
      	$('newfolderinput').value=''; 
      	}
}


 Richeditor = function (pageid,textname) {
     // <![CDATA[     
      new Ajax.InPlaceRichEditor($(textname), 'saveContent.php?pageid='+pageid+'&textname='+textname, {
      ajaxOptions: {method: 'post',
      onSuccess: function(transport) {      
      $('mediafileselectEditor').hide();
      $('linkselectEditor').hide();
      Informer.notice('... wurde gespeichert');
      }
      },
        tinymceToElementSize: true,
        okText: 'speichern',
        cancelText: 'abbrechen',
        okControl: 'button',
        cancelControl: 'button',
        savingText: '. '
       }, 
      tinymce_advanced_options
      );
    // ]]>
}
 RicheditorBlog = function (pageid,textname) {
     // <![CDATA[     
      new Ajax.InPlaceRichEditor($(textname), 'saveContent.php?pageid='+pageid+'&textname='+textname, {
      ajaxOptions: {method: 'post',
      onSuccess: function(transport) {      
      $('mediafileselectEditor').hide();
      $('linkselectEditor').hide();
      Informer.notice('... wurde gespeichert');
      ajaxUpdater('blog','blog.php?inc=1&mid='+pageid);
      }
      },
        tinymceToElementSize: true,
        okText: 'speichern',
        cancelText: 'abbrechen',
        okControl: 'button',
        cancelControl: 'button',
        savingText: '. '
       }, 
      tinymce_advanced_options
      );
    // ]]>
}
 RicheditorLeftbar = function (pageid,textname) {
     // <![CDATA[     
      new Ajax.InPlaceRichEditor($(textname), 'saveContent.php?pageid='+pageid+'&textname='+textname, {
      ajaxOptions: {method: 'post',
      onSuccess: function(transport) {      
      $('mediafileselectEditor').hide();
      $('linkselectEditor').hide();
      Informer.notice('... wurde gespeichert');
      }
      },
        tinymceToElementSize: true,
        okText: 'speichern',
        cancelText: 'abbrechen',
        okControl: 'button',
        cancelControl: 'button',
        savingText: '. '
       }, 
      tinymce_advanced_options_leftbar
      );
    // ]]>
}
Simpleeditor = function (pageid,textname) {
  new Ajax.InPlaceEditor(
      textname,'saveContent.php?textname='+textname+'&pageid='+pageid,
      {
        ajaxOptions: {
          method: 'post'
        },
        rows:8,cols:110,
        okControl: 'button',cancelControl: 'button',savingText: '. '
        }      
   );
}
Lineeditor = function (pageid,textname) {
  new Ajax.InPlaceEditor(
      textname,'saveContent.php?textname='+textname+'&pageid='+pageid,
      {
        ajaxOptions: {
          method: 'post'
        },
        okControl: 'button',cancelControl: 'button',savingText: '. '
        }      
   );
}
