// Benötigt Prototype.js und scriptaculous.js

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


showInlinecontent = function(url,setWidth,setHeight,headline){
// SYNTAX
// showInlinecontent('url','breite','höhe','headlinetext'
 var viewportwidth;
 var viewportheight;
 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
 if (typeof window.innerWidth != 'undefined') {
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
 } 
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
 else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0) {
       viewportwidth = document.documentElement.clientWidth,
       viewportheight = document.documentElement.clientHeight
 } 
 // older versions of IE 
 else {
       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
       viewportheight = document.getElementsByTagName('body')[0].clientHeight
 }
//document.write('<p>Your viewport width is '+viewportwidth+'x'+viewportheight+'</p>');

//  var dimension = $('body').getDimensions();
  var screenwidth = viewportwidth;
  var screenheight = viewportheight;
  
  $('iBox').style.width = screenwidth-1 + "px";
  $('iBox').style.height = screenheight-1 + "px";

  if(setWidth == ''){setWidth = '948';}
  $('inlinecontent').style.width=setWidth + 'px';
  
  if(setHeight == ''){setHeight = '700';}
  $('inlinecontent').style.height=setHeight + 'px';
  
  var marginL = (screenwidth - setWidth - 1)/2;
  $('inlinecontent').style.marginLeft = marginL + 'px';
  
  var offset = calcInlinecontent(setHeight,viewportheight);
  $('inlinecontent').style.top=offset+'px';

  showBox = function() {$('inlinecontent').show();}  
// alert(url); 
  Effect.Appear('iBox', { duration: 0.3, from:0.0, to:0.6,fps:15,  transition:Effect.Transitions.linear, afterFinish:showBox});
  ajaxUpdater('inlinecontentshowcase','iBox.php?url='+url+'&setWidth='+setWidth+'&setHeight='+setHeight+'&headline='+headline);
}
// Imagelayer margin-top berechnen, höhe wird mit übergeben
function calcInlinecontent (imageheight,viewportheight){
var rahmen = '17'; // Rahmen oberhalb Bild
var VPmargin = (viewportheight-imageheight)/2-rahmen; // sichtbare margin oben und unten vom inhalt
var VPmarginabs =  VPmargin;
//if(VPmarginabs < 100){VPmarginabs = '100';}
return VPmarginabs;
}



showNewInlinecontent = function(url,setWidth,setHeight,headline){
// SYNTAX
// showInlinecontent('url','breite','höhe','headlinetext'
  ajaxUpdater('inlinecontentshowcase','iBox.php?url='+url+'&setWidth='+setWidth+'&setHeight='+setHeight+'&headline='+headline);
}


hideInlinecontent = function(){
  var closeiBox = 1; 


// RANDBEDINGUNGEN
		  if (document.getElementById('editprodukt') != null){
						setTimeout('updateProdukte()',100);
		      }
		  
		  // <DIV id="checkbeforclose" style="display:none;">.</DIV>
		  if (document.getElementById('checkbeforclose') != null){
		    check = confirm("\nSind alle Änderungen gespeichert?\n\nNicht gespeicherte Änderungen gehen verloren!");
		    if (check == true){
			  	closeiBox = 1;
					}else{
						closeiBox = 0;
					}
		    }   
      
  if(closeiBox == 1){
    Effect.Fade('iBox', { duration: 0.3 });
    $('inlinecontent').hide();
    $('inlinecontentshowcase').update('<IMG SRC="./globalimages/loadingbar.gif" style="margin-top:150px;margin-bottom:150px;" ALIGN="CENTER" WIDTH="66" HEIGHT="10" VSPACE="0" HSPACE="0" BORDER="0">');
    return false;
  }
}



