
function init(){
	new Effect.Appear('main',{ duration: 1,afterFinish:function(){showNav();} });
}

function showNav(){
	new Effect.BlindDown('left',{ duration: 0.75 });
	new Effect.BlindDown('right',{ duration: 0.75 });
}


open_box = '';

function openBox(box){	
	if(open_box!=''){
		//closeBox(open_box);
		window.setTimeout("closeBox('"+open_box+"')", 1000);
	}
	$(box.id + '_loader').show();
	addContentToBox(box.id);
	open_box = box.id;
	window.setTimeout("goOn('"+box.id+"')", 1000);
	//goOn(box.id);
}

function goOn(box){
	$(box + '_loader').hide();
	new Effect.BlindUp(box +'_img',{ duration: 0.75 });
	new Effect.BlindDown(box + '_more',{ duration: 0.5 });
	$(box).addClassName('hover_helper');
	$(box + '_txt').style.color ='#566723';
	$(box).onmousedown = function(){closeBox(this.id);open_box ='';};

}

function closeBox(box){
	new Effect.BlindUp(box + '_more',{ duration: 0.5,afterFinish:function(){
		$(box + '_img').show();
		} });
	$(box).removeClassName('hover_helper');
	$(box + '_txt').style.color ='#000000';
	$(box).onmousedown = function(){openBox(this);};
}


function addContentToBox(box){
	// big image
	
	$(box + "_imgBig").innerHTML = '';
	imageColl1 = new Image(); 
	imageColl1.src ='index.php?rex_resize=209c__157h__'+ $(box+"_imageColl1").value;
	imageColl1.onload = function() {
		$(box + "_imgBig").appendChild(imageColl1);
	}	
	
	$(box + "_imgThumb1").innerHTML = '';
	imageColl2 = new Image(); 
	imageColl2.src ='index.php?rex_resize=66c__49h__'+ $(box + "_imageColl2").value;
	imageColl2.alt = '.';
	imageColl2.onload = function(){
		$(box + "_imgThumb1").appendChild(imageColl2);
	}
	
	$(box + "_imgThumb2").innerHTML = '';
	imageColl3 = new Image(); 
	imageColl3.src ='index.php?rex_resize=66c__49h__'+ $(box + "_imageColl3").value;
	imageColl3.alt = '.';
	imageColl3.onload = function(){
		$(box + "_imgThumb2").appendChild(imageColl3);
	}
	
	$(box + "_imgThumb3").innerHTML = '';
	imageColl4 = new Image(); 
	imageColl4.src ='index.php?rex_resize=66c__49h__'+ $(box + "_imageColl4").value;
	imageColl4.alt = '.';
		imageColl4.onload = function(){
			$(box + "_imgThumb3").appendChild(imageColl4);
		}
}

// --------------------------------------- kontaktform ------------
function checkForm(){
	noEmptyElements = true;
	
	rn_text = emptyTextarea();
	rn_name =emptyName();
	rn_mail = validEmail();
	
	if ( rn_text && rn_name && rn_mail ) { 
		document.getElementById('error_msg').style.display = 'none';
		noEmptyElements =true;
		}
		else { 
		document.getElementById('error_msg').style.display = 'block';
	    noEmptyElements = false;
	}
	
	return noEmptyElements;
}


function emptyTextarea(){
	if(document.cont_f.cont_f_message.value!=''){
		document.getElementById('cont_f_message').style.background = "#222222";
		return true;
	}
	else{
		document.getElementById('cont_f_message').style.background = "#FFFFFF";
		document.cont_f.cont_f_message.focus();
		return false;
	}
}

function emptyName(){
	if(document.cont_f.cont_f_name.value!=''){
		document.getElementById('cont_f_name').style.background = "#222222";
		return true;
	}
	else{
		document.getElementById('cont_f_name').style.background = "#FFFFFF";
		document.cont_f.cont_f_name.focus();
		return false;
	}
}

function validEmail() {

	var form_email_element = document.cont_f.cont_f_mail;
	
	// 
	var reg_ex_email =/^\w[\w|\.|\-]+@\w[\w|\.|\-]+\.[a-zA-Z]{2,4}$/;
	
	if(reg_ex_email.test(form_email_element.value)) {
		document.getElementById('cont_f_mail').style.background = "#222222";
		return true;
	}
	else {
		document.getElementById('cont_f_mail').style.background = "#FFFFFF";
		form_email_element.focus();
		return false;
	}
	
}

