
var web800_is_ie = (document.all) ? 1: 0;

var status_of_web800 = "web800_calm";


var all_window_element          = new Array();
var calm_window_element         = new Array();
var connecting_window_element   = new Array();
var talking_window_element      = new Array();
var disconnected_window_element = new Array();
var no_activex_window_element   = new Array();


var float_window_element        = new Array();


var all_window_offset_x         = new Array();
var all_window_offset_y         = new Array();

var num_window_offset_x		= new Array();
var num_window_offset_y		= new Array();


var is_mouse_down   = false;
var offset_x        = 0;
var offset_y        = 0;


var current_x       = 0;    
var current_y       = 0;    
var last_scroll_x   = 0; 	
var last_scroll_y   = 0; 	
var last_x   = 0; 	// 上一次滚动的x方向的距离
var last_y   = 0; 	// 上一次滚动的y方向的距离
var all_x = 0;	


var web800_server_addr  = "";   
var web800_server_port  = 0;    
var web800_destination  = "";   
var web800_serial       = "";   


var check_phone_status_timer;



function embed_activex_web800() {

    if (!web800_is_ie)
    {
        return;
    }

	document.writeln("<OBJECT ID=\"WebCall\"");
	document.writeln(" CLASSID=\"CLSID:CEF68671-C1B9-498F-91DD-FCC141175059\" ");
	document.writeln(" CODEBASE=\"http://www.web800.tv/call/anyb2c.cab#version=1,0,6,1\">");
	document.writeln("<\/OBJECT>");
	

	try {
	    WebCall.GetStatus();
	} catch (e) {
	    status_of_web800 = "web800_no_activex";
	}
}


function set_web800_account(server, port, destination, serial) {
    web800_server_addr  = server;
    web800_server_port  = port;
    web800_destination  = destination;
    web800_serial       = serial;
}


