//before common.js
document.write("<div id=\"pa\"  style=\"position:absolute; visibility:hidden; z-index:1000;\"></div>");

function showSites(){	
	document.getElementById("otherSites").className="display";
}
function hideSites(){
	document.getElementById("otherSites").className="hidden";
}
function changeBg(obj){
	obj.style.backgroundColor=="#dbe0b8"?obj.style.backgroundColor="white":obj.style.backgroundColor="#dbe0b8";
}
function slideLine(ul, delay, speed, lh) {
	var slideBox = (typeof ul == 'string')?document.getElementById(ul):ul;
	var delay = delay||500, speed=speed||20, lh = lh||20;
	var tid = null, pause = false;
	var start = function() {
		tid=setInterval(slide, speed);
	}
	var slide = function() {
		if (pause) return;
		slideBox.scrollTop += 2;	
		if (slideBox.scrollTop % lh == 0) {
			clearInterval(tid);
			slideBox.firstChild.appendChild(slideBox.getElementsByTagName('li')[0]);
			slideBox.scrollTop = 0;
			setTimeout(start, delay);
		}
	}
	slideBox.onmouseover=function(){pause=true;}
	slideBox.onmouseout=function(){pause=false;}
	setTimeout(start, delay);
}

//About BusyTrade Part
var menuid=0;

ycn=window.ycnui||{};

ycn.Common=new function(){this.lTrim=function(i){return i.replace(/^\s*/,"");};this.rTrim=function(i){return i.replace(/\s*$/,"");};this.trim=function(i){return this.rTrim(this.lTrim(i));};this.getEl=function(i){if(!document.getElementById)return false;if(typeof i==="string"){return document.getElementById(i);}else{return i;}};this.getElByClassName=function(t,n,s,el){var el=(el)?el:document;var itm=el.getElementsByTagName(t);var num=1;for(i=0;i<itm.length;i++){if(itm[i].className===n&&s===num){return itm[i];}else if(itm[i].className===n){num++;}}

	 return false;};

	 this.isIE6=function(){return navigator.userAgent.search('MSIE')>0&&navigator.userAgent.search('6')>0;}

	 this.isIE=function(){return navigator.userAgent.search('MSIE')>0;}

	 this.isOpera=function(){return navigator.userAgent.indexOf('Opera')>-1;}

	 this.isMoz=function(){return navigator.userAgent.indexOf('Mozilla/5.')>-1;}

};


ycn=window.ycn||{};

ycn.Event={

	 addEvent:function (obj,evType,fn){

	 if(obj.addEventListener)

	 {

		 obj.addEventListener(evType,fn,false);

		 return true;

	 }else if(obj.attachEvent){

		 var r=obj.attachEvent("on"+evType,fn);

		 ycn.EventCache.add(obj,evType,fn);

		 return r;

	 }else{return false;}

	 },

	 removeEvent:function (obj,evType,fn){

	 if(obj.removeEventListener){

		 obj.removeEventListener(evType,fn,false);

		 return true;

	 }else if(obj.detachEvent){

		 var r=obj.detachEvent("on"+evType,fn);

		 return r;

	 }else{return false;}

	 },

	 getEvent:function (e)

	 {

	 e=window.event||e;

	 e.leftButton=false;

	 if(e.srcElement==null&&e.target!=null)

	 {

		 e.srcElement=e.target;

		 e.leftButton=(e.button==1);		 

	 }else if(e.target==null&&e.srcElement!=null){

		 e.target=e.srcElement;

		 e.leftButton=(e.button==0);

	 }else if(e.srcElement!=null&&e.target!=null){

	 }else{return null}

	 if(document.body&&document.documentElement)

	 {

		 e.mouseX=e.pageX||(e.clientX+Math.max(document.body.scrollLeft,document.documentElement.scrollLeft));

		 e.mouseY=e.pageY||(e.clientY+Math.max(document.body.scrollTop,document.documentElement.scrollTop));

	 }else{

		 e.mouseX=-1;

		 e.mouseY=-1;

	 }

	 return e;

	 },

	 stopEvent:function (e)

	 {

	 if(e&&e.cancelBubble!=null)

	 {

		 e.cancelBubble=true;

		 e.returnValue=false;

	 }

	 if(e&&e.stopPropagation&&e.preventDefault)

	 {

		 e.stopPropagation();

		 e.preventDefault();

	 }

	 return false;

	 }

};

