var $_=function() 
{
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string') 
		{
			if(document.getElementById)
				element = document.getElementById(element);
			else if(document.all)
				element = document.all[element];
			
		}
		if (arguments.length == 1) 
		{
			return element;
		}
		elements.push(element);
	}
	return elements;
};
function show(level){
	try
	{
	if(level=="0"){
		$_("showTitle").className = "title1";
		$_("show1").style.display = "block";
		$_("show11").style.display = "block";
		$_("show12").style.display = "block";
		$_("show13").style.display = "block";
	}else if(level=="1"){
		$_("show1").style.display = "block";
		
		$_("show11").style.display = "none";
		$_("show12").style.display = "none";
		$_("show13").style.display = "none";
	}else if(level=="11"){
		$_("show1").style.display = "block";
		$_("show11").style.display = "block";
		$_("show12").style.display = "none";
		$_("show13").style.display = "none";
	}else if(level=="12"){
		$_("show1").style.display = "block";
		$_("show11").style.display = "none";
		$_("show12").style.display = "block";
		$_("show13").style.display = "none";
	}else if(level=="13"){
		$_("show1").style.display = "block";
		$_("show11").style.display = "none";
		$_("show12").style.display = "none";
		$_("show13").style.display = "block";
	}else if(level=="140"){
		$_("show114").className = "shopnameT_hover";
		$_("show114").style.backgroundColor = "#fff";
		$_("show114").style.color = "#f27d00";
		$_("show14sub").style.display = "block";
	}else if(level=="150"){
		$_("show115").className = "shopnameT_hover";
		$_("show115").style.backgroundColor = "#fff";
		$_("show115").style.color = "#f27d00";
		$_("show15sub").style.display = "block";
	}
	}catch(e){}
}
function hidden(level){
	try
	{
	if(level=="1"){
		$_("showTitle").className = "title2";
		$_("show1").style.display = "none";
		$_("show11").style.display = "none";
		$_("show12").style.display = "none";
		$_("show13").style.display = "none";
		$_("foot").style.display = "none";
	}else if(level=="11"){
		$_("show11").style.display = "none";
	}else if(level=="12"){
		$_("show12").style.display = "none";
	}else if(level=="13"){
		$_("show13").style.display = "none";
	}else if(level=="140"){
		$_("show114").className = "";
		$_("show114").style.color = "";
		$_("show14sub").style.display = "none";
	}else if(level=="150"){
		$_("show115").className = "";
		$_("show115").style.color = "";
		$_("show15sub").style.display = "none";
	}
	}catch (e){}
}
function addBookmark(title) {
	var url=parent.location.href;
	if (window.sidebar) {
		window.sidebar.addPanel(title, url,"");
	} else if( document.all ) {
		window.external.AddFavorite( url, title);
	} else if( window.opera && window.print ) {
		return true;
	}
}
function setHomePage(){
	var url=parent.location.href;
	if (document.all)
	{
		document.body.style.behavior='url(#default#homepage)';
	        	document.body.setHomePage(url);
	} 
	else if (window.sidebar) 
	{
	        if(window.netscape)
	        {
	            try
	            {
	                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
	            }
	            catch (e)
	            {
	                alert(head_setHomePage_error );
	            }
	        }
	      var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
	    prefs.setCharPref('browser.startup.homepage',url);
	}
}

