jQuery.noConflict();





function libLANG() {
	jQuery('#lang ul li').hover(
		function() {
			jQuery(this).find('ul:first').slideDown('fast');
		},
		function() {
			jQuery(this).find('ul:first').slideUp(1);
		}
	);
}

function AGENTUR_NET() {
	jQuery('#agentur_net ul li').hover(
		function() {
			jQuery(this).find('ul:first').slideDown('fast');
		},
		function() {
			jQuery(this).find('ul:first').slideUp(1);
		}
	);
	
	jQuery('#agentur_net').click(
		function() {
			//alert(jQuery(this).find('a').attr('href'));
			//window.parent.location = jQuery(this).find('a').attr('href');
			window.open(jQuery(this).find('a').attr('href'));
		}
	)
	
}

function Prod_uebersicht_HOVER() {
	jQuery('#csc-menu ul li div.teaser_image').hover(
		function() {
			jQuery(this).css({'filter' : 'alpha(opacity=60)', '-moz-opacity' : '.60', 'opacity' : '.60'});
		},
		function() {
			jQuery(this).css({'filter' : 'alpha(opacity=99)', '-moz-opacity' : '.99', 'opacity' : '.99'});
		}
	);
	jQuery('#csc-menu ul li div.teaser_image2').hover(
		function() {
			jQuery(this).prev().css({'filter' : 'alpha(opacity=60)', '-moz-opacity' : '.60', 'opacity' : '.60'});
		},
		function() {
			jQuery(this).prev().css({'filter' : 'alpha(opacity=99)', '-moz-opacity' : '.99', 'opacity' : '.99'});
		}
	);
}



