/** This is drain.define.js*/
var HTTP_PREFIX = "/drain_news";

$(function(){

	fetchHttpPrefix = function(){
		return HTTP_PREFIX;
	};

	buildRequest = function(url){
		url+="?utype="+localStorage.utype+"&uname="+localStorage.uname+"&pwd="+localStorage.pwd;
		return url;
	};

	isLogin = function(){  
		if(localStorage.uname==undefined||localStorage.uname==''){
			window.location.href = 'system/login.jsp';
		}
	};

	$.ajaxSetup({
		dataType: "json",
		async:true,
		contentType:"application/json",
	});

	reset = function () {
		alertify.set({
			labels : {
				ok   : "确认",
				cancel : "取消"
			},
			delay : 5000,
			buttonReverse : true,
			buttonFocus  : "ok"
		});
	};

	adminLogout = function(){
		reset();
		alertify.confirm("确认退出吗？",function(e){
			if(e){
				localStorage.utype='';
				localStorage.uname='';
				localStorage.pwd ='';
				window.location.href = 'system/login.jsp';
			}
		});
	}

	String.prototype.endWith=function(str){ 
		var reg=new RegExp(str+"$"); 
		return reg.test(this); 
	} 
});