// JavaScript Document
function trim(val)
{ 
	return val.replace(/^\s+|\s+$/g,"");
}
function isInt16(value)
{
	 if(isNaN(value))
	 {
		return false;	 
	}
	if(parseInt(value) < 0)
	{
		return false;	
	}
	if(value.indexOf('.') >= 0)
	{
		return false;
	}
	return true;
}
function add(f)
{	
	
	var url 	= "<?php echo $config['nhadat_url']; ?>";
	var pars 	= "m=realestate&suppressHeaders=1&f=" + f;
	
	var myAjax 	= new Ajax.Request
	(
		url, 
		{
			method		: "get",
			parameters	: pars,
			onFailure	: reportError
		}
	)
	Element.update("luu_" + f, "<a id='xoa_"+f+"' href=javascript:void(0); title='Xóa tin đã lưu' onclick='delete_favor("+f+");'>Tin đã lưu</a>");
}
function delete_favor(id)
{
	var url 	= "<?php echo $config['nhadat_url']; ?>";
	var pars 	= "m=realestate&suppressHeaders=1&deleteFavorId=" + id;
	
	var myAjax 	= new Ajax.Request
	(
		url, 
		{
			method		: "get",
			parameters	: pars,
			onFailure	: reportError
		}
	)
	Element.update("luu_" + id, "<a href=javascript:void(0); onclick='add("+id+");'>Lưu tin</a>");
}

function remove(f)
{	
	
	var url 	= "<?php echo $config['nhadat_url']; ?>";
	var pars 	= "m=public&suppressHeaders=1&f=" + f;
	var myAjax 	= new Ajax.Request
	(
		url, 
		{
			method		: "get",
			parameters	: pars,
			onFailure	: reportError
		}
	)
	Element.remove("xoa_" + f);
}
function checkEmail(stringIn) 
{
		
	var re = /^([A-Za-z0-9\_\-]+\.)*[A-Za-z0-9\_\-]+@[A-Za-z0-9\_\-]+(\.[A-Za-z0-9\_\-]+)+$/;
    var sEMail = stringIn;
    if (sEMail=="")
	{
		return (false);
	}
	else if (sEMail.search(re) == -1)
	{
		return (false);
	}
	else
	{
		return (true);
    }
}
function isBlackListTag(strCheck)
{
	var arrList = new Array();
	arrList[0] = "<";
	arrList[1] = ">";
	arrList[2] = "=";
	arrList[3] = "#";
	arrList[4] = "[";
	arrList[5] = "]";
	arrList[6] = "{";
	arrList[7] = "}";
	arrList[8] = "*";
	arrList[9] = "^";
	arrList[10] = "~";
	arrList[11] = "\$";
	for(var i=0;i<arrList.length;i++)
	{
		if(strCheck.indexOf(arrList[i])>=0)	
		{
			return true;	
		}
	}
	return false;
}
/*
	Author: vutt <vutt@von-inc.com>
	Date: 30/11/2007
	Description:Kiem tra gia tri nhap vao
*/
function checkInputNormalText(strCheck)
{
    var strMessage = strCheck; 
    if (strMessage=="")
	{		 	
		return (false);
	}
	else if(isBlackListTag(strCheck))
	{
		return (false);
	}
	else
	{
		return (true);
    }
}