function familien_HOVER() {



	jQuery("#element_1399 p:eq(0)").css({'margin-top' : '15px'});
	jQuery("#element_1400 p:eq(0)").css({'margin-top' : '15px'});




	
	var wechselbild1 = jQuery('#col1 .csc-textpic-imagerow:eq(1) > .csc-textpic-image > dt img').attr('src');
	var wechselbild_norm1 = jQuery('#col1 .csc-textpic-imagerow:eq(0) > .csc-textpic-image > dt > a').html();
	
	var wechselbild2 = jQuery('#c1 .csc-textpic-imagerow:eq(1) > .csc-textpic-image > dt img').attr('src');
	var wechselbild_norm2 = jQuery('#c1 .csc-textpic-imagerow:eq(0) > .csc-textpic-image > dt > a').html();
	
	var wechselbild3 = jQuery('#c2 .csc-textpic-imagerow:eq(1) > .csc-textpic-image > dt img').attr('src');
	var wechselbild_norm3 = jQuery('#c2 .csc-textpic-imagerow:eq(0) > .csc-textpic-image > dt > a').html();
	
	var wechselbild4 = jQuery('#col3 .csc-textpic-imagerow:eq(1) > .csc-textpic-image > dt img').attr('src');
	var wechselbild_norm4 = jQuery('#col3 .csc-textpic-imagerow:eq(0) > .csc-textpic-image > dt > a').html();
	

	
	jQuery('#col1 .csc-textpic-imagerow:eq(1) > .csc-textpic-image > dt > img').css({'display' : 'none'});
	jQuery('#c1 .csc-textpic-imagerow:eq(1) > .csc-textpic-image > dt > img').css({'display' : 'none'});
	jQuery('#c2 .csc-textpic-imagerow:eq(1) > .csc-textpic-image > dt > img').css({'display' : 'none'});
	jQuery('#col3 .csc-textpic-imagerow:eq(1) > .csc-textpic-image > dt > img').css({'display' : 'none'});
	
	jQuery('.csc-textpic-imagerow').click(
		function() {
			//alert(jQuery(this).find('a').attr('href'));
			window.location.href = jQuery(this).find('a').attr('href');
		}
	)
	
	jQuery('#col1 a:eq(0)').hover(
		function() {
			jQuery('#col1 .csc-textpic-imagerow:eq(0) > .csc-textpic-image > dt > a img').attr({ 
          src: wechselbild1
        });

			jQuery('#c1 .csc-textpic-imagerow:eq(0) > .csc-textpic-image > dt > a').html(wechselbild_norm2);
			jQuery('#c2 .csc-textpic-imagerow:eq(0) > .csc-textpic-image > dt > a').html(wechselbild_norm3);
			jQuery('#col3 .csc-textpic-imagerow:eq(0) > .csc-textpic-image > dt > a').html(wechselbild_norm4);
			
			jQuery('#c1 .famtext').slideUp('fast');
			jQuery('#c2 .famtext').slideUp('fast');
			jQuery('#c3 .famtext').slideUp('fast');
			jQuery('#col3 .famtext').slideUp('fast');
			jQuery('#col1 .famtext').slideDown('fast');
		},
		function() {
			jQuery('#col1 .csc-textpic-imagerow:eq(0) > .csc-textpic-image > dt > a').html(wechselbild_norm1);
		}
	);
	jQuery('#c1 > div:eq(0)').hover(
		function() {
			jQuery('#c1 .csc-textpic-imagerow:eq(0) > .csc-textpic-image > dt > a img').attr({ 
          src: wechselbild2
        });

			
			jQuery('#col1 .csc-textpic-imagerow:eq(0) > .csc-textpic-image > dt > a').html(wechselbild_norm1);
			jQuery('#c2 .csc-textpic-imagerow:eq(0) > .csc-textpic-image > dt > a').html(wechselbild_norm3);
			jQuery('#col3 .csc-textpic-imagerow:eq(0) > .csc-textpic-image > dt > a').html(wechselbild_norm4);
			
			jQuery('#c2 .famtext').slideUp('fast');
			jQuery('#c3 .famtext').slideUp('fast');
			jQuery('#col1 .famtext').slideUp('fast');
			jQuery('#col3 .famtext').slideUp('fast');
			jQuery('#c1 .famtext').slideDown('fast');
		},
		function() {
			jQuery('#c1 .csc-textpic-imagerow:eq(0) > .csc-textpic-image > dt > a').html(wechselbild_norm2);
		}
	);
	jQuery('#c2 > div:eq(0)').hover(
		function() {
			jQuery('#c2 .csc-textpic-imagerow:eq(0) > .csc-textpic-image > dt > a img').attr({ 
          src: wechselbild3
        });

			
			
			jQuery('#col1 .csc-textpic-imagerow:eq(0) > .csc-textpic-image > dt > a').html(wechselbild_norm1);
			jQuery('#c1 .csc-textpic-imagerow:eq(0) > .csc-textpic-image > dt > a').html(wechselbild_norm2);
			jQuery('#col3 .csc-textpic-imagerow:eq(0) > .csc-textpic-image > dt > a').html(wechselbild_norm4);
			
			jQuery('#c1 .famtext').slideUp('fast');
			jQuery('#c3 .famtext').slideUp('fast');
			jQuery('#col1 .famtext').slideUp('fast');
			jQuery('#col3 .famtext').slideUp('fast');
			jQuery('#c2 .famtext').slideDown('fast');
		},
		function() {
			jQuery('#c2 .csc-textpic-imagerow:eq(0) > .csc-textpic-image > dt > a').html(wechselbild_norm3);
		}
	);
	jQuery('#col3 > div:eq(0)').hover(
		function() {
			jQuery('#col3 .csc-textpic-imagerow:eq(0) > .csc-textpic-image > dt > a img').attr({ 
          src: wechselbild4
        });

			
			jQuery('#col1 .csc-textpic-imagerow:eq(0) > .csc-textpic-image > dt > a').html(wechselbild_norm1);
			jQuery('#c1 .csc-textpic-imagerow:eq(0) > .csc-textpic-image > dt > a').html(wechselbild_norm2);
			jQuery('#c2 .csc-textpic-imagerow:eq(0) > .csc-textpic-image > dt > a').html(wechselbild_norm3);
			
			jQuery('#c1 .famtext').slideUp('fast');
			jQuery('#c2 .famtext').slideUp('fast');
			jQuery('#c3 .famtext').slideUp('fast');
			jQuery('#col1 .famtext').slideUp('fast');
			jQuery('#col3 .famtext').slideDown('fast');
		},
		function() {
			jQuery('#col3 .csc-textpic-imagerow:eq(0) > .csc-textpic-image > dt > a').html(wechselbild_norm4);
		}
	);
}