/**
**param: sysdate must be the  number of milliseconds between the desired date and midnight on January 1, 1970 (UTC)
**/
var Months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
var Days=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];
function setHomePageTime(milliseconds)
{
	/*this is timezone offset*/
	var sysdate = new Date(milliseconds+28800000);
	var hours = sysdate.getUTCHours();
	var minutes = sysdate.getUTCMinutes();
	var seconds = sysdate.getUTCSeconds();
	var month = sysdate.getUTCMonth();
	 var date = sysdate.getUTCDate();
	 var year = sysdate.getUTCFullYear()%100;
	 var day = sysdate.getUTCDay();
	if(year<10) year="0"+year;
	if(date<10) date="0"+date;
	if(hours>=24) hours-=24;
	if(hours<10) hours="0"+hours;
	if(minutes<10) minutes="0"+minutes;
	if(seconds<10) seconds="0"+seconds;
	$_('timeField').innerHTML  = changeNumberToImage(hours)+":"+changeNumberToImage(minutes)+":"+changeNumberToImage(seconds);
	$_('dateField').innerHTML  = Months[month]+"-"+date+"-"+year+" "+Days[day];
	if((sysdate.getUTCDay()==0 || sysdate.getUTCDay()==6)&&$_('wordIndicator').src!="/images/no_atwork.gif" )
	{
		$_('wordIndicator').src="/images/no_atwork.gif";
	}
	else if((sysdate.getUTCHours()>=18 || sysdate.getUTCHours() <9) && $_('wordIndicator').src!="/images/no_atwork.gif")
	{
		$_('wordIndicator').src="/images/no_atwork.gif";
	}
	else if($_('wordIndicator').src!="/images/atwork.gif")
	{
		$_('wordIndicator').src="/images/atwork.gif";
	}
	window.setTimeout("setHomePageTime("+(milliseconds+1000)+")",999);
	
}
function changeNumberToImage(n)
{
	var root_url = '<img src="http://images.zhaoonline.com/images/common/imgno<digit>.gif" width=14 height=15 />';
	var result="";
	var s = n.toString();
	for(var i=0;i<s.length;i++)
	{
		result += root_url.replace(/<digit>/,s.substr(i,1));
	}
	return result;
}
//=================================================================================================================================

