jQuery.fn.reSize = function(w,h){
	var blogimage=new Image(); 
	blogimage.src=$(this).attr("src");
	if(blogimage.width>0 && blogimage.height>0) { 
		flag=true; 
		if(blogimage.width>=w) { 
			var twidth=w; 
			var theight=(blogimage.height*w)/blogimage.width; 
		}
		else { 
			var twidth=blogimage.width; 
			var theight=blogimage.height; 
		}
		if (theight>=h) {
			var twidth=(blogimage.width*h)/blogimage.height; 
			var theight=h; 
		}
		$(this).width(twidth);
		$(this).height(theight);
	} 
};

function isUndefined(variable) {
	return typeof variable == 'undefined' ? true : false;
}
jQuery.fn.absmiddle = function(){
	theight=$(this).height();
	$(this).css("margin-top",(450-theight)/2);
};
function gettitle() {
	kdocTitle = document.title;//标题 
	if(kdocTitle == null){ 
		var t_titles = document.getElementByTagName("title") ;
		if(t_titles && t_titles.length >0) { 
			kdocTitle = t_titles[0]; 
		}else{ 
			kdocTitle = ""; 
		} 
	} 
	return kdocTitle;
}

//添加收藏夹
jQuery.fn.addfav = function() {
	if ($.browser.msie)
		window.external.addFavorite(window.location.href,gettitle());
	if ($.browser.mozilla)
		window.sidebar.addPanel(gettitle(),window.location.href, "");
};

//设置首页
jQuery.fn.sethome = function() {
	var obj=$(this)[0];
	var url=$(this).attr("href");
	try {
		obj.style.behavior='url(#default#homepage)';
		obj.setHomePage(url);
	} catch(e) {
		if(window.netscape) {
			try {
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
			} catch (e) { 
				alert("此操作被浏览器拒绝!"); 
			}
			var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
			prefs.setCharPref('browser.startup.homepage',url);
		}
	}
};

jQuery.fn.alertForm = function(id,text) {
	var ids=id.split(",");
	var titles=text.split(",");
	for (var i=0;i<ids.length;i++) {
		var id_1=ids[i];
		if ($("#"+id_1).val()=="") {
			alert("\""+titles[i]+"\"不能为空!");
			return false;
		}
	}
	return true;
};

function gourl(url) {
	window.location.href=url;
}
function checkdp(url,type) {
	var group=parseInt("10");
	var tmpurl=window.location.href;
	tmpurl=tmpurl.split("index.php")[0];
	if (group==1) {
		$.win();
		return false;
	} else {
		if (type==1) {
			window.open(url);
		} else {
			url=tmpurl+url;
			gourl(url);
		}
	}
}

function implode (glue, pieces) {
	var i = '', retVal='', tGlue='';
	if (arguments.length === 1) {
		pieces = glue;
		glue = '';
	}
	if (typeof(pieces) === 'object') {
		if (pieces instanceof Array) {
			return pieces.join(glue);
		} else {
			for (i in pieces) {
				retVal += tGlue + pieces[i];
				tGlue = glue;
			}
			return retVal;
		}
	} else {
		return pieces;
	}
}
