jQuery.noConflict();

var fadeSpeed = 800; 
var fadeOutSpeed = 400; 
function gotoLink(address) { 
    
}

function sendMail() {
    
    var firma = jQuery('#firma').val();
    var name = jQuery('#name').val(); 
    var strasse = jQuery('#strasse').val(); 
    var ort = jQuery('#ort').val(); 
    var tel = jQuery('#tel').val(); 
    var email = jQuery('#email').val(); 
    var webseite = jQuery('#webseite').val();
    var nachricht = jQuery('#nachricht').val();
    var submit = jQuery('#submit').val();  
    
    
    if (name != "" && email != "" && nachricht != "") {
        jQuery.post("sendmail.ajax.php", {  firma: firma, 
                                        name: name, 
                                        strasse: strasse, 
                                        ort: ort, 
                                        tel: tel, 
                                        email: email, 
                                        webseite: webseite, 
                                        nachricht: nachricht,
                                        submit: submit  
        }, function(content) {
            jQuery("#container_right").fadeOut(fadeSpeed, function(){ 
                jQuery("#container_right").html(content); 
                jQuery("#container_right").fadeIn(fadeSpeed); 
            }) ;
        });
    } else {
        jQuery.post("kontakt.ajax.php", {abschnitt: "kontaktformular",
                                        firma: firma, 
                                        name: name, 
                                        strasse: strasse, 
                                        ort: ort, 
                                        tel: tel, 
                                        email: email, 
                                        webseite: webseite, 
                                        nachricht: nachricht,
                                        submit: submit 
    }, function(content) {
        jQuery("#container_right").fadeOut(fadeSpeed, function(){ 
            jQuery("#container_right").html(content); 
            jQuery("#container_right").fadeIn(fadeSpeed); 
        }) ;
    });
    }
}

function showProject(id, title)
{
    jQuery.post("projekt.ajax.php", {projektid: id}, function(content) {
        jQuery("#container_right").fadeOut(fadeSpeed, function(){ 
            jQuery("#container_right").html(content); 
            jQuery("#container_right").fadeIn(fadeSpeed);
            pageTracker._trackPageview("Projekt - " + title);
        }) ;
    });
}

function showSection(section, title)
{
    jQuery.post("lebenslauf.ajax.php", {abschnitt: section}, function(content) {
        jQuery("#container_right").fadeOut(fadeSpeed, function(){ 
            jQuery("#container_right").html(content); 
            jQuery("#container_right").fadeIn(fadeSpeed); 
            pageTracker._trackPageview("Lebenslauf - " + title);
        }) ;
    });
}

function showContact(section)
{
    jQuery.post("kontakt.ajax.php", {abschnitt: section}, function(content) {
        jQuery("#container_right").fadeOut(fadeSpeed, function(){ 
            jQuery("#container_right").html(content); 
            jQuery("#container_right").fadeIn(fadeSpeed); 
        }) ;
    });
}

function showService(service, title)
{
    jQuery.post("service.ajax.php", {service: service}, function(content) {
        //jQuery("#container_right").html(content); 
        
        jQuery("#container_right").fadeOut(fadeSpeed, function(){ 
            jQuery("#container_right").html(content); 
            jQuery("#container_right").fadeIn(fadeSpeed) ;
            pageTracker._trackPageview("Erfahrung - " + title); 
        }) ; 
    });
}

function showCompany(id, title)
{
    jQuery.post("firma.ajax.php", {firmaid: id}, function(content) {
        jQuery("#container_right").fadeOut(fadeSpeed, function(){ 
            jQuery("#container_right").html(content); 
            jQuery("#container_right").fadeIn(fadeSpeed); 
            pageTracker._trackPageview("Firma - " + title);
        }) ;
    });
}