function libMEDIA() {
	jQuery('#bg').cycle(
		{
			fx:     'fade',
			timeout: 3000,
			speed:   1250,
			random:  1
		}
	);
}



function tableformat(){
	var anz_tr = jQuery('#col2 table.contenttable tbody').find("tr").length;
	for (zaehler = 1; zaehler <= anz_tr; zaehler += 2) {
		jQuery('#col2 table.contenttable tbody tr:eq('+zaehler+')').css({'background' : '#ffffff'});
	}

	
}
	
	














function referenzGallery()
{
	var divCounter = 0;
	var thumbCounter = 0;
	var curImage = 0;
	var categoryCounter = 0;
	var hasSlide = false;
	var height;
	
		//----------------------------building UP--------------------------------------------
		//wrap all Content Elements
		jQuery('#col2 > .referenzen').wrapAll ('<div id="referenzWrap"></div>');
		
		
		//create OverviewDiv
		jQuery('#col2 > #referenzWrap').before('<div id="category">'+jQuery('#col2 > h2').text()+'</div>');
		jQuery('#col2 > #category').after('<div id="categoryContainer"></div>');
		jQuery('#col2 > #referenzWrap').before('<div id="overview">Übersicht</div>');
		
		//create Prev/Next Buttons
		jQuery('#referenzWrap').after('<div id="referenzNav"> <a id="prev" href="#">Prev</a> <a id="next" href="#">Next</a> </div>');
		
		
		//create OverviewDropDown
		jQuery('#col2 > #overview').after('<div id="overviewContainer"><div id="overviewDropDown"></div></div>');
		
		jQuery('#col2 > #overviewContainer').prepend('<div id="prevOverview"></div>');
		jQuery('#col2 > #overviewContainer').append('<div id="nextOverview"></div>');
		
		//wrap all Elements
		
		
		//----------------------------building UP END--------------------------------------------
				
		//pass imageID to thumbs
	/*	var counter = 0;
		jQuery('#col2 > #referenzWrap > .referenzen').each(function(){
			var newId = jQuery(this).attr("id");
			counter++;
			jQuery('#col2 > #referenzWrap > .referenzen:nth-child('+counter+') > .thumbnail').attr('id', newId);
		});

				*/
		//Counter 4 preview
		jQuery('#col2 > #referenzWrap >.referenzen').each (function(){
			divCounter++;
			
		}); 
		
		height = Math.ceil(divCounter/7) *88; //height for OverviewContainer
		if(height > 340){
				height = 340;
		}
		jQuery('#overviewContainer').css({'display':'block','height' : height});
			
			
		
		
		//loading Categories

		jQuery('#col1 > .referenzen > #csc-menu > ul > li > a').each (function(){
			jQuery('#categoryContainer').append('<a href="/'+jQuery(this).attr("href")+'">'+jQuery(this).text()+'</a><br/>');
			//current Category orange
			if(jQuery(this).text() == jQuery('#col2 > h2').text()){
				jQuery('#categoryContainer > a:contains('+jQuery(this).text()+')').css({'color' : '#e79f00' });
			}
			categoryCounter++;
			
			
		}); 
		
			
		//Animate Divs
		jQuery('#referenzWrap')
		.cycle(
		{
			fx:      'scrollHorz',
			timeout:  6500,
			prev:    '#prev',
			next:    '#next',
			easing: 'easeInOutSine',
			pager: '#overviewDropDown',
			pagerClick: stopAnimation,
			prevNextClick: stopAnimation,
			pause:    1
		}
		);
		

		
		var linkCounter = 0;
		//load Thumbs into Overview DropDown
		jQuery('#col2 > #referenzWrap > .referenzen > .thumbnail').each(function(){
			
			jQuery('#overviewDropDown  > a:eq('+linkCounter+')').append(jQuery(this));
			linkCounter++;
				
		});
		
		
		
		//check if overview has to slide (pics > 35)
		
		if(divCounter > 28){
			hasSlide = true;
			
			var divsInRow = divCounter / 4;
			jQuery('#overviewDropDown').css({'width' : (750/7 * divsInRow +80) });
			//jQuery('#referenzNav').css({'z-index' : 800 });
			jQuery('#nextOverview').css({'visibility' : 'visible' });
			jQuery('#prevOverview').css({'visibility' : 'visible' });

		}
	
		//hide OverviewContainer at first circle-animation
		jQuery("#overviewContainer").delay(6500,function(){
			jQuery("#overviewContainer").animate({
					
					height: "0px"
			
				},
				650,
				'easeInBack',
				function(){
					jQuery("#overviewContainer").css({'display' : 'none'});
				}
			);
	
		});
		
		
		
		
		//add Overview Mouse-Listener
			
		jQuery("#overview").mouseover( function() { 
			jQuery('#overviewContainer').css({'display' : 'block'});
		
			jQuery('#overviewContainer').animate({
					
					height: height+1
			
				},
				650,
				'easeOutBack'			
			);
			
			jQuery('#categoryContainer').animate({
					
					height: "0px"
			
				},
				650,
				'easeInBack',
				function(){
					jQuery("#categoryContainer").css({'display' : 'none'});
				}
			);
			

		} );
		
		jQuery("#overviewContainer").mouseleave(function(){
			jQuery(this).animate({
					
					height: "0px"
			
				},
				650,
				'easeInBack',
				function(){
					jQuery("#overviewContainer").css({'display' : 'none'});
				}
			);
			
		});
		
		// add Category Mouse-Listener
		
		jQuery("#category").mouseover( function() { 
			jQuery('#categoryContainer').css({'display' : 'block'});
			
			var height = categoryCounter * 18;
		
			jQuery('#categoryContainer').animate({
					
					height: height
			
				},
				650,
				'easeOutBack'			
			);
			
			jQuery('#overviewContainer').animate({
					
					height: "0px"
			
				},
				650,
				'easeInBack',
				function(){
					jQuery("#overviewContainer").css({'display' : 'none'});
				}
			);

		} );
		
		jQuery("#categoryContainer").mouseleave(function(){
			jQuery('#categoryContainer').animate({
					
					height: "0px"
			
				},
				650,
				'easeInBack',
				function(){
					jQuery("#categoryContainer").css({'display' : 'none'});
				}
			);
			
		});
		
		jQuery("#prevOverview").mouseover(function(){
			if(jQuery('#overviewDropDown').position().left <0){
				jQuery('#overviewDropDown').animate({ 
				left: 0
				}, jQuery('#overviewDropDown').width());
			
			}
			
		}).mouseout(function(){
			jQuery('#overviewDropDown').stop();
		});
		
		jQuery("#nextOverview").mouseover(function(){
			
			if((jQuery('#overviewDropDown').position().left) -711   > (jQuery('#overviewDropDown').width() * -1)){
				jQuery('#overviewDropDown').animate({ 
					
					left: (jQuery('#overviewDropDown').width() * -1)+765
				  }, jQuery('#overviewDropDown').width() );
			} 
		}).mouseout(function(){
			jQuery('#overviewDropDown').stop();
		});

		
		
		//add Thumbnail-Listener
		
		jQuery(".thumbnail >img").mouseover( function() { 
			jQuery(this).css({'border':'solid 2px #e79f00'});

		} );
		
		jQuery(".thumbnail >img").mouseout( function() { 
			jQuery(this).css({'border':'solid 2px #ffffff'});

		} );
	
	
}
function stopAnimation(){
	jQuery('#referenzWrap').cycle('pause');
	jQuery('#overviewContainer').animate({
					
					height: "0px"
			
				},
				650,
				'easeInBack',
				function(){
					jQuery("#overviewContainer").css({'display' : 'none'});
				}
			);
}



