function lightbox(id){
	
	sajax_request_type = 'POST';
	x_put_in_lightbox(id,saved);
	sajax_target_id = '';
}

function del_lightbox(id){

	if(confirm("Wollen Sie das Bild wirklich aus der Lightbox entfernen?")){
	
		sajax_request_type = 'POST';
		sajax_target_id = 'lightbox';
		x_del_lightbox(id,1);
		sajax_target_id = '';
	}
}

function get_news(){
	
	setTimeout(push_news, 10000);
	
}
 function push_news(){
	 
	 var v=1;
	 
	 sajax_request_type = 'POST';
	 sajax_target_id = 'news_start';
	 x_get_news(v,1);
	 sajax_target_id = '';
	 
	 get_news();
 }


function saved(){
	
	//alert('Bild wurde gesichert');
	document.getElementById('info').style.display="block";
	setTimeout("meldung_close();", 3000);
}

function meldung_close(){
	document.getElementById('info').style.display="none";
}


function change_illustrator(id_illustrator){
	document.location.href='index.php?id_illustrator='+id_illustrator;
}

function change_style(id_style){
	document.location.href='index.php?id_style='+id_style;
}

function get_styles(id_illustrator){
	
	//alert('ok');
	
	sajax_request_type = 'POST';
	sajax_target_id = 'categorie_liste';
	x_get_styles(id_illustrator,1);
	sajax_target_id = '';
	
}

function get_illustrators(id_style){
	
	//alert(id_style);
	
	sajax_request_type = 'POST';
	sajax_target_id = 'illustrator_liste';
	x_get_illustrators(id_style,1);
	sajax_target_id = '';
	
}

function get_zoomtext(id){
	
	return 'test';
}

function strrchr (haystack, needle) {
    // Finds the last occurrence of a character in a string within another  
    // 
    // version: 1109.2015
    // discuss at: http://phpjs.org/functions/strrchr
    // +   original by: Brett Zamir (http://brett-zamir.me)
    // +   input by: Jason Wong (http://carrot.org/)
    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
    // *     example 1: strrchr("Line 1\nLine 2\nLine 3", 10).substr(1)
    // *     returns 1: 'Line 3'
    var pos = 0;
 
    if (typeof needle !== 'string') {
        needle = String.fromCharCode(parseInt(needle, 10));
    }
    needle = needle.charAt(0);
    pos = haystack.lastIndexOf(needle);
    if (pos === -1) {
        return false;
    }
    	
   
    return haystack.substr(pos);
}


function check_mailform_data(){
	
	var mail_name = document.mailform.mail_name.value;
	var mail_surname = document.mailform.mail_surname.value;
	var mail_email = document.mailform.mail_email.value;
	var mail_comment = document.mailform.mail_comment.value;
	var code = document.mailform.code.value;
	
	var checked = true;
	
	if (mail_name.length==0)
	{
		document.mailform.mail_name.style.borderColor="red";
		checked = false;
	}
	
	if (mail_surname.length<3)
	{
		document.mailform.mail_surname.style.borderColor="red";
		checked = false;
	}
	
	if (mail_email.length<2)
	{
		document.mailform.mail_email.style.borderColor="red";
		checked = false;
	}
	
	if (mail_comment.length<4)
	{
		document.mailform.mail_comment.style.borderColor="red";
		checked = false;
	}
	
	if (code.length<4)
	{
		document.mailform.code.style.borderColor="red";
		checked = false;
	}
	
	if (checked==true){
		document.mailform.method = "post";
		document.mailform.action = "index.php?module=kontakt&headline=KONTAKT&id=27&lang=de";
		document.mailform.submit();
	} else {
		alert("Bitte ergänzen Sie die rot makierten Felder")
	}

	return checked;
}

function newsletter(aktion){
	
	var name = document.mailform.name.value;
	var email = document.mailform.email.value;
	
	checked = true; 
	
	if (name.length<2)
	{
		document.mailform.name.style.borderColor="red";
		checked = false;
	}
	
	if (email.length<7)
	{
		document.mailform.email.style.borderColor="red";
		checked = false;
	}
	
	if(checked==false){
		alert('Bitte ergänzen Sie die rot makierten Felder');
	} else {
		
		sajax_request_type = 'POST';
		x_newsletter(name,email,aktion,news_msg);
		sajax_target_id = '';
		
	}
	
}

function news_msg(ver){
	
	alert(ver);
}