function SelectUI(args)
{
	this.bindId = args.bindId;
	this.instance = args.instance;
	this.maxHeight = args.maxHeight || "100";
	
	this.containerClass = args.containerClass;
	this.inputClass = args.inputClass;
	this.imageClass = args.imageClass;
	this.wrapperClass = args.wrapperClass;
	this.contentClass = args.contentClass;
	this.highLightClass = args.highLightClass;
	this.dropDownImage = args.dropDownImage;
	
	this.offsetTopDelta = args.offsetTopDelta||0;
	this.offsetLeftDelta = args.offsetLeftDelta||0;
	
	var bindElement = document.getElementById(this.bindId);
	this.width = args.width||bindElement.offsetWidth;
	this.top = 0;
	this.left = 0;
	var parent  = bindElement;
	while(parent!=null)
	{
		this.top += parseInt(parent.offsetTop)||0;
		this.left += parseInt(parent.offsetLeft)||0;
		parent = parent.offsetParent;
	}
	this.top += bindElement.offsetHeight;
	var wrapper = document.createElement("div");
	var mask = document.createElement("div");
	var content = document.createElement("div");
	var iframe = document.createElement("iframe");
	
	wrapper.style.position="absolute";
	//wrapper.style.top = this.top+"px";
	//wrapper.style.left = this.left+"px";
	wrapper.style.zIndex="1000000002";
	wrapper.style.width = this.width+"px";
	wrapper.style.height = this.maxHeight+"px";
	
	if(this.wrapperClass)
	{
		wrapper.className = this.wrapperClass;
	}
	else
	{
		wrapper.style.border = "1px solid";
		wrapper.style.backgroundColor="#fff";
	}
	wrapper.style.display="none";
	mask.style.top = "0px";
	mask.style.left = "0px";
	mask.style.position="absolute";
	mask.style.zIndex="1000000001";
	mask.style.opacity="0.01";
	mask.style.filter="alpha(opacity=1)";
	
	iframe.width="100%";
	iframe.height="100%";
	iframe.marginheight="0";
	iframe.marginwidth="0";
	
	content.style.zIndex="1000000003";
	content.style.position="absolute";
	
	
	mask.appendChild(iframe);
	wrapper.appendChild(mask);
	wrapper.appendChild(content);
	
	content.style.width="100%";
	content.style.overflowY="auto";
	content.style.overflowX="hidden";
	
	this.wrapper = wrapper;
	this.content = content;
	
	document.body.appendChild(wrapper);
	
	/*get values*/
	var options = bindElement.options;
	this.values = new Array();
	this.map = new Array();
	this.selected = 0;
	for(var i=0;i<options.length;i++)
	{
		this.values.push(options[i].text);
		this.map[i]=options[i].value;
		if(options[i].selected==true)
			this.selected = i;
	}
	/**/
	
	this.select = bindElement;
	/*repaint*/
	var div = document.createElement("div");
	
	if(this.containerClass)
		div.className = this.containerClass;
	else
	{
		div.style.width = this.width;
		div.style.float = "left";
	}
	var input = document.createElement("input");
	input.value = this.values[this.selected];
	input.name = this.instance;
	input.id = this.instance;
	input.type="text";
	input.style.cursor="pointer";
	
	input.setAttribute("readonly",true);
	if(this.inputClass)
	{
		input.className = this.inputClass;
		input.style.border="none";
	}
	else
	{
		input.style.float="left";
	}
	
	var image = new Image();
	image.src = this.dropDownImage;
	image.name = this.instance;
	image.style.cursor="pointer";
	
	if(this.imageClass)
		image.className = this.imageClass;
	else
		image.float = "right";
	
	div.appendChild(input);
	div.appendChild(image);
	
	
	this.select.parentNode.insertBefore(div,this.select);
	this.select.style.display="none";
	this.isShow = false;
	/**/
	
	
	bindElement = input;
	this.bindElement = input;
		
	if(bindElement.addEventListener)
	{
		bindElement.addEventListener("keydown",new Function('e',this.instance+".keydown(e)"),false);
		image.addEventListener("click",new Function('e',this.instance+".active(e)"),false);
		//bindElement.addEventListener("focus",new Function('e',this.instance+".show(e)"),false);
		bindElement.addEventListener("click",new Function('e',this.instance+".active(e)"),false);
		window.addEventListener("resize",new Function('e',this.instance+".resize(e)"),false);
	}
	else
	{
		bindElement.attachEvent("onkeydown",new Function('e',this.instance+".keydown(e)"));
		image.attachEvent("onclick",new Function('e',this.instance+".active(e)"));
		//bindElement.attachEvent("onfocus",new Function('e',this.instance+".show(e)"));
		bindElement.attachEvent("onclick",new Function('e',this.instance+".active(e)"));
		window.attachEvent("onresize",new Function('e',this.instance+".resize(e)"));
	}
				
};
SelectUI.prototype.show=function(values)
{
	while(this.content.firstChild)this.content.removeChild(this.content.firstChild);
	this.content.scrollTop = null;
	this.locate=0;
	var ul = document.createElement("ul");
	for(var i=0;i<values.length;i++)
	{
		var li = document.createElement("li");
		li.setAttribute("name",this.instance);
		
		if(li.addEventListener)
		{
			li.addEventListener("mouseover",this.move,false);
			li.addEventListener("click",this.click,false);
		}
		else
		{
			li.attachEvent("onmouseover",this.move);
			li.attachEvent("onclick",this.click);
		}
		
		li.innerHTML = values[i];
		ul.appendChild(li);
	}
	this.content.appendChild(ul);
	this.resize();
	this.wrapper.style.display="block";
	this.content.scrollTop="0";

};
SelectUI.prototype.hide=function()
{
	this.wrapper.style.display="none";
};
SelectUI.prototype.navigate=function(direction)
{
	if(!this.locate) this.locate=0;
	var lis = this.content.getElementsByTagName("li");
	this.locate = this.locate+direction;
	
	if(this.locate>lis.length) this.locate = this.locate%lis.length;
	if(this.locate<0) this.locate = lis.length+this.locate+1;
	
	
	for(var i=0;i<lis.length;i++)
	{
		if(this.highLightClass)
			lis[i].className="";
		else
			lis[i].style.backgroundColor="";
	}
	
	if(this.locate==0 || lis.length==0)  
	{
		document.getElementById(this.bindId).value=this.originalValue;
		return;
	}
	if(this.highLightClass)
		lis[this.locate-1].className=this.highLightClass;
	else
		lis[this.locate-1].style.backgroundColor="#f00";
	var value = this.getValue();
	if(value)
	{
		this.bindElement.value=value;
		this.select.value = this.map[this.locate-1];
		if(this.select.onchange)
			this.select.onchange.call(this.select);
	}
	
	if(!this.isShow) return;
	
	var totalHeight =parseInt( lis[this.locate-1].offsetParent.scrollHeight >lis[this.locate-1].offsetParent.clientHeight? lis[this.locate-1].offsetParent.scrollHeight :lis[this.locate-1].offsetParent.clientHeight);
	
	if(parseInt(lis[this.locate-1].offsetTop) > parseInt(lis[this.locate-1].offsetParent.clientHeight)-parseInt(lis[this.locate-1].offsetHeight))
		lis[this.locate-1].offsetParent.scrollTop = parseInt(lis[this.locate-1].offsetTop)- parseInt(lis[this.locate-1].offsetParent.clientHeight) + lis[this.locate-1].offsetHeight;
			
	if(direction<0 && totalHeight-parseInt(lis[this.locate-1].offsetTop) > parseInt(lis[this.locate-1].offsetParent.clientHeight) || (direction>0 && this.locate==1))
		lis[this.locate-1].offsetParent.scrollTop = lis[this.locate-1].offsetTop + lis[this.locate-1].offsetParent.clientTop;
};

