function menu_slide(id,direction)
{
  if(document.getElementById("menu"+id).style.display == "none"){
     Effect.SlideDown("menu"+id, {scaleY:'false',duration:0.8}); return false;
     }//END if(document.getElementById("menu"+id).style.display == "none")
     else{
         Effect.SlideUp("menu"+id, {scaleY:'false',duration:0.8}); return false;
         }//END else(document.getElementById("menu"+id).style.display == "none")
}//END function menu_slide(id,direction)



function ShowFullMenu()
{
for(var i = 1; i <= 6; i++){
   Effect.SlideDown("menu"+i, {scaleY:'false',duration:0.8});
   }//END for(var i = 1; i <= 6; i++)
}//END function menu_slide(id,direction)


/**
* where: artikelS.inc.php
* what : open a div and place the zoomed-in image in the center
*/
function zoomPicture()
{
    var img     = new Image();
        img.src = $("#zoompic").attr('src');
    var width   = img.width;
    var height  = img.height;   
    var parent  = $("#article").position();
    var postop  = (($('#article').height()+10)/2) - (height/2);
    var posleft = ($('#article').width()/2) - (width/2);

    $("#photo > span").css({'position':'absolute', 'top':postop, 'left':posleft, 'display':'none'});  
    $("#photo > span > a").css({'position':'absolute', 'marginLeft':width-10, 'marginTop':-10, 'zIndex': '2000'});    
    
    $("#photo")    
      .animate({'width':$('#article').width(),'height':$('#article').height()+10 },1000)
      .css({'visibility':'visible','top': parent.top, 'left': parent.left});
      
    $("#photo > span").fadeIn(1000);
}


$(document).ready(function() {

  /**
  *  where: artikelS.inc.php
  *  what : open a div and place the zoomed-in image in the center
  */   
  $(".mainpic").bind('click', function(event){
    event.preventDefault();
    zoomPicture();
    })//END function ShowPicture()
 
 
 
  /**
  *  where: artikelS.inc.php
  *  what : close zoomed article picture
  */   
  $(".closepic").bind('click',function(){
    $("#photo").animate({'width':0,'height':0 },1000);
    $("#photo > span").fadeOut('slow'); 
    })//END $(".closepic").bind('click',function()
    


  /**
  *  where: artikelS.inc.php
  *  what : change pictures
  */   
  $(".addpic")
    .bind('click', function(event){
          event.preventDefault();
           this.old = $("#articlepreview").attr('src'); //grosses bild der artikelvorschau zum startzeitpunkt
          $('#articlepreview').attr('src',$(this).children('span').children('img').attr('src')); // &auml;ndern der artikelvorschau
          $("#zoompic").attr('src', $(this).children('span').children('img').attr('src').replace("thumb160_", "")); // aendern des zoompic
          
          $(this).children('span').children('img').attr('src',this.old);
          $(this).children('img').attr('src',this.old.replace("thumb160_","thumb_"));
          event.stopImmediatePropagation();          
          zoomPicture();
     });
  
  
  
  /**
  * where: cash.inc.php
  * what : toggle bonuscode info from hidden to visible and the other way round.
  */
  $(".link").click(function(){
    $('#bonus_info').slideToggle('slow');
    });//END $(".link").click(function()
  
  
  
  /**
  * where: index.inc.php (if isset get-parameter subsubmenu with the value "filtertechnik"
  * what : makes the advert draggable
  */  
  $('#filtermsg').draggable().bind('mouseup', function(){ SetFilterAdPosition();});

  
  
  /**
  * where: artikelS.inc.php
  * what : send an e-mail to a friend, to advise him a special product
  */ 
  $('#friendlysub').bind('click',function(){  
    var loadUrl  = "ajax_mail.php";
    var from     = $("#from").val();
    var to       = $("#to").val();       
    var subject  = $("#subject").val();
    var textarea = $("#msg").val();

    $.get(  
        loadUrl
        , "from=" + from + "&to=" + to + "&subject=" + subject +"&msg="+ textarea
        , function(responseText){                         
                   if(responseText == "passed"){
                     alert("Ihre Produktempfehlung wurde soeben per E-Mail versandt.");
                     }//END if(response == "passed")
                     else if(responseText == "blocked"){
                             alert("Der von Ihnen eingegebene Empfänger hat dem Erhalt von Empfehlungen widersprochen.");
                             }//END else if(response == "blocked")
                         else{
                             alert("Ihre Produktempfehlung konnte leider nicht versandt werden, bitte überprüfen Sie Ihre Angaben.");
                             }//END else(response == "passed")
                   }
        ,"html"  
        );//END $.get   
  
    $('#messageframe').css({'display':'none'});
    });
    
    
    
  /**
  * where: hotline.inc.php
  * what : use lightbox plugin for the gallery
  */
  $('a.lightbox').lightBox();  

  
   
  var gaJsHost = (("http:" == document.location.protocol) ? "http://ssl." : "http://www.");
  
  $.getScript(
    gaJsHost + "google-analytics.com/ga.js",
    function(){
              try {
                  var pageTracker = _gat._getTracker('UA-921358-4');
                  pageTracker._trackPageview();
                  }catch(err) {}        
              }
    );
  
  
  
  $('#slider').nivoSlider({
  pauseTime:5000,
  prevText: 'zurück',
  nextText: 'weiter',
  linkTitle: 'zum Artikel',
  pauseOnHover:true,
  directionNavHide:true,
  controlNav:false
  });
  
});


/**
* Filter Ad
*/
function HideFilterAdvert()
{
  if(xmlHttp){
    try{
       //set paramter string
       var params = "hide=true";       
       xmlHttp.open("GET", "ajax_filtermsg.php?" + params, true);
       xmlHttp.send(null);
       document.getElementById("filtermsg").style.display = "none";
       }//END try
       //show errors
       catch(e){
               setTimeout("HideFilterAdvert(),1000");
               //alert("Can`t connect to server: \n" + e.toString());
               }//END catch
   }//END if(xmlHttp)
}//END function friendlymail()



function SetFilterAdPosition()
{
  if(xmlHttp){
    try{
       var offset = $("#filtermsg").offset();
       var x = offset.left;
       var y = offset.top;  
       //set paramter string
       var params = "position=true&x=" +x+ "&y="+y;
       xmlHttp.open("GET", "ajax_filtermsg.php?" + params, true);
       xmlHttp.send(null);
       }//END try
       //show errors
       catch(e){
               setTimeout("SetFilterAdPosition(),1000");
               //alert("Can`t connect to server: \n" + e.toString());
               }//END catch
   }//END if(xmlHttp)
}//END function SetFilterAdPosition()



