
	var BG_COLOR_UP		= "#9CCF39";
	var BG_COLOR_DOWN	= "#FF8A8C";
	var BG_COLOR_NORMAL	= "WHITE";

	var FONT_COLOR_UP	= "BLACK";
	var FONT_COLOR_DOWN	= "BLACK";
	var FONT_COLOR_NORMAL	= "BLACK";
	

	var CHART_QUERY_URL 	= "../web_rate_system/chart.php?b=19&w=210&h=180&memx=6";	//チャートURL
	var CHART_QUERY_URL2	= "../web_rate_system/chart.php?b=66&w=610&h=400";	//チャートURL

	var RATE_FILE_PATH	= "./web_rate_system/rate.php";		//レートファイル
	var UPDATE_TIME		= 1000;					//レート 更新頻度
	var UPDATE_TIME_CHART	= 60000;				//チャート 更新頻度

	var EXPAND_URL 	= "index_ex.html?p=";		//拡大チャートのURLかパス
	var EXPAND_URL2	= "./chart/index_ex.html?p=";	//拡大チャートのURLかパス



//////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////


/*@cc_on _d=document;eval('var document=_d')@*/

var _si_nativeSetInterval = window.setInterval;
var _si_nativeClearInterval = window.clearInterval;
var _si_intervalTime = 10;
var _si_counter = 1;
var _si_length = 0;
var _si_functions = {};
var _si_counters = {};
var _si_numbers = {};
var _si_intervalId = undefined;
var _si_loop = function() {
    var f = _si_functions, c = _si_counters, n = _si_numbers;
    for(var i in f) {
        if(!--c[i]) {
            f[i]();
            c[i] = n[i];
        }
    } 
};
window.setInterval = function(handler, time) {
    if(typeof handler == 'string')
        handler = new Function(handler);
    _si_functions[_si_counter] = handler;
    _si_counters[_si_counter] = _si_numbers[_si_counter] = Math.ceil(time / _si_intervalTime);
    if (++_si_length && !_si_intervalId) {
       _si_intervalId = _si_nativeSetInterval(_si_loop, _si_intervalTime);
    }
    return _si_counter++;
};
window.clearInterval = function(id) {
    if(_si_functions[id]) {
        delete _si_functions[id];
        delete _si_numbers[id];
        delete _si_counters[id];
        if (!--_si_length && _si_intervalId) {
            _si_nativeClearInterval(_si_intervalId);
            _si_intervalId = undefined;
        }
    }
};
//////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////



	function POP_CHART (id){
		URL= EXPAND_URL + document.getElementById(id).value;
		window.open(URL, "window_name","width=610,height=450");

	}
	function POP_CHART2 (v1){
		URL= EXPAND_URL2 + v1;
		window.open(URL, "window_name","width=610,height=450");
	}
	function POP_CHART3 (v1){
		URL= EXPAND_URL + v1;
		window.open(URL, "window_name","width=610,height=450");
	}
	
	function GoSelect(num,sel){
		document.getElementById( num + "_VALUE" ).value = sel.options[sel.selectedIndex].value;
		IMG_LOADER ();
		RATE_LOADER ();
	}





	function ActionSet (v1,v2){

				if (document.getElementById(v1)) {

					if (document.getElementById(v1).innerHTML){
						if(document.getElementById(v1).innerHTML > v2){
							document.getElementById(v1).style.backgroundColor = BG_COLOR_DOWN;
							document.getElementById(v1).style.color = FONT_COLOR_DOWN;

						}
						if(v2 > document.getElementById(v1).innerHTML  ){
							document.getElementById(v1).style.backgroundColor = BG_COLOR_UP;
							document.getElementById(v1).style.color = FONT_COLOR_UP;

						}
						if(v2 == document.getElementById(v1).innerHTML  ){
							document.getElementById(v1).style.backgroundColor = BG_COLOR_NORMAL;
							document.getElementById(v1).style.color = FONT_COLOR_NORMAL;
							return;
						}
					}

					document.getElementById(v1).innerHTML = v2;
				}
	}
	
	

	
	function rate_display1 (){
		rate_array = document.getElementById("TEMP_RATE").value;

		if (rate_array){
			lineData = rate_array.split(";");

			var REV = "";
			for (var i=0; i < lineData.length; i++){
				//>
				REV = lineData[i].split("<>");

				ActionSet(REV[0]+"_BID"			,REV[1]);
				ActionSet(REV[0]+"_ASK"			,REV[2]);
				ActionSet(REV[0]+"_CHANGE"		,REV[3]);
				ActionSet(REV[0]+"_HIGH"		,REV[4]);
				ActionSet(REV[0]+"_LOW"			,REV[5]);
				ActionSet(REV[0]+"_BUY_SWAP"	,parseInt(REV[6], 10));
				ActionSet(REV[0]+"_SELL_SWAP"	,parseInt(REV[7], 10));
			}
		}
	}
	
	
	
	
	
	
	
	
	
	function rate_display2 (){
		rate_array = document.getElementById("TEMP_RATE").value;

		if (rate_array){
			lineData = rate_array.split(";");

		
			for (var i=0; i < lineData.length; i++){
				//>
				REV = lineData[i].split("<>");
				if (!document.getElementById(REV[0]+"_BID"))continue;
				document.getElementById(REV[0]+"_BID").value = REV[1];
				document.getElementById(REV[0]+"_ASK").value = REV[2];
			}
			
		}
		RATE_LOADER();  
	}	
	
	
	
//////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////


var xmlhttp = false;

if(window.XMLHttpRequest) {
  xmlhttp = new XMLHttpRequest();
} else if(window.ActiveXObject) {
  try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  } catch(e) {
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
}

function CallAjax(id, dofile,timer,img) {

	if (!img) {
		document.getElementById(id).innerHTML = "確認中.... ";
	}
	CallAjax2(id, dofile,timer);

}
function CallAjax2(id, dofile,timer) {

	if (timer > 0) {setInterval("  CallAjax2('" + id + "','" +dofile+ "',0)  ",timer);}
		 
	if (!xmlhttp || xmlhttp.readyState==1 || xmlhttp.readyState==2 || xmlhttp.readyState==3){
		if (timer == "0") {var i=Math.floor(Math.random()*600);setTimeout("  CallAjax2('" + id + "','" +dofile+"',0)  ",i+700);}
  		return;
	}


var date = new Date();
var timestamp = date.getTime();

	xmlhttp.open('GET', dofile +'?'+ timestamp, true);
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			document.getElementById(id).innerHTML = xmlhttp.responseText;
		}
	}
  xmlhttp.send("");

}


function HttpAbort(id) {
  if (xmlhttp.readyState == 0 || xmlhttp.readyState == 4) return;
  xmlhttp.abort();
  document.getElementById(id).innerHTML = 'disconnected';
}