SelectUI.prototype.getValue = function()
{
	var lis = this.content.getElementsByTagName("li");
	if(this.locate>0 && this.locate<=lis.length)
		if(this.valueFilter)
			return this.valueFilter(lis[this.locate-1].innerHTML);
		else
			return lis[this.locate-1].innerHTML;
	return null;
};

SelectUI.prototype.click=function(e)
{
	if(!e) e = window.event;
	
	var srcElement = e.srcElement || e.target;
	eval("var self="+srcElement.getAttribute("name"));
	
	var lis = self.content.getElementsByTagName("li");
	for(var i=0;i<lis.length;i++)
	{
		if(lis[i]==srcElement)
		{
			self.locate = i+1;
			var value = self.getValue();
			if(value)
			{
				document.getElementById(self.instance).value=value;
				self.select.value = self.map[self.locate-1];
				if(self.select.onchange)
					self.select.onchange.call(self.select);
			}
		}
	}
	self.hide();
	if(e.stopPropagation)
		e.stopPropagation();
	else
		e.cancelBubble =true;
};

SelectUI.prototype.active=function(e)
{
	
	if(!e) e = window.event;
	
	var srcElement = e.srcElement || e.target;
	eval("var self="+srcElement.getAttribute("name"));
	
	if(self.isShow)
	{
		self.isShow = false;
		self.hide();
		var value = self.getValue();
		if(value)
		{
			document.getElementById(self.instance).value=value;
			self.select.value = self.map[self.locate-1];
			if(self.select.onchange)
				self.select.onchange.call(self.select);
		}
	}
	else
	{
		self.isShow = true;
		self.show(self.values);
	}
	if(e.stopPropagation)
		e.stopPropagation();
	else
		e.cancelBubble =true;
};

SelectUI.prototype.move=function(e)
{
	if(!e) e = window.event;
	
	var srcElement = e.srcElement || e.target;

	eval("var self="+srcElement.getAttribute("name"));
	var lis = self.content.getElementsByTagName("li");
	for(var i=0;i<lis.length;i++)
	{
		if(lis[i]==srcElement)
		{
			self.locate = i+1;
			if(self.highLightClass)
				lis[self.locate-1].className=self.highLightClass;
			else
				lis[self.locate-1].style.backgroundColor="#f00";
			
			
		}
		else
		{
			if(self.highLightClass)
				lis[i].className="";
			else
				lis[i].style.backgroundColor="";
		}
	}
	if(e.stopPropagation)
		e.stopPropagation();
	else
		e.cancelBubble =true;
};

SelectUI.prototype.keydown=function(e)
{
	if(!e) e = window.event;
	if(e.srcElement)
		eval("var self="+e.srcElement.getAttribute("name"));
	else
		eval("var self="+e.target.getAttribute("name"));
	
	if(e.keyCode=='38')
		self.navigate(-1);
	else if(e.keyCode == '40')
		self.navigate(1);
	else if(e.keyCode == '13')
		self.hide();
	if(e.stopPropagation)
		e.stopPropagation();
	else
		e.cancelBubble =true;		
};

SelectUI.prototype.keyup=function(e)
{
	if(!e) e = window.event;
	
	if(e.srcElement)
		eval("var self="+e.srcElement.getAttribute("id"));
	else
		eval("var self="+e.target.getAttribute("id"));
	if(e.keyCode=='8' ||( e.keyCode!='38' && e.keyCode!='40' && e.keyCode!='13'))
	{
		self.originalValue = document.getElementById(self.bindId).value;
	}
	
	if(e.stopPropagation)
		e.stopPropagation();
	else
		e.cancelBubble =true;	
};
SelectUI.prototype.resize=function(e)
{	
	var bindElement = document.getElementById(this.instance);
	var parent  = bindElement;
	this.top = 0;
	this.left = 0;
	while(parent!=null)
	{
		this.top += parseInt(parent.offsetTop)||0;
		this.left += parseInt(parent.offsetLeft)||0;
		parent = parent.offsetParent;
	}
	this.top += bindElement.offsetHeight;
	
	this.wrapper.style.top = this.top+this.offsetTopDelta+"px";
	this.wrapper.style.left = this.left+this.offsetLeftDelta+"px";
	
};

