function showPopup(elemname) {
	$("#" + elemname).show(
		"normal",
		function() {
			$(".photoblogimg").fadeTo("medium", 0.33,
				function() {
					$("#milchglas").css("display", "block");
				}
			);
		}
	);
	$("#hline2").css("display", "none");
	$("#hline3").css("display", "none");
	$("#hline").css("visibility", "hidden");

	return false;
}

function showVideoPopup(elemname, vwidth, vheight, vname) {
	$("#" + elemname).show(
		"normal",
		function() {
			$("#projekt #milchglas").css("display", "block");
		}
	);
	$("#hline2").css("display", "none");
	$("#hline3").css("display", "none");
	$("#hline").css("visibility", "hidden");

	$('#film').flash({
		src: '/flash/video/htmlvideo_skinned.swf',
		width: vwidth,
		height: vheight,
		allowFullscreen: "true",
		menu: false,
		expressInstall: true,
		version: "9.0.115",
		flashvars: {
			v: "/videos/referenzen/" + vname,
			img: "/flash/video/start.jpg",
			autoPlay: "true",
			allowFullscreen: "true",
			allowScriptAccess: "always",
			bgcolor: "#FFFFFF",
			playIcon: "#CC0000",
			playIconAlpha: "1.0",
			btnIcon: "#CCCCCC",
			timerUp: "#CCCCCC",
			btnIcon: "#CCCCCC",
			barPlaying: "#CCCCCC",
			controlsBg: "#CCCCCC",
			controlsBgAlpha: 0.5
		}
	});

	return false;
}

function hidePopup(elemname) {
	$("#" + elemname).hide(
		"normal",
		function() {
			$("#milchglas").css("display", "none");
			$(".photoblogimg").fadeTo("medium", 1);
		}
	);
	$("#hline2").css("display", "block");
	$("#hline3").css("display", "block");
	$("#hline").css("visibility", "visible");

	return false;
}


var indexPopupBild=0;
var countPopupBild=0;
function initPopup(i) {
	indexPopupBild=i;
	showPopupImg();
}
function showPopupImg() {
	var elem = document.getElementById('pofoimg');
	if(elem) {
		var apath = elem.src.split('/');
		apath.pop();
		apath.push('' + indexPopupBild + '.png');
		var s = apath.join('/');
		elem.src = s;
	}
}
function nextPopup() {
	indexPopupBild++;
	if(indexPopupBild > countPopupBild) {
		indexPopupBild = 1;
	}
	initPopup(indexPopupBild);
	return false;
}
function prevPopup() {
	indexPopupBild--;
	if(indexPopupBild < 1) {
		indexPopupBild = countPopupBild;
	}
	initPopup(indexPopupBild);
	return false;
}

function getPopupX(inneroffset) {
	return (document.body.offsetWidth-993) / 2 + inneroffset;
}

function gmapinitialize(lati, longi, ttipp, cont) {
	var myLatlng = new google.maps.LatLng(lati, longi);
	var myOptions = {
		zoom: 13,
		center: myLatlng,
		mapTypeId: google.maps.MapTypeId.ROADMAP
	}

	var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

	var infowindow = new google.maps.InfoWindow({
		content: cont
	});

	var marker = new google.maps.Marker({
		position: myLatlng,
		map: map,
		title: ttipp
	});

	google.maps.event.addListener(marker, 'click', function() {
		infowindow.open(map, marker);
	});

}


var pushInterval;
var pushTarget;
function pushEnter(target) {
	pushTarget = target;
	pushInterval = window.setInterval("pushTimer()", 500);
}
function pushLeave() {
	window.clearInterval(pushInterval);
}
function pushTimer() {
	window.clearInterval(pushInterval);
	location.href = pushTarget;
}

var intervalTeaser=null;
var indexTeaser=1;
var countTeaser=3;
function teaserWechsel() {
	indexTeaser++;
	if(indexTeaser>countTeaser) indexTeaser=1;

	$('img.teaserrotation').hide();
	$('#teaserrotation'+indexTeaser).show();
} // func