function create_web800_window(x, y) {

    if (!web800_is_ie)
        return;   
        

	var web800_main_frame = '';
	
	web800_main_frame += '<div id="web800_main_frame" style="border:outset 0px; z-index:99; position:absolute; left:' + x + 'px; top:' + y + 'px; overflow:hidden; display:none">';
	web800_main_frame += '<table cellspacing="0" cellpadding="0" border="0" width="187" height="240" background="http://www.web800.tv/img/keyMain.gif">';
	web800_main_frame += '<tr><td></td></tr>';
	web800_main_frame += '</table>';
	web800_main_frame += '</div>';	
	

	var web800_messages = '';
	
	web800_messages += '<div id="web800_msg_connecting" style="left:' + (x + 18) + 'px; top:' + (y + 95) + 'px; border:outset 0px; z-index:100; position:absolute; overflow:hidden; display:none;"><img src="http://www.web800.tv/img/keyMessage2.gif"></div>';			
	web800_messages += '<div id="web800_msg_talking" style="left:' + (x + 18) + 'px; top:' + (y + 95) + 'px; border:outset 0px; z-index:100; position:absolute; overflow:hidden; display:none;"><img src="http://www.web800.tv/img/keyMessage4.gif"></div>';
	web800_messages += '<div id="web800_msg_disconnected" style="left:' + (x+18) + 'px; top:' + (y + 95) + 'px; border:outset 0px;  z-index:100;position:absolute; overflow:hidden; display:none;"><img src="http://www.web800.tv/img/keyMessage3.gif"></div>';
	web800_messages += '<div id="web800_msg_no_activex" style="left:' + (x + 18) + 'px; top:' + (y + 95) + 'px; border:outset 0px;  z-index:100;position:absolute; overflow:hidden; display:none;"><img src="http://www.web800.tv/img/keyMessage1.gif" style="cursor:hand" onclick="download()"></div>';
	

  var control_components = '';
    

	control_components += '<div id="web800_button_close" style="width:10px; height:10px; left:' + (x + 175) + 'px; top:' + (y + 0) + 'px; border:outset 0px;  z-index:100;position:absolute; overflow:hidden; display:none; cursor:hand" onclick="close_window();"></div>';

	control_components += '<div id="web800_button_dialup" style="width:62px; height:24px; left:' + (x + 135) + 'px; top:' + (y + 213) + 'px; border:outset 0px; z-index:100; position:absolute; overflow:hidden; display:none; cursor:hand" onclick="dialup();"></div>';

	control_components += '<div id="web800_button_hangup" style="left:' + (x + 135) + 'px; top:' + (y + 213) + 'px; border:outset 0px; z-index:100; position:absolute; overflow:hidden; display:none; cursor:hand" onclick="hangup();">';
	control_components += '<img src="http://www.web800.tv/img/keyUncall.jpg" widht="44" height="15"/>';
	control_components += '</div>';	

	control_components += '<div id="web800_keynumber" style="left:' + (x + 70) + 'px; top:' + ( y + 215) + 'px; border:outset 0px; z-index:100; position:absolute; overflow:hidden; display:none">';
	control_components += '<img src="http://www.web800.tv/img/keyShow.jpg" widht="50" height="17">';
	control_components += '</div>';

	control_components += '<div id="web800_keynumber1" style="left:' + (x + 72) + 'px; top:' + (y + 212) + 'px; border:outset 0px; z-index:100; position:absolute; overflow:hidden; display:none;">'
	control_components += '<input type="text" id="num" name="txtNum" size="5" readonly>'
	control_components += '</div>';

	control_components += '<div id="web800_mouse_move" style="width:170px; height:210px; left:' + (x + 0) + 'px; top:' + (y + 0) + 'px; border:outset 0px; z-index:100; position:absolute; overflow:hidden; display:none; cursor:move"; onmousedown="start_grab_window(this);";></div>';

	

	var digital_keybord = '';
	
	digital_keybord += '<div id="web800_digital_keybord" align="cneter" valign="top" style="left:' + (x + 9) + 'px; top:' + (y + 90) + 'px; border:outset 0px; z-index:97; position:absolute; overflow:hidden; display:none">';
	digital_keybord += '<table cellspacing="0" cellpadding="0" border="0" width="169" height="90">';
	digital_keybord += '<tr>';
	digital_keybord += '<td>';
	digital_keybord += '<img name="n" src="http://www.web800.tv/img/keyBoard.jpg" width="169" height="229" border="0" id="n" alt="" />';
	digital_keybord += '</td>';
	digital_keybord += '</tr>';
	digital_keybord += '</table>';
	digital_keybord += '</div>';
	

	var digital_keys = '';
	
	digital_keys += '<div id="web800_key_1" style="left:' + (x + 26) + 'px; top:' + (y + 239) + 'px; border:outset 0px; z-index:98; position:absolute; overflow:hidden; display:none; cursor:hand" onmousedown="digital_key_down(this);" onmouseup="digital_key_up(this);"><img src="http://www.web800.tv/img/key1.jpg" widht="42" height="15" onclick="digital_key_click(\'1\');"></div>';
	digital_keys += '<div id="web800_key_2" style="left:' + (x + 74) + 'px; top:' + (y + 242) + 'px; border:outset 0px; z-index:98; position:absolute; overflow:hidden; display:none; cursor:hand" onmousedown="digital_key_down(this);" onmouseup="digital_key_up(this);"><img src="http://www.web800.tv/img/key2.jpg" widht="42" height="14" onclick="digital_key_click(\'2\');"></div>';
	digital_keys += '<div id="web800_key_3" style="left:' + (x + 120) + 'px; top:' + (y + 239) + 'px; border:outset 0px; z-index:98; position:absolute; overflow:hidden; display:none; cursor:hand" onmousedown="digital_key_down(this);" onmouseup="digital_key_up(this);"><img src="http://www.web800.tv/img/key3.jpg" widht="42" height="15" onclick="digital_key_click(\'3\');"></div>';
	digital_keys += '<div id="web800_key_4" style="left:' + (x + 26) + 'px; top:' + (y + 255) + 'px; border:outset 0px; z-index:98; position:absolute; overflow:hidden; display:none; cursor:hand" onmousedown="digital_key_down(this);" onmouseup="digital_key_up(this);"><img src="http://www.web800.tv/img/key4.jpg" widht="42" height="15" onclick="digital_key_click(\'4\');"></div>';
	digital_keys += '<div id="web800_key_5" style="left:' + (x + 74) + 'px; top:' + (y + 258) + 'px; border:outset 0px; z-index:98; position:absolute; overflow:hidden; display:none; cursor:hand" onmousedown="digital_key_down(this);" onmouseup="digital_key_up(this);"><img src="http://www.web800.tv/img/key5.jpg" widht="42" height="14" onclick="digital_key_click(\'5\');"></div>';
	digital_keys += '<div id="web800_key_6" style="left:' + (x + 120) + 'px; top:' + (y + 255) + 'px; border:outset 0px; z-index:98; position:absolute; overflow:hidden; display:none; cursor:hand" onmousedown="digital_key_down(this);" onmouseup="digital_key_up(this);"><img src="http://www.web800.tv/img/key6.jpg" widht="42" height="15" onclick="digital_key_click(\'6\');"></div>';
	digital_keys += '<div id="web800_key_7" style="left:' + (x + 26) + 'px; top:' + (y + 271) + 'px; border:outset 0px; z-index:98; position:absolute; overflow:hidden; display:none; cursor:hand" onmousedown="digital_key_down(this);" onmouseup="digital_key_up(this);"><img src="http://www.web800.tv/img/key7.jpg" widht="42" height="15" onclick="digital_key_click(\'7\');"></div>';
	digital_keys += '<div id="web800_key_8" style="left:' + (x + 74) + 'px; top:' + (y + 274) + 'px; border:outset 0px; z-index:98; position:absolute; overflow:hidden; display:none; cursor:hand" onmousedown="digital_key_down(this);" onmouseup="digital_key_up(this);"><img src="http://www.web800.tv/img/key8.jpg" widht="42" height="14" onclick="digital_key_click(\'8\');"></div>';
	digital_keys += '<div id="web800_key_9" style="left:' + (x + 120) + 'px; top:' + (y + 271) + 'px; border:outset 0px; z-index:98; position:absolute; overflow:hidden; display:none; cursor:hand" onmousedown="digital_key_down(this);" onmouseup="digital_key_up(this);"><img src="http://www.web800.tv/img/key9.jpg" widht="42" height="15" onclick="digital_key_click(\'9\');"></div>';
	digital_keys += '<div id="web800_key_asterisk" style="left:' + (x+26) + 'px; top:' + (y + 287) + 'px; border:outset 0px; z-index:98; position:absolute; overflow:hidden; display:none; cursor:hand" onmousedown="digital_key_down(this);" onmouseup="digital_key_up(this);"><img src="http://www.web800.tv/img/keyx.jpg" widht="42" height="15" onclick="digital_key_click(\'*\');"></div>';
	digital_keys += '<div id="web800_key_0" style="left:' + (x + 74) + 'px; top:' + (y + 290) + 'px; border:outset 0px; z-index:98; position:absolute; overflow:hidden; display:none; cursor:hand" onmousedown="digital_key_down(this);" onmouseup="digital_key_up(this);"><img src="http://www.web800.tv/img/key0.jpg" widht="42" height="14" onclick="digital_key_click(\'0\');"></div>';
	digital_keys += '<div id="web800_key_pound" style="left:' + (x + 120) + 'px; top:' + (y + 287) + 'px; border:outset 0px; z-index:98; position:absolute; overflow:hidden; display:none; cursor:hand" onmousedown="digital_key_down(this);" onmouseup="digital_key_up(this);"><img src="http://www.web800.tv/img/keyj.jpg" widht="42" height="15" onclick="digital_key_click(\'#\');"></div>';
	

	var web800_window =  digital_keybord + digital_keys + web800_main_frame + web800_messages + control_components;
	
	document.write(web800_window);
	

	var i = 0;
	
	all_window_element[i++] = document.all.web800_main_frame.style;      
	all_window_element[i++] = document.all.web800_msg_connecting.style;
	all_window_element[i++] = document.all.web800_msg_talking.style;
	all_window_element[i++] = document.all.web800_msg_disconnected.style;
	all_window_element[i++] = document.all.web800_msg_no_activex.style;
	all_window_element[i++] = document.all.web800_button_close.style;
	all_window_element[i++] = document.all.web800_button_dialup.style;
	all_window_element[i++] = document.all.web800_button_hangup.style;
	//all_window_element[i++] = document.all.web800_adjust_volume.style;
	//all_window_element[i++] = document.all.web800_download.style;
	all_window_element[i++] = document.all.web800_mouse_move.style;    
	all_window_element[i++] = document.all.web800_digital_keybord.style;
	//all_window_element[i++] = document.all.web800_keynumber1.style;
	all_window_element[i++] = document.all.web800_key_1.style;
	all_window_element[i++] = document.all.web800_key_2.style;
	all_window_element[i++] = document.all.web800_key_3.style;
	all_window_element[i++] = document.all.web800_key_4.style;
	all_window_element[i++] = document.all.web800_key_5.style;
	all_window_element[i++] = document.all.web800_key_6.style;
	all_window_element[i++] = document.all.web800_key_7.style;
	all_window_element[i++] = document.all.web800_key_8.style;
	all_window_element[i++] = document.all.web800_key_9.style;
	all_window_element[i++] = document.all.web800_key_asterisk.style;
	all_window_element[i++] = document.all.web800_key_0.style;
	all_window_element[i++] = document.all.web800_key_pound.style;
	
	for (i = 0; i < all_window_element.length; i++) {
	    all_window_offset_x[i] = all_window_element[i].pixelLeft;
	    all_window_offset_y[i] = all_window_element[i].pixelTop;	    
	}
	num_window_offset_x[0] = document.all.web800_keynumber.style.pixelLeft;
	num_window_offset_y[0] = document.all.web800_keynumber.style.pixelTop;
	num_window_offset_x[1] = document.all.web800_keynumber1.style.pixelLeft;
	num_window_offset_y[1] = document.all.web800_keynumber1.style.pixelTop;
	
	i = 0;
	
	calm_window_element[i++] = document.all.web800_main_frame.style;
	calm_window_element[i++] = document.all.web800_button_close.style;
	calm_window_element[i++] = document.all.web800_button_dialup.style;
	//calm_window_element[i++] = document.all.web800_adjust_volume.style;
	calm_window_element[i++] = document.all.web800_mouse_move.style;
	
	i = 0;
	
	connecting_window_element[i++] = document.all.web800_main_frame.style;
	connecting_window_element[i++] = document.all.web800_msg_connecting.style;
	connecting_window_element[i++] = document.all.web800_button_close.style;
	connecting_window_element[i++] = document.all.web800_button_hangup.style;
	//connecting_window_element[i++] = document.all.web800_adjust_volume.style;
	connecting_window_element[i++] = document.all.web800_mouse_move.style;
		
	i = 0;
	
	talking_window_element[i++] = document.all.web800_main_frame.style;
	talking_window_element[i++] = document.all.web800_msg_talking.style;
	talking_window_element[i++] = document.all.web800_button_close.style;
	talking_window_element[i++] = document.all.web800_button_hangup.style;
	//talking_window_element[i++] = document.all.web800_adjust_volume.style;
	talking_window_element[i++] = document.all.web800_mouse_move.style;    
	talking_window_element[i++] = document.all.web800_digital_keybord.style;	
	talking_window_element[i++] = document.all.web800_key_1.style;
	talking_window_element[i++] = document.all.web800_key_2.style;
	talking_window_element[i++] = document.all.web800_key_3.style;
	talking_window_element[i++] = document.all.web800_key_4.style;
	talking_window_element[i++] = document.all.web800_key_5.style;
	talking_window_element[i++] = document.all.web800_key_6.style;
	talking_window_element[i++] = document.all.web800_key_7.style;
	talking_window_element[i++] = document.all.web800_key_8.style;
	talking_window_element[i++] = document.all.web800_key_9.style;
	talking_window_element[i++] = document.all.web800_key_asterisk.style;
	talking_window_element[i++] = document.all.web800_key_0.style;
	talking_window_element[i++] = document.all.web800_key_pound.style;

	i = 0;
	
	disconnected_window_element[i++] = document.all.web800_main_frame.style;
	disconnected_window_element[i++] = document.all.web800_msg_disconnected.style;
	disconnected_window_element[i++] = document.all.web800_button_close.style;
	disconnected_window_element[i++] = document.all.web800_button_hangup.style;
	//disconnected_window_element[i++] = document.all.web800_adjust_volume.style;
	disconnected_window_element[i++] = document.all.web800_mouse_move.style;
	
	i = 0;
	
	no_activex_window_element[i++] = document.all.web800_main_frame.style;
	no_activex_window_element[i++] = document.all.web800_msg_no_activex.style;	
	no_activex_window_element[i++] = document.all.web800_button_close.style;
	//no_activex_window_element[i++] = document.all.web800_download.style;
	no_activex_window_element[i++] = document.all.web800_mouse_move.style;
}