function AutoCompleteUI(args)
{
	this.instance = args.instance;
	this.bindId = args.bindId;
	this.maxHeight = args.maxHeight || "100";
	
	this.wrapperClass = args.wrapperClass;
	this.contentClass = args.contentClass;
	this.highLightClass = args.highLightClass;
	this.valueFilter = args.valueFilter;
	this.remoteCaller = args.remoteCaller;
	
	
	var bindElement = document.getElementById(this.bindId);
	this.width = args.width||bindElement.offsetWidth;

	var wrapper = document.createElement("div");
	var mask = document.createElement("div");
	var content = document.createElement("div");
	var iframe = document.createElement("iframe");
	
	wrapper.style.position="absolute";
	//wrapper.style.top = this.top+"px";
	//wrapper.style.left = this.left+"px";
	wrapper.style.zIndex="1000000002";
	wrapper.style.width = this.width+"px";
	wrapper.style.height = this.maxHeight+"px";
	
	if(this.wrapperClass)
	{
		wrapper.className = this.wrapperClass;
	}
	else
	{
		wrapper.style.border = "1px solid";
		wrapper.style.backgroundColor="#fff";
	}
	wrapper.style.display="none";
	mask.style.top = "0px";
	mask.style.left = "0px";
	mask.style.position="absolute";
	mask.style.zIndex="1000000001";
	mask.style.opacity="0.01";
	mask.style.filter="alpha(opacity=1)";
	
	iframe.width="100%";
	iframe.height="100%";
	iframe.marginheight="0";
	iframe.marginwidth="0";
	
	content.style.zIndex="1000000003";
	content.style.position="absolute";
	
	
	mask.appendChild(iframe);
	wrapper.appendChild(mask);
	wrapper.appendChild(content);
	
	content.style.width="100%";
	//content.style.height="100%";
	content.style.overflowY="auto";
	content.style.overflowX="hidden";
	
	this.wrapper = wrapper;
	this.content = content;
	
	document.body.appendChild(wrapper);
	
	if(bindElement.addEventListener)
	{
		bindElement.addEventListener("keydown",new Function('e',this.bindId+".keydown(e)"),false);
		bindElement.addEventListener("keyup",new Function('e',this.bindId+".keyup(e)"),false);
		bindElement.addEventListener("blur",new Function('e',this.bindId+".hide()"),false);
		window.addEventListener("resize",new Function('e',this.bindId+".resize(e)"),false);
	}
	else
	{
		bindElement.attachEvent("onkeydown",new Function('e',this.bindId+".keydown(e)"));
		bindElement.attachEvent("onkeyup",new Function('e',this.bindId+".keyup(e)"));
		bindElement.attachEvent("onblur",new Function('e',this.bindId+".hide()"));
		window.attachEvent("onresize",new Function('e',this.bindId+".resize(e)"));
	}
	
				
};
AutoCompleteUI.prototype.show=function(values)
{
	while(this.content.firstChild)this.content.removeChild(this.content.firstChild);
	this.locate=0;
	var ul = document.createElement("ul");
	for(var i=0;i<values.length;i++)
	{
		var li = document.createElement("li");
		li.setAttribute("name",this.bindId);
		
		if(li.addEventListener)
		{
			li.addEventListener("mouseover",new Function('e',this.bindId+".move(e)"),false);
			li.addEventListener("click",new Function('e',this.bindId+".click(e)"),false);
		}
		else
		{
			li.attachEvent("onmouseover",new Function('e',this.bindId+".move(e)"));
			li.attachEvent("onclick",new Function('e',this.bindId+".click(e)"));
		}
		
		li.innerHTML = values[i];
		ul.appendChild(li);
	}
	this.content.appendChild(ul);
	if(values.length>0)
	{
		this.resize();
		this.wrapper.style.display="block";
	}
	else
		this.wrapper.style.display="none";
	this.content.scrollTop="0";
	
	var maxHeight = 0;
	this.content.style.height="";
	//this.content.style.width=this.content.clientWidth+"px";
	if(window.navigator.appName.toLowerCase()=="netscape")
		maxHeight = this.content.offsetHeight;
	else
		maxHeight = this.content.scrollHeight;
	if(maxHeight>this.maxHeight)
	{
		this.wrapper.style.height=this.maxHeight+"px";
		this.content.style.height=this.wrapper.style.height;
	}
	else
		this.wrapper.style.height=maxHeight+"px";
	

};
AutoCompleteUI.prototype.hide=function()
{
	this.wrapper.style.display="none";
	while(this.content.firstChild)this.content.removeChild(this.content.firstChild);
};


