// ----- Slideshow for the Homepage ---------------------------------------------------------------------
example = new Image();
var k=0;
var routine = 0;
var start= 0;

function slideshow(){
	slide=new Array("intouch","capeconc");
	document.images.example.src = "../_images/examples/" +slide[k] +".jpg";
	k++;
	if(k==2)k=0;
	clearTimeout(routine);
	routine = setTimeout("slideshow()",3000);
}

function slider(){
	clearTimeout(start);
	start = setTimeout("slideshow()",3000);
}

// ------ Show Random Client Feedback ---------------------------------------------------------------------
rdm=100;
function random_feedback(){
	while(rdm>5){
		rdm=Math.round(Math.random()*10+1);}	
	rdm_feedb="feedb"+rdm;
	document.getElementById(rdm_feedb).style.display ='block';
}

// ------ CheckInputForms if every field is valid ---------------------------------------------------------------------
function select_me(selected){
	document.getElementById(selected).className = 'w210 inp_selected';
}

function unselect_me(selected){
	document.getElementById(selected).className = 'w210';
	CheckInput();
}

function checkText(selected){
	count = document.getElementById(selected).value.length;
	if (count<3)
		document.getElementById(selected).className = 'w210 inp_invalid';
	else
		document.getElementById(selected).className = 'w210 inp_valid';
	CheckInput();
}

function checkMail(selected){
	var x = document.getElementById(selected).value
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x))
		 document.getElementById(selected).className = 'w210 inp_valid';
	else
		document.getElementById(selected).className = 'w210 inp_invalid';
	CheckInput();
}

function compareText(orginal_,copy_){
	var orginal = document.getElementById(orginal_).value;
	var copy = document.getElementById(copy_).value;
	if(orginal==copy){
			document.getElementById(orginal_).className = 'w210 inp_valid';
			document.getElementById(copy_).className = 'w210 inp_valid';}
	else{
			document.getElementById(orginal_).className = 'w210 inp_valid';
			document.getElementById(copy_).className = 'w210 inp_invalid';}
	if(orginal==""){
		document.getElementById(orginal_).className = 'w210 inp_invalid';}
	if(copy==""){
		document.getElementById(copy_).className = 'w210 inp_invalid';}
	CheckInput();
}

function CheckInput(){
	validForm=1;
	for(k=0; k<checkFields.length; k++){
		if(document.getElementById(checkFields[k]).className != 'w210 inp_valid'){
			validForm=0;}
	}
	if(validForm==1){
		document.getElementById("submit").disabled = "";
		document.getElementById("submit").className = 'submit';}
	else{
		document.getElementById("submit").disabled = true;
		document.getElementById("submit").className = 'submit_d';}
}

function clearFields(){
	for(f=0; f<checkFields.length; f++){
		document.getElementById(checkFields[f]).className = 'w210';
		document.getElementById(checkFields[f]).value = "";
	}
	CheckInput();
}