function standort_highlight(){
	jQuery("#standortausgabe ul li:eq(0)").css({'background' : '#fff3df'});
}

function get_dimensions(){
	var fensterbreite = jQuery(window).width();
	var fensterhoehe = jQuery(window).height();

	var calcfsh = fensterhoehe-100;
	var calcfsb = calcfsh;
	

 	jQuery('.scribd a.thickbox').each (function(){
			var alter_link = jQuery(this).attr('href');
			jQuery(this).attr('href', jQuery(this).attr('href')+"&height="+calcfsh+"&width="+calcfsb+"");
	});
	
	
	jQuery('.scribd a.thickbox').hover(
		function() {
			jQuery(this).css({'filter' : 'alpha(opacity=60)', '-moz-opacity' : '.60', 'opacity' : '.60'});
		},
		function() {
			jQuery(this).css({'filter' : 'alpha(opacity=99)', '-moz-opacity' : '.99', 'opacity' : '.99'});
		}
	);
}

// Delay Plugin for jQuery
// - http://www.evanbot.com
// - © 2008 Evan Byrne
 
jQuery.fn.delay = function(time,func){
	this.each(function(){
		setTimeout(func,time);
	});
	
	return this;
};

	

	
	
	
function fake_locator(){	
	jQuery('#gaulwelt').click(
		function() {
			jQuery("#gaulwelt_stoerer").show("slow");
		}
	)
}