ycn.EventCache=function()

{

	 var listEvents=[];

	 return {

	 listEvents:listEvents,add:function (node,sEventName,fHandler,bCapture){

		 listEvents[listEvents.length]=arguments;

	 },flush:function (){

		 var i,item;

		 for(i=listEvents.length-1;i>=0;i=i-1)

		 {

	 item=listEvents[i];

	 if(item[0].removeEventListener){item[0].removeEventListener(item[1],item[2],item[3]);};

	 if(item[1].substring(0,2)!="on"){item[1]="on"+item[1];};

	 if(item[0].detachEvent){item[0].detachEvent(item[1],item[2]);};

	 item[0][item[1]]=null;

		 };

	 }

	 };

}();

var _rnd=Math.random();

var pa_m={mail_api:""+_rnd,album_api:""+_rnd,mus_api:""+_rnd,weath_api:""+_rnd,fin_api:""+_rnd,myweb_api:""+_rnd,is_request:true,conobj:null,pa_panel:null,pa_con_height:178,pa_cur_con:null,pa_cur_pre:null,close_timer:null,wait_timer:null,wait_close_timer:null,is_in_anim:false,is_in_pa:true,is_load_da:false,musicbox:{noconid:"pamus_no",conid:"pamus_con"}};function string_len(str,len){if(str.length>len){return str.substring(0,len)+"..";}return str;}



function disp_pa_preview(el){
	
	setid(el.id);

	 if(!pa_m.is_in_pa||pa_m.pa_cur_pre==el.id){return ;}

	 var p=el.parentNode;

	 while(p.tagName.toLowerCase()!='ul'&&p.tagName.toLowerCase()!='body'){p=p.parentNode;}

	 if(p.tagName.toLowerCase()!='ul'){return ;}

	 var con=ycn.Common.getEl(p.id+"previewdiv");

	 if(!con){return ;}

	 pa_m.pa_cur_pre=el.id;

	 if(pa_m.pa_cur_con!=null&&pa_m.pa_cur_con!=con){

	 con.innerHTML='';

	 var o_con=pa_m.pa_cur_con;

	 o_con.innerHTML='';

	 if(ycn.Common.getEl(o_con.id.replace("previewdiv",""))){

		 var o_tabs=ycn.Common.getEl(o_con.id.replace("previewdiv",""));

		 o_tabs.className="patabslst "+o_tabs.id;

	 }

	 var m=(o_con.offsetHeight)?o_con.offsetHeight:pa_m.pa_con_height;

	 o_con.style.visibility="hidden";

	 o_con.style.overflow="hidden";

	 var close_con=function (){

		 m-=30;

		 if(m<=0){

	 o_con.style.height=0;

	 o_con.style.display="none";

	 window.clearInterval(tt_1)

		 }else{

	 o_con.style.height=m+"px";

		 }

	 }

	 var tt_1=window.setInterval(close_con,1);

	 }

	 var class_name=p.id+"_"+el.id;

	 el.parentNode.parentNode.className=(el.parentNode.parentNode.className.indexOf(class_name)>0)?el.parentNode.parentNode.className:"patabslst "+class_name;

	 var n=(con.offsetHeight)?con.offsetHeight:0;

	 pa_m.is_in_anim=true;

	 pa_m.pa_cur_con=con;

	 con.style.visibility="visible";

	 con.style.display="block";

	 con.style.overflow="hidden";

	 var open_con=function(){

	 n+=30;

	 if(n>=pa_m.pa_con_height){

		 con.style.height=pa_m.pa_con_height+"px";

		 con.style.overflow="visible";

		 pa_m.is_in_anim=false;

		 pa_preview_cont(con,el.id);

		 window.clearInterval(tt_0);

	 }else{con.style.height=n+"px";}

	 }

	 var tt_0=window.setInterval(open_con,1);

}

