/*

	irancivilcenter.com
	JavaScript for Companies

	Code Copyright (c) 2005 AmirBehzad Eslami, All rights reserved.
	
*/


function openDialog(url, _width, _height)
{
			
	var _LEFT = (screen.width / 2) - (_width / 2);
	var _TOP = (screen.height / 2) - (_height / 2);

	objHistoryWin = window.open(url, 'objHistoryWin', 'width=' + _width + ',height=' + _height + ',left=' + _LEFT + ',top=' + _TOP + ',scrollbars=yes,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no');
	objHistoryWin.focus();

}


function formAlert(strMessage, objField)
{

	if ((objField.type == "text") || (objField.type == "password"))
	{
		objField.style.backgroundColor = "#ffd";
		objField.style.borderColor = "#000";
	}

	alert(strMessage);
	objField.focus();
	
	return false;

}


function resetFormColors(strFormName)
{

	with (document.forms[strFormName]) {
	
		for (var i=0; i<document.forms[strFormName].elements.length; i++)
		{
			if ((elements[i].disabled == false) &&
				((elements[i].type == "text") || (elements[i].type == "password")))
			{
				elements[i].style.backgroundColor = "#fff";
				elements[i].style.borderColor = "#A4BDEA";
			}
		}

	}
	
	return;

}




function check_email(e) 
{
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";

	for(i=0; i < e.length ;i++)
	{
		if(ok.indexOf(e.charAt(i))<0)
		{ 
			return (false);
		}	
	} 

	if (document.images) 
	{
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(re) && e.match(re_two)) 
		{
			return (-1);		
		} 
	}
}