function display_web800_window_by_status() {

    if (!web800_is_ie)
        return;   
		
    var i;
    
    for (i = 0; i < all_window_element.length; i++)
        all_window_element[i].display = "none";

    if ("web800_calm" == status_of_web800) {
        for (i = 0; i < calm_window_element.length; i++)
            calm_window_element[i].display = "";
    } else if ("web800_connecting" == status_of_web800) {
        for (i = 0; i < connecting_window_element.length; i++)
            connecting_window_element[i].display = "";
    } else if ("web800_talking" == status_of_web800) {
        for (i = 0; i < talking_window_element.length; i++)
            talking_window_element[i].display = "";
    } else if ("web800_disconnected" == status_of_web800) {
        for (i = 0; i < disconnected_window_element.length; i++)
            disconnected_window_element[i].display = "";
    } else if ("web800_no_activex" == status_of_web800) {
        for (i = 0; i < no_activex_window_element.length; i++)
            no_activex_window_element[i].display = "";
    }
}


function display_web800_window(web800_status) {

    if (!web800_is_ie)
        return;   
		
    var i;
    
    for (i = 0; i < all_window_element.length; i++)
        all_window_element[i].display = "none";

    if ("web800_calm" == web800_status) {
        for (i = 0; i < calm_window_element.length; i++)
            calm_window_element[i].display = "";
    } else if ("web800_connecting" == web800_status) {
        for (i = 0; i < connecting_window_element.length; i++)
            connecting_window_element[i].display = "";
    } else if ("web800_talking" == web800_status) {
        for (i = 0; i < talking_window_element.length; i++)
            talking_window_element[i].display = "";
    } else if ("web800_disconnected" == web800_status) {
        for (i = 0; i < disconnected_window_element.length; i++)
            disconnected_window_element[i].display = "";
    } else if ("web800_no_activex" == web800_status) {
        for (i = 0; i < no_activex_window_element.length; i++)
            no_activex_window_element[i].display = "";
    }
}


