// JavaScript Document
function moveover_category_box(grid){
	grid.style.background='#FFFAE7';
	grid.style.border='2px solid #FF3300';
	grid.style.padding='8px';
}

function moveout_category_box(grid){
	grid.style.background='none';
	grid.style.border='none';
	grid.style.padding='10px';
}

function cat_specifi(id){
	window.open('offerlist-'+id+'.html');
}

function boxrequest(serverPage,objID){
	var xmlhttp=getHTTPObject();
	if(!xmlhttp)return;
	var obj=document.getElementById(objID);
	xmlhttp.open("GET",serverPage);
	xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState==4&&xmlhttp.status==200){
			obj.innerHTML=xmlhttp.responseText;
			start=document.getElementById('pinyin_title');
			setSource(start,obj);
			MyMar=setInterval(move,speed);
		}
	}
		xmlhttp.send(null);
}

var isopen_pinyin=false;
var speed=10;//速度
var ci = 10;//运动次数
var left=0;//方框左位置
var top=0;//方框上位置
var width=0;//方框宽
var height=0;//方框高
var aimleft=0;//目标左位置
var aimtop=0;//目标上位置
var aimwidth=0;//目标宽
var aimheight=0;//目标高
var lb=0;//左步长
var tb=0;//上步长
var wb=0;//宽步长
var hb=0;//高步长
var fk = null;
var aim = null;
var MyMar = null;

function initObj(end){
	if (!fk){fk = document.getElementById('fk');}
	if (!aim){aim = end;}
}
/*
* 取得对象位置、大小
* 取得目标对象位置、大小
*/
function setSource(obj,end){
	initObj(end);
	left      = parseInt(obj.style.left);
	top       = parseInt(obj.style.top);
	width     = obj.offsetWidth;
	height    = obj.offsetHeight;
	aimleft   = parseInt(aim.style.left);
	aimtop    = parseInt(aim.style.top);
	//alert(left+'-'+top+'-'+aimleft+'-'+aimtop);
	aimwidth  = aim.offsetWidth;
	aimheight = aim.offsetHeight;
	fk.style.display='';
	if(MyMar)clearInterval(MyMar);
}
/**
* 设置方向步长、宽高步长
*/
function setStep(){
	lb = (aimleft-left)/ci;
	tb = (aimtop-top)/ci;
	wb = (aimwidth-width)/ci;
	hb = (aimheight-height)/ci;
}
/**
* 移动
*/
function move(){
	setStep();
	left+=lb;
	top+=tb;
	width+=wb;
	height+=hb;
	if(left<aimleft-2 || top<aimtop-2 || width<aimwidth-2 || height<aimheight-2){
		fk.style.left = left+"px";
		fk.style.top = top+"px";
		fk.style.width = width+"px";
		fk.style.height = height+"px";
	}else{
		hiddenFK();
		var catalog=document.getElementById('pinyin_body');
		catalog.style.visibility='visible';
		clearInterval(MyMar);
	}
}
function hiddenFK(){
	initObj();
	fk.style.display='none';
}

function showIndexbyPY(letter,obj){
	if(isopen_pinyin==true)return;
	var isIe=(document.all)?true:false;
	var styleStr=(isIe)?"filter:alpha(opacity=50);":"opacity:0.5;";
	posx=(isIe)?findPosX(obj)+6:findPosX(obj)-5;
	posy=(isIe)?findPosY(obj)+7:findPosY(obj)-1;
	//create title--
	var top=document.getElementById('pinyin_title');
	//top.style.cssText=styleStr;
	top.style.visibility='visible';
	top.style.background='#DBF3FF';
	top.style.width='18px';
	top.style.height='20px';
	top.style.top=posy+'px';
	top.style.left=posx+'px';
	top.style.border='1px solid #008ACC';
	top.style.borderBottom='1px solid #DBF3FF';
	top.innerHTML=letter;
	//--
	//create body--
	var parent=document.getElementById('category_frame');
	var bodyX=(isIe)?findPosX(parent)+12:findPosX(parent);
	var bodyY=(isIe)?findPosY(parent)+33:findPosY(parent)+25;
	var sc=screen.width;
	if(sc>1000)
    var bodyWidth=(isIe)?(sc-339)+'px':(sc-335)+'px';
	else
	var bodyWidth='680px';
	if(parent.style.width)bodyWidth=(parseInt(parent.style.width)-22)+'px';
	var catalog=document.getElementById('pinyin_body');
	//catalog.style.visibility='visible';
	catalog.style.width=bodyWidth;
	catalog.style.height='auto';
	catalog.style.top=bodyY+'px';
	catalog.style.left=bodyX+'px';
	catalog.style.background='#DBF3FF';
	catalog.style.border='1px solid #008ACC';
	//catalog.onmouseout=hideIndexbyPY;
	isopen_pinyin=true;
	boxrequest('quotes/pinyin_index.php?letter='+letter,'pinyin_body');
}

function hideIndexbyPY(){
	var child1=document.getElementById('pinyin_title');
	child1.style.visibility="hidden";
	child1.style.height="0px";
	child1.style.width="0px";
	var child2=document.getElementById('pinyin_body');
	child2.style.visibility="hidden";
	child2.style.height="0px";
	child2.style.width="0px";
	isopen_pinyin=false;
}

function checkIndexbyPY(letter,obj){
	if(isopen_pinyin==false){
		showIndexbyPY(letter,obj);
	}else{
	hideIndexbyPY();
	showIndexbyPY(letter,obj);
	}
}
