$(document).ready(function() {
	  // Open Links in new Window - sorry, you know, most customers want that...
    $('#portfolio a').filter(function() {
        if (this.hostname && this.hostname !== location.hostname){            
            $(this).click(function() {
                window.open(this.href); 
                return false; 
            });
        }
    })

	// Open Overlay for Links
	$("#contactLink").overlay({
		    color: '#ccc'
	});
	
	$("#visitenkarteLink").overlay({
		    color: '#ccc'
	});
	
	
	// Initialize Contact Form
	var options = { 
			target:        '#alert'
	}; 
	$('#contactForm').ajaxForm(options);
	
	  $('input[type="text"]').focus(function() {  
	      $(this).addClass("focusField");  
	  });  
	  $('input[type="text"]').blur(function() {  
	      $(this).removeClass("focusField");  
	  });
	
});

$('#sitetitle').airport(['<h1>roterblitz.de</h1>','<h1>Dirk Petscheleit</h1>','<h1>Webdesigner</h1>','<h1>Webentwickler</h1>']);
// $('#visitenkarteLink').airport(['<h1>roterblitz.de</h1>','<h1>Dirk Petscheleit</h1>','<h1>Webdesign</h1>']);

$.fn.clearForm = function() {
  return this.each(function() {
	var type = this.type, tag = this.tagName.toLowerCase();
	if (tag == 'form')
	  return $(':input',this).clearForm();
	if (type == 'text' || type == 'password' || tag == 'textarea')
	  this.value = '';
	else if (type == 'checkbox' || type == 'radio')
	  this.checked = false;
	else if (tag == 'select')
	  this.selectedIndex = -1;
  });
};

// Activate Local Scroll	
$('#navigation').localScroll({offset:-150});
$('#footer').localScroll({offset:-150});


// Set/ Unset Highlights	
$('#footer').click(function(){
	unHighlightPortfolio();
	unHighlightKontakt();
});
	
$('#portfolioLink').click(function(){
	highlightPortfolio();
});

$('#kontaktLink').click(function(){
	highlightKontakt();
});

// Switch Stylesheets
$("#white").click(function() {
		$("link[rel=stylesheet]").attr({href : "css/weiss.css"});
		$("#header img").attr({src : "img/logo_weiss.png"});
		$("#hcard-Dirk-Petscheleit img").attr({src : "img/logo_schwarz.png"});
});

$("#black").click(function() {
		$("link[rel=stylesheet]").attr({href : "css/schwarz.css"});
		$("#header img").attr({src : "img/logo_schwarz.png"});
		$("#hcard-Dirk-Petscheleit img").attr({src : "img/logo_weiss.png"});
});

$('#print').click(function(){
		window.print();
});

// Set Tooltips
$("#portfolio a").tooltip({ 
    position: ['center', 'right'], 
    offset: [0, 0], 
    effect: 'toggle'
});


// Functions

function highlightPortfolio() {
	$("#portfolio span").each(function(){
  	$(this).addClass("highlight");
  });
	unHighlightKontakt();
}

function unHighlightPortfolio() {
	$("#portfolio span").each(function(){
  	$(this).removeClass("highlight");
  });
}

function highlightKontakt() {
	$("#kontakt span").each(function(){
  	$(this).addClass("highlight");
  });
	unHighlightPortfolio();
}

function unHighlightKontakt() {
 	$("#kontakt span").each(function(){
   	$(this).removeClass("highlight");
  });
}

	