﻿
var cDOMtype = '';
if (document.getElementById)
{
	cDOMtype = "std";
}
else if (document.all)
{
	cDOMtype = "ie4";
}
else if (document.layers)
{
	cDOMtype = "ns4";
}

//随滚动条滚动
var INIT_TOP = 0;
var INIT_LEFT = 0;

function scrollImg(){ 
    var posX,posY; 
    if (window.innerHeight) { 
        //posX = window.pageXOffset; 
        posY = window.pageYOffset; 
    } 
    else if (document.documentElement && document.documentElement.scrollTop) { 
       // posX = document.documentElement.scrollLeft; 
        posY = document.documentElement.scrollTop; 
    } 
    else if (document.body) { 
        //posX = document.body.scrollLeft; 
        posY = document.body.scrollTop; 
    } 
    var ad=document.getElementById("_callfloat"); 
    ad.style.top=(posY+INIT_TOP)+"px"; 
    //ad.style.left=(posX+50)+"px"; 
    setTimeout("scrollImg()",100); 
} 

//漂浮
var yPos = 0; 
var step = 1;
var delay = 30; 
var height = 0;
var Hoffset = 0;
var Woffset = 0;
var yon = 0;
var xon = 0;
var pause = true;
var interval;
//img1.style.top = yPos;
function changePos() 
{
	width = document.body.clientWidth;
	height = document.body.clientHeight;
	Hoffset = fc_getObj("_callfloat").offsetHeight;
	Woffset = fc_getObj("_callfloat").offsetWidth;
	fc_getObj("_callfloat").style.left = INIT_TOP + document.body.scrollLeft+"px";
	fc_getObj("_callfloat").style.top = yPos + document.body.scrollTop+"px";
	//fc_getObj("debug").innerHTML = fc_getObj("_callfloat").style.left+"|"+fc_getObj("_callfloat").style.top;
	if (yon) 
		{yPos = yPos + step;}
	else 
		{yPos = yPos - step;}
	if (yPos < 0) 
		{yon = 1;yPos = 0;}
	if (yPos >= (height - Hoffset)) 
		{yon = 0;yPos = (height - Hoffset);}
	if (xon) 
		{INIT_TOP = INIT_TOP + step;}
	else 
		{INIT_TOP = INIT_TOP - step;}
	if (INIT_TOP < 0) 
		{xon = 1;INIT_TOP = 0;}
	if (INIT_TOP >= (width - Woffset)) 
		{xon = 0;INIT_TOP = (width - Woffset);   }
	}
	
	function start()
	 {
	 	fc_getObj("_callfloat").visibility = "visible";
		interval = setInterval('changePos()', delay);
	}
	function pause_resume() 
	{
		if(pause) 
		{
			clearInterval(interval);
			pause = false;}
		else 
		{
			interval = setInterval('changePos()',delay);
			pause = true; 
		}
	}
	

function fc_getObj(obj){
		switch (cDOMtype)
		{
			case "std":
			{
				return document.getElementById(obj);
			}
			break;

			case "ie4":
			{
				return document.all[obj];
			}
			break;

			case "ns4":
			{
				return document.layers[obj];
			}
			break;
		}

}


//var _callcenter_imgs = "/images/logo/081204_69075417.gif";
//var _callcenter_postion = 4;
//var _callcenter_type = 2;
//左上方:1   右上方:2   左中方:3   右中方:4 

function _callcenter_init(){
	//如果为漂浮，则初始位置固定为左上方。
	if(_callcenter_type==2)_callcenter_postion=1;

	//alert(_callcenter_postion);

   if(fc_getObj("_callfloat")==null){
    var _callfloat = document.createElement("div");
    _callfloat.id = "_callfloat";
    _callfloat.style.position = "absolute";
    _callfloat.style.zIndex = 10000;
    document.body.insertBefore(_callfloat,null);
    _callfloat.innerHTML = "<a href=\"http://freecall.400online.com.cn/Home.aspx?cid="+_callcenter_cid+"\" target=\"_blank\"><img src=\"http://freecall.400online.com.cn"+_callcenter_imgs+"\" border=\"0\" /></a>";
    switch(_callcenter_postion){
        case 1:
            INIT_TOP = 10;
            _callfloat.style.top = "10px"
            _callfloat.style.left = "10px";
        
        break;
        
        case 2:
            INIT_TOP = 10;
            _callfloat.style.top = "10px"
            _callfloat.style.right = "10px";
        
        break;
        
        case 3:
            INIT_TOP = 300;
            _callfloat.style.top = "300px"
            _callfloat.style.left = "10px";
        
        break;
        
        case 4:
            INIT_TOP = 300;
            _callfloat.style.top = "300px"
            _callfloat.style.right = "10px";
        
        break;
    
    }
    
    if(_callcenter_type==1){
        scrollImg(); 
    }else if(_callcenter_type==2){
        start();
    
    }else{
        // do nothing
    }
    
    
   } 

}