AutoCompleteUI.prototype.navigate=function(direction)
{
	if(!this.locate) this.locate=0;
	var lis = this.content.getElementsByTagName("li");
	this.locate = this.locate+direction;
	
	if(this.locate>lis.length) this.locate = this.locate%lis.length;
	if(this.locate<0) this.locate = lis.length+this.locate+1;
	
	
	for(var i=0;i<lis.length;i++)
	{
		if(this.highLightClass)
			lis[i].className="";
		else
			lis[i].style.backgroundColor="";
	}
	
	if(this.locate==0 || lis.length==0)  
	{
		document.getElementById(this.bindId).value=this.originalValue;
		return;
	}
	if(this.highLightClass)
		lis[this.locate-1].className=this.highLightClass;
	else
		lis[this.locate-1].style.backgroundColor="#f00";
	
	var totalHeight =parseInt( lis[this.locate-1].offsetParent.scrollHeight >lis[this.locate-1].offsetParent.clientHeight? lis[this.locate-1].offsetParent.scrollHeight :lis[this.locate-1].offsetParent.clientHeight);
	
	if(parseInt(lis[this.locate-1].offsetTop) > parseInt(lis[this.locate-1].offsetParent.clientHeight)-parseInt(lis[this.locate-1].offsetHeight))
		lis[this.locate-1].offsetParent.scrollTop = parseInt(lis[this.locate-1].offsetTop)- parseInt(lis[this.locate-1].offsetParent.clientHeight) + lis[this.locate-1].offsetHeight;
			
	if(direction<0 && totalHeight-parseInt(lis[this.locate-1].offsetTop) > parseInt(lis[this.locate-1].offsetParent.clientHeight) || (direction>0 && this.locate==1))
		lis[this.locate-1].offsetParent.scrollTop = lis[this.locate-1].offsetTop + lis[this.locate-1].offsetParent.clientTop;
	
	
	var value = this.getValue();
	if(value)
		document.getElementById(this.bindId).value=value;
};

AutoCompleteUI.prototype.getValue = function()
{
	var lis = this.content.getElementsByTagName("li");
	if(this.locate>0 && this.locate<=lis.length && lis.length>0)
		if(this.valueFilter)
			return this.valueFilter(lis[this.locate-1].innerHTML);
		else
			return lis[this.locate-1].innerHTML;
	return null;
};

AutoCompleteUI.prototype.click=function(e)
{
	if(!e) e = window.event;
	
	var srcElement = e.srcElement || e.target;
	
	var lis = this.content.getElementsByTagName("li");
	for(var i=0;i<lis.length;i++)
	{
		if(lis[i]==srcElement)
		{
			this.locate = i+1;
			var value = this.getValue();
			if(value)
				document.getElementById(this.bindId).value=value;
		}
	}
	this.hide();
	if(e.stopPropagation)
		e.stopPropagation();
	else
		e.cancelBubble =true;
};

AutoCompleteUI.prototype.move=function(e)
{
	if(!e) e = window.event;
	
	var srcElement = e.srcElement || e.target;

	var lis = this.content.getElementsByTagName("li");
	for(var i=0;i<lis.length;i++)
	{
		if(lis[i]==srcElement)
		{
			this.locate = i+1;
			if(this.highLightClass)
				lis[this.locate-1].className=this.highLightClass;
			else
				lis[this.locate-1].style.backgroundColor="#f00";
			
			var value = this.getValue();
			if(value)
				document.getElementById(this.bindId).value=value;
		}
		else
		{
			if(this.highLightClass)
				lis[i].className="";
			else
				lis[i].style.backgroundColor="";
		}
	}
	if(e.stopPropagation)
		e.stopPropagation();
	else
		e.cancelBubble =true;
};

AutoCompleteUI.prototype.keydown=function(e)
{
	if(!e) e = window.event;
	
	
	if(e.keyCode=='38')
		this.navigate(-1);
	else if(e.keyCode == '40')
		this.navigate(1);
	else if(e.keyCode == '13')
		this.hide();
	if(e.stopPropagation)
		e.stopPropagation();
	else
		e.cancelBubble =true;		
};

