var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-21392128-3']);
_gaq.push(['_trackPageview']);

(function() {
	var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
	ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

$(document).ready(function(){
	$("#kontakt").css("height", $("#wrapper").height()-$("#footer").height()-$("#header").height());
	
  /*
	jQuery('#ctrl_2').click(function(){
		if (jQuery(this).val() == 'Suchbegriff') {
			jQuery(this).val('');
		}
    });
	*/
  
  if (!Modernizr.input['placeholder']) {
    $('[placeholder]').focus(function() {
      var input = $(this);
      if (input.val() == input.attr('placeholder')) {
        input.val('');
        input.removeClass('placeholder');
      }
    }).blur(function() {
      var input = $(this);
      if (input.val() == '' || input.val() == input.attr('placeholder')) {
        input.addClass('placeholder');
        input.val(input.attr('placeholder'));
      }
    }).blur().parents('form').submit(function() {
      $(this).find('[placeholder]').each(function() {
        var input = $(this);
        if (input.val() == input.attr('placeholder')) {
          input.val('');
        }
      })
    });
  }
  
	$(window).resize(function() {
		$("#kontakt").css("height", $("#wrapper").height()-$("#footer").height()-$("#header").height());
	});
	$(document).resize(function() {
		$("#kontakt").css("height", $("#wrapper").height()-$("#footer").height()-$("#header").height());
	});
	
	$("#linkXing").hover(
		function () {
			$(this).attr('src', '/tl_files/onemedia/images/icon_xing_hover.png');
		}, 
		function () {
			$(this).attr('src', '/tl_files/onemedia/images/icon_xing.png');
		}
	);
	
	$("#linkFacebook").hover(
		function () {
			$(this).attr('src', '/tl_files/onemedia/images/icon_facebook_hover.png');
		}, 
		function () {
			$(this).attr('src', '/tl_files/onemedia/images/icon_facebook.png');
		}
	);
	
	$(function() {
		$('a.lightbox').lightBox({
			imageLoading: '/tl_files/onemedia/images/lightbox-ico-loading.gif',
			imageBtnClose: '/tl_files/onemedia/images/lightbox-btn-close.gif',
			imageBtnPrev: '/tl_files/onemedia/images/lightbox-btn-prev.gif',
			imageBtnNext: '/tl_files/onemedia/images/lightbox-btn-next.gif'
		});
	});
		
	$('#facebookWall').fbWall({
		id:'194288420599923',
		accessToken:'206158599425293|27d6dfd77bfc586d60fd18fa.1-1324100322|cR9BFJ95UI0-O2J6gZwe4vQirlA',
		showGuestEntries:false,
		showComments:false,
		max:3,
		timeConversion:24
	});
	
	if ($("#onemedia-staff").attr("src") == "/tl_files/onemedia/images/staff_placeholder.png") {
		var number = getRandom(1, 6);
		$("#onemedia-staff").attr("src", "/tl_files/onemedia/images/staff_"+number+".png");
	}
	
});

function getRandom(min, max) {
	if (min > max) {
		return (-1);
	}
	if (min == max) {
		return (min);
	}
 
    return (min + parseInt(Math.random() * (max-min+1)));
}
