﻿function email_validate(src) 
{
  var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
  return regex.test(src);
}

function phone_validate(src)
{
	var regex = /^[0-9+-]+[0-9-]{2,4}$/;
	return regex.test(src);
}

function insertBr(text)
{
	var text_save = '';
	for (var i = 0; i < text.length; i++)
	{
		if (text.charAt(i) == "\n") text_save += '<br />';
		else text_save += text.charAt(i);
	}
	return text_save;
}

function sendMessage()
{
	var email = document.getElementById('email').value;
	if (email == '') return alert('You must type your e-mail address!');
	else if (email_validate(email) == false) return alert('Correct your e-mail address!');
	var phone = document.getElementById('phone').value;
	if (phone != '')
	{
		if (phone_validate(phone) == false) return alert('Correct your phone number!');
	}
	var message = document.getElementById('message').value;
	if (message == '') return alert('You must type your message!');
	document.forms[0].submit();
}

function checkColumns()
{
	var c_left = document.getElementById('content_left');
	var c_right = document.getElementById('content_right');
	
	c_right.innerHTML += c_left.style.color;
	
	if (c_left.style.height > c_right.style.height)
	{
		var pad = c_left.style.height - c_right.style.display;
		c_right.style.paddingBottom = "100px;";
	}	
}

function P7_colH2()
{
	var i, oh, h = 0, tg, el, np, dA = document.p7eqc, an = document.p7eqa; 
	if (dA && dA.length)
	{
		for (i = 1; i < dA.length; i += 2)
		{
			dA[i+1].style.paddingBottom = '';
		}
		for (i = 1; i < dA.length; i += 2)
		{
			oh=dA[i].offsetHeight; 
			h = (oh > h) ? oh :h;
		}
		for (i = 1; i < dA.length; i += 2)
		{ 
			oh = dA[i].offsetHeight;
			if (oh<h) 
			{ 
				np = h - oh;
				if (!an && dA[0] == 1)
				{ 
					P7_eqA2(dA[i+1].id, 0, np);
				}
				else
				{
					dA[i+1].style.paddingBottom = np + "px";
				}
			}
		}
		document.p7eqa = 1;
		document.p7eqth = document.body.offsetHeight;
		document.p7eqtw = document.body.offsetWidth;
	}
}

function P7_eqT2()
{
	if (document.p7eqth != document.body.offsetHeight || document.p7eqtw != document.body.offsetWidth)
	{
		P7_colH2();
	}
}

function P7_equalCols2()
{ 
	var c, e, el;
	if (document.getElementById)
	{
		document.p7eqc = new Array();
		document.p7eqc[0] = arguments[0];
		for (i = 1; i<arguments.length; i+=2)
		{
			el = null;
			c = document.getElementById(arguments[i]);
			if (c) 
			{
				e=c.getElementsByTagName(arguments[i+1]);
				if (e) 
				{
					el = e[e.length-1];
					if (!el.id)
					{
						el.id = "p7eq" + i;
					}
				}
			}
			if (c&&el) 
			{
				document.p7eqc[document.p7eqc.length] = c;
				document.p7eqc[document.p7eqc.length] = el
			}
		}
		setInterval("P7_eqT2()",10);
	}
}

function P7_eqA2(el,p,pt)
{
	var sp=1, inc=20, g = document.getElementById(el); 
	np = (p >= pt) ? pt : p;
	g.style.paddingBottom = np + "px";
	if (np < pt)
	{
		np+=inc;
		setTimeout("P7_eqA2('"+el+"',"+np+","+pt+")",sp);
	}
}