function fake_loc_ger(){
	var url = location.href;
	if (url.indexOf("land=de") > 0){
		check_country("de");
	}
}





function check_country(land){	
	if(land == "at"){
		jQuery("#gaulwelt_stoerer2").show("slow");
	}
	if(land == "de"){
		jQuery("#gaulwelt_stoerer_de").show("slow");
	}
}


function closest(){	
	jQuery('#x_close').click(
		function() {
			jQuery("#gaulwelt_stoerer2").hide("slow");
		}
	)
	jQuery('#de_close').click(
		function() {
			jQuery("#gaulwelt_stoerer_de").hide("slow");
		}
	)
}




function checkFields_werte(city,zip,lnd){
	//alert(city+'_____'+zip+'______'+lnd);
	if(lnd == "--"){
		alert("Bitte wählen Sie ein Land aus!");
		return false;
	}
	if(lnd == "at"){
		jQuery("#gaulwelt_stoerer2").show("slow");
		return false;
	}
	if(lnd == "de"){
		jQuery("#gaulwelt_stoerer_de").show("slow");
		return false;
	}
	if(city == "" && zip == ""){
		alert("Bitte geben Sie eine Postleitzahl oder einen Ort an!");
		return false;
	} else {
		document.forms.locator.submit();
	}
}


function newshover() {
	jQuery('.tt_news_list_facelift .item-facelift h3.title').hover(
 		function() {
			jQuery(this).parent().next().toggle();
				jQuery(this).mousemove(function(e){
				//	jQuery(this).parent().next().css("top",e.pageY-jQuery(this).parent().next().height()-jQuery(this).parent().next().height()+"px");
					jQuery(this).parent().next().css("top",e.pageY-250-jQuery(this).parent().next().height()+"px");
					jQuery(this).parent().next().css("left",e.pageX-40+"px");
				}); 
		},
		function() {
			jQuery(this).parent().next().toggle();
		}
	);
}

function mo_locator() {
	jQuery('.mo_info').click(
		function() {
			jQuery(this).parent().parent().next().slideDown('slow');
			newpos = setTimeout(function() {
				jQuery('#footer').css('bottom','-80px');
			}, 500);
		}
	);
	
	jQuery('div.close').click(
		function() {
			jQuery(this).parent().slideUp('slow');
		}
	);
}

jQuery(document).ready(
	function() {
		libLANG();
		AGENTUR_NET();
		//libMEDIA();
		Prod_uebersicht_HOVER();
		standort_highlight();	
		tableformat();
		fake_locator();
		check_country();
		closest();
		fake_loc_ger();
		newshover();
		mo_locator();
	}
);