var errorCode = ['動作完成','抱歉!您不是從管理平台進入的','資料庫新增錯誤，請重新操作'];
function ajax_conn(){
	var http_request = false;
	
    if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
    } else if (window.ActiveXObject) { // IE
      try {
        http_request = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          http_request = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {}
      }
    }
	return http_request;
}
function ajax_getdata(url){
var http_request = ajax_conn();
http_request.open('GET', url+'&parm='+new Date().getTime(),false);
http_request.send(null);
return http_request.responseText;
}
function jsonDecode(arr){
	return eval('(' + arr + ')');
}
function showLoading(){
	var loadingDiv = document.createElement("div");
	loadingDiv.setAttribute("id", 'ajax-loading');  
	loadingDiv.style.position = "absolute";  
	loadingDiv.style.zIndex = "1000";  
	loadingDiv.style.left = (document.body.clientWidth/2)+"px";  
	loadingDiv.style.top = (document.body.clientHeight/2)+"px";
	loadingDiv.style.background = "url(/images/ajax-loader.gif)";
	loadingDiv.style.width = "32px";
	loadingDiv.style.height = "32px";
	var ie = (document.all) ? 1 : 0;
	if(ie){ var backgroundDiv = document.createElement('<div id="ajax-background" style="position:absolute;zIndex:900;left:0px;top:0px;background:#666666;width:'+document.body.clientWidth+'px;height:'+document.body.clientHeight+'px;*filter:progid:DXImageTransform.Microsoft.Alpha(opacity=50,finishOpacity=0,style=0,startX=0,startY=0);"></div>');
	}else{
		var backgroundDiv = document.createElement("div");
		backgroundDiv.setAttribute("id", 'ajax-background');
		backgroundDiv.style.position = "absolute";  
		backgroundDiv.style.zIndex = "900";
		backgroundDiv.style.left = "0px";  
		backgroundDiv.style.top = "0px";
		backgroundDiv.style.background = "#EFEFEF";
		backgroundDiv.style.width = document.body.clientWidth+"px";
		backgroundDiv.style.height = document.body.clientHeight+"100px";
		backgroundDiv.style.opacity = .5;
	}
	document.body.appendChild(backgroundDiv);
	document.body.appendChild(loadingDiv);
}
function closeLoading(){
	var loadingDiv = document.getElementById('ajax-loading');
	var backgroundDiv = document.getElementById('ajax-background');
	document.body.removeChild(loadingDiv);
	document.body.removeChild(backgroundDiv);
}

function Get_Cookie(check_name) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );
		
		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}