function do_wait_open(e){

	 if(pa_m.is_in_anim||pa_m.is_in_pa){return ;}

	 if(ycn.Common.isIE()){var el=window.event.srcElement;}else{var el=this;}

	 while(el.tagName.toLowerCase()!='li'&&el.tagName.toLowerCase()!='body'){el=el.parentNode;}

	 if(el.tagName.toLowerCase()!='li'){return ;}

	 el=el.getElementsByTagName('a')[0];

	 if(pa_m.wait_timer){window.clearTimeout(pa_m.wait_timer);}

	 pa_m.wait_timer=window.setTimeout(function (){disp_pa_preview(el);},200); 
	

}

function keep_pre_con(e){

	 if(pa_m.is_in_anim||pa_m.is_in_pa){return ;}

	 if(pa_m.wait_close_timer!=null){window.clearTimeout(pa_m.wait_close_timer);}

	 if(pa_m.wait_timer){window.clearTimeout(pa_m.wait_timer);}

	 ycn.Event.stopEvent(ycn.Event.getEvent(e));

}

function keep_pa_preview(e){

	 pa_m.is_in_pa=true;

	 if(pa_m.wait_close_timer!=null){window.clearTimeout(pa_m.wait_close_timer);}

	 ycn.Event.stopEvent(ycn.Event.getEvent(e));

}

function close_pa_preview(e){

	 pa_m.is_in_pa=false;

	 pa_m.wait_close_timer=window.setTimeout(function (){do_close_pa(e)},2000);

	 ycn.Event.stopEvent(ycn.Event.getEvent(e));

}

function do_close_pa(e){

	 if(pa_m.is_in_pa){return ;}

	 if(pa_m.is_in_anim){return ;}

	 pa_m.is_in_anim=true;

	 var o_con=pa_m.pa_cur_con;

	 if(!o_con){pa_m.is_in_anim=false;return ;}

	 if(ycn.Common.getEl(o_con.id.replace("previewdiv",""))){

	 var o_tabs=ycn.Common.getEl(o_con.id.replace("previewdiv",""));

	 o_tabs.className="patabslst "+o_tabs.id;
	 
	 document.getElementById("yhm_"+menuid).className="yhm_a";

	 }

	 var m=(o_con.offsetHeight)?o_con.offsetHeight:pa_m.pa_con_height;

	 o_con.innerHTML='';

	 o_con.style.visibility="hidden";

	 o_con.style.overflow="hidden";

	 var close_con=function (){

	 m-=30;

	 if(m<=0){

		 o_con.style.height=0;

		 o_con.style.display="none";

		 pa_m.is_in_anim=false;

		 pa_m.pa_cur_con=null;

		 pa_m.pa_cur_pre=null;

		 window.clearInterval(pa_m.close_timer);

	 }else{o_con.style.height=m+"px";}

	 }

	 pa_m.close_timer=window.setInterval(close_con,1);

}