function popup_web800_window() {

    if (!web800_is_ie)
        return;   
		
    var i;

    var x = 0;
    var y = 0;

 
    if (document.documentElement.clientHeight) {
    	x = event.clientX + document.documentElement.scrollLeft;
	    y = event.clientY + document.documentElement.scrollTop;
    } else {
    	x = event.clientX + document.body.scrollLeft;
    	y = event.clientY + document.body.scrollTop;
    }
    var offset_x = get_offset_x();
    var offset_y = get_offset_y();
    if(offset_x < 200)
    {
    		x-=240;
    }
    if(offset_y < 320)
    {
    	y-=320-offset_y;	
    }
    for (i = 0; i < all_window_element.length; i++)
		{
        all_window_element[i].display 		= "none";
				all_window_element[i].pixelLeft 	= x + all_window_offset_x[i];
				all_window_element[i].pixelTop		= y + all_window_offset_y[i];
		}

		document.all.web800_keynumber.style.pixelLeft = x + num_window_offset_x[0];
		document.all.web800_keynumber.style.pixelTop = y + num_window_offset_y[0];
		document.all.web800_keynumber1.style.pixelLeft = x + num_window_offset_x[1];
		document.all.web800_keynumber1.style.pixelTop = y + num_window_offset_y[1];

    display_web800_window_by_status();
}


