$(document).ready(function(){	
	//SizeUp für die Seite Contact
	/*$('div.contact_adress div.right').each(function(index, elm) {
		var setname = 'set'+index;
		
		//Rel-Attribut als Verknüpfung hinzufügen
		$(this).children('a.sizeup').attr('rel', setname);
		
		var myset = new SizeUp(setname);
		myset.slideshow = false;
		myset.timer = 5000;
		myset.anchorpoint = "bottom-left";
		
		//die Bilder ausblenden und die Adressen dem Objekt hinzufügen
		$(this).children('div.sizeup_big').each(function(index, elm) {
			$(this).hide();
			myset.add($(this).children('img').attr('src'));
		});
		
		//Objekt initialisieren
		myset.init();
	});*/
	
	//News Bilder in Single View
	/*$('div.news-single p.img a.sizeup').each(function(index, elm) {
		switch(index) {
			//Thumbnail
			case 0:
				$(this).click(function(e) {
					//Original Bild aufziehen lassen
					$('div.news-single p.img a.sizeup:eq(1)').slideToggle("normal");
					return false;
				});
				
				break;
			//Original Bild
			case 1:
				$(this).hide();
				$(this).css({ "position":"absolute", "top":$('div.news-single p.img a.sizeup:eq(0) img').offset().top, "left":"85px"});
				$(this).click(function(e) {
					$(this).slideToggle("normal");
					return false;
				});
				break;
		}
	});*/
	
	//Validieren des Form "We are G2 emea"
	$('form#officesform').submit(function() {
		$(this).children("p.error").fadeOut('fast');
		
		if($(this).children("select option:selected").attr('value') != "2") {
			return true;
		}
		
		$(this).children("p.error").fadeIn('normal');
		return false;
	});
	
	//Validieren des Filter-Forms für Panorama
	/*$('form#searchform').submit(function() {
		//Wenn keine Checkbox ausgewählt ist, dann nicht absenden
		if($(this).children("input:checked").length == 0) {
			return false;
		}
		
		//Wenn alles in Default-Einstellung, dann auf die "normale" Übersicht umleiten
		if($(this).children("select#o option:selected").attr('value') == "" &&
		   $(this).children("select#c option:selected").attr('value') == "" &&
		   $(this).children("select#b option:selected").attr('value') == "" &&
		   $(this).children("input:checked").length == 4) {
			$(this).attr('action', 'index.php?id=3');
		}
		
		return true;
	});*/
	
	$('p.currentclients').each(function(index){
		$(this).html($.trim($(this).html()));
		if($(this).text() == "") {
			$(this).hide();
			$('h4.currentclients:eq('+index+')').hide();
		}
	});
	
	hideCollaborators('creatives');
	hideCollaborators('online');
	hideCollaborators('shopper');
	hideCollaborators('data');
	
	
	//Formular stylen
	$.NiceJForms.build({
		selectRightSideWidth:12,
		imagesPath:"fileadmin/templates/css/_nicejforms/"
	});
	
	//Hover für Go-Button
	$('#btn_go').bind('mouseover', function() {
		$(this).attr('src', 'fileadmin/templates/css/_img/btn_go_red.gif');
	});
	$('#btn_go').bind('mouseout', function() {
		$(this).attr('src', 'fileadmin/templates/css/_img/btn_go_grey.gif');
	});
	
	//Hover für Send-Button
	$('#send').bind('mouseover', function() {
		$(this).attr('src', 'fileadmin/templates/css/_img/btn_send_hover.gif');
	});
	$('#send').bind('mouseout', function() {
		$(this).attr('src', 'fileadmin/templates/css/_img/btn_send.gif');
	});
	
	//Hover für Reset-Button
	$('#reset').bind('mouseover', function() {
		$(this).children('img').attr('src', 'fileadmin/templates/css/_img/btn_reset_hover.gif');
	});
	$('#reset').bind('mouseout', function() {
		$(this).children('img').attr('src', 'fileadmin/templates/css/_img/btn_reset.gif');
	});
	
	//Hover für Submit-Button
	$('#submit').bind('mouseover', function() {
		$(this).attr('src', 'fileadmin/templates/css/_img/btn_showme_hover.gif');
	});
	$('#submit').bind('mouseout', function() {
		$(this).attr('src', 'fileadmin/templates/css/_img/btn_showme.gif');
	});
	
	//Für "Network" ein smoothes Scrollen hinzufügen
	$('ul#textlinks').localScroll();
	$('p.csc-linkToTop').localScroll();
	
});


	
function hideCollaborators(name) {
	var hide = 0;
	$('ul.'+name+' li').each(function() {
		$(this).html($.trim($(this).html()));
		if($(this).text() == "") hide++;
	});
	if(hide == 2) $('ul.'+name).hide();
}

function scrollToHeadquarter() {
	var timer = window.setTimeout(function() {
		window.clearTimeout(timer);
		if(window.pageYOffset < 10 || document.documentElement.scrollTop < 10) {
			$.scrollTo($('div.contact_headquater'),{duration:1000});
		}
	}, 1500);
}

