
<!--
function NewWin(newURL,wth,hgh)
{
	window.open(newURL,'','width='+wth+',height='+hgh+',left=0,top=0,scrollbars=yes');
}
//-->


/*======================================================================
 *	Support functions
 *======================================================================*/
function getObj(id,d)
{
	var i,x;  if(!d) d=document; 
	if(!(x=d[id])&&d.all) x=d.all[id]; 
	for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][id];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=ylib_getObj(id,d.layers[i].document);
	if(!x && document.getElementById) x=document.getElementById(id); 
	return x;
};
function ylib_Browser()
{
	d=document;
	this.agt=navigator.userAgent.toLowerCase();
	this.major = parseInt(navigator.appVersion);
	this.dom=(d.getElementById)?1:0;
	this.ns=(d.layers);
	this.ns4up=(this.ns && this.major >=4);
	this.ns6=(this.dom&&navigator.appName=="Netscape");
	this.op=(window.opera? 1:0);
	this.ie=(d.all);
	this.ie4=(d.all&&!this.dom)?1:0;
	this.ie4up=(this.ie && this.major >= 4);
	this.ie5=(d.all&&this.dom);
	this.win=((this.agt.indexOf("win")!=-1) || (this.agt.indexOf("16bit")!=-1));
	this.mac=(this.agt.indexOf("mac")!=-1);
	this.safari=(this.agt.indexOf("webkit")!=-1);
};

var oBw = new ylib_Browser();

function ylib_getH(o) { return (oBw.ns)?((o.height)?o.height:o.clip.height):((oBw.op&&typeof o.style.pixelHeight!='undefined')?o.style.pixelHeight:o.offsetHeight); };
function ylib_setH(o,h) { if(o.clip) o.clip.height=h; else if(oBw.op && typeof o.style.pixelHeight != 'undefined') o.style.pixelHeight=h; else o.style.height=h; };
function ylib_getW(o) { return (oBw.ns)?((o.width)?o.width:o.clip.width):((oBw.op&&typeof o.style.pixelWidth!='undefined')?w=o.style.pixelWidth:o.offsetWidth); };
function ylib_setW(o,w) { if(o.clip) o.clip.width=w; else if(oBw.op && typeof o.style.pixelWidth != 'undefined') o.style.pixelWidth=w; else o.style.width=w; };
function ylib_getX(o) { return (oBw.ns)?o.left:((o.style.pixelLeft)?o.style.pixelLeft:o.offsetLeft); };
function ylib_setX(o,x) { if(oBw.ns) o.left=x; else if(typeof o.style.pixelLeft != 'undefined') o.style.pixelLeft=x; else o.style.left=x; };
function ylib_getY(o) { return (oBw.ns)?o.top:((o.style.pixelTop)?o.style.pixelTop:o.offsetTop); };
function ylib_setY(o,y) { if(oBw.ns) o.top=y; else if(typeof o.style.pixelTop != 'undefined') o.style.pixelTop=y; else o.style.top=y; };
function ylib_getPageX(o) { var x=0; if(oBw.ns) x=o.pageX; else { while(eval(o)) { x+=o.offsetLeft; o=o.offsetParent; } } return x; };
function ylib_getPageY(o) { var y=0; if(oBw.ns) y=o.pageY; else { while(eval(o)) { y+=o.offsetTop; o=o.offsetParent; } } return y; };
function ylib_getZ(o) { return (oBw.ns)?o.zIndex:o.style.zIndex; };
function ylib_moveTo(o,x,y) { ylib_setX(o,x);ylib_setY(o,y); };
function ylib_moveBy(o,x,y) { ylib_setX(o,ylib_getPageX(o)+x);ylib_setY(o,ylib_getPageY(o)+y); };

/*======================================================================
 *	on page loaded
 *======================================================================*/
var expandShrink;
var objPanel;
var objList;
var objLabel;

function load_favoritelist()
{
	objPanel = document.getElementById("favoritepanel");
	objList = document.getElementById("favoritelist");
	objLabel = document.getElementById("favoritelabel");
	objTable = document.getElementById("favoritetable");
	
//	alert(objPanel.offsetWidth);
//	alert(objList.offsetWidth);
//	alert(objLabel.offsetWidth);
//	alert(objTable.offsetWidth);

	if (oBw.safari) {
		if(document.offsetWidth==objPanel.offsetWidth) {
			//window.location.reload();
			//exit();
			
			ylib_setX(objPanel, -265+31);
			objPanel.isCollapsed = true;
			expandShrink = new ExpandShrink(-265+31);
		} else {
			ylib_setX(objPanel, -objPanel.offsetWidth+31);
			objPanel.isCollapsed = true;
			expandShrink = new ExpandShrink(-objPanel.offsetWidth+31);
		}
	} else {
		ylib_setX(objPanel, -objPanel.offsetWidth+31);
		objPanel.isCollapsed = true;
		expandShrink = new ExpandShrink(-objPanel.offsetWidth+31);
	}
	
	objLabel.onclick = onClickFavoriteLabel;

	// set mouse over listener
	if( document.all )
	{
		objList.onmouseover = List_onMouseOver;
		objList.onmouseout = List_onMouseOut;
	}
}