jQuery(document).ready(function(){


    var hoehe_inhalt  = jQuery("#content").height(); 
    var hoehe_fenster = jQuery("#pagecontent").height();  
    
    //jQuery("#imageholder").hide();
    //jQuery("#container_right").hide();
    //jQuery("#container_left").hide();
    
    jQuery("#imageholder").fadeIn(fadeSpeed); 
    jQuery("#container_left").fadeIn(fadeSpeed);
    jQuery("#container_right").fadeIn(fadeSpeed);
    
    /*
    jQuery("a").click(function(event) {
        
        var address = jQuery(this).attr("href");
        event.preventDefault();
        
        jQuery("#imageholder").fadeOut(fadeOutSpeed);
        jQuery("#container_right").fadeOut(fadeOutSpeed); 
        jQuery("#container_left").fadeOut(fadeOutSpeed, function() { window.open(address, "_self"); } );
    });
    
    jQuery("a.details").click(function(event) {
        
        var address = jQuery(this).attr("href");
        event.preventDefault();
        
        //jQuery("#container_right").fadeOut(fadeOutSpeed, function() { window.open(address, "_self"); } );
    });
    */
    
    jQuery("a.whitelink").click(function(){
        jQuery("a.whitelink").css("color", "#fff");
        jQuery(this).css("color", "#409FE8");
    });
    
    jQuery("a.btn").click(function(event){ 
        
        var address = jQuery(this).attr("href");
        event.preventDefault();
        jQuery("#imageholder").fadeOut(fadeOutSpeed);
        jQuery("#container_right").fadeOut(fadeOutSpeed); 
        jQuery("#container_left").fadeOut(fadeOutSpeed, function() { window.open(address, "_self"); } );
        
        jQuery(this).parent().find('a.active').removeClass("active");
        jQuery(this).addClass("active");
    });
    
    jQuery("a.intern").click(function(event){ 
        
        var address = jQuery(this).attr("href");
        event.preventDefault();
        jQuery("#imageholder").fadeOut(fadeOutSpeed);
        jQuery("#container_right").fadeOut(fadeOutSpeed); 
        jQuery("#container_left").fadeOut(fadeOutSpeed, function() { window.open(address, "_self"); } );
    });

    // Accordion
    jQuery('#projekte').find('.titel').click(function() {

        jQuery(this).parent().find('.vorschau:visible').slideUp();
        jQuery(this).parent().find('.titel').removeClass('selected');
        
        jQuery(this).next().slideToggle();
        jQuery(this).addClass('selected');
    });
    
    jQuery('#firmen').find('.titel').click(function() {

        jQuery(this).parent().find('.firma:visible').slideUp();
        jQuery(this).parent().find('.titel').removeClass('selected');
        
        jQuery(this).next().slideToggle();
        jQuery(this).addClass('selected');
    });
    
    var i = 0; 
    
    var pos;
    var slider_y; 
    var sliderbar_height = 340;
    var percent;
    /*
    jQuery('#slider_left').Draggable( 
        {
            onStop: function() { 
                scroll(this, "#content_left", "#pagecontent_left"); 
            },
            axis:	'vertically',
            containment : 'parent',
        }
    ); 
    
    jQuery('#slider_right').Draggable( 
        {
            onStop: function() { 
                scroll(this, "#content_right", "#pagecontent_right"); 
            },
            axis:	'vertically',
            containment : 'parent',
        }
    ); 
    */
    
    function scroll(slider, div, window) {
        posi = jQuery(slider).position();
        slider_y = posi.top;
        percent = slider_y / jQuery(slider).parent().height();
        hoehe_inhalt = jQuery(div).height(); 
        hoehe_fenster = jQuery(window).height(); 
        
        content_height = hoehe_inhalt - hoehe_fenster; 
        content_position = content_height * percent; 
        
        jQuery(div).animate({ 
            top: '-'+Math.round(content_position)+'px'
          }, 400, "linear" );
    }
    
    jQuery("#newsbox #newsnavi a.news").click(function(){
        //var hoehe = jQuery("#newsbox #content_news").height() + 50; 
        jQuery("#newsbox #newsnavi a.news").css("color", "#409fe8");
        jQuery("#newsbox #newsnavi a.twitter").css("color", "#fff");  
        
        
        jQuery("#newsbox").animate({"height": 680 }, "slow");
        jQuery("#newsbox #content_twitter").fadeOut(fadeOutSpeed, function(){
        
            jQuery("#newsbox #content_news").fadeIn(null, function(){
                    jQuery('#scrollContent').show(); 
                    jQuery('#scrollContent').css("height", "630px").jScrollPane(
                    {scrollbarWidth: 5, animateTo: true
                    });
                }); 
            });
            
        jQuery("#newsbox #close").fadeIn();
        pageTracker._trackPageview("Newsbox");
    });
    
    jQuery("#newsbox #newsnavi a.twitter").click(function(){
        
        jQuery("#newsbox #newsnavi a.news").css("color", "#fff");
        jQuery("#newsbox #newsnavi a.twitter").css("color", "#409fe8");
        
        if (jQuery("#newsbox #content_news").css("display") == "block") {
            jQuery("#newsbox #content_news").fadeOut(null, function(){
                jQuery("#scrollContent").insertBefore("#newsbox .jScrollPaneContainer"); 
                jQuery("#newsbox .jScrollPaneContainer").remove();
            }); 
        } else {
            jQuery('#scrollContent').hide(); 
            //jQuery("#newsbox #content_twitter").html("<img src='./images/loader.gif' align='center' />");
            //var hoehe = jQuery("#newsbox #content_twitter").height() + 50 ; 
            //jQuery("#newsbox").animate({""height": hoehe }, "slow");
        }

        jQuery.post("twitter.ajax.php", null, function(content) {

            jQuery("#newsbox #content_twitter").html(content);
            pageTracker._trackPageview("Twitter-News");
            
            hoehe = jQuery("#newsbox #content_twitter").height() + 50 ; 
            jQuery("#newsbox").animate({"height": hoehe }, "slow");
            
            jQuery("#newsbox #content_twitter").fadeIn();  
            jQuery("#newsbox #close").fadeIn(); 
        });
        
        
    });
    
    jQuery("#newsbox #close").click(function(){

        jQuery("#newsbox #content_news").fadeOut();
        jQuery("#newsbox #content_twitter").fadeOut();
        jQuery("#newsbox #newsnavi a.news").css("color", "#fff");
        jQuery("#newsbox #newsnavi a.twitter").css("color", "#fff");
        
        
        jQuery("#newsbox #close").fadeOut(null, function() { jQuery("#newsbox").animate({"height": "26px" }, "slow");} );
    });
    
    // Scrollable Areas
    
    
    
    jQuery('.pagecontent').jScrollPane({
       scrollbarWidth: 5,
       animateTo: true
    });
    
	
	// Tooltips
	jQuery('#projekte .vorschau a img').easyTooltip();  
	

    

});