AutoCompleteUI.prototype.keyup=function(e)
{
	if(!e) e = window.event;
	
	if(e.keyCode=='8' ||( e.keyCode!='38' && e.keyCode!='40' && e.keyCode!='13'))
	{
		this.originalValue = document.getElementById(this.bindId).value;
		this.remoteCaller(document.getElementById(this.bindId).value,this,this.show);
	}
	
	if(e.stopPropagation)
		e.stopPropagation();
	else
		e.cancelBubble =true;	
};

AutoCompleteUI.prototype.resize=function(e)
{	
	var bindElement = document.getElementById(this.bindId);
	var parent  = bindElement;
	this.top = 0;
	this.left = 0;
	while(parent!=null)
	{
		this.top += parseInt(parent.offsetTop)||0;
		this.left += parseInt(parent.offsetLeft)||0;
		parent = parent.offsetParent;
	}
	this.top += bindElement.offsetHeight;
	
	this.wrapper.style.top = this.top+"px";
	this.wrapper.style.left = this.left+"px";
	
}; 

/*
  instance: instance name
  marquee:id
  direction:up,down,left,right
  delay: 1 smallest, the smaller the faster
  amount: 1 smallest, the bigger the faster
*/


function Marquee(instance, marquee, direction, delay, amount,whenStop,stopTime) {
	this.instance = instance;
	this.marquee = document.getElementById(marquee);
	this.delay = delay;
	this.whenStop = whenStop || 0;
	this.stopTime = stopTime || 0;
	this.rollCount = 0;
	this.expireTime = this.stopTime;
	if (this.delay == null) {
		this.delay = 1;
	}
	this.amount = amount;
	if (this.amount == null) {
		this.amount = 1;
	}
	this.direction = direction;
	this.width = this.marquee.clientWidth;
	this.height = this.marquee.clientHeight;
	this.container = document.createElement("table");
	this.container.border = 0;
	this.container.cellspacing = "0";
	this.container.cellpadding = "0";
	var _HTML = this.marquee.innerHTML;
	this.marquee.innerHTML = "";
	this.marquee.appendChild(this.container);
	var _tr = this.container.insertRow(this.container.rows.length);
	var _td = _tr.insertCell(_tr.cells.length);
	_td.innerHTML = _HTML;
	this.scrollHeight = this.container.clientHeight;
	this.scrollWidth = this.container.clientWidth;
	switch (this.direction.toLowerCase()) {
	  case "up":
	  case "down":
		if (this.scrollHeight >= this.height) {
			var _tr = this.container.insertRow(this.container.rows.length);
			var _td = _tr.insertCell(_tr.cells.length);
			_td.innerHTML = _HTML;
			this.scrollHeight = this.container.clientHeight;
		}
		if (this.direction.toLowerCase() == "down") {
			this.marquee.scrollTop = this.scrollHeight / 2;
		}
		break;
	  default:
		if (this.scrollWidth >= this.width) {
			var _td = _tr.insertCell(_tr.cells.length);
			_td.innerHTML = _HTML;
			this.scrollWidth = this.container.clientWidth;
		}
	}
	this.marquee.m = this;
	this.intervalId = null;
	this.marquee.onmouseover = function () {
		this.m.Stop();
	};
	this.marquee.onmouseout = function () {
		this.m.Start();
	};
	this.Start();
};
Marquee.prototype.Start = function () {
	this.intervalId = setInterval(this.instance + ".Scroll()", this.delay);
};
Marquee.prototype.Stop = function (sender) {
	if (this.intervalId != null) {
		clearInterval(this.intervalId);
	}
};
Marquee.prototype.Scroll = function () {
	if(this.expireTime<this.stopTime)
	{
		this.expireTime -= this.delay; 
		if(this.expireTime<0)
			this.expireTime = this.stopTime;
		return;
	}
	
	
	switch (this.direction.toLowerCase()) {
	  case "up":
		if ((this.marquee.scrollTop + this.height) >= this.scrollHeight) {
			this.marquee.scrollTop -= this.scrollHeight / 2;
		}
		if (this.scrollHeight > this.height) {
			this.marquee.scrollTop += this.amount;
			this.rollCount +=1;
		}
		if(parseInt(this.marquee.scrollTop)%this.whenStop==0)
			this.expireTime -= 1;
		break;
	  case "down":
		if (this.marquee.scrollTop <= 0) {
			this.marquee.scrollTop += this.scrollHeight / 2;
		}
		if (this.scrollHeight > this.height) {
			this.marquee.scrollTop -= this.amount;
			this.rollCount +=1;
		}
		if(parseInt(this.marquee.scrollTop)%this.whenStop==0)
				this.expireTime -= 1;
		break;
	  case "right":
		if (this.marquee.scrollLeft <= 0) {
			this.marquee.scrollLeft += this.scrollWidth / 2;
		}
		if (this.scrollWidth > this.width) {
			this.marquee.scrollLeft -= this.amount;
			this.rollCount +=1;
		}
		if(parseInt(this.marquee.scrollLeft)%this.whenStop==0)
			this.expireTime -= 1; 
		break;
	  default:
		if ((this.marquee.scrollLeft + this.width) >= this.scrollWidth) {
			this.marquee.scrollLeft -= this.scrollWidth / 2;
		}
		if (this.scrollWidth > this.width) {
			this.marquee.scrollLeft += this.amount;
			this.rollCount +=1;
		}
		if(parseInt(this.marquee.scrollLeft)%this.whenStop==0)
			this.expireTime -= 1; 
	}
};

