$(document).ready(function(){

	/*	###################	Hauptnavi			######################	*/
	var nav_a_buttons = $('#nav_main li a');
	var css;

  	if($.browser.mozilla) {
		css = {'-moz-border-radius':'7px'}
		nav_a_buttons.css(css);
  	} else if($.browser.safari) {
  		css = {'-webkit-border-radius':'7px'}
  		nav_a_buttons.css(css);
  	} else {

  		var position = new Array();
  		position[0]	= new Array('0px 0px','0px -31px');
  		position[1]	= new Array('-89px 0px','-89px -31px');
  		position[2]	= new Array('-209px 0px','-209px -31px');
  		position[3]	= new Array('-460px 0px','-460px -31px');
  		position[4]	= new Array('-257px 0px','-257px -31px');
  		position[5]	= new Array('-316px 0px','-316px -31px');
  		position[6]	= new Array('-389px 0px','-389px -31px');
  		
  		nav_a_buttons.css('background-image','url(img/layout/bg_nav_fix.png)');
  		
		$('#nav_main li a').each(function(ind){		
			if($(this).attr('class') == 'active'){
				$(this).css('background-position',position[ind][1]);
			} else {
				$(this).css('background-position',position[ind][0]);
			}
		
			$(this).mouseover(function(){
				$(this).css('background-position',position[ind][1]);
			}).mouseout(function(){
				if($(this).attr('class') == 'active'){
					$(this).css('background-position',position[ind][1]);
				} else {
					$(this).css('background-position',position[ind][0]);
				}
			});
		});

   	}
	
	
	/*	###################	Robots				######################	*/
	
	loadRobot();
    
    function loadRobot() {
	   	var robot_div	= $('#robot');
	   	var robot_class	= robot_div.attr('class');
		var robot_src	= "img/layout/robots/"+robot_class+".png";
		//robot_src		= robot_src.substr(4);
		//robot_src		= robot_src.substring(0,robot_src.length-1);
		var robot_img	= new Image();
		//alert(robot_src);
		robot_div.hide();
		
		$(window).load(function () {
	    	var imgfix = $('#referenzen .imagefix');
	    	if(typeof(imgfix.val()) != 'undefined') {
	    		robot_div.fadeIn(1000, function(){
	    			imgfix.css('background-color', 'transparent');
	    		}); 
	    	} else {
	    		robot_div.fadeIn(1000);
	    	}
	    	
	    }).attr('src', robot_src);
    }
    
    /* Handrobot */
    var handrobot	= $('#robot.webdesign');
    var handmargin = $('#left .webdesign_margin');
    var handactive	= 0;
    handrobot.click(function(){
    	if(handactive == 0){
    		handrobot.animate({marginLeft:'-700px'},'slow');
    		handmargin.animate({marginTop:'15px'},'slow');
    		handactive	= 1;
    	} else {
    		handrobot.animate({marginLeft:'0px'},'slow');
    		handmargin.animate({marginTop:'140px'},'slow');
    		handactive	= 0;
    	}
    });
    
  	/*	###################	Sonstige Funktionen	######################	*/
  	
  	// Titel Plugin laden falls benötigt
  	if($('a.title')){
  		$('head').append('<link rel="stylesheet" type="text/css" href="css/tip.css" />');
  		$.getScript('js/tip.js', function(){
  			$('a.title').cluetip({splitTitle: '|'});
  		});
  	}
  	
  	/* Unklickbar machen */
	$("a[href='#']").click(function(){
		return false;
	});
	
	/* Screen Class hinzufuegen */
	//$.getScript('js/screens.js');
	$('a').each(function(){
		if($(this).attr('href').substr(0,7) == 'http://') {
			if($(this).attr('class').match('noscreen') != 'noscreen'){
				$(this).addClass('screens');
			}
		}
	});
	
	// wait funktion
	$.fn.wait = function(time, type) {
        time = time || 1000;
        type = type || "fx";
        return this.queue(type, function() {
            var self = this;
            setTimeout(function() {
                $(self).dequeue();
            }, time);
        });
    };
});