/* Architektenprofile Übersicht - Hover für Bilder */
function imghoverprepare(){
	jQuery('.imghoversize').each(function(){
		if(jQuery(this).attr('rel')!=''){
			var imageArr = jQuery(this).attr('rel').split(";");
			var hoverSrc = imageArr[0];
			var imageWidth = parseInt(imageArr[1])+parseInt(20);
			var imageHeight = parseInt(imageArr[2])+parseInt(20);
			
			jQuery(this).bind('mouseenter', function(){
				if(jQuery(this).children('.imghoverview').size() > 0){
					jQuery(this).children('.imghoverview').fadeIn();
					
				} else if(jQuery('.imghoverview', this).size() == 0) {
					var newHoverImage = new Image();
					newHoverImage.src = hoverSrc;
					/*newHoverImage.setAttribute('class', 'imghoverview');*/
					
					jQuery(this).prepend(newHoverImage);
					var orgWidth = jQuery('.projektimg', this).width();
					var orgHeight =jQuery('.projektimg', this).height();
					
					var imgWidth = Math.round((imageWidth-orgWidth)/2);
					var imgHeight = Math.round((imageHeight-orgHeight)/2);
					
					jQuery(newHoverImage).css({
						'left':(-imgWidth)+"px"
						,'top':(-imgHeight)+"px"
					}).addClass('imghoverview');
					
					jQuery(this).children('.imghoverview').fadeIn();
				}
			});
			
			jQuery(this).bind('mouseleave', function(el){
				if(jQuery('.imghoverview', this).size() > 0){
					jQuery(this).children('.imghoverview').hide();
				}
			});
		}
	});
}

//xpngFix();
(function ($){
$.noConflict();
$(document).ready(function(){
	var searchVal = $('#search-input').val();
	$('#search-input').click(function(){
		this.value= '';
	}).blur(function(){
		if (!this.value)
			this.value = searchVal;
	});
	
	// Lightbox
	$('.absatz, .article-detail, .release-detail, .news-detail, .teaser-box, .right, .projekte').tinyLightbox({item:'a[rel="lightbox"]'});
	
	$('.architect h3').click(function(){
		$(this).next('.details').slideToggle(300);
	});
	
	// E-Mail Spamschutz
	$('.email').each(function(){
		e = this.rel.replace('/','@');
		this.href = 'mailto:' + e;
		$(this).text(e);
	});

	//teaser group	
	var groupsCount = $('.teaser-group').length,
		groupNr = 1;
	$('.teaser-group .arrow-right').click(function(){
		if (groupNr<groupsCount)
		{
			$(this).parent().parent().hide().next('.teaser-group').show();
			groupNr++;
		};
	});
	$('.teaser-group .arrow-left').click(function(){
		if (groupNr>1)
		{
			$(this).parent().parent().hide().prev('.teaser-group').show();
			groupNr--;
		};
	});
	
	/*
	$('.header_image').slideshow(images, 
		{
			fadeSpeed: 1000,
			changeSpeed: 5000,
			delayBeforeStart: 1000
		}
	);
	*/
	
	jQuery('.maxi').bind('mouseleave', function(){
		jQuery('.maxi').fadeOut(100);
	});
	
	jQuery('.popupclose').click(function(){
		jQuery('#popup_notfound').hide();
	});
	
	jQuery('#architektenprofilsuche').click(function(){
		if(document.getElementById('architektenprofilsuche').checked == true){
			jQuery('#suche').attr('action', jQuery('#architektenprofilseite').val());
			jQuery('#architektenprofilcheck').val('true');
		} else {
			jQuery('#suche').attr('action', jQuery('#suchestartdefault').val());
			jQuery('#architektenprofilcheck').val('false');
		}
	});
	
	jQuery('.projekte').cycle({ 
		fx:     'scrollHorz', 
		prev:   '.gal_prev', 
		next:   '.gal_next', 
		timeout: 0 
	});
	
	jQuery('.aprojektdetailimg').mouseover(function(){
		jQuery('.projekt_aktiv').removeClass('projekt_aktiv');
		jQuery('.projektdetailimg', this).addClass('projekt_aktiv');
		var elementId = jQuery(this).attr('id');
		elementId = elementId.substr(2);
		var textReplace = jQuery('#hover'+elementId).html();
		
		if(textReplace=="")
			textReplace = '&nbsp;';
		
		jQuery('#projektdetailstext').html(textReplace);
	});
	
	jQuery('input, label', '#suche').change(function(){
		jQuery('#number').html('<img src="/ccds_tpl_img/loading.gif" />');
	});
	
	imghoverprepare();
});


})(jQuery);


function closeNotfound()
{
	jQuery('#popup_notfound').hide();
}

if((document.getElementById("popup_notfound")) && (document.getElementById("popup_notfound").style.display=="block" || document.getElementById("popup_notfound").style.display==""))
{
	window.setTimeout("closeNotfound()", 5000);
}