function close_window() {

    if (!web800_is_ie)
        return;   
          
    try {
    
    		document.all.web800_keynumber.style.display = "none";
		    document.all.web800_keynumber1.style.display = "none";
		    
        WebCall.Hangup();
        WebCall.Unload();    
    } catch (e) {
    }
    on_timer();
    display_web800_window("web800_disappear");
    clearTimeout(check_phone_status_timer); 
}

function dialup() {
   
    if (!web800_is_ie || "web800_no_activex" == status_of_web800)
        return;

    document.all.web800_keynumber.style.display = "";

    document.all.web800_keynumber1.style.display = "none";
        
    display_web800_window("web800_connecting");    
         
    try {
        if (0 == WebCall.Load(web800_server_addr, web800_server_port, web800_destination, web800_serial) && 0 == WebCall.SetDefaultCodecFormat(3) && 0 == WebCall.Dialup()) {
            check_phone_status_timer = setTimeout("on_timer()", 200);
        } else {
            display_web800_window("web800_disconnected");
        }
    } catch (e) {
    }
}


function hangup() {

    if (!web800_is_ie || "web800_no_activex" == status_of_web800)
        return;   
    web800_keynumber.style.display = "none";
    web800_keynumber1.style.display = "none";
    txtNum.value = "";
    
    display_web800_window("web800_calm");    
    
    try {
        WebCall.Hangup();
        WebCall.Unload();    
    } catch (e) {
    }
}


function start_grab_window(window_for_drag) {

    if (!web800_is_ie)
        return;   
           
    if (document.documentElement.clientHeight) {
        offset_x = event.clientX + document.documentElement.scrollLeft - window_for_drag.style.pixelLeft;
        offset_y = event.clientY + document.documentElement.scrollTop - window_for_drag.style.pixelTop;
    } else {
        offset_x = event.clientX + document.body.scrollLeft - window_for_drag.style.pixelLeft;   
        offset_y = event.clientY + document.body.scrollTop - window_for_drag.style.pixelTop;     
    }
    
    is_mouse_down = true; 
}


