
  	var _fullheight=225;//225//220
	var _halfheight=88;//89;
	var _singlewidth=160;
	
	var _marginright=10; //12!
	var _marginbottom=0;//20;//12
	
	var _doublewidth=2*_singlewidth+_marginright;
	
	var _opacity=0.5;
	var activeKat;
	var inactiveColor=0.21;
	var activePost;
	var activeBox;
	var _pre="michael";
	var _domain1="mfranken";
	var _domain2=".com";
	var _urlid; //wert nur wenn url get parameter, script wir in index.php gesetzt
	var animationRunning=false;
	
/* mobile detect*/
var isMobile= false;
if( navigator.userAgent.match(/Android/i) ||
 navigator.userAgent.match(/webOS/i) ||
 navigator.userAgent.match(/iPhone/i) ||
 navigator.userAgent.match(/iPod/i)||
 navigator.userAgent.match(/iPad/i)
 ){
isMobile=true;
}
var isMsie=false;
if(jQuery.browser.msie){isMsie=true;}

/*++++++++++flashdetect++++++++++++++++*/
var hasFlash = $.flash.available; //false
/*if(isMobile==false){
try {
  var fo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
  if(fo) hasFlash = true;
}catch(e){
  if(navigator.mimeTypes ["application/x-shockwave-flash"] != undefined) hasFlash = true;
}
}*/
function checkflash(){
	if(hasFlash==false){
	$('#flashobj').css("height","100px");
	}
}


/*++++++++++allgemein++++++++++++++++*/	




$(window).resize(function() {
	if(animationRunning!=true){
 		single_postHeight();
	}
});

	
$(function(){
	$("body").css("display","");//wird im body auf hidden gestellt
	checkflash();
	if(isMsie){
		$('.box').addClass('box-js');
		$('.box ').find('img').css("opacity",_opacity);
	  	$('.box ').css("margin-right",_marginright.toString()+"px");
	   	$('.box ').css("padding-right","0px");
	  
	 
	}else{
	$('.box .thumb_bg').addClass('box-js');
	}
	
	
	$('#single_post').css("overflow","hidden");
	$('#single_post').css("height","0px"); //wird bei single post in index php. geändert
	


	
	//ajaxLoaded();
})

/*+++mail++++++++++++++++++++++*/
$(function(){
	$('#mail').html(mailDecode());
})
function mailDecode(){
	var _add=_pre+"@"+_domain1+_domain2;
	var _text='<a href="mailto:'+_add+'">'+_add+'</a>';
	
	return _text;//"Kontakt / Impressum";

}

/*function registerSwf(){
swfobject.registerObject("swfobj_0", "12", "http://localhost/wp_test/wp-content/plugins/swfobj/expressInstall.swf");
	
}*/


	
/*++++++++++Masonry Raster ordnen++++++++++++++++*/	

$(document).ready(initializeGrid);
function initializeGrid() {
/*	  $(".box").each(function() {
	  $(this).css("margin-right",_marginright.toString()+"px");
	  $(this).css("margin-bottom",_marginbottom.toString()+"px");
	});*/
	  /*$("#single_images  img").each(function() {
	  $(this).css("margin-right",_marginright.toString()+"px");
	  $(this).css("margin-bottom",_marginbottom.toString()+"px");
	});*/
	  //$("img").each(function() {
	  //$(this).css("margin-bottom","0px");
	  
   // });
   
   
/*	$(".fullheight img").each(function() {
	  $(this).css("height",_fullheight.toString()+"px");
	});
	 $(".halfheight img").each(function() {
	  $(this).css("height",_halfheight.toString()+"px");
	});
	$(".single img").each(function() {
	  $(this).css("width",_singlewidth.toString()+"px");
	});
	$(".double img").each(function() {
	  $(this).css("width",_doublewidth.toString()+"px");
	});
	 $(".quadrat img").each(function() {
	  $(this).css("height","88px");//_singlewidth.toString()
	});*/

	
	$('#thumb_container').masonry({
	  columnWidth: _singlewidth+_marginright, 
	  itemSelector: '.box'
	});
/*	$('#single_images').masonry({
	  columnWidth: 1,//_singlewidth+_marginright, 
	  itemSelector: 'img'
	});*/

}	
	