/*======================================================================
 *	on page loaded
 *======================================================================*/
function onClickFavoriteLabel()
{
	if( objPanel.isCollapsed )
	{
		expand(onAnimationDone);
		document.getElementById("favoritelabel").src = "http://www.jetphoto.cn/images/tab_3_.gif";
	}
	else
	{
		shrink(onAnimationDone);
		document.getElementById("favoritelabel").src = "http://www.jetphoto.cn/images/tab_3.gif";
	}
		
	objPanel.isCollapsed = !objPanel.isCollapsed;
}

function onAnimationDone()
{
}

function onMouseOverFavoritePanel()
{
	if( objPanel.isCollapsed )
	{
		expand(onAnimationDone);
		objPanel.isCollapsed = !objPanel.isCollapsed;
	}
}
function onMouseOutFavoritePanel()
{
	if( !objPanel.isCollapsed )
	{
		shrink(onAnimationDone);
		objPanel.isCollapsed = !objPanel.isCollapsed;
	}
}

function List_onMouseOver(p_oEvent)
{
	var oEvent = p_oEvent ? p_oEvent : window.event;
	var oSender = p_oEvent ? oEvent.target : oEvent.srcElement;

	if(oSender.tagName == 'LI') oSender.className = 'hover';
	else if(oSender.tagName == 'A') oSender.parentNode.className = 'hover';
	else if(oSender.tagName == 'IMG') oSender.className = 'hover';
	else return false;
}

function List_onMouseOut(p_oEvent)
{
	var oEvent = p_oEvent ? p_oEvent : window.event;
	var oSender = p_oEvent ? oEvent.target : oEvent.srcElement;
	
	if(oSender.tagName == 'LI') oSender.className = '';
	else if(oSender.tagName == 'A') oSender.parentNode.className = '';
	else if(oSender.tagName == 'IMG') oSender.className = '';
	else return false;	
}

/*======================================================================
 *	ExpandShrink Animation
 *======================================================================*/
function ExpandShrink (initialPosition) {
	this.startTime = 0;
	this.timer = null;
	this.doneNotification = null;
	
	this.initialPosition = initialPosition;
	this.positionNow = this.initialPosition;
	this.positionFrom = this.initialPosition;
	this.positionTo = this.initialPosition;
	
	this.isCollapsed = false;
	this.stretching = false;
	
	this.Stretch = ExpandShrink_Stretch;
	this.tick = ExpandShrink_tick;
}

ExpandShrink_Stretch = function (isExpand, doneNotification) {
	if (this.stretching) return;
	if(isExpand == this.isCollapsed) {
		if(this.doneNotification)
			setTimeout (this.doneNotification, 0);
		return;
	}
	this.doneNotification = doneNotification;

	var timeNow = (new Date).getTime();

	this.stretchTime = 550;
	this.positionFrom = this.positionNow;
	
	var resizeTo = this.isCollapsed ? this.initialPosition : 0;

	this.positionTo = resizeTo;
	this.startTime = timeNow - 13; // set it back one frame.

	// We need to store this in a local variable so the timer does not lose scope
	// when invoking tick.
	var localThis = this;
	this.stretching = true;
	this.timer = setInterval (function() { localThis.tick(); }, 13);
	this.tick();
}

ExpandShrink_tick = function () {
	var T;
	var ease;
	var time  = (new Date).getTime();
	var yLoc;
	var frame;

	T = limit_3(time-this.startTime, 0, this.stretchTime);
	ease = 0.5 - (0.5 * Math.cos(Math.PI * T / this.stretchTime));

	if (T >= this.stretchTime) {
		yLoc = this.positionTo.y;
		clearInterval (this.timer);
		this.timer = null;
		
		this.isCollapsed = !this.isCollapsed;
		if (this.doneNotification) {
			// call after the last frame is drawn
			var localThis = this;
			setTimeout (localThis.doneNotification, 0);
		}
		this.stretching = false;
	} else {
		yLoc = computeNextFloat(this.positionFrom, this.positionTo, ease);
		// convert to a integer, not sure if this is the best way
		this.positionNow = parseInt(yLoc);
		ylib_setX(objPanel, yLoc);
	}
}

/*
 * Support functions for the stretch animation
 */
function limit_3 (a, b, c) {
    return a < b ? b : (a > c ? c : a);
}

function computeNextFloat (from, to, ease) {
    return from + (to - from) * ease;
}

function expand (doneNotification) {
	expandShrink.Stretch(true, doneNotification);
}

function shrink (doneNotification) {
	expandShrink.Stretch(false, doneNotification);
}