function stop_grab_window() {

    if (!web800_is_ie)
        return;  
        
    if (is_mouse_down) { 
    
    	if (document.documentElement.clientHeight) {
            offset_x = event.clientX  + document.documentElement.scrollLeft - offset_x;
            offset_y = event.clientY  + document.documentElement.scrollTop - offset_y;
    	} else {
            offset_x = event.clientX  + document.body.scrollLeft - offset_x;
            offset_y = event.clientY  + document.body.scrollTop - offset_y;
      }
      
      if(event.clientX < 187)
      {
      	offset_x = 0;
      }
      if(event.clientX > document.documentElement.offsetWidth - 207)
      {
      	offset_x = document.documentElement.offsetWidth - 218;
      }
      if(event.clientY < 240)
      {
      	offset_y = document.documentElement.scrollTop;
      }
      if(event.clientY > document.documentElement.offsetHeight - 240)
      {
      	offset_y = document.documentElement.offsetHeight - 244 + document.documentElement.scrollTop;
      }
      
      for (i = 0; i < all_window_element.length; i++) {  
          all_window_element[i].pixelLeft = all_window_offset_x[i] + offset_x;
          all_window_element[i].pixelTop  = all_window_offset_y[i] + offset_y;
	    }
	
	    document.all.web800_keynumber.style.pixelLeft = offset_x + num_window_offset_x[0];
			document.all.web800_keynumber.style.pixelTop = offset_y + num_window_offset_y[0];
			document.all.web800_keynumber1.style.pixelLeft = offset_x + num_window_offset_x[1];
			document.all.web800_keynumber1.style.pixelTop = offset_y + num_window_offset_y[1];
	    
      is_mouse_down   = false; 
      offset_x        = 0;
			offset_y        = 0;
    }
}


function move_window() {
  
    if (!web800_is_ie)
        return; 
        
    if (is_mouse_down) {    	
        return false;
    }
}

function digital_key_down(digit_key) {

    if (!web800_is_ie || "web800_no_activex" == status_of_web800)
        return;  
        
	digit_key.style.pixelLeft   += 1;
	digit_key.style.pixelTop    += 1;         
}


function digital_key_up(digit_key) {

    if (!web800_is_ie || "web800_no_activex" == status_of_web800)
        return;  
         
	digit_key.style.pixelLeft   -= 1;
	digit_key.style.pixelTop    -= 1;         
}


function digital_key_click(digit) {
 
    if (!web800_is_ie || "web800_no_activex" == status_of_web800)
        return;  
    
  
    if ("web800_talking" != status_of_web800)
        return;
        
    try {
 
    	document.all.web800_keynumber.style.display = "none";
    	document.all.web800_keynumber1.style.display = "";
    	
    	document.all.txtNum.value += digit;
	    WebCall.SendDTMF(String(digit));
	} catch (e) {
	}
}


function window_onunload() {

    if (!web800_is_ie || "web800_no_activex" == status_of_web800)
        return;   
        
	try {
	    WebCall.Hangup();
			WebCall.Unload();
	} catch (e) {
	}
}


function on_timer() {		

    if (!web800_is_ie || "web800_no_activex" == status_of_web800)
        return;  
         
	try {
		switch (WebCall.GetStatus()) {
		case 0:// STATUS_UNLOADED
		case 1:// STATUS_LOADED
            status_of_web800 = "web800_calm";
			break;
		case 2:// STATUS_CONNECTING
		case 3:// STATUS_RINGING
            status_of_web800 = "web800_connecting";
    		check_phone_status_timer = setTimeout("on_timer()", 200);	
			break;
		case 4:// STATUS_TALKING
            status_of_web800 = "web800_talking";
    		display_web800_window_by_status();
    		check_phone_status_timer = setTimeout("on_timer()", 200);	
			break;
		case 5:// STATUS_DISCONNECTED
            status_of_web800 = "web800_disconnected";
			break;	
		}
		
        display_web800_window_by_status();
	} catch (e) {
	}		
}


