/*
window.addEvent('domready', function() {
	//flashheader loading
	var FO = { movie:"swf/flash_praesie_01_start.swf", width:"957", height:"274", majorversion:"9", build:"0", wmode:"opaque" };
	UFO.create(FO, "flashheader");
	myPopup.show();
	if(diaShow)
		diaShow.init();
});
*/

var myModal  = function(){
	var ismodal;

	return{
		isModal:function(){
			return this.ismodal;
		},
		show:function(){
			ismodal = true;
			$('modal_container').setStyle('width',window.getScrollWidth()+"px");
			$('modal_container').setStyle('height',window.getScrollHeight()+"px");
			$('modal_container').setStyle('display','');
		},
		hide:function(){
			ismodal = false;
			$('modal_container').setStyle('display','none');
		}
	}
}();


/*
 * myPopup is a simple widget to show a popup content loaded by an ajax request
 */
var myPopup = function(){
	return {
		hide: function(){
			myModal.hide();
			$('popup').setStyle('display','none');
		},
		show: function(url){
			myModal.show();
			$('popup').setStyle('display','');
			//$('popup').setStyle('overflow','visible');
			this.center();
		},
		center: function(){
			var posx = window.getScrollWidth() / 2 - $('popup').getStyle('width').toInt() / 2;
			//var posy = window.getScrollHeight() / 2 - $('popup').getStyle('height').toInt() / 2;
			var posy = window.getScrollTop() + (window.getHeight() / 2 - $('popup').getStyle('height').toInt() / 2);
			$('popup').setStyle('top',posy+"px");
			$('popup').setStyle('left',posx+"px");
		},
		setHeight: function(height){

			$('pu_cl').setStyle('height',height+"px");
			$('pu_cr').setStyle('height',height+"px");
			height -= 20;
			$('pu_c').setStyle('height',height+"px");
		}
	}
}();
/*
var diaShow = function(){
	var dia_images = new Array(
		'img/diashow/leistungen/01.jpg',
		'img/diashow/leistungen/02.jpg',
		'img/diashow/leistungen/03.jpg',
		'img/diashow/leistungen/04.jpg',
		'img/diashow/leistungen/05.jpg'
	);

	var dia_thumbs = new Array(
		'img/diashow/leistungen/thumbs/01.jpg',
		'img/diashow/leistungen/thumbs/02.jpg',
		'img/diashow/leistungen/thumbs/03.jpg',
		'img/diashow/leistungen/thumbs/04.jpg',
		'img/diashow/leistungen/thumbs/05.jpg'
	);

	var dia_captions = new Array(
		'<b>Konferenz Biogas 2007</b><br/>Lorem ipsum dolor sit amet, consetetur sadipscing elitr',
		'<b>Konferenz Biogas 2008</b><br/>Lorem ipsum dolor sit amet, consetetur sadipscing elitr',
		'<b>Konferenz Biogas 2009</b><br/>Lorem ipsum dolor sit amet, consetetur sadipscing elitr',
		'<b>Konferenz Biogas 2010</b><br/>Lorem ipsum dolor sit amet, consetetur sadipscing elitr',
		'<b>Konferenz Biogas 2011</b><br/>Lorem ipsum dolor sit amet, consetetur sadipscing elitr'
	);

	var idx = 0;

	return{
		init:function(){
			//start at index 0 and don't display the prev container
			idx = 1;
			this.prev();
		},

		next:function(){
			$('container_prev').setStyle('visibility','visible');
			idx++;
			//check if idx = 0 or last idx
		 	if(idx == dia_images.length-1){
				$('container_next').setStyle('visibility','hidden');
				$('dia_caption').setHTML(dia_captions[idx]);
				$('dia_img').src = dia_images[idx];
				$('thumb_prev').src = dia_thumbs[idx-1];
			}else{
				$('container_next').setStyle('visibility','visible');
				$('dia_caption').setHTML(dia_captions[idx]);
				$('dia_img').src = dia_images[idx];
				$('thumb_prev').src = dia_thumbs[idx-1];
				$('thumb_next').src = dia_thumbs[idx+1];
			}
		},
		prev:function(){
			$('container_next').setStyle('visibility','visible');
			idx--;
			if(idx == 0){
				$('container_prev').setStyle('visibility','hidden');
				$('dia_caption').setHTML(dia_captions[idx]);
				$('dia_img').src = dia_images[idx];
				$('thumb_next').src = dia_thumbs[idx+1];
			}else{
				$('container_prev').setStyle('visibility','visible');
				$('dia_caption').setHTML(dia_captions[idx]);
				$('dia_img').src = dia_images[idx];
				$('thumb_prev').src = dia_thumbs[idx-1];
				$('thumb_next').src = dia_thumbs[idx+1];
			}
		}
	}
}();
*/
var activeDiaShow = false;
var myAJAX = function(){
	return{
		load_diaPopup :  function(diashow){
			new Ajax('inc/dia_markup.inc.php',{
				method: 'get',
				update: $('pu_content'),
				evalScripts:true,
				onComplete: function()
				{
					/*diaShow.init()*/
					diashow.init();
					activeDiaShow = diashow;
					myPopup.setHeight(422);
					//resize the popup
					myPopup.show();
				}
			}).request();
		},
		load_stPopup :  function(){
			new Ajax('inc/send_to_markup.inc.php',{
				method: 'get',
				update: $('pu_content'),
				evalScripts:true,
				onComplete: function()
				{
					myPopup.setHeight(262);
					//resize the popup
					myPopup.show();
				}
			}).request();
		},
		load_spPopup :  function(){
			new Ajax('inc/klangroben_markup.inc.php',{
				method: 'get',
				update: $('pu_content'),
				evalScripts:true,
				onComplete: function()
				{
					myPopup.setHeight(322);
					//resize the popup

					myPopup.show();
					/*switch on one sprachprobe*/
					load_sp_flash('swf/klangproben/eng_mark_twain_01.swf');
					myAcordeon2.show('sp_acordeon3');
				}
			}).request();
		},
		load_imprintPopup :  function(){
			new Ajax('content/imprint.inc.php',{
				method: 'get',
				update: $('pu_content'),
				evalScripts:true,
				onComplete: function()
				{
					myPopup.setHeight(345);
					//resize the popup

					myPopup.show();
				}
			}).request();
		},
		load_en_waitPopup :  function(){
			new Ajax('inc/en_wait_markup.inc.php',{
				method: 'get',
				update: $('pu_content'),
				evalScripts:true,
				onComplete: function()
				{
					myPopup.setHeight(122);
					//resize the popup

					myPopup.show();
				}
			}).request();
		}
	}
}();


