var checkmouseoverReturn=false;
var mouseoverclass='menu_start_azeti_link';
var pageid1=63;
var menuepid1=4;
var actpageid=63;

jQuery.noConflict();

jQuery(document).ready(function(){
  jQuery('#teaser_start').hide();
  jQuery('#teaser_start a').css("whiteSpace","nowrap");

  sideShadow();
  expmenu();

  jQuery.get("preload.php", { lang: jQuery('#sr_language_menu_select').val() },function(data){
    jQuery('#bg_content_box').html(data);
  });

  jQuery('.content_box').change(function() {
    setTimeout('sideShadow()',500);
  });
  jQuery('.menu_start_azeti_link').mouseout();
  jQuery('.menu_start_monitoring_link').mouseout();
  jQuery('.menu_start_it_security_link').mouseout();
  
  jQuery('.menu_start_azeti_link').mouseout(function(){checkmouseoverReturn=false;});
  jQuery('.menu_start_monitoring_link').mouseout(function(){checkmouseoverReturn=false;});
  jQuery('.menu_start_it_security_link').mouseout(function(){checkmouseoverReturn=false;});

  jQuery('.menu_start_azeti_link').mouseover(function(){if(checkmouseoverReturn==false){jQuery('.menu_start_monitoring_link').mouseout();jQuery('.menu_start_it_security_link').mouseout();mouseoverclass='menu_start_azeti_link';pageid1=63;menuepid1=4;checkmouseover();}});
  jQuery('.menu_start_monitoring_link').mouseover(function(){if(checkmouseoverReturn==false){jQuery('.menu_start_azeti_link').mouseout();jQuery('.menu_start_it_security_link').mouseout();mouseoverclass='menu_start_monitoring_link';pageid1=60;menuepid1=34;checkmouseover();}});
  jQuery('.menu_start_it_security_link').mouseover(function(){if(checkmouseoverReturn==false){jQuery('.menu_start_azeti_link').mouseout();jQuery('.menu_start_monitoring_link').mouseout();mouseoverclass='menu_start_it_security_link';pageid1=61;menuepid1=12;checkmouseover();}});
  
  jQuery('.menu_start_azeti_link').click(function(){return false;});
  jQuery('.menu_start_monitoring_link').click(function(){return false;});
  jQuery('.menu_start_it_security_link').click(function(){return false;});
  
  setTimeout('startTeaser()',1000);
});

function startTeaser()
{
  jQuery('#teaser_start .bodytext').hide();
  jQuery('#teaser_start a').hide();
  jQuery('#teaser_start a').css("whiteSpace","nowrap");

  jQuery('#teaser_start').show("drop",{ direction: "right" },500,function(){
    jQuery('#teaser_start .bodytext').show("drop",{ direction: "right" },500,function(){
      jQuery('#teaser_start a').show("drop",{ direction: "right" },500);
    });
  });
}

function checkmouseover()
{
  checkmouseoverReturn=true;
  setTimeout('getSlideContent()',500);
}


function getSlideContent() {
  if(checkmouseoverReturn==true && actpageid!=pageid1)
  {
    jQuery('#menu_start_bg_png').hide();
    jQuery('.filter_bg_menu_start_azeti').hide();
    jQuery('.filter_bg_menu_start_it_security').hide();
    jQuery('.filter_bg_menu_start_monitoring').hide();
    jQuery('a.menu_start_it_security_link').removeClass('menu_start_link_act');
    jQuery('a.menu_start_monitoring_link').removeClass('menu_start_link_act');
    jQuery('a.menu_start_azeti_link').removeClass('menu_start_link_act');

    if(pageid1==63)
    {
      jQuery('.filter_bg_menu_start_azeti').show();
      jQuery('a.menu_start_azeti_link').addClass('menu_start_link_act');
      jQuery('.content_outer_box').css({'background-image' : 'url(images/bg_content_start_azeti.jpg)'});
    }
    else if(pageid1==60)
    {
      jQuery('.filter_bg_menu_start_monitoring').show();
      jQuery('a.menu_start_monitoring_link').addClass('menu_start_link_act');
      jQuery('.content_outer_box').css({'background-image' : 'url(images/bg_content_start_monitoring.jpg)'});
    }
    else if(pageid1==61)
    {
      jQuery('.filter_bg_menu_start_it_security').show();
      jQuery('a.menu_start_it_security_link').addClass('menu_start_link_act');
      jQuery('.content_outer_box').css({'background-image' : 'url(images/bg_content_start_it_security.jpg)'});
    }

    jQuery('#menu_start_bg_png').show();
    jQuery.get("content_box.php", { pageid: ""+pageid1+"", menue_pid: ""+menuepid1+"", lang: jQuery('#sr_language_menu_select').val() },function(data){
      jQuery('#bg_content_box').css({'background-image' : 'url('+getImagePath(data)+')'});
      jQuery('#teaser_start').fadeOut("400");
      jQuery('.content_box').fadeOut("400", function() {
        jQuery('.content_box').html(modyfyData(data));
        jQuery.get("teaser_start.php", { pageid: ""+pageid1+"", lang: jQuery('#sr_language_menu_select').val() },function(data){
          jQuery('#teaser_start').html(data);
          startTeaser();
          jQuery('.content_box').fadeIn("200");
          actpageid=pageid1;
        });
      });
    });
  }
  checkmouseoverReturn=false;

  return false;
}


function sideShadow()
{
  var bildmitte=jQuery(window).width()/2;

  jQuery('.side_shadow_outer_box').height(jQuery('.content_outer_box').height()-28);
  jQuery('#side_shadow').height(jQuery('.content_outer_box').height()-28);
  jQuery('.filter_side_shadow').height(jQuery('.content_outer_box').height()-28);
  //jQuery('.side_shadow_outer_box').css('left',eval(bildmitte-490)+"px");
}

function expmenu()
{
  var bildmitte=jQuery(window).width()/2;
  var leftPos=0;

  if((bildmitte-471)>0) leftPos=bildmitte-471;
  jQuery('.expmenu').css('marginLeft',leftPos+"px");
}

function modyfyData(data) {
    data=str_replace('###IMG_START###'+getImagePath(data)+'###IMG_STOP###','',data);

    return data;
}
function getImagePath(data) {
    var start=strpos(data, '###IMG_START###', 0);
    var stop=strpos(data, '###IMG_STOP###', 0);

    return str_replace('###IMG_START###','',data.substr(start,eval(stop-start)));
}

function strpos (haystack, needle, offset) {
    var i = (haystack+'').indexOf(needle, (offset ? offset : 0));
    return i === -1 ? false : i;
}

function str_replace(search, replace, subject) {
    return subject.split(search).join(replace);
}