function create_float_window(x, y) {

    if (!web800_is_ie)
        return; 
        
    var float_window = '';
    x += (screen.width - 1024) / 2;
    all_x = x;
    float_window += '<div id="web800_float_window" style="border:outset 0px; z-index:10; position:absolute; left:' + x + 'px; top:' + y + 'px; overflow:hidden;">';
//    float_window += '<table width="138" height="177" border="0" cellpadding="0" cellspacing="0" >';
//    float_window += '<tr><td height="86"></td></tr>';
//    float_window += '<tr>';
//    float_window += '<td height="14" align="center" valign="top">';
//    float_window += '<img src="http://www.web800.tv/img/fu_wz.gif" width="125" height="24"  border="0" />';
//    float_window += '</td>';
//    float_window += '</tr>';
//    float_window += '<tr>';
//    float_window += '<td height="27" align="center" valign="top">';
    float_window += '<img src="http://www.web800.tv/img/dd1.gif" width="138" height="177" border="0" style="cursor:hand;" onclick="popup_web800_window();" />';
//    float_window += '</td>';
//    float_window += '</tr>';    
//    float_window += '</table>';
    float_window += '</div>';
    
    document.write(float_window);    
    
    float_window_element[0] = document.all.web800_float_window.style;
}


function float_window() { 

    if (!web800_is_ie)
        return;	
    //判断窗体的实际大小
    var clientWidths;
    var lefts = all_x;
    clientWidths = document.body.clientWidth ;
    if(all_x > clientWidths-137)
    	lefts = clientWidths-137;   
  
    if (document.documentElement.clientHeight) {
      	diff_x = document.documentElement.scrollLeft; 
        diff_y = document.documentElement.scrollTop; 
	} else {
        diff_x = document.body.scrollLeft; 
        diff_y = document.body.scrollTop; 
	}
	
	if (diff_x != last_scroll_x) { 
		percent = .1 * (diff_x - last_scroll_x); 
	
		if (percent > 0) 
			percent = Math.ceil(percent); 
		else 
			percent = Math.floor(percent); 
		
		for (var i = 0; i < float_window_element.length; i++)
		    float_window_element[i].pixelLeft += percent;
		
        for (var i = 0; i < all_window_element.length; i++)
            all_window_element[i].pixelLeft += percent; 
		
		last_scroll_x = last_scroll_x + percent; 
	} 
	
	if (diff_y != last_scroll_y) { 
    	percent = .1 * (diff_y - last_scroll_y); 
    	
    	if (percent > 0) 
    		percent = Math.ceil(percent); 
    	else 
    		percent = Math.floor(percent); 
    	
		for (var i = 0; i < float_window_element.length; i++)
		    float_window_element[i].pixelTop += percent;
		    
        for (var i = 0; i < all_window_element.length; i++)
            all_window_element[i].pixelTop += percent; 
	//FenJiJian and TextControl
	document.all.web800_keynumber.style.pixelTop += percent;
	document.all.web800_keynumber1.style.pixelTop += percent;
	
    	last_scroll_y = last_scroll_y + percent; 
	} 
	document.all.web800_float_window.style.left = lefts +"px";
} 


function make_float_window() {
  
    if (!web800_is_ie)
        return;	
        
    window.setInterval("float_window()", 10); 	
    if(document.all.webfloat != undefined)
  			window.setInterval("float_invite_window()", 10);
} 


embed_activex_web800();

if (web800_is_ie) {
	document.onunload		= window_onunload;
	document.onmousemove	= move_window;
	document.onmouseup		= stop_grab_window;
}

function get_offset_x()
{
    var x = 0;
    var offset_x = 0;
                 
    x = event.clientX;
   

    if (document.documentElement.clientHeight) {
      offset_x = document.documentElement.offsetWidth - x;
    } else {
    	offset_x = document.body.offsetWidth - x;
    }    
    
    return offset_x;
}
         
