jQuery.fn.center = function () {
	this.css("position","absolute");
	var top=( $(window).height() - this.height() ) / 2+$(window).scrollTop();
	var left=( $(window).width() - this.width() ) / 2+$(window).scrollLeft();
	this.css("top", top<0?0:top + "px");
	this.css("left", left<0?0:left + "px");
	return this;
};

$(document).ready(function(){	
	$('#area_gew').mouseenter(function(e) {		
		show_home_text("gewaechshaeuser","produkte");
	});
	$('#area_car').mouseenter(function(e) {		
		show_home_text("carports","produkte");
	});
	$('#area_ueb').mouseenter(function(e) {		
		show_home_text("ueberdachungssysteme","produkte");
	});
	$('#area_zub').mouseenter(function(e) {		
		show_home_text("zubehoer","produkte");
	});
	$('#area_gew').mouseleave(function(e) {		
		hide_home_text("gewaechshaeuser","produkte");
	});
	$('#area_car').mouseleave(function(e) {		
		hide_home_text("carports","produkte");
	});
	$('#area_ueb').mouseleave(function(e) {		
		hide_home_text("ueberdachungssysteme","produkte");
	});
	$('#area_zub').mouseleave(function(e) {		
		hide_home_text("zubehoer","produkte");
	});
	$('#gw_area_1').mouseenter(function(e) {		
		show_home_text("1","qualitaet_gw");
	});
	$('#gw_area_2').mouseenter(function(e) {		
		show_home_text("2","qualitaet_gw");
	});
	$('#gw_area_3').mouseenter(function(e) {		
		show_home_text("3","qualitaet_gw");
	});
	$('#gw_area_4').mouseenter(function(e) {		
		show_home_text("4","qualitaet_gw");
	});
	$('#gw_area_5').mouseenter(function(e) {		
		show_home_text("5","qualitaet_gw");
	});
	$('#gw_area_6').mouseenter(function(e) {		
		show_home_text("6","qualitaet_gw");
	});
	$('#gw_area_7').mouseenter(function(e) {
		show_home_text("7","qualitaet_gw");
	});
	$('#gw_area_8').mouseenter(function(e) {		
		show_home_text("8","qualitaet_gw");
	});
	$('#gw_area_9').mouseenter(function(e) {		
		show_home_text("9","qualitaet_gw");
	});
	$('#gw_area_9').mouseenter(function(e) {		
		show_home_text("9","qualitaet_gw");
	});
	$('#gw_area_10').mouseenter(function(e) {		
		show_home_text("10","qualitaet_gw");
	});
	$('#gw_area_1').mouseleave(function(e) {		
		hide_home_text("1","qualitaet_gw");
	});
	$('#gw_area_2').mouseleave(function(e) {		
		hide_home_text("2","qualitaet_gw");
	});
	$('#gw_area_3').mouseleave(function(e) {		
		hide_home_text("3","qualitaet_gw");
	});
	$('#gw_area_4').mouseleave(function(e) {		
		hide_home_text("4","qualitaet_gw");
	});
	$('#gw_area_5').mouseleave(function(e) {		
		hide_home_text("5","qualitaet_gw");
	});
	$('#gw_area_6').mouseleave(function(e) {		
		hide_home_text("6","qualitaet_gw");
	});
	$('#gw_area_7').mouseleave(function(e) {		
		hide_home_text("7","qualitaet_gw");
	});
	$('#gw_area_8').mouseleave(function(e) {		
		hide_home_text("8","qualitaet_gw");
	});
	$('#gw_area_9').mouseleave(function(e) {		
		hide_home_text("9","qualitaet_gw");
	});
	$('#gw_area_10').mouseleave(function(e) {		
		hide_home_text("10","qualitaet_gw");
	});
	$('#cp_area_1').mouseenter(function(e) {		
		show_home_text("1","qualitaet_cp");
	});
	$('#cp_area_2').mouseenter(function(e) {		
		show_home_text("2","qualitaet_cp");
	});
	$('#cp_area_3').mouseenter(function(e) {		
		show_home_text("3","qualitaet_cp");
	});
	$('#cp_area_4').mouseenter(function(e) {		
		show_home_text("4","qualitaet_cp");
	});
	$('#cp_area_5').mouseenter(function(e) {		
		show_home_text("5","qualitaet_cp");
	});
	$('#cp_area_6').mouseenter(function(e) {		
		show_home_text("6","qualitaet_cp");
	});
	$('#cp_area_7').mouseenter(function(e) {
		show_home_text("7","qualitaet_cp");
	});
	$('#cp_area_1').mouseleave(function(e) {		
		hide_home_text("1","qualitaet_cp");
	});
	$('#cp_area_2').mouseleave(function(e) {		
		hide_home_text("2","qualitaet_cp");
	});
	$('#cp_area_3').mouseleave(function(e) {		
		hide_home_text("3","qualitaet_cp");
	});
	$('#cp_area_4').mouseleave(function(e) {		
		hide_home_text("4","qualitaet_cp");
	});
	$('#cp_area_5').mouseleave(function(e) {		
		hide_home_text("5","qualitaet_cp");
	});
	$('#cp_area_6').mouseleave(function(e) {		
		hide_home_text("6","qualitaet_cp");
	});
	$('#cp_area_7').mouseleave(function(e) {		
		hide_home_text("7","qualitaet_cp");
	});
	$('.top').mouseenter(function(e) {
		e.preventDefault();
		$(this).children('.navi_a').css("background-position","0px -35px");		
	});
	$('.top').mouseleave(function(e) {
		if(!$(this).children('a').hasClass('active')) $(this).children('.navi_a').css("background-position","0px 0px");
	});
	$('.has_sub').mouseenter(function(e) {
		e.preventDefault();
		$(this).children('.subsubmenu').css("display","block");
	});
	$('.has_sub').mouseleave(function(e) {
		e.preventDefault();
		$(this).children('.subsubmenu').css("display","none");
	});
	$('.g_type').click(function(e) {
		e.preventDefault();
		$.ajax({
			url: "../../data/gewaechshaeuser/type_img.php?id="+$(this).attr("id"),
			success: function(data) {
				var src=$('#gewaechshaus_bild').attr("src");
				src=src.substring(0,src.lastIndexOf('/')+1)+data;
				$('#gewaechshaus_bild').attr("src",src);
			}
		});
	});
	$('#play_btn').click(function(e) {
		e.preventDefault();
		runVideo();
	});
	$('#fade').click(function(e) {
		stopVideo();
	});
});

