
var scrolled1 = 0;
var scrolled2 = document.getElementById("scroll_work").scrollHeight;
var stop_value = 321;

function check_valid_email(str_email)
{
	var  ret_val = true;
	func_email = str_email;
	if(func_email.indexOf("@") < 2)
	{
	 ret_val=false
	}
	if(func_email.indexOf(".") == 1 || func_email.indexOf(".") == func_email.length)
	{
	 ret_val=false
	}
	return ret_val;
}

function settimeout_scroll()
{
	if(document.getElementById("scroll_work").scrollTop >= ((document.getElementById("scroll_work").scrollHeight) - 350))
		scroll_back_up();
	int_val = window.setInterval("scroll_up()",10);
}

function scroll_up()
{
	document.getElementById("scroll_work").scrollTop  = document.getElementById("scroll_work").scrollTop + 1;
	scrolled1 = scrolled1 + 1;
	if (scrolled1 == stop_value)
	{
		kill_time_out_up();
		scrolled1 = 0;
	}
}

function kill_time_out_up()
{
 window.clearInterval(int_val);
 window.setTimeout("wait_10s();",10000);
}

function wait_10s()
{
	settimeout_scroll();
} 

function scroll_down()
{
	document.getElementById("scroll_work").scrollTop  = document.getElementById("scroll_work").scrollTop - 1;
	scrolled2 = scrolled2 - 1;
	if (scrolled2 <= 0)
	{
		kill_time_out_down();
		scrolled2 = document.getElementById("scroll_work").scrollHeight;
	}
}

document.getElementById("scroll_work").scrollTop = 0; 

function settimeout_scroll_back()
{
	int_val = window.setInterval("scroll_down()",10);
}

function check_val_land()
{
	fname = document.getElementById("fname").value;
	company = document.getElementById("company").value;
	phone = document.getElementById("phone").value;
	email = document.getElementById("email").value;
	if(fname == "" || phone=="" || email == "")
	{
		alert("יש למלא שם , טלפון , כתובת דואר אלקטרוני תקינה");
	}
	else
	{
		if(check_valid_email(email) == true)
			document.getElementById("lform").submit();
		else
		{
			alert("יש להקליד כתובות דואר אלקטרוני תיקנה");
			document.getElementById("email").focus();
		}
	}
}