function init_pa_tabs(){

	 var pa=ycn.Common.getEl('pabd');

	 var patabs1=ycn.Common.getEl('patabs1');

	 var patabs2=ycn.Common.getEl('patabs2');
	 var patabs3=ycn.Common.getEl('patabs3');

	 if(!pa||!patabs1||!patabs2)return;

	 pa_m.pa_panel=pa;

	 var prediv=new Array;

	 prediv[0]=ycn.Common.getElByClassName('div','papreviewdiv',1,pa);

	 prediv[1]=ycn.Common.getElByClassName('div','papreviewdiv',2,pa);
	 prediv[2]=ycn.Common.getElByClassName('div','papreviewdiv',3,pa);

	 if(!prediv[0]||!prediv[1]||!prediv[2]){return ;}

	 var tabs1=patabs1.getElementsByTagName('li');

	 var tabs2=patabs2.getElementsByTagName('li');
	 var tabs3=patabs3.getElementsByTagName('li');

	 for(var i=0;i<tabs1.length;i++){ycn.Event.addEvent(tabs1[i],'mouseover',do_wait_open);}

	 for(var i=0;i<tabs2.length;i++){ycn.Event.addEvent(tabs2[i],'mouseover',do_wait_open);}
	 for(var i=0;i<tabs3.length;i++){ycn.Event.addEvent(tabs3[i],'mouseover',do_wait_open);}

	 ycn.Event.addEvent(pa,'mouseout',close_pa_preview);

	 ycn.Event.addEvent(pa,'mouseover',keep_pa_preview);

	 ycn.Event.addEvent(prediv[0],'mouseover',keep_pre_con);

	 ycn.Event.addEvent(prediv[1],'mouseover',keep_pre_con);
	 ycn.Event.addEvent(prediv[2],'mouseover',keep_pre_con);

	 if(ycn.Common.getEl('patop')){ycn.Event.addEvent(ycn.Common.getEl('patop'),'mouseover',function (){if(pa_m.wait_timer){clearTimeout(pa_m.wait_timer);}});}

}

function setid(id){
	switch(id){
		case 'pa_1':
			pa_m.pa_con_height=105;
			break;
		case 'pa_2':
			pa_m.pa_con_height=135;
			break;
		case 'pa_3':
			pa_m.pa_con_height=125;
			break;
		case 'pa_4':
			pa_m.pa_con_height=130;
			break;
					case 'pa_5':
			pa_m.pa_con_height=120;
			break;
					case 'pa_6':
			pa_m.pa_con_height=130;
			break;
	}
}

var offsetxpoint=3; //Customize x offset of tooltip
var offsetypoint=35; //Customize y offset of tooltip
var ie=document.all;
var ns6=document.getElementById && !document.all;
var enabletip=false;
if (ie||ns6)
var tipobj=document.all? document.all["pa"] : document.getElementById ? document.getElementById("pa") : "";

function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function overlib( stext ){
	return ddrivetip( stext );
}
function ddrivetip(thetext, thecolor, thewidth){
	if (ns6||ie){
		if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px";
		if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor;
		tipobj.innerHTML=thetext;
		enabletip=true;
		return false;
	}
}

function positiontip(e){
	if (enabletip){
		var curX=(ns6)?e.pageX : event.x+ietruebody().scrollLeft;
		var curY=(ns6)?e.pageY : event.y+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
		var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20;
		var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20;

		var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000;

//if the horizontal distance isn't enough to accomodate the width of the context menu
		if (rightedge<tipobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
			tipobj.style.left = ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px";
		else if (curX<leftedge)
			tipobj.style.left="5px";
		else
//position the horizontal position of the menu where the mouse is positioned
			tipobj.style.left=curX+offsetxpoint+"px";

//same concept with the vertical position
		if (bottomedge<tipobj.offsetHeight)
			tipobj.style.top = ie ? ietruebody().scrollTop + event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px";
		else
			tipobj.style.top=curY+offsetypoint+"px";
			tipobj.style.visibility="visible";
	}
}

function nd(){
	return hideddrivetip();
}
function hideddrivetip(){
	if (ns6||ie){
		enabletip=false;
		tipobj.style.visibility="hidden";
//tipobj.style.left="-1000px";
		tipobj.style.left="";
		tipobj.style.backgroundColor='';
		tipobj.style.width='';
	}
}

document.onmousemove=positiontip;
