/**
 * @author Oleg Korovin (http://olegrorovin.spb.ru/)
 */

// TODO открытие в новом окне в ИЕ.
// target="_blank" дает не вкладку, а новое окно.

var Url = {

 /***************************************/
	cur	:  window.location,

 /***************************************/
	navigate	: function(sUrl){
		window.location = this.get(sUrl);
	},

 /***************************************/
	reload		: function(){
		window.location = window.location.href.split('#')[0] + '';
	},

 /***************************************/
	get		: function(sUrl){
		sUrl = (sUrl || window.location.href) + '';
		sUrl = sUrl.split('#')[0] + '';

		if( sUrl.indexOf('http://') != -1)
			sUrl = sUrl.substr(7);
		sUrl = sUrl.substr( sUrl.indexOf('/') );
		return sUrl;
	},

 /***************************************/
	ajax	: function(sUrl,oVals,iTimeLimit,fFunc,sMethod){
		var oThis = this;

		if(! JsHttpRequest ) return;

		var req = new JsHttpRequest();
		var tId = setTimeout( function(){ req.abort(); } , iTimeLimit * 1000 );

		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				clearTimeout(tId);
				if(fFunc) fFunc( typeof req.responseJS == 'object' ? req.responseJS : null , req.responseText);
			}
		}

		req.open(sMethod, oThis.get(sUrl), true);
		req.send(oVals);
	}
};


/**/


