//执行返回来的脚本,1.2.1中此方法被取消
jQuery.fn.evalScripts = function(){
	return this.find("script").each(function(){
		if ( this.src )
			jQuery.getScript( this.src );
		else
			jQuery.globalEval( this.text || this.textContent || this.innerHTML || "" );
	}).end();
}

function switchDisplay(id){
	var obj=document.getElementById(id);
	if(obj!=null){
		var divstyle=obj.style.display	
		if(divstyle=="none"){
			obj.style.display="block";
		}else{
			obj.style.display="none";
		}
	}
}
function openWin(url, width, height){
	if(width==null){
		width="600";
	}
	if(height==null){
		height="450";
	}
	var Win = window.open(url,'','width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=no,status=no' );
}
function openModal(url,width,height,parmenter){
	if (url.indexOf('?')<0){
    	url=url +"?nowtime="+ new Date().getTime();
   	}else{ 
		url=url+'&nowtime='+new Date().getTime();
	}
	if(width==null){
		width="550";
	}
	if(height==null){
		height="500";
	}
	if(parmenter==null){
		parmenter=window;
	}	
	return window.showModalDialog(url,parmenter,'dialogWidth='+width+'px;dialogHeight='+height+'px;top=0,left=0,toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no,status=no');
}	    
function openFeeTryCompute(url)
{
	openModal(url,550,450,'');
}
/**
 * 寫入指定要求的cookie
 * name : cookie名字
 * value: cookie值
 * seconds:cookie過期時間,單位:秒
 */
function writeCookie(name, value, seconds)
{
	var expire = "";
	if(seconds)
	{
		expire = new Date((new Date()).getTime() + seconds * 1000);
		expire = "; expires=" + expire.toGMTString()+"; path=/";
	}
	document.cookie = name + "=" + escape(value) + expire;
}


// Example:
// alert( readCookie("myCookie") );
/**
 *	讀取指定名字的cookie值
 * name : 要讀取的cookie名字
 */
function readCookie(name)
{
	var cookieValue = "";
	var search = name + "=";
	if(document.cookie.length > 0)
	{ 
		offset = document.cookie.indexOf(search);
		if (offset != -1)
		{
			offset += search.length;
			end = document.cookie.indexOf(";", offset);
			if (end == -1) 
			{
				end = document.cookie.length;
			}
			cookieValue = unescape(document.cookie.substring(offset, end));
		}
	}
	return cookieValue;
}
String.prototype.trim=function()
{
   return   this.replace(/(^\s*)|(\s*$)/g,"");
}
