var app = {};
app.onloadf = [];
app.addload = function(f){app.onloadf.push(f);};
app.onload = function()
{
	$(app.onloadf).each(function(){this();});	
};
window.onload = app.onload;

$.ajaxSetup({type:'POST', async:false});

app.addload(function()
{
	if($.browser.msie)
	{
		var cont_off = $("#container").offset().left;
		var foot_off = $("#footer").offset().left
		if(foot_off < cont_off)
			$("#footer").css({marginLeft:'1px'}).css({marginLeft:'0px'});
		
	}
});



$(function()
{
	$("input,select")
		.live('keypress',
			  function(e)
			  {
					if(e.keyCode==13 && this.form)
					 {
					 	this.form.submit();
						return false;
					 }			  
			});

	$("input[name=q],.newsl-field").clickclear().click().trigger('blur');
	$.ajax({url:'/application/request/load_configs',data:''
				,success:
				function(data)
				{
					if(!data) return app.configs = {};
					app.configs = utils.eval(data);
				}});
	/*
	*/
});





function lang(term)
{
	if(!app.configs.lang || !app.configs.lang[term]) return '';	
	return app.configs.lang[term];
}



$.php =
{
	json_decode:function(str_json){var json=window.JSON;if(typeof json==='object'&&typeof json.parse==='function'){try{return json.parse(str_json);}catch(err){if(!(err instanceof SyntaxError)){throw new Error('Unexpected error type in json_decode()');}
this.php_js=this.php_js||{};this.php_js.last_error_json=4;return null;}}
var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;var j;var text=str_json;cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+
('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}
if((/^[\],:{}\s]*$/).test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return j;}
this.php_js=this.php_js||{};this.php_js.last_error_json=4;return null;}
	,nl2br:function(str, is_xhtml) {
		var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br />' : '<br>';
		return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ breakTag +'$2');
	}
	
};