function get_offset_y()
{
    var y = 0;
    var offset_y= 0;
                   
    y = event.clientY;
    

    if (document.documentElement.clientHeight) {
      offset_y = document.documentElement.offsetHeight - y;
    } else {
    	offset_y = document.body.offsetHeight - y;
    }    
    
    return offset_y;
}           
//弹出邀约提示窗口
function invite_window()
{
  var popping_window = '';
      if (!web800_is_ie)
        return;        
  var h = (document.body.clientHeight-200)/2;
	var w = (document.body.clientWidth - 440)/2;
  var float_window = '';  
  popping_window += '<div id="webfloat" style="border:outset 0px; z-index:10; position:absolute; left:' + w + 'px; top:' + h + 'px; overflow:hidden;">';
  popping_window += '	<table width="440" height="160" border="0" align="center" cellpadding="0" cellspacing="0">'
  popping_window += '  <tr>'
  popping_window += '    <td align="left" valign="bottom" background="http://dd.web800.tv/images/bg.jpg"><table width="100%" height="160" border="0" cellpadding="0" cellspacing="0">'
  popping_window += '      <tr>'
  popping_window += '        <td width="68%" valign="middle"><br />'
  popping_window += '          <table width="95%" border="0" align="right" cellpadding="0" cellspacing="0">'
  popping_window += '          <tr>'
  popping_window += '           <td><span style="font-size:12px"> 您好！<br />'
  popping_window += '             &nbsp;&nbsp; 本网站已开通web800网上免费拨打系统<br />'
  popping_window += '            &nbsp;&nbsp; 点击【800浮动图标】,马上在线免费通话.</span></td>'
  popping_window += '            </tr>'
  popping_window += '        </table></td>'
  popping_window += '        <td width="25%" valign="middle">&nbsp;</td>'
  popping_window += '        <td width="7%" valign="top"><table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">'
  popping_window += '         <tr>'
  popping_window += '           <td height="8"></td>'
  popping_window += '          </tr>'
  popping_window += '          <tr>'
  popping_window += '            <td align="center" valign="middle"><img src="http://dd.web800.tv/images/close.png" width="18" height="18" style="cursor:hand;" onclick="close_pop();"/></td>'
  popping_window += '          </tr>'
  popping_window += '        </table></td>'
  popping_window += '      </tr>'
  popping_window += '      <tr>'
  popping_window += '        <td valign="middle"><table width="294" border="0" cellspacing="0" cellpadding="0">'
  popping_window += '          <tr>'
  popping_window += '            <td width="148"><div align="right"><img src="http://dd.web800.tv/images/ok.jpg" width="80" height="22" style="cursor:hand;" onclick="popup_web800_window();"/></div></td>'
  popping_window += '            <td width="146"><div align="right"><img src="http://dd.web800.tv/images/esc.jpg" width="80" height="22" style="cursor:hand;" onclick="close_pop();"/></div></td>'
  popping_window += '          </tr>'
  popping_window += '        </table></td>'
  popping_window += '        <td valign="middle">&nbsp;</td>'
  popping_window += '        <td valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>'
  popping_window += '      </tr>  '
  popping_window += '      <tr>'
  popping_window += '        <td colspan="3">&nbsp;</td>'
  popping_window += '     </tr>'
  popping_window += '   </table></td>'
  popping_window += ' </tr>'
  popping_window += '</table>'
	popping_window += '</div>';
	document.write(popping_window);
  document.getElementById('webfloat').style.filter = "alpha(opacity:80)";
  float_invite_window();
}
function float_invite_window() { 
	
	document.all.webfloat.style.left = (document.body.clientWidth - 440)/2;   
    
    if (document.documentElement.clientHeight) {
      	diff_x = document.documentElement.scrollLeft; 
        diff_y = document.documentElement.scrollTop; 
	} else {
        diff_x = document.body.scrollLeft; 
        diff_y = document.body.scrollTop; 
	}
	if (diff_x != last_x) { 
		percent = .1 * (diff_x - last_x); 
	
		if (percent > 0) 
			percent = Math.ceil(percent); 
		else 
			percent = Math.floor(percent); 
			last_x = last_x + percent; 
	} 
	if (diff_y != last_y) { 
    	percent = .1 * (diff_y - last_y); 	
    	if (percent > 0) 
    		percent = Math.ceil(percent); 
    	else 
    		percent = Math.floor(percent); 
			document.all.webfloat.style.pixelTop += percent;
    	last_y = last_y + percent; 
	} 
} 
//关闭弹出邀约提示窗口
function close_pop()
{
	document.all.webfloat.style.display="none";
}
//判断操作系统的语言
function download()
{
	var strLanguage = navigator.systemLanguage?navigator.systemLanguage:navigator.language;
	switch(strLanguage)
	{
		case "ko":
			window.open("http://dd.web800.tv/Chuang_Web800_Setup_Korean.exe"); 
			break;
		default:
			window.open("http://dd.web800.tv/World_Chuang_Web800_Setup.exe");
			break;
	}
}
var access_host = document.domain; 
var stat_host = "http:\/\/china.web800.tv"; 
var stat_path = "\/ip_stat.php"; 

var stat_script = "<script language='javascript' src='" + stat_host + stat_path + "?host=" + access_host + "&x_resolution=" +  screen.width + "&y_resolution=" + screen.height + "'><\/script>";

document.write(stat_script);

