// JavaScript Document

		window.dhtmlHistory.create({
			toJSON: function(o) {
				return Object.toJSON(o);
			}
			, fromJSON: function(s) {
				return s.evalJSON();
			}
		});
		
		var yourListener = function(newLocation, historyData) {
			var location = newLocation.substring(1);
			if(location == "")
			 location = "home";
			open_content(location);
		}
		
		window.onload = function() {
			dhtmlHistory.initialize();
			dhtmlHistory.addListener(yourListener);
		};

	var be_0; //Public damit die Buttons funktionieren
	
	function open_content(sec)
	{
		
		var data = 'section=open_content&sec=' + sec;
		
		new Ajax.Request("./ax/index.ax.php",
			{
				method: 'post',
				parameters: data,
				onLoading: showloader("content"),
				onSuccess: function(r)  
				{ 
					$('sec').value = sec;
					
					var response = eval('('+ r.responseText +')');
					$('content').innerHTML = response['content'];
					if(response['content_image'] == true)
					{
						var pics1 = response.content_images;
						var buttons1=new Array ("img/style/image_slide/pre_photo.png", "img/style/image_slide/play_photo.png", "img/style/image_slide/stop_photo.png", "img/style/image_slide/next_photo.png");
						be_0 = new be_slideshow("0",pics1,"slideshow",720,response['content_image_height'],"#FFFFFF",3,1,20,"y","n","y",buttons1);
						be_0.b_insert();
					}	
					var children = $$('a.active');
		
					children.each(function(child){
					 child.removeClassName('active');
					});
					
					window.document.title = response['content_title'];
						
					$('main_menu').innerHTML = response['menu'];

					dhtmlHistory.add("x" + sec);
					$(sec).addClassName('active')
					
					$('language_menu').style.display = "none";
				},
				onFailure: function(r) 
				{
						throw new Error('Update project failed: '+ r.statusText);
				}
			}				
		);
	}
	
	function language_selected(lan)
	{	
		var data = 'section=language_selected&sec=' + $('sec').value + '&lan=' + lan;
		
			new Ajax.Request("./ax/index.ax.php",
			{
				method: 'post',
				parameters: data,
				onLoading: showloader("content"),
				onSuccess: function(r)  
				{ 
					hideloader();
					var response = eval('('+ r.responseText +')');
					$('content').innerHTML = response['content'];
					if(response['content_image'] == true)
					{
						var pics1 = response.content_images;
						var buttons1=new Array ("img/style/image_slide/pre_photo.png", "img/style/image_slide/play_photo.png", "img/style/image_slide/stop_photo.png", "img/style/image_slide/next_photo.png");
						be_0 = new be_slideshow("0",pics1,"slideshow",720,300,"#FFFFFF",3,1,20,"y","n","y",buttons1);
						be_0.b_insert();
					}	
					var children = $$('a.active');
		
					children.each(function(child){
					 child.removeClassName('active');
					});
					
					
					window.document.title = response['content_title'];
						
					$('main_menu').innerHTML = response['menu'];
					
					$('div_language_menu').innerHTML = response['language_menu'];
				}
			});
	}
	
function evalScript(scripts)
{	
	try
	{	if(scripts != '')	
		{	var script = "";
			scripts = scripts.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi, function(){
	       	                         if (scripts !== null) script += arguments[1] + '\n';
 	        	                        return '';});
			if(script) (window.execScript) ? window.execScript(script) : window.setTimeout(script, 0);
		}
		return false;
	}
	catch(e)
	{	alert(e)
	}
}


function searchSite()
{
	var data = 'section=btn_search_site_clicked&term=' + $("txt_search").value;
	
	new Ajax.Request("./ax/index.ax.php",
	{
		method: 'post',
		parameters: data,
		onSuccess: function(r)  
		{ 
			var response = eval('('+ r.responseText +')');
			$('content').innerHTML = response['content'];
		}
	});
}

function search_loadPage(page)
{
	var data = 'section=btn_search_site_clicked&term=' + $("txt_search").value + '&page=' + page;
	
	new Ajax.Request("./ax/index.ax.php",
	{
		method: 'post',
		parameters: data,
		onSuccess: function(r)  
		{ 
			var response = eval('('+ r.responseText +')');
			$('content').innerHTML = response['content'];
		}
	});
}
function search_loadPage_Limit(limit)
{
	var data = 'section=btn_search_site_clicked&term=' + $("txt_search").value + '&limit=' + limit;
	
	new Ajax.Request("./ax/index.ax.php",
	{
		method: 'post',
		parameters: data,
		onSuccess: function(r)  
		{ 
			var response = eval('('+ r.responseText +')');
			$('content').innerHTML = response['content'];
		}
	});
}

function showloader(divID)
{
   var dimensions = $(divID).getDimensions();

    var loaderimg = '<div align="center" id="loaderimg" style="height:'+ dimensions.height +'px;width:'+ dimensions.width +'px;background: white;filter:alpha(opacity=66);-moz-opacity:.66;opacity:.66;"><img src="img/style/loader.gif" style="margin-top: '+ dimensions.height/2.5 +'px"/></div>';

    Element.insert(divID, {top: loaderimg});

    Element.absolutize('loaderimg');
}

function hideloader()
{
	$("loaderimg").style.display = "none";
}


function btn_save_contact_clicked()
{
	var data = 'section=btn_save_contact_clicked&' + $("frm_contact").serialize();
	
	new Ajax.Request("./ax/index.ax.php",
	{
		method: 'post',
		parameters: data,
		onSuccess: function(r)  
		{ 
			var response = eval('('+ r.responseText +')');
			$('div_message').innerHTML = response['message'];
			
			if(response['success'] == 1)
			{
				$('cnt_sexcode_1').checked 	= false;
				$('cnt_sexcode_2').checked 	= false;
				$('cnt_name_first').value 	= "";
				$('cnt_name_last').value 		= "";
				$('cnt_company').value 			= "";
				$('cnt_email').value 				= "";
				$('cnt_phone').value 				= "";
				$('cnt_text').value 				= "";
			}
		}
	});
}


// Input-Boxen onFocus löschen
function clearDefault(el) {
	if (el.defaultValue==el.value) el.value = ""
}

function alpha(){
	var text=document.inisession.code.value;
	var i;
	var llarg=text.length;
		for(i=0;i<llarg;i++)	{
			if ( ((text.charAt(i)<'0') || (text.charAt(i)>'9')) && ((text.charAt(i)<'a') || (text.charAt(i)>'z')) && ((text.charAt(i)<'A') || (text.charAt(i)>'Z')) ){
			alert('Es sind keine Sonderzeichen zugelassen!');
			return false;
		}
		//alert(document.inisession.code.value);
	}
}

function MM_jumpMenu(targ,selObj,restore)
{
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
}
