function nl2br (str, is_xhtml) 
{
    breakTag = '<br />';
    if (typeof is_xhtml != 'undefined' && !is_xhtml) {
        breakTag = '<br>';
    }
    return (str + '').replace(/([^>]?)\n/g, '$1'+ breakTag +'\n');
}
function echeck(str)
{
	//var str=document.getElementById(x).value;
	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	
	if (str.indexOf(at)==-1) return false;
	else if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) return false;
	else if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) return false;
	else if (str.indexOf(at,(lat+1))!=-1) return false;
	else if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) return false;
	else if (str.indexOf(dot,(lat+2))==-1) return false;
	else if (str.indexOf(" ")!=-1) return false;
	else return true;
}
function hidediv(div_id) 
{
	if (document.getElementById) 
	{ // DOM3 = IE5, NS6
		document.getElementById(div_id).style.visibility = 'hidden';
		document.getElementById(div_id).style.display = 'none';
	}
	else 
	{
		if (document.layers) 
		{ // Netscape 4
			document.div_id.visibility = 'hidden';
			document.div_id.display = 'none';
		}
		else 
		{ // IE 4
			document.all.div_id.style.visibility = 'hidden';
			document.all.div_id.style.display = 'none';
		}
	}
}
function showdiv(div_id) 
{
	if (document.getElementById) 
	{ // DOM3 = IE5, NS6
		document.getElementById(div_id).style.visibility = 'visible';
		document.getElementById(div_id).style.display = 'block';
	}
	else 
	{
		if (document.layers) 
		{ // Netscape 4
			document.div_id.visibility = 'visible';
			document.div_id.display = 'none';
		}
		else 
		{ // IE 4
			document.all.div_id.style.visibility = 'visible';
			document.all.div_id.style.display = 'none';
		}
	}
}
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function convert_html_entities(string)
{
	string = string.replace(/&amp;/g, '&'); //encode ampersand
	string = string.replace(/&quot;/g, '"'); //encode quote
	string = string.replace(/&apos;/g, "'"); //encode apostrophe
	string = string.replace(/&lt;/g, '<'); //encode less than
	string = string.replace(/&gt;/g, '>'); //encode greater than
	return string;
}
var verbose_logging = false;
var LOG_MESSAGE = 1;
var LOG_ERROR = 2;
function write_log(message, type)
{
	var d = new Date();
	
	var curr_hour = d.getHours();
	var curr_min = d.getMinutes();
	var curr_sec = d.getSeconds();
	var mili_sec = d.getMilliseconds();
	//air.trace(curr_hour + ':' + curr_min + ':' + curr_sec + ' - ' + message);
	if(verbose_logging && window.console)
	{
		if(type == LOG_ERROR)
			console.error(curr_hour + ':' + curr_min + ':' + curr_sec + ':' + mili_sec + ' - ' + message);
		else
			console.log(curr_hour + ':' + curr_min + ':' + curr_sec + ':' + mili_sec + ' - ' + message);
	
	}
}
//var api_url = 'http://m.getitdoneapp.com/api.php';
//var api_url = 'http://getitdoneapp.com/api.php';
//var api_url = 'http://204.236.225.252/api.php'
function send_request(type, action, callback, err_callback)
{
	$.ajax({
		type : 'POST',
		url : api_url,
		dataType : 'json',
		data: {
			account_id : account_id,
			sync_key: 0,
			action : type,
			changes : action
		},
		success : function(data){
			write_log('send_request:success');
			if (data.error === true)
			{
				if(err_callback)
					err_callback(data.msg);
			}
			else
			{
				if(callback)
					callback(data);
			}
		},
		error : function(XMLHttpRequest, textStatus, errorThrown) {
			write_log('send_request:error');
			if(err_callback)
				err_callback(errorThrown);
		}
	});
}
jQuery(function() {
	jQuery.support.borderRadius = false;
	jQuery.each(['BorderRadius', 'borderRadius', 'MozBorderRadius','WebkitBorderRadius','OBorderRadius','KhtmlBorderRadius'], function() {
		if(document.body.style[this] !== undefined) jQuery.support.borderRadius = true;
		return (!jQuery.support.borderRadius);
	});
});
