function initPage()
{
	var inputs = document.getElementsByTagName("input");
	for (var i=0; i<inputs.length; i++)
	{
		if (inputs[i].type == "text" && (inputs[i].name == "email"))
		{
			var form = getAncestor(inputs[i], "form");
			if (form)
				form.onsubmit = handleSubmit;

			inputs[i].onfocus = function () {
					if (this.value == "Enter your e-mail:")
						this.value = "";
				}
			inputs[i].onblur = function () {
					if (this.value == "" && this.name == "email") this.value = "Enter your e-mail:";
				}	
		}
	}
}

function handleSubmit()
{
	var re = new RegExp('^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$');
	var element = this.elements["email"];
	if (element)
	{
		if (element.value == "")
		{
			alert("Email address is empty!");
			return false;
		}
		else
			return element.value.match(re)
				|| (alert("You have entered incorrect email address!"), false);
	}
	return true;
}

function getAncestor(element, tagName)
{
	var node = element;
	while (node.parentNode && (!node.tagName ||
			(node.tagName.toUpperCase() != tagName.toUpperCase())))
		node = node.parentNode;
	return node;
}

if (window.addEventListener)
	window.addEventListener("load", initPage, false);
else if (window.attachEvent){
	window.attachEvent("onload", initPage);
		}

function getObjectX(object) {return getObjectC(object, "x")}
function getObjectY(object) {return getObjectC(object, "y")}
function getObjectC(object, c)
{
    pos = 0;
    while (object != null) 
    {
        pos += (c == "y") ? object.offsetTop : object.offsetLeft;
        object = object.offsetParent;
    }
    return pos;
}


function pop_up(_this,_url,_name)
{
	w = 600;
	h = 400;
	
	if(window.screen.Height - getObjectY(_this) <  h)
	{
		_top = getObjectY(_this)-h -120+ "px";
	}
	else
	{
		_top = getObjectY(_this)+50+ "px";
	}
	
	_left = 20;
	window.open (_url, _name, 'left='+_left+',top='+_top+',width='+w+',height='+h+',status=no,toolbar=no,resizable=no,menubar=no,location=no'); 
	return false;		
}	


	