////////////////////////////////////////////////////////////////
//
// @method void wOpenURL(url)
//
// @desc Öffnet eine Seite
//
// @return void
//
////////////////////////////////////////////////////////////////

function wOpenURL(url){
  if(location.pathname.indexOf('/weblication/grid5/') != 0){
    location.href = url;
  }
}

////////////////////////////////////////////////////////////////
//
// @method void wOpenPopupURL(url, width, height)
//
// @desc Öffnet eine Seite in einem Popup
//
// @return void
//
////////////////////////////////////////////////////////////////

function wOpenPopupURL(url, width, height){

  var name = '';
  
  if(width == '' || width == ' '){
    width = 786;
  }
  if(height == '' || height == ' '){
    height = 677;
  }
  
  url = url.replace(/&amp;/g, '&');
  options = ',location=no, menubar=no,toolbar=no,resizable=no,scrollbars=no,status=no';
  width   = parseInt(width);
  height  = parseInt(height);

  var posLeft = (screen.width / 2)  - (width  / 2);
  var posTop  = (screen.height / 2) - (height / 2);
  window.open(url, name, 'top='+posTop+',left='+posLeft+',width='+width+',height='+height+',' + options);
}

////////////////////////////////////////////////////////////////
//
// @method void wSendMailNospam(data)
//
// @desc Öffnet eine E-Mail zum Versenden
//
// @return void
//
////////////////////////////////////////////////////////////////

function wSendMailNospam(data){
  location.href = 'mailto:' + data.replace('|', '@');
}

////////////////////////////////////////////////////////////////
//
// @method void wEmbedNavpoint(id, url)
//
// @desc Öffnet eine Seite in einem Vorschaulayer der Navigation
//
// @return void
//
////////////////////////////////////////////////////////////////

function wEmbedNavpoint(id, url){

  if(typeof wEditor == 'object'){
    return false;
  }
   
  url = url.indexOf('?') == -1 ? url + '?viewmode=embed' : url + '&viewmode=embed';
  
  url = url.replace('[URL]', location.pathname + location.search);
  
  if($('#navpoint_' + id).data('hasLoaded') == '1'){             
    $('#navEmbed_' + id).show();
  }
  else{
    $.ajax({
      type: "GET",
      url: url,
      success: function(result){
        $('#navpoint_' + id).data('hasLoaded', '1');                  
        $('#navEmbed_' + id).html(result);
        
        var navpointLeft = $('#navpoint_' + id).offset().left;
        
        $('#navEmbed_' + id).show();
        
        var layerLeft = $('#navEmbed_' + id).offset().left;
        
        var blockMainRight = $('#blockMain').offset().left + $('#blockMain').width();        
        
        if(layerLeft < navpointLeft){
          $('#navEmbed_' + id).css('left', String(navpointLeft - layerLeft - 6) + 'px');
        }
        
        var layerRight = $('#navEmbed_' + id).offset().left + $('#navEmbed_' + id).width();
                     
        if(layerRight > blockMainRight){
          $('#navEmbed_' + id).css('left', String(parseInt($('#navEmbed_' + id).css('left')) - (layerRight - blockMainRight)) + 'px');
        }
        
        jQuery('#navpoint_' + id).mouseout(function(){
          $('#navEmbed_' + id).hide();
        });
        
        jQuery('#navEmbed_' + id).mouseover(function(){
          $('#navEmbed_' + id).show();
        });
        
        jQuery('#navEmbed_' + id).mouseout(function(){
          $('#navEmbed_' + id).hide();
        });    
      }
    });
  }
}                        
              
