if (top.location != self.location)
{
	top.location = self.location;
}

function addLoadEvent(func)
{
    var oldonload = window.onload;
    if (typeof window.onload != 'function')
    {
        window.onload = func;
    }
    else
    {
        window.onload = function()
        {
            oldonload();
            func();
        }
    }
}

function highlightObject(id, cssclass)
{
	//alert ("in here id=" + id);
	var ele = document.getElementById(id);
	ele.className = cssclass;
}

function showHide(id)
{
	var ele = document.getElementById(id);
	var toggle = document.getElementById('toggle');
	if(ele.style.display == 'none')
	{
		ele.style.display = 'block';

	}
	else
	{
		ele.style.display = 'none';

	}
}
function autotab(original,destination)
{
	if (original.getAttribute&&original.value.length==original.getAttribute("maxlength"))
		destination.focus()
}

function setMinAndMax(min, max)
{
	//alert("in set min and max");
	document.forms[0].min.value = min;
	document.forms[0].max.value = max;
	return true;
}

function clearForm()
{
	for (i=0; i<(document.forms[0].elements.length-3); i++)
	{
		document.forms[0].elements[i].value = "";
	}
}

function alertMe(value)
{
	alert(value);
}

function popUp(url, w, h)
{
    window.open('/popup.php?p=' + url, 'info', 'width=' + w + ', height=' + h + ', menubar=0, scrollbars=1');
    return false;
}

function validateLogin()
{
    var msg = "";
    var email_pattern = /[\w\-]+\@[\w\-]+\.\w{2,3}/;
    if (!email_pattern.test(document.getElementById('user').value))
    {
        msg = "Your email address does not appear to be valid";
    }

    if (document.getElementById('login_password').value.length == 0)
    {
        if (msg == "")
        {
            msg = "Please enter your password."
        }
        else
        {
            msg = msg + " and your password is blank.";
        }
    }
    if (msg == "")
    {
        return true;
    }
    else
    {
        alert(msg);
        return false;
    }
}