var myAcordeon = function(){
	var current_open = "";

	return{
		show : function(name){
			if(current_open != "")
				this.hide(current_open);
			$(name).setHTML($(name+'_content_h').innerHTML);
			current_open = name;
		},
		hide : function(name){
			$(name).setHTML($(name+'_content_n').innerHTML);
		}

	}
}();


var myAcordeon2 = function(){
	var current_open = "";

	return{
		show : function(name){
			if(current_open != "")
				this.hide(current_open);
			$(name).setHTML($(name+'_content_h').innerHTML);
			current_open = name;
		},
		hide : function(name){
			$(name).setHTML($(name+'_content_n').innerHTML);
		}

	}
}();

function load_sp_flash(file){
		//flashheader loading
		var blah = { movie: file , width:'217', height:'247', majorversion:'9', build:'0' }
		/*, wmode:'opaque' };*/
		UFO.create(blah, 'klangprobe_flash');


}

function send_send_to_form(){
	var error = "";
	if($('st_from_name').value == ""){
		error += "Bitte geben Sie Ihren Namen ein.\n";
	}
	if($('st_from_email').value == ""){
		error += "Bitte geben Sie Ihre E-Mail-Adresse ein.\n";
	}
	if($('st_from_name').value == ""){
		error += "Bitte geben Sie einen Empfängernamen ein.\n";
	}
	if($('st_from_name').value == ""){
		error += "Bitte geben Sie eine Empfänger E-Mail-adresse ein.\n";
	}
	if(error != "")
		alert(error);
	else{
		$('st_url').value = location.href;
		$('send_to_form_f').submit();
	}
}

function send_kontakt_form(){
	var error = "";
	if($('surename').value == ""){
		error += "Bitte geben Sie Ihren Namen ein.\n";
	}
	if($('name').value == ""){
		error += "Bitte geben Sie Ihren Vornamen ein.\n";
	}
	if($('business').value == ""){
		error += "Bitte geben Sie an für welches Unternehmen Sie tätig sind.\n";
	}
	if($('email').value == ""){
		error += "Bitte geben Sie Ihre E-Mail-Adresse an.\n";
	}
	if($('tel').value == ""){
		error += "Bitte geben Sie eine Telefonnumer an.\n";
	}
	if(error != "")
		alert(error);
	else{
		$('kontakt_form_form').submit();
	}
}