// JavaScript Document

n = (document.layers) ? 1:0;
ie = (document.all) ? 1:0;
var myWidth = 0, myHeight = 0;

function alertSize() {
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
}

function getWidth(){
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    return window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    return document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    return document.body.clientWidth;
  }
}

function slidex1 (id, x) {
	step = 5;
	var endPoint = x;
	if (n) obj = document.layers[id];
	if (ie) obj = document.all[id].style;
	obj.xpos = parseInt(obj.left);
	if (Math.abs(obj.xpos + step) < endPoint) {
		if (x < 0) step = (-1)* step;
		obj.xpos += step;
		obj.left = obj.xpos;
		setTimeout("slidex1('" + id + "'," + x + ")", 30);
	}
}

function slidex2 (id, x) {
	var step = 5;
	var endPoint =(getWidth()/2) + 470 + x;
	if (n) obj = document.layers[id];
	if (ie) obj = document.all[id].style;
	obj.xpos = parseInt(obj.left);
	if (Math.abs(obj.xpos - step) > endPoint) {
		if (x < 0) step = (-1)* step;
		obj.xpos += step;
		obj.left = obj.xpos;
		setTimeout("slidex2('" + id + "'," + x + ")", 30);
	}
}

function isrefresh()
{
	var currW=myWidth, currH=myHeight;
	alertSize();

	if(currW!= myWidth)
	{
		getstart();
	}

	setTimeout('isrefresh()',500); //指定1秒刷新一次	   
}

function getstart(){

	var startpoint=(getWidth()/2)-470;
	var startpoint2=(getWidth()/2)+470;

	if (n)document.layer1.left=startpoint;
	if (ie)layer1.style.posLeft=startpoint;
	if (n)document.layer2.left=startpoint2;
	if (ie)layer2.style.posLeft=startpoint2;

	//alert(startpoint+ " " +(layer1.style.posLeft+170));
	slidex1("layer1", layer1.style.posLeft+170);
	
	//alert(startpoint2+ " " +("-10"));
	slidex2("layer2", (-600));

	alertSize();
	isrefresh();
}