jQuery.noConflict();
jQuery(function() {

    jQuery('.content-item h4').click(function() {
    	if(jQuery(this).parent().hasClass('closed')) {
            jQuery(this).parent().removeClass('closed').find('p').show();                    
        } else {
            jQuery(this).parent().addClass('closed').find('p').hide();                   
        }
    });
    
    jQuery('<div />').attr({ id: 'popup' }).appendTo('#page');
    jQuery('<div />').attr({ id: 'popup_bg' }).appendTo('#page');
    
    
    jQuery('<div />').addClass('content').appendTo('#popup');
    jQuery('<h2 />').html('<span class="h">' + jQuery('#mainmenu .active').text().replace('• ', '') + '<span />').appendTo('#popup .content');
    jQuery('<span />').addClass('close').html('schlie&szlig;en').prependTo('#popup h2');
    
    jQuery('a.teaser').click(function(e) {
    	e.stopPropagation();
    	e.preventDefault();
    	id = jQuery(this).attr('id');    	
    	nr = id.replace("t-", "");   
    	ordner = jQuery('#folder').val();	
        headClass = jQuery('#detail-' + id).find('input.headclass').val();
    	
    	jQuery('#popup h2').removeClass('hide white whiteh2').addClass(headClass);
    	
    	jQuery('#popup .content .text').remove();
    	jQuery('#popup .content .bg').remove();
    	jQuery('#popup .labelpic').remove('');
    	
    	jQuery('<div />').addClass('bg').css({'height' : 225 , 'background' : 'url(/includes/angebote/' + ordner + '/' + nr + '-box.jpg) repeat-x'}).appendTo('#popup .content'); 
    	
    	
    	jQuery('<div />').addClass('text').html('<br />Fragen Sie uns:<br />Telefon: 0365-23505<br />info@foto-schmidt-gera.de').appendTo('#popup .content'); 
    	
    	 
    	jQuery('<div />').html(jQuery('#detail-' + id).html()).prependTo('#popup .text');   
    	  	
    	if(jQuery(this).find('span').length > 0 && jQuery('#detail-' + id).find('h4').length < 1) {
            jQuery('<h4 />').html(jQuery(this).find('span').html()).prependTo('#popup .text');
        }
    	    	
    	
    	if(jQuery('#label-' + id).length > 0) {
    		jQuery('#popup').append(jQuery('#label-' + id).clone().removeClass('hidden').addClass('labelpic').show());
    	}   
    	
    	
    	
    	
    	jQuery('#popup').show().find('.close').unbind().click(function() {
    		jQuery('#popup, #popup_bg').hide();
    	});
    	jQuery('#popup_bg').show();
    	
    });
    
    jQuery('#teaserpopup_content').css({
    	marginTop : - (jQuery('#teaserpopup_content img').height() / 2),
    	height : jQuery('#teaserpopup_content img').height()
    });
    
    jQuery('#teaserpopup_content .close').unbind().click(function() {
    		jQuery('#teaserpopup_content, #teaserpopup_bg').hide();
    	});

    

});