/*++++++++++Mouse-funktionen++++++++++++++++*/	

/*boxlinks mouseover functionen*/	
$(function() {
	 
  $(".box .post_link,.box .kat ")
	  .mouseover(function() { 
	  var box=$(this).closest(".box");
	  
	
	  //$(box).find(".short_text").find("a").not(".post_link").css("text-decoration","underline");
		   
	  /*titel bekommt BG-Farbe*/ 
	  //$(box).find(".short_text").find(".post_link").css("background-color","#83F5B0");
	  $(box).find(".short_text").find(".post_link").addClass('titlehover');
	  
	  /*titel bekommt BG-Farbe*/ 
	  $(box).find('img').css("opacity","1");
	  
	  
	  

	   if(activeKat!=undefined){
	
		//$(box).not("."+activeKat).style.filter='';

	  //$(box).not("."+activeKat).css("filter","");
	  removeAlpha($(box).not("."+activeKat))
	
	  
	   }
	  }
	  )
	  
	  .mouseout(function() {
	  var box=$(this).closest(".box");
	  //$(box).find(".short_text").find(".post_link").css("background-color","#fff");
	  $(box).find(".short_text").find(".post_link").removeClass('titlehover');
	  //$(box).find(".short_text").find("a").css("text-decoration","none");
	  $(box).find('img').css("opacity",_opacity);
	  if(activeKat!=undefined){
	  	$(box).not("."+activeKat).css("opacity",inactiveColor);
	  }
	  })
});	

/*boxlinks click functionen- Post wird über Ajax geladen */	
$(function() {
	$(".post_link").click(function(e) {
		window.scrollTo(0, 0);
		
		var _url=$(this).attr('href').toString();
		var _id = _url.split("p=");
		var _newUrl=_id[1];
	
		 $.address.parameter("id",_newUrl);	//alert($.address.parameter("id"));
		//$('#single_post').html( "<div id='post_1'></div>" );
		//$('#post_1').css("position","relative")
		
		e.preventDefault();
	});
});

$.address.change(function(event) { 

	var _id=$.address.parameter("id");
	var _kat=$.address.parameter("kat");
	activeBox="post-"+_id;
	if(_id!=undefined){ //soll bei erstmaligen Seiteneintritt nicht ausgelöst werden
		if(_id!=activePost){//wenn Post schon offen, dann passiert nichts
			 //ist jetzt in post_link click  window.scrollTo(0, 0); 

			var _url="?page_id=87&id="+_id;
			if(_kat!=undefined){_url+="&kat="+_kat;}
/*				$('#single_post').animate({
				height: 300,
	 			}, 800);*/
			
			//$('#post_1').load(_url,ajaxLoaded); 
			document.body.className = 'wait';
			$.get(_url, function(data) {
				 
  $('#post_1').html(data);
 
  ajaxLoaded();

});

			activePost=_id;
		}
	}else{// wenn _id=undefined dann offenes Projekt geschlossen
	
		closeProject();
	
		}
	//if(_kat==undefined){kat="featured"}

	if(_kat!=undefined){
		if(_kat!=activeKat){//wenn sich kategorie geändert hat, dann sortiere
		
		$("#showall").css("display","block");
		$("#showall").find("span").text(_kat);
			sortKat("."+_kat);	
			activeKat=_kat;
		}
	}else{//alert("kat=undefined");
	$("#showall").css("display","none");
		if(activeKat!=undefined){// keine parameterkategorie und boxen verstellt sind(activeKat ist eingestellt)
		activeKat=undefined;
		resetBoxorder();
		//$(".box").css("opacity",1);
		katMove();
		}
	}	
	
		
});


/*box klick auf Kategorie, sortieren wird auf gerufen, sortKat() */	
$(function(){
	//$("#projekte_auswahl a,.kat").not('.kat_reset').click(function(e){

	setKatLink($('#projekte_auswahl a').not('.kat_reset'),true);
	setKatLink($('.kat'));
	katReset();
});	