Marquee.prototype.Step = function(step) {
	if(this.expireTime<this.stopTime)
	{
		switch (this.direction.toLowerCase()) {
		  case "up":
			if ((this.marquee.scrollTop + this.height) >= this.scrollHeight) {
				this.marquee.scrollTop -= this.scrollHeight / 2;
			}
			if (this.scrollHeight > this.height) {
				this.marquee.scrollTop += step*this.whenStop;
			}
			break;
		  case "down":
			if (this.marquee.scrollTop <= 0) {
				this.marquee.scrollTop += this.scrollHeight / 2;
			}
			if (this.scrollHeight > this.height) {
				this.marquee.scrollTop -= step*this.whenStop;
			}
			break;
		  case "right":
			if (this.marquee.scrollLeft <= 0) {
				this.marquee.scrollLeft += this.scrollWidth / 2;
			}
			if (this.scrollWidth > this.width) {
				this.marquee.scrollLeft -= step*this.whenStop;
			}
			break;
		  default:
			if ((this.marquee.scrollLeft + this.width) >= this.scrollWidth) {
				this.marquee.scrollLeft -= this.scrollWidth / 2;
			}
			if (this.scrollWidth > this.width) {
				this.marquee.scrollLeft += step*this.whenStop;
			}
		}
	}
};
function ExchangeRates()
{
	this.rates=[];
	this.auctions=[];
	this.currentBuyCharge=0;
	this.currentMoneyKind='';
}
ExchangeRates.prototype.push=function(o)
{
	this.rates.push(o);
};
ExchangeRates.prototype.getRates=function(i)
{
	return this.rates[i];
};
ExchangeRates.prototype.getLength=function()
{
	return this.rates.length;
};
ExchangeRates.prototype.setRateId=function(rateId)
{
	for(var i=0;i<this.rates.length;i++)
	{
		if(rateId==this.rates[i].id)
		{
			this.currentMoneyKind = this.rates[i].moneyKind;
			this.currentBuyCharge = this.rates[i].buyCharge;
		}
	}
};
ExchangeRates.prototype.setCurrency=function(currency)
{
	for(var i=0;i<this.rates.length;i++)
	{
		if(currency==this.rates[i].moneyKind)
		{
			this.currentMoneyKind = this.rates[i].moneyKind;
			this.currentBuyCharge = this.rates[i].buyCharge;
		}
	}
};

ExchangeRates.prototype.getMoneyKind=function()
{
	return this.currentMoneyKind;
};

ExchangeRates.prototype.transformPrice=function(price)
{
	return (price*100/this.currentBuyCharge).toFixed(2);
};
var exchangeRates=new ExchangeRates();
function changeExchangeRate()
{	
	//exchangeRates.setRateId($_('currency').value);exchangeRates.reCaculateAll('moneyKind','moneyValue')
	$_("currencyForm").submit();
}
function initCurrency()
{
	var allcookies = document.cookie;
	var pos = allcookies.indexOf("ZHAOONLINE_USER_CURRENCY=");
	if (pos != -1) {
		var start = pos + 25;
		var end = allcookies.indexOf(";", start);
		if (end == -1) end = allcookies.length;
		var value = allcookies.substring(start, end);
		$_('currency').value = value;
	}
	exchangeRates.setCurrency($_('currency').value);
	
} 
function keyClick()
{
	if(document.getElementById("keyword").value=="Please enter Lot ID or name")
	{
		document.getElementById("keyword").value="";
	}
	return;
}

