// Created by Andrei Neagu
// on 21.06.2009

 function gettopOffset(){
  var top = 0;
  // getting Browsers Height
  if (window.innerHeight){
      top = window.innerHeight/2;
  } else if(document.documentElement.clientHeight){
      top = document.documentElement.clientHeight/2;
  } else if( document.body.clientHeight ){
      top = document.body.clientHeight/2 ;
  }
  return top;
 }
 
  function createTitle(title){
  return '<div id="inner_title_dialogbox">'+title+'</div>';
  }

 function getleftOffset(){
  var left=0;
  // getting Browsers Width
  if (window.innerWidth){
      left = window.innerWidth/2;
  } else if(document.documentElement.innerWidth){
      left = document.documentElement.innerWidth/2;
  } else if( document.body.clientWidth){
      left = document.body.clientWidth/2;
  }
  return left;
 }
 
 
 function getScrollLeft() {
  if (self.pageYOffset)
    return self.pageXOffset;
  else if (document.documentElement && document.documentElement.scrollTop)
    return document.documentElement.scrollLeft;
  else if (document.body)
		return document.body.scrollLeft;
}

function getScrollTop() {
  if (self.pageYOffset)
    return self.pageYOffset;
  else if (document.documentElement && document.documentElement.scrollTop)
    return document.documentElement.scrollTop;
  else if (document.body)
    return document.body.scrollTop;
}

 /**
  * Creates Popup-border around the given content
  * @param content String ex: <div id="maincontent"> ... </div>
  * @param width the width of the popup
  * @param height the height of the popup
  */
 function setDialogBorder(content, width ,height, close){
 
  var return_val =
 '<div align="center" id="outer_border_dialogbox" style=" width:'+width+'px; ' + ((height && height > 0)? 'height:'+height+'px;': '') +'">'+
 '<div class="popup_main" style="'+((height && height > 0)? 'height:'+height+'px;': '')+'font-size:12px; font-family:tahoma;">'
  +content+
  ((close)? '<div id="popup_fotter" style="margin-top:20px;margin-bottom:10px;margin-left:'+(width/2-60)+'px;"><div id="schliessen_button" onClick="closeDialog();"> schließen </div></div>' : '') +
  '</div></div>';
      return  return_val;
 }
 
 /**
  *Creates a standard popup on the screen containig the given "content"
  * @param content String ex: <div id="maincontent"> ... </div>
  * @param width the width of the popup. If not specified default value = 300px
  * @param height the height of the popup.  If not specified default value = 200px
  */
  function opendialog(content, width, height,title,close){
    var body = document.getElementById('dialog_html');
     if(width){}else{ width = 300;}
     if(height){}else{height = 0;}
     if(title){ content =  createTitle(title) +'<div style=\"margin:10px 4px 10px 4px;\">'+ content+'</div>'; }
    body.innerHTML = setDialogBorder(content, width , height,close);
    
    body.style.left =getScrollLeft() + (getleftOffset() - width /2) + "px";
    body.style.top = getScrollTop() + (gettopOffset() - height /2) + "px";
    body.style.display = "";
    }

  function opent(){
  var content ="<div style='margin:10px 4px 10px 4px; font-family:verdana; font-size: 12px;'>Versandkosten betragen 14,64€ brutto im Inland. Für Nachnahme werden 2€ von der DHL erhoben.</div>";
  var width = 700;
  var height = 0;
  var title = "Versandkosten";
  var close = true;
  opendialog(content,width,height,title,close);
  };

  function openVersandKosten(){
  var content ="<div style='margin:10px 4px 10px 4px; font-family:verdana; font-size: 12px;'>Versandkosten betragen 14,64€ brutto im Inland. Für Nachnahme werden 2€ von der DHL erhoben.</div>";
  var width = 700;
  var height = 0;
  var title = "Versandkosten";
  var close = true;
  opendialog(content,width,height,title,close);
  };

  /**
   * Closes the dialog Frame
   */
  function closeDialog(){
    var body = document.getElementById('dialog_html');
    body.style.display = 'none';
  }
  