function setKatLink(jqueryObj,closePost){
	
	jqueryObj.click(function(e){
		var _kat=$(this).text();
		/*active(_kat.toLowerCase());*/	// wird doch nciht gebraucht
		if(_kat.toLowerCase()!=activeKat){
		$.address.parameter("kat", _kat.toLowerCase());
		}else{
			katBoxRuckel();// aktive boxen bewegen sich nur als feedback
			}
		if(closePost==true){
			closeProject(500);
		//$.address.parameter("id", "");
		}
		e.preventDefault();
	})
	
}

function katReset(){
	$(".kat_reset").click(function(e){
		$.address.parameter("kat", '');
		//$("#showall").hide();
	e.preventDefault();	
	})
}




	
/*++++++++Headerinfo Projekte ordnen++++*/
	
$(function(){
if(isMobile==false){
	$("#projekte_ordnen").mouseover(function() {
		
	$("#projekte_auswahl").css("visibility","visible");			
	});
	$("#projekte_ordnen").mouseout(function() {
	$("#projekte_auswahl").css("visibility","hidden");	
	$("#projekte_ordnen").css("background-color","#ffffff");	
	})
	}else{
	/*touchpad**/
	$("#projekte_ordnen").click(function(event) {
		$('body').click(function() {
				
			$("#projekte_auswahl").css("visibility","hidden");	
			$("#projekte_ordnen").css("background-color","#ffffff");
	 		$('body').unbind('click');
		 });
	event.stopPropagation();
	$("#projekte_auswahl").css("visibility","visible");			
	});
	/*touchpad**/
	}
});	
	

function closeProject(time){
	animationRunning=true;
	if(time==undefined){
		time=400;
	}
	activePost=undefined;
	$('#single_post').stop();
	if($('#single_post').height()>0){
	$('#single_post').animate({
	height: 0 }, time,removeContent);
	}
	
}

function removeContent(){
	animationRunning=false;
	$.address.parameter("id","");
	$("#post_1").html("<div></div>");//nicht gut. da masonry error
	}



  
function ajaxLoaded(){
	//document.body.style.cursor = 'default';
	document.body.className = ''
	checkflash();
	/*if(hasFlash==true){
		var swfanzahl=$('object').length/2;
		//for(i=0;i<swfanzahl;i++){
			//swfobject.switchOffAutoHideShow();

			//swfobject.registerObject("swfobj_"+i, "19", "http://localhost/wp_test/wp-content/plugins/swfobj/expressInstall.swf");
			//alert(i);
			
			}
		
		}*/
	setKatLink($('#katlinks a'),true);
	$("#bt_close").click(function(){closeProject();})
	var _next=$('.box$[name='+activeBox+']').next().find('.post_link');
	var _prev=$('.box$[name='+activeBox+']').prev().find('.post_link');

	if(_next.get(0)!=undefined){
	//$("#bt_next").css("visibility","visible");
	$("#bt_next").css("display","default");
	$("#bt_next").click(function(){
	_next.trigger('click');
		})
	}else{
		//$("#bt_next").css("visibility","hidden");
		$("#bt_next").css("display","none");
		}
	if(_prev.get(0)!=undefined){
	//$("#bt_prev").css("visibility","visible");
	$("#bt_prev").css("display","default");
	$("#bt_prev").click(function(){
	_prev.trigger('click');
		})
	}else{
		//$("#bt_prev").css("cursor","default");
	/*	$("#bt_prev").mouseover(
		function(){
			
			$(this).css("opacity","0.1");
		})*/
		
		
		$("#bt_prev").click(function(){
		
		closeProject();
		});
	//$("#bt_prev").css("visibility","hidden");
	//$("#bt_prev").css("opacity","0.1");
		
		//$("#bt_prev").css("display","none");
		
		}

	//muss nochmal aufgerufen werden!!		 
/*	$('#single_images').masonry({
		columnWidth: 1,//_singlewidth+_marginright, 
		itemSelector: 'img'
	});	*/	 	
		
	//var targHeight=$('#single_post').attr("scrollHeight");
	
	$('#single_post').stop();
	var targHeight=$('#post_1').height();
	animationRunning=true;
	
	if(targHeight==$('#single_post').height()){
	$('#single_post').animate({
		height: targHeight+10
	 }, 200);	
	}
	
	
		$('#single_post').animate({
		height: targHeight
	 }, 300,function(){animationRunning=false;});
	// document.body.className = ''
}





			
/*++++++++Kategorie Sortierfunktion++++*/		
function sortKat(katbox){
	resetBoxorder();
	var _box;
	_box=undefined;
	
//neu	$(".box").each(function(){removeAlpha($(this))});//in resetboxorder
$(".box").not(katbox).css("opacity",inactiveColor); //wandert in callback nach Animation
/*$(".box").not(katbox).prepend('<div class="whitetrans"></div>');
$(".whitetrans").css("opacity","0.8");
$(".whitetrans").css("position","absolute");
$(".whitetrans").css("width","100%");
$(".whitetrans").css("height","100%");
$(".whitetrans").css("background-color","#fff");*/
	$(katbox).not(".kat").each(function(){
		//$(this).parent().css("opacity","1");//weg??
		//this.style.filter='';
		
		removeAlpha($(this));//neu in resetbox order
		if(_box==undefined){
		$(this).detach();
		$('#thumb_container').prepend($(this));
		_box=$(this);
		}else{
		$(this).insertAfter(_box)
		_box=$(this);
		}
	});
	
	katMove(katbox);
	
}