/* onReady */
$(document).ready(function(){
	
	var tmpDate=new Date();
	var tmpTime=tmpDate.getTime();

	$('#teaserrotation1').each(function(index) {
		intervalTeaser = window.setInterval("teaserWechsel()", 8000);
	});

	$.validator.messages.required = '';
	$.validator.messages.email = 'Bitte eine gültige eMail Adresse eingeben.';
	$("form.validate").validate({
		invalidHandler: function(e, validator) {
			var errors = validator.numberOfInvalids();
			if (errors) {
				var message = (errors == 1) ? 'Es fehlt noch ein Pflichtfeld, um Ihnen eine Bestätigung zuschicken zu können.' : 'Es fehlen noch ' + errors + ' Pflichtfelder, um Ihnen eine Bestätigung zuschicken zu können.';
				$("div.error span").html(message);
				$("div.error").show();
			} else {
				$("div.error").hide();
			} // if
		}
	});

	$('a.validateandsend').click(function() {
		$('form.validate').validate();
	});

/* Homepage */
/*	$('#fhomepage').flash({ 
		src: '/flash/intro.swf',
		width: 993,
		height: 335,
		wmode: 'transparent'
	}); */

/* Agentur */
/*	$('#aplay').flash({ 
		src: '/flash/agentur.swf',
		width: 995,
		height: 286,
		wmode: 'transparent'
	}); */

/* Referenzen */
/*	$('#pfkarussell').flash({ 
		src: '/flash/referenzen.swf?t='+tmpTime,
		width: 993,
		height: 300,
		wmode: 'transparent'
	}); */

/* Awards */
/*	$('#awkarussell').flash({ 
		src: '/flash/award.swf?t='+tmpTime,
		width: 993,
		height: 300,
		wmode: 'transparent'
	}); */

/* Video Solutionsday */
	$('#filmsday2011').flash({ 
		src: '/flash/video/htmlvideo_skinned.swf',
		width: 448,
		height: 336,
		allowFullscreen: "true",
		menu: false,
		expressInstall: true,
		version: "9.0.115",
		flashvars: {
			v: "/flash/video/Zusammenschnitt_Solutionsday.flv",
			img: "/flash/video/Zusammenschnitt_Solutionsday.jpg",
			autoPlay: "true",
			allowFullscreen: "true",
			allowScriptAccess: "always",
			bgcolor: "#FFFFFF",
			playIcon: "#CC0000",
			playIconAlpha: "1.0",
			btnIcon: "#CCCCCC",
			timerUp: "#CCCCCC",
			btnIcon: "#CCCCCC",
			barPlaying: "#CCCCCC",
			controlsBg: "#CCCCCC",
			controlsBgAlpha: 0.5
		}
	});

	$('body#mit-anfahrt_test, body#mit-anfahrt').each(function() {
		gmapinitialize(50.253635, 8.64588, 'M.I.T e-Solutions GmbH', '<b>M.I.T e-Solutions GmbH</b><br />Am Zollstock 1<br />61381 Friedrichsdorf<br><br><a href="http://maps.google.com/maps?f=q&source=s_q&hl=de&geocode=&q=Am+Zollstock+1,+Friedrichsdorf,+Deutschland&sll=50.25372,8.64558&sspn=0.077929,0.149689&ie=UTF8&hq=&hnear=Am+Zollstock+1,+Seulberg+61381+Friedrichsdorf,+Hochtaunuskreis,+Hessen,+Deutschland&z=16">Route suchen</a>');
	});

	$('body#mit-anfahrtm').each(function() {
		gmapinitialize(48.086650, 11.644230, 'Büro München', '<b>Büro München</b><br />Carl-Wery-Straße 42<br />81739 München<br><br><a href="http://maps.google.com/maps?f=q&source=s_q&hl=de&geocode=&q=Carl-Wery-Stra%C3%9Fe+42,+M%C3%BCnchen,+Bundesrepublik+Deutschland&sll=48.088649,11.64519&sspn=0.020353,0.037422&ie=UTF8&hq=&hnear=Carl-Wery-Stra%C3%9Fe+42,+M%C3%BCnchen+81739+M%C3%BCnchen,+Bayern,+Bundesrepublik+Deutschland&t=h&z=16">Route suchen</a>');
	});

	$('#hline img.hline').mouseover(function() {
		var iid=$(this).attr('id');
		iid=iid.substr(iid.length-1,1);
		$('#tfdefault, #tf1, #tf2, #tf3').hide();
		$('#hlineimg1, #hlineimg2, #hlineimg3').css('top', '1px');
		$('#tf'+iid).show();
		$('#hlineimg'+iid).css('top', '-11px');
		$('#indeximage').attr('src', '/img/cont/index' + iid + '.jpg');
	});

});