function hide_home_text(id,box) {
	if(box=='produkte') {
		$('#'+box+'_info').html('<h1>Herzlich Willkommen bei KGT</h1><p>Mit unserem Internetauftritt haben wir f&uuml;r Sie die Basis einer optimalen Informationsplattform geschaffen. Nehmen Sie sich ein wenig Zeit und informieren Sie sich &uuml;ber unsere hochwertigen Produkte "Made in Germany". Wir w&uuml;nschen Ihnen viel Spa&szlig; beim St&ouml;bern.</p>');
	} else {
		$.ajax( {
			url: BASEURL+"data/"+box+"/info.php",
			success: function(data) {
				$('#'+box+'_info').html(data);
			}
		});
	}
}

function show_home_text(id,box) {
	if(box=='produkte') {
		switch(id) {
			case 'carports':
				$('#'+box+'_info').html('<h1>Carports</h1><p>Sch&uuml;tzen Sie, was Ihnen lieb ist</p><p>KGT Carports bestechen nicht nur durch ihr stilvolles Design, sondern sie &uuml;berzeugen auch vor allem durch die hohe Qualit&auml;t der Konstruktion!</p>');
				break;
			case 'gewaechshaeuser':
				$('#'+box+'_info').html('<h1>Gew&auml;chsh&auml;user & Fr&uuml;hbeete</h1><p>Ihr Garten ist immer etwas Besonderes</p><p>KGT Gew&auml;chsh&auml;user und Fr&uuml;hbeete wurden speziell f&uuml;r den anspruchsvollen Hobby-G&auml;rtner von heute entwickelt. Vielleicht auch f&uuml;r Sie der Beginn einer "bl&uuml;henden" Beziehung!?</p>');
				break;
			case 'ueberdachungssysteme':
				$('#'+box+'_info').html('<h1>&Uuml;berdachungen</h1><p>Ihr Platz an der Sonne - vor Wind und Wetter gesch&uuml;tzt! </p><p>Die filigrane, aber dennoch sehr stabile Konstruktion aus speziellen Aluminium-Profilen, passt sich flexibel an Ihre &ouml;rtlichen Gegebenheiten an. Die ausgereifte Verglasungstechnik erm&ouml;glicht eine einfache und schnelle Eigenmontage.</p>');
				break;
			case 'zubehoer':
				$('#'+box+'_info').html('<h1>Zubeh&ouml;r</h1><p>Kreative Ideen f&uuml;r Ihr Zuhause</p><p>Praktisches und passgenaues Zubeh&ouml;r, speziell f&uuml;r ihr Qualit&auml;ts-Produkt aus unserem Hause! Steigern Sie Ihren Nutzen!</p>');
				break;
		}	
	} else {
		$.ajax( {
			url: BASEURL+"data/"+box+"/"+id+".php",
			success: function(data) {
				$('#'+box+'_info').html(data);
			}
		});
	}
}


function stopVideo() {
	$('#video_now').empty();
    $('#layer').empty();
    $('#layer').fadeTo(500,0);
    $('#fade').fadeTo(500,0);
    setTimeout("vanish()",500);
}

function vanish() {
	$('#layer').css("width","0");
	$('#layer').css("height","0");
	$('#fade').css("width","0");
	$('#fade').css("height","0");
}

function runVideo() {
	$('#layer').flash({
		src: BASEURL+'player.swf',
		wmode: 'transparent',
		width: 960,
		height: 540,
		flashvars: {"url":BASEURL+"data/qualitaet_gw/video/KGT-Qualitaet.flv"}
	});
	$('#fade').css("width",$(document).width());
	$('#fade').css("height",$(document).height());
	$('#layer').fadeTo(0,0);
	$('#layer').fadeTo("slow",1.0);
	if(navigator.userAgent.indexOf('MSIE')>-1) {
		$('#fade').fadeTo("slow",1);
	} else {
		$('#fade').fadeTo("slow",0.8);
	}
	$('#layer').css("width","960px");
	$('#layer').css("height","540px");
	$('#layer').center();
	$('#layer').css("display","block");
}