function katMove(katbox){
	
	$('#thumb_container').masonry({
        columnWidth: _singlewidth+_marginright, 
        itemSelector: '.box',
		 animate: true,
		 animationOptions: {
		 duration:500//'fast'
		 //complete:function(){$(".box").not(katbox).css("opacity",inactiveColor)},
		 }
    }//,katMoveEnd
	 
	);
	
}

//function sortDefault(){
//	for (i=1;i<=5;i++){
//		var _id=i+1
//		$('#'+_id).insertBefore('#'+i)
//	}
//	 $('#thumb_container').masonry({
//		columnWidth: _singlewidth+_marginright, 
//		itemSelector: '.box',
//		animate: true
//	});
//}

function resetBoxorder(){
	
	var anzahl=$('#thumb_container').children().size();
		for (i=0;i<=anzahl;i++){
			var _id=i+1;
			$('#'+_id).insertAfter('#'+i);
			removeAlpha($('#'+_id));
			
		}
}
function removeAlpha(obj){
	obj.css("opacity","1");
	if(isMsie){
		obj.removeAttr("filter");
		obj.css("filter","");
	}
	
	
	}


function single_postHeight(){
$('#single_post').css('height','auto');	
$('#single_post').height($('#post_1').height());	
}
function katBoxRuckel(){

$('.'+activeKat).each(function(){
	var _pos=$(this).position();
	$(this).animate({
	left: _pos.left+10

	 }, 400);

	$(this).animate({
	left: _pos.left
	 }, 100);
}
)
}

function resizeFlash(_width){
	
	$("#flashobj").animate({
	width:_width},
	400);
	
	
	}



/* wird doch nicht gebraucht, soll mit aktivem  etwas machen

function active(_kat){ 
	//$('.short_text').find('.kat').css("color","#000");
	//$('.short_text').find('.'+_kat).css("color","#999");
	//$('.short_text').find('.kat').css("text-decoration","none")
	//$('.short_text').find('.'+_kat).css("text-decoration","line-through")
	$('.short_text').find('.kat').unbind('mouseenter mouseleave');
	$('.short_text a+ .'+_kat).hover(
	function () {//komischer bug erster kat a ref wird nicht gefunden daher in index.php ein leeres a href vorher platziert
    $(this).addClass("katlink-hover");
  },
  function () {
    $(this).removeClass("katlink-hover");
  }

	);
}*/

