function BtnAction( oThisNode, iImgHeight )
{
	oThisNode.style.backgroundPosition='0px '+iImgHeight+'px';
}

var tmpint_cgd = 0;
function changedisplay(x){
	alert(changedisplay)
	tmpint_cgd++;
	if(document.all)
	{
		var img = x.parentNode.parentNode.firstChild;
	}
	else
	{
		var temp_use=x.parentNode.parentNode.cleanWhitespace();
		var img = temp_use.firstChild;
	}
	img.style.zIndex = tmpint_cgd;
	//x.parentNode.parentNode.firstChild.firstChild.style.zIndex = tmpint_cgd;
}

function redir_eventcode(url,eventcode){
	pageStatistics(eventcode);
	document.location.href = url;
}

function rotabanner(postid,url){
	var pars = new Date();
	pars+= '&postid=' + postid;
	var myAjax = new Ajax.Request('/main/banner/rotation_count.php', {method:'GET', parameters:pars});
	document.location.href = url;
}

function Cy_block_pckage()
{
	this.reflashnewminihompy = function (divid,num){
		var miniList = new Ajax.Request('/resource/common/include/main/frame_main_left_newminihompy.php?idd=T&dummy='+ new Date().getTime(),
		{
			method: "post",
			parameters: "s="+num,
			onComplete: function (result)
			{
				Html=result.responseText;
				if(Html)
				{
					if (divid == 'undifined')
						divid = 'block_newminihompy';
					var ele = getElementsById_loop('div',divid,'id');
					ele[0].outerHTML = Html;
				}
			}
		});
	}
}

//patch
var setOuterHtml = function(s){
	var range = this.ownerDocument.createRange();
	range.setStartBefore(this);
	var fragment = range.createContextualFragment(s);
	this.parentNode.replaceChild(fragment, this);
};

if(window.HTMLElement) {
	HTMLElement.prototype.__defineSetter__("outerHTML", setOuterHtml);
}

/*
Return array for all elements
Useing tag_type, tag_attribute and keywords which your want to match
tag_type : div, table, lu, li ect..
tag_attribute : attname, id etc..
*/
function getElementsById_loop(tag, attname, elemAtt) {
	var elem = document.getElementsByTagName(tag);
	var arr = new Array();
	for(i = 0,iarr = 0; i < elem.length; i++) {
		att = elem[i].getAttribute(elemAtt);
		if (att != null && att != ''){
			if(att.indexOf(attname) != -1) {
				arr[iarr] = elem[i];
				iarr++;
			}
		}
	}
	return arr;
}


function angel_card(cyid){
	WinOpen('/main/sns/cards.php?cyid='+cyid,'cards',450,468,'no','no','no','');
}
function WinOpen(strUrl,strName,WinWidth,WinHeight,ScrollBar,Resize,WinGubun,strProperty, left, top){
	if (left != "")
		var x = left;
	else
		var x=screen.width/2 - WinWidth/2;

	if (top != "")
		var y = top;
	else
		var y=screen.height/2 - WinHeight/2;

	var OpBrWin;
	if (WinGubun == "Normal")															// ???? ??? ? ??(? ??, ???, ????)
		{ OpBrWin = window.open(''+strUrl+'',''+strName+'','scrollbars='+ScrollBar+',resizable='+Resize+',width='+WinWidth+',height='+WinHeight+','+strProperty+''); }
	else																													// ??? ?? ???? ????? ??.(WinGubun : Center)
		{ OpBrWin = window.open(''+strUrl+'',''+strName+'','left='+x+', top='+y+', width='+WinWidth+', height='+WinHeight+',scrollbars='+ScrollBar+',resizable='+Resize+','+strProperty+''); }

	if(OpBrWin){
		OpBrWin.focus();
	}
	return(OpBrWin);
}

function OpenNameUIPublic(strName, strGetData){
	//???? ?? ???
	if(strName == "WinBuddyMake"){
		var strUrl = "/common/include/buddy_invite_makeC_Wview.php" + strGetData;
//		var strUrl = "/common/include/buddy_invite_requestedC_Wview.php" + strGetData;	// ?? ?? ??
		var WinWidth = "310";
		var WinHeight = "460";
	}
	//???? ?? > ??? ?? ?? ???
	else if(strName == "WinBuddyReceiver"){
		var strUrl = "/common/include/buddy_invite_receiverC_Mview.php" + strGetData;
		var WinWidth = "438";
		var WinHeight = "450";
	}
	//?? ???
	else if(strName == "WinMemoSend"){
		//var strUrl = "/main/memo_writeC_Wview_backup.php" + strGetData;
		var strUrl = "/main/memo_writeC_Wview.php" + strGetData;
		var WinWidth = "310";
		var WinHeight = "460";
	}
	//?? ??? ???? ???
	else if(strName == "WinBuddyNameChange"){
		//alert(strGetData);
		//var strUrl = "/main/buddy_name_changeC_Wview.php" + strGetData;

		var strUrl = "/common/include/buddy_change_makeC_Wview.php" + strGetData;
		var WinWidth = "310";
		var WinHeight = "460";

	}

	else if(strName == "WinBuddyNameChange_re"){
		//alert(strGetData);
		//var strUrl = "/main/buddy_name_changeC_Wview.php" + strGetData;

		var strUrl = "/common/include/buddy_change_re_makeC_Wview.php" + strGetData;
		var WinWidth = "388";
		var WinHeight = "410";

	}

	var ScrollBar = "no";
	var Resize = "no";
	var WinGubun = "Normal";
	var strProperty = "";

	WinOpen(strUrl,strName,WinWidth,WinHeight,ScrollBar,Resize,WinGubun,strProperty);
}



var CyBlockP=new Cy_block_pckage();

function MallImageResize(objId, myH, myW) {
	//myImage = new Image();
	objImg = document.getElementById(objId);
	if (objImg == null) return;
	//myImage.src = objImg.src;
	var height = objImg.height;
	var width = objImg.width;
	var objwidth;
	var objheight;

	if (typeof(myH) == "undefined")  myH = 80;
	if (typeof(myW) == "undefined")  myW = 80;

	if(height > width) {
		if(height > myH) {
			objheight = myH;
			objwidth = parseInt(((width*myH)/height),10);
			MallImageResizeDO(objImg,objheight,objwidth);
		}
	}else if (width > height) {
		if (width > myW) {
			objwidth = myW;
			objheight = parseInt(((height*myW)/width),10);
			MallImageResizeDO(objImg,objheight,objwidth);
		}
	}else{
		if(height>myH && width>myW)
			MallImageResizeDO(objImg,myH,myW);
	}
}
function MallImageResizeDO(obj,h,w){
	objImg.style.height = h;
	objImg.style.width = w;
	objImg.height = h;
	objImg.width = w;
}



function changeHtmlValue(url,blockid,pars,compel){
	var eleblock = document.getElementById(blockid);
	if (eleblock.innerHTML.length < 180 || compel){
		var myAjax = new Ajax.Updater(blockid, url, {method: 'get', parameters: pars});
	}
}


//move from mall_only.js
var item_win;
function item_view(item_type, intItemid, fn,chkbox_id){

	if(!fn){
		fn = document.frmItemView;
	}

	if(item_type =="30"){//음악
	strUrl = "about:blank";
	frmAction = "/mall/item_view_music.php";
	strName = "itemViewwindow";
	WinWidth = 441;
	WinHeight = 215;
	ScrollBar = 0;
	Resize = "no";
	WinGubun = "Center";
	strProperty = "";
	}else{
		strUrl = "about:blank";
		frmAction = "/mall/item_view_ps.php";
		strName = "itemViewwindow";
		WinWidth = 932;
		WinHeight = 705;
		ScrollBar = 0;
		Resize = "no";
		WinGubun = "Center";
		strProperty = "";
	}
	if(item_win){
		if(!item_win.closed){
			item_win.close();
		}
	}
	if(parent.frmHidden){
		recive_id = parent.frmHidden.document.getElementById("recive_id").value;
		recive_name = parent.frmHidden.document.getElementById("recive_name").value;
		frmAction = frmAction + "?FromWho=" + recive_id + "&FromWhoName=" + recive_name;
	}
	item_win = WinOpen(strUrl,strName,WinWidth,WinHeight,ScrollBar,Resize,WinGubun,strProperty);
	var x=screen.width/2 - WinWidth/2;
	var y=screen.height/2 - WinHeight/2;
	item_win.moveTo(x,0);
	fn.action=frmAction;
	fn.target = "itemViewwindow";
	fn.intItemid.value=intItemid;
	fn.submit();
}

function itemBuy(itemID,itemDuration,itemCost){
	var strUrl = "/mall/item_buy.php?";
	strUrl += "ChkValues="+itemID;
	strUrl += "&SelValues="+itemDuration+"|"+itemCost;
	strName = "itemBuyWindow";
	WinWidth = 388;
	WinHeight = 290;
	ScrollBar = "yes";
	Resize = "yes";
	WinGubun = "Center";
	strProperty = "";
	item_win = WinOpen(strUrl,strName,WinWidth,WinHeight,ScrollBar,Resize,WinGubun,strProperty);
	var x=screen.width/2 - WinWidth/2;
	var y=screen.height/2 - WinHeight/2;
	item_win.moveTo(x,0);
}

//move from common.js
var stalkerUnused;
var str_login_msg="請登入後使用";
var str_msg_buddy_self = "你不能將自己加入麻吉.";
var str_msg_memo_send_self = "您不能將留言發送給自己.";
var str_msg_buddy_friend_id_none = "該Cyworld會員不存在.";
var YourHompy_GSP;
var MyHompy_GSP;

// flash object convert
function conv_object_for_ie(obj_id){
    var arr_obj_conv = document.getElementById(obj_id);
    if(arr_obj_conv.length>1){
    	for(i=0;i<arr_obj_conv.length;i++){
    		if(arr_obj_conv[i].style.display  == "none"){
    			arr_obj_conv[i].innerHTML = arr_obj_conv[i].innerHTML;
    			arr_obj_conv[i].style.display = "inline";
    		}
    	}
    }
    else{
    	if(arr_obj_conv.style.display  == "none"){
    		arr_obj_conv.innerHTML = arr_obj_conv.innerHTML;
    		arr_obj_conv.style.display = "inline";
    	}
    }
}

function chk_broswer(){
	if (navigator.appName.indexOf("Microsoft")!=-1)
		return(true);
	else
		return(false);
}

function getCookie(name){
    var cname = name + "=";
    var dc = document.cookie;

    if (dc.length > 0) {
     begin = dc.indexOf(cname);

        if (begin != -1) {
         begin += cname.length;
         end = dc.indexOf(";", begin);

         if (end == -1) end = dc.length;
             return unescape(dc.substring(begin, end));
        }
    }
    return "";
}

function trim(s){
	return s.replace(/(^\s*)|(\s*$)/g, "");
}

function open_minihompy(mh_id, login_id, redirect_url, menuid,folderid,open_map){
	var domain = "http://tw.cyworld.com";
	var strUrl = domain + "/ps/ps_gate.php?mh_id=" + mh_id +"&menuid=" +menuid + "&folderid=" + folderid;
	if(redirect_url)
		strUrl = strUrl + "&redirect_url=" + encodeURIComponent(redirect_url);
	strUrl = strUrl + "&open_map=" + encodeURIComponent(open_map);
	var strUrlTmp = "about:blank";
	var WinWidth = "932";
	var WinHeight = "568";
	var ScrollBar = "yes";
	var Resize = "no";
	var WinGubun = "";
	var strProperty = "";

	function focusHompy(obj)
	{
		if(obj.focus) obj.focus();
		else setTimeout(function(){focusHompy(obj)},300);
	}

	if (mh_id == 0 && login_id == 0){
		alert('請您登入後使用。');
	}else{
		if(mh_id == login_id){
			var strName = "MyHompy_GSP";
			if(!MyHompy_GSP || MyHompy_GSP.closed || top.window.name != "MyHompy_GSP"){
				MyHompy_GSP = WinOpen(strUrl,strName,WinWidth,WinHeight,ScrollBar,Resize,WinGubun,strProperty);
			}else{
				MyHompy_GSP.location.replace(strUrl);
			}
			setTimeout(function(){focusHompy(MyHompy_GSP)},300);
			//MyHompy_GSP.focus();

		}else{
			var strName = "YourHompy_GSP";
			if(!YourHompy_GSP || YourHompy_GSP.closed || top.window.name != "YourHompy_GSP"){
				YourHompy_GSP = WinOpen(strUrl,strName,WinWidth,WinHeight,ScrollBar,Resize,WinGubun,strProperty);
			}else{
				YourHompy_GSP.location.replace(strUrl);
			}
			setTimeout(function(){focusHompy(YourHompy_GSP)},300);
			//YourHompy_GSP.focus();

		}
	}



}

function go_url(target_window, url){
	document.location.href = url;
}
var music_win;
function OpenPreviewMusicPlayer(myitemids) {
	var opUrl = '/ps/ps_music_C_loading.php?pCount=0&myitemids='+myitemids+'&action=preview';
	music_win = window.open(opUrl, "P3AODPlayer","width=350,height=479");
}
function showControl(popupObj)
{
	if (popupObj.overFlag) {
		var i;
		for (i = 0; i < popupObj.overFlag.length; ++i)
			popupObj.overFlag[i].style.visibility = "";
	}
	popupObj.overFlag = null;
}
function hideControl (tagName, popupObj)
{
	if (document.all) {
		var x = cmGetX (popupObj);
		var y = cmGetY (popupObj);
		var w = popupObj.offsetWidth;
		var h = popupObj.offsetHeight;
		var i;
		for (i = 0; i < document.all.tags(tagName).length; ++i) {
			var obj = document.all.tags(tagName)[i];
			if (!obj || !obj.offsetParent) continue;
			var ox = cmGetX (obj);
			var oy = cmGetY (obj);
			var ow = obj.offsetWidth;
			var oh = obj.offsetHeight;
			if (ox > (x + w) || (ox + ow) < x) continue;
			if (oy > (y + h) || (oy + oh) < y) continue;
			if(obj.style.visibility == "hidden") continue;
			if(!popupObj.overFlag)
				popupObj.overFlag = new Array ();
			popupObj.overFlag[popupObj.overFlag.length] = obj;
			if(tagName == "IFRAME"){
				if(obj.name == "mh_buddy" || obj.name == "actionFrame" || obj.name == "my_buddy")
					obj.style.visibility = "hidden";
			}
			else{
			obj.style.visibility = "hidden";

			}
		}
	}
}
function cmGetY (obj){
	var y = 0;
	do{
		y += obj.offsetTop;
		obj = obj.offsetParent;
	}
	while (obj);
	return y;
}
function cmGetX (obj){
	var x = 0;
	do
	{
		x += obj.offsetLeft;
		obj = obj.offsetParent;
	}
	while (obj);
	return x;
}
function go_globalcyworld(v,str_national)
{
	window.open ('http://www.cyworld.com/global_locale.asp?etc='+str_national+'&chk=N','CyWorld_GSP1','');
}

function checkImgSize(obj,param)
{
	var width=80;
	var height=80;
	if(param)
	{
		tempParam=param.split('x');
		try{width=tempParam[0];}catch(e){width=80;}
		try{width=tempParam[1];}catch(e){height=80;}
	}
	if((obj.width != width || obj.height != height  ) /*&& (obj.width > 0 || obj.height > 0)*/)
	{
		$(obj.parentNode).setStyle({backgroundImage:'url('+obj.src+')',backgroundColor:'#eee'})
		$(obj).hide();
	}
	else if( obj.width <= 0 || obj.height <= 0)
	{
//		alert(obj.width+':'+obj.height);
	}
}

function imgSizeError(obj)
{
	obj.src='http://img.tw.cyworld.com/image/banner/80_pic.jpg';
}

function processBlock(block)
{
	$(block)._CyBlock=new CyBlock(block);;
}

function CyBlock(block)
{
	/*
	_url: (URL)
	_refreshtype: [ 1 | 0 ]
	_moretype: [ list | url | refresh | page ]
	_btnlink: (URL with _moretype)
	_code: (Event-Code)
	_extraType: [ subscribe ]
	_extraLink: (Javascript-Function with _extraType)
	_listExpand: [ true | false ]
	 */
	var _self=this;
	this.ajaxUrl=[];
	this.blockName=block;
	this.refreshType=[];//0:keep,1:refresh every click
	this.btnUrl=[];
	this.btnExtraUrl=[];
	this.moreType=[];
	this.tabCount=0;
	this.activeTab=0;//which tab is activted now , changed after tab click
	this.waitting2ActiveTab=null;//which tab will be Active after this class init , reference to the property: _default
	this.tabNode=null;// the container of tabs
	this.moreNode=null;//the more botton
	this.extraBtnType=[];  //the extra botton Type
	this.extraBtnLink=[];  //the extra botton Link
	this.extraBtnNode=null;   //the extra botton Node
	this.contentLessCount=5;
	this.containNode=null;
	this.contentCount=0;
	this.ajaxLoadingState=[];
	this.contentListId=[];
	this.tabEventCode=[];
	this.loadingNode=null;
	this.pageInfo=[];
	this.expandInfo=[];
	this.tabClick={
		click:function(e)
		{
			e=e?e:event;
			srcElement = e.srcElement? e.srcElement : e.target;
			_self.tabNode.immediateDescendants().each(function(Child){
				Child.firstChild.setAttribute('href','#');
				if(srcElement==Child.firstChild)
				{
					if(Child.getAttribute('_moretype')=='url')
						_self.moreNode.innerHTML=_self.moreUrl;
					else if(Child.getAttribute('_moretype')=='list')
						_self.moreNode.innerHTML=_self.moreListMore;
					else if(Child.getAttribute('_moretype')=='refresh')
						_self.moreNode.innerHTML=_self.moreRefresh;
					else if(_self.moreNode)
						_self.moreNode.innerHTML='';
					_self.tabClick.setTabMouseInOutEvent(Child,'On');
					_self.activeTab=Child.getAttribute('_tabIndex');
					if(Child.getAttribute('_extraType')=='subscribe')
						_self.extraBtnNode.innerHTML=_self.extraSubscribe;
				}
				else
					_self.tabClick.setTabMouseInOutEvent(Child);
			});
			if(_self.refreshType[_self.activeTab]!=1) srcElement.removeAttribute('href');
			_self.tabClick.hideTabContent();
			(_self.removeLoadingNode());
			_self.checkMoreStatus();
			if( _self.ajaxUrl[_self.activeTab])// need to get content or not
			{
				if(_self.moreType[_self.activeTab]=='list')
				{
					if(_self.tabNode.childNodes[_self.activeTab].getAttribute('_listExpand'))
						_self.expandInfo[_self.activeTab]=true;
					else
						_self.expandInfo[_self.activeTab]=false;
				}

				if($(_self.contentListId[_self.activeTab]) && _self.refreshType[_self.activeTab]==1 )
					_self.tabClick.getAjaxContent();
				else if(!$(_self.contentListId[_self.activeTab]))
					_self.tabClick.getAjaxContent();
			}
			if(_self.refreshType[_self.activeTab]!=1)
				_self.tabClick.showTabContent();
			if( _self.tabEventCode[_self.activeTab])
				_self.sendEvent();
			return false;
		},
		setTabMouseInOutEvent:function(obj,isOn)
		{
			var regexFirst = new RegExp(/frist/gi);// leon miss spell this
			var regexLast = new RegExp(/last/gi);
			if(regexFirst.test(obj.className))
				var str_middle='_frist';
			else if(regexLast.test(obj.className))
				var str_middle='_last';
			else
				var str_middle='';
			if(!isOn)
			{
				obj.onmouseover=function(){this.className='Tab'+str_middle+'_Over'};
				obj.onmouseout=function(){this.className='Tab'+str_middle};
				obj.className='Tab'+str_middle;
			}
			else
			{
				obj.onmouseover=null;
				obj.onmouseout=null;
				obj.className='Tab'+str_middle+'_On';
			}
		},
		getAjaxContent:function(option)
		{
			var url=_self.ajaxUrl[_self.activeTab];
			var myWorkingTab=_self.activeTab;
			pars='dummy='+new   Date().getTime();
			if(_self.moreType[_self.activeTab]=='page' && option=='reload' )
				pars=pars+'&p='+_self.pageInfo[_self.activeTab].current
			else if(_self.moreType[_self.activeTab]=='page' && option!='reload' )
				pars=pars+'&p='+_self.pageInfo[_self.activeTab].next
			else if(_self.moreType[_self.activeTab]=='list' && _self.expandInfo[_self.activeTab])
				pars=pars+'&p=expand';
//			if(_self.ajaxLoadingState[_self.activeTab])
//				return false;
			var result= new Ajax.Request(url,{
					method: "post",
                	postBody: pars,
					onComplete:function(html){
						_self.removeLoadingNode();
						if(_self.activeTab!=myWorkingTab)
							return false;
						var tempNode=document.createElement('div');
						var responseJavaScript=html.responseText.extractScripts();
						if(_self.moreType[myWorkingTab]=='page')
							if(responseJavaScript.length)
							{
								_self.pageInfo[myWorkingTab].tp=responseJavaScript.map(function(script){return eval(script);});
								if(option!='reload')
									_self.pageInfo[myWorkingTab].current=_self.pageInfo[myWorkingTab].next;
							}
						tempNode.innerHTML=html.responseText;
						tempNode=$(tempNode).cleanWhitespace();
						tempNode.firstChild.setAttribute('id',_self.contentListId[myWorkingTab])
						fg.appendChild(tempNode.firstChild);
						if($(_self.contentListId[_self.activeTab]) /*&& _self.activeTab==myWorkingTab*/ )//replace or append
								_self.containNode.replaceChild(fg,$(_self.contentListId[_self.activeTab]))
						else
						{
							_self.containNode.appendChild(fg);
							_self.contentCount++;
//							if(_self.activeTab!=myWorkingTab) $(_self.contentListId[myWorkingTab]).hide();
						}
						_self.ajaxLoadingState[myWorkingTab]=0;
						_self.checkMoreStatus();
					},
					onLoading :function(){
						_self.ajaxLoadingState[_self.activeTab]=1;
					},
					onCreate:function(){_self.putLoadingNode();}
				});
		},
		hideTabContent:function()
		{
			for (var i=0;i<_self.contentCount;i++)
				$(_self.containNode.childNodes[i]).hide();

			return true;
		},
		showTabContent:function()
		{
			if($(_self.contentListId[_self.activeTab]))
				$(_self.contentListId[_self.activeTab]).show();
			else
				;/*alert('trying to show a not exist tab :'+_self.activeTab)*/
		},
		expendContent:function()
		{
			var tempNode=_self.getTabContentListNode();
			var tempCount=tempNode.childNodes.length;
			for (var i=0;i<tempCount;i++)
				$(tempNode.childNodes[i]).show();
			_self.expandInfo[_self.activeTab]=true;
		},
		collapseContent:function()
		{
			var tempNode=_self.getTabContentListNode();
			var tempCount=tempNode.childNodes.length;
			if(_self.tabNode.childNodes[_self.activeTab].getAttribute('_lesscount'))
				contentLessCount=_self.tabNode.childNodes[_self.activeTab].getAttribute('_lesscount');
			else
				contentLessCount=_self.contentLessCount;
			for (var i=tempCount-1;i>=contentLessCount;i--)
				$(tempNode.childNodes[i]).hide();
			_self.expandInfo[_self.activeTab]=false;
		},
		fireClick:function(tab)
		{
			var targetObj=$(_self.tabNode.childNodes[tab]).firstChild
			if(!document.all)
			{
				MozEvtLeftClick=document.createEvent("MouseEvents");
				MozEvtLeftClick.initMouseEvent('click',true,false,window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
				targetObj.dispatchEvent(MozEvtLeftClick)
			}
			else
				setTimeout(function(){targetObj.click()},500);
		}
	}


	this.checkMoreStatus=function(){

		var tempNode=this.getTabContentListNode();
		if(!this.moreNode) return false;
		this.moreNode.hide();
		if(this.extraBtnNode)
			this.extraBtnNode.hide();
		if(this.moreType[this.activeTab]=='url')
		{
			this.moreNode.innerHTML=this.moreUrl;
			if(_self.btnUrl[_self.activeTab])
				this.moreNode.onclick = function(){document.location.href = _self.btnUrl[_self.activeTab]};
			else
				this.moreNode.onclick = function(){alert('此功能尚未開放');};
			this.moreNode.show();
		}
		if(this.moreType[this.activeTab]=='refresh')
		{
			this.moreNode.innerHTML=this.moreRefresh;
			this.moreNode.onclick = function(){_self.tabClick.getAjaxContent();return false;};
			this.moreNode.show();
		}

		if(this.moreType[this.activeTab]=='list')
		{
			if(tempNode)
			{
				tempCount=tempNode.childNodes.length;
				if(this.tabNode.childNodes[this.activeTab].getAttribute('_lesscount'))
					contentLessCount=this.tabNode.childNodes[this.activeTab].getAttribute('_lesscount');
				else
					contentLessCount=this.contentLessCount;
				if(tempCount > contentLessCount )
				{
					if(tempNode.childNodes[contentLessCount] && $(tempNode.childNodes[contentLessCount]).visible())
					{
						this.moreNode.innerHTML=this.moreListLess;
						this.moreNode.onclick = function(){_self.tabClick.collapseContent();_self.checkMoreStatus();return false;};
					}
					else if(tempNode.childNodes[contentLessCount] && !$(tempNode.childNodes[contentLessCount]).visible())
					{
						this.moreNode.innerHTML=this.moreListMore;
						this.moreNode.onclick = function(){_self.tabClick.expendContent();_self.checkMoreStatus();return false;};
					}
					this.moreNode.show();
				}
			}
		}

		if(this.moreType[this.activeTab]=='page')
		{
			this.moreNode.innerHTML=this.moreNextPage;
			this.pageInfo[this.activeTab].prev=((this.pageInfo[this.activeTab].current-1)>0)?(this.pageInfo[this.activeTab].current-1):1;
			this.pageInfo[this.activeTab].next=((this.pageInfo[this.activeTab].current+1)<=this.pageInfo[this.activeTab].tp)?this.pageInfo[this.activeTab].current+1:1;
			this.moreNode.onclick = function(){_self.tabClick.getAjaxContent();return false;};
//			alert('in checkMore, prev is:'+this.pageInfo[this.activeTab].prev +' next is '+this.pageInfo[this.activeTab].next)
			this.moreNode.show();
		}

		if(this.extraBtnType[this.activeTab] == 'subscribe')
		{
			this.extraBtnNode.innerHTML = this.extraSubscribe;
			if (_self.extraBtnLink[_self.activeTab]) {
				var tmp_str = _self.extraBtnLink[_self.activeTab];
				eval("var tmpfn=function(){" + tmp_str + ";return false;}");
				this.extraBtnNode.onclick = tmpfn;
			}
			else
				this.extraBtnNode.onclick = function(){
					alert('此功能尚未開放');
				};

//			if(!this.moreNode.visible())
//			{
//				//this.extraBtnNode.style.right='8px';
//				$(this.extraBtnNode).setStyle({
//  					right: '8px'
//				});
//				for(name in this.extraBtnNode.style) $('debugg').value+=name+':'+eval('this.extraBtnNode.style.'+name)+'\n'
//			}

			this.extraBtnNode.show();
		}
	}
	this.getTabContentListNode=function()
	{
		try{
			return $($(_self.contentListId[_self.activeTab]).cleanWhitespace().firstChild).cleanWhitespace();
		}
		catch(e){return null;}
	}
	this.removeTab=function(removeNum,activeNum)
	{
		if (!activeNum && isNaN(activeNum))
		{
			if ((removeNum - 1) >= 0 && $(this.tabNode.childNodes[removeNum - 1]))
				activeNum = removeNum - 1;
			else
				if ($(this.tabNode.childNodes[removeNum + 1]))
					activeNum = removeNum + 1;
		}

		if ($(this.tabNode.childNodes[removeNum]))
			var result=this.tabNode.childNodes[removeNum].className.match(/(frist|last)/gi);
		try{var str_middle=result[0];}catch(e){var str_middle='';}

		if (str_middle)
		{
			if (str_middle == 'last')
			{
				var nearOne = removeNum - 1;
				if (nearOne == 0)
					str_middle = 'frist';
			}
			else
			{
				var nearOne = removeNum + 1;
			}

			if ($(this.tabNode.childNodes[nearOne]))
			{
				$(this.tabNode.childNodes[nearOne]).className = 'Tab_' + str_middle;
				this.tabClick.setTabMouseInOutEvent($(this.tabNode.childNodes[nearOne]));
			}
		}

		if ($(this.tabNode.childNodes[removeNum]))
			$(this.tabNode.childNodes[removeNum]).hide();

		this.tabClick.setTabMouseInOutEvent($(this.tabNode.childNodes[this.activeTab]));
		this.tabClick.setTabMouseInOutEvent($(this.tabNode.childNodes[activeNum]), 'On');
		this.activeTab = activeNum;
		if (removeNum != activeNum)
			this.tabClick.getAjaxContent();
	}

	if($(block))
	{
		var tempCount=0;
		var thisBlockClass=$(block).firstDescendant().firstDescendant().className;
		var tab=$A($(block).getElementsByClassName(thisBlockClass));
		$A(tab).each(function(Node){
			_self.tabNode=Node.cleanWhitespace();
			//這一段在找 moreNode
			try
			{
				_self.moreNode=$(block).getElementsByClassName('BlockTab_btn')[0];
				_self.extraBtnNode=$(block).getElementsByClassName('Order_btn')[0];;
			}
			catch(e)
			{
				_self.moreNode=null;
				_self.extraBtnNode=null;
			}
			_self.tabNode.immediateDescendants().each(function(Child){
						_self.btnUrl[_self.btnUrl.length]				=Child.getAttribute('_btnlink');
						_self.ajaxUrl[_self.ajaxUrl.length]				=Child.getAttribute('_url');
						_self.refreshType[_self.refreshType.length]		=Child.getAttribute('_refreshtype');
						_self.moreType[_self.moreType.length]			=Child.getAttribute('_moretype');
						_self.tabEventCode[_self.tabEventCode.length]	=Child.getAttribute('_code');
						_self.extraBtnType[_self.extraBtnType.length]	=Child.getAttribute('_extraType');
						_self.extraBtnLink[_self.extraBtnLink.length]	=Child.getAttribute('_extraLink');
						_self.expandInfo[_self.expandInfo.length]		=Child.getAttribute('_listExpand');
//						alert(_self.btnUrl[_self.btnUrl.length-1]+':'+_self.ajaxUrl[_self.ajaxUrl.length-1]+':'+_self.refreshType[_self.refreshType.length-1]+':'+_self.moreType[_self.moreType.length-1]);
						Child.onclick = function(event){_self.tabClick.click(event);return false;};
						Child.firstChild.onfocus = function(){this.blur();};
						Child.setAttribute('_tabIndex',tempCount);
						if(Child.getAttribute('_default'))_self.waitting2ActiveTab=_self.btnUrl.length-1;
						_self.contentListId[tempCount]=block+'_list'+(tempCount).toString();
						if(Child.getAttribute('_moretype')=='page')
							_self.pageInfo[_self.moreType.length-1]={'current':1,'next':1,'prev':1,'tp':1};
						tempCount++;
				});
		});
		this.tabCount=this.btnUrl.length;
		var containNode=$A($(block).getElementsByClassName('BlockContent'));
		$A(containNode).each(function(Node){
			_self.containNode=Node.cleanWhitespace();
			var i=0;
			_self.containNode.immediateDescendants().each(function(Node){Node.setAttribute('id',_self.contentListId[i]);i++;});
			this.containNode=Node;
		});
		this.contentCount=(this.containNode.childNodes)?this.containNode.childNodes.length:0;
		this.checkMoreStatus();
		if(this.waitting2ActiveTab)
			this.tabClick.fireClick(this.tabNode.childNodes[this.waitting2ActiveTab].firstChild);
	}

//	if(!$(block)._CyBlock)	$(block)._CyBlock=_self;
}
CyBlock.prototype.moreUrl='<div class="Btn_more" onMouseOver="BtnAction(this,13);" onMouseOut="BtnAction(this,0);">';
CyBlock.prototype.moreListMore='<a class="LinkStyle_open00 LinkStyle_color03 LinkAction_line03" href="#">更多</a>';
CyBlock.prototype.moreListLess='<a class="LinkStyle_close00 LinkStyle_color03 LinkAction_line03" href="#">縮小</a>';
CyBlock.prototype.moreRefresh='<a class="LinkStyle_color01 LinkAction_line03 LinkStyle_refresh01" href="#" >立即更新</a>';
CyBlock.prototype.moreClose='<a href="#" class="Btn_titleClose" onfocus="this.blur();">關閉</a>'
CyBlock.prototype.moreOpen='<a href="#" class="Btn_titleOpen" onfocus="this.blur();">展開</a>'
CyBlock.prototype.moreNextPage='<a href="#" class="LinkStyle_nextPage00 LinkStyle_color03 LinkAction_line03" onfocus="this.blur();">下一頁</a>'
CyBlock.prototype.extraSubscribe='<a class="LinkStyle_color03 LinkAction_line03" href="#">訂閱設定</a>';
CyBlock.prototype.setTabProperty=function(obj){
	if(obj.word)
		this.tabNode.childNodes[this.activeTab].firstChild.innerHTML=obj.word;
	if(obj.url)
	{
		this.btnUrl[this.activeTab]=obj.url;
		this.tabNode.childNodes[this.activeTab].setAttribute('_btnlink',obj.url);
	}
	if(obj.type)
	{
		this.tabNode.childNodes[this.activeTab].setAttribute('_moretype',obj.type);
		this.moreType[this.activeTab]=obj.type
	}
	if(obj.ajax)
	{
		this.tabNode.childNodes[this.activeTab].setAttribute('_ajaxurl',obj.ajax);
		this.ajaxUrl[this.activeTab]=obj.ajax;
	}
	if(obj.refreshtype)
	{
		this.tabNode.childNodes[this.activeTab].setAttribute('_refreshtype',obj.refreshtype);
		this.refreshType[this.activeTab]=obj.refreshtype;
	}
	if(obj.code)
	{
		this.tabNode.childNodes[this.activeTab].setAttribute('_code',obj.code);
		this.tabEventCode[this.activeTab]=obj.code;
	}
	this.checkMoreStatus();
}
CyBlock.prototype.hideContentBlock=function(obj,className){
	var _self=this;
	function setMoreNode(moreNode,moreType,LessClose)
	{
		if(LessClose=='less')
		{
			if(moreType=='list') moreNode.innerHTML=_self.moreListLess;
			if(moreType=='block') moreNode.innerHTML=_self.moreClose;
		}
		else if(LessClose=='more')
		{
			if(moreType=='list') moreNode.innerHTML=_self.moreListMore;
			if(moreType=='block') moreNode.innerHTML=_self.moreOpen;
		}
	}
	if($(obj))
	{
		try{var topBlockNode=$(obj.parentNode.parentNode);}catch(e){alert('this blcok is not supported!');return false;}
		var targetBlock=$A($(topBlockNode).getElementsByClassName(className));
		var moreType=$(topBlockNode).getAttribute('_moretype');
		var nodeLimit=$(topBlockNode).getAttribute('_limit');
		var moreNode=$A($(topBlockNode).getElementsByClassName('BlockTitle_second'));
		if(!moreType){alert('missing attribute: _moretype');return false;}
		moreNode.each(function(Node){moreNode=Node;})
		targetBlock.each(function(Node){
			Node=Node.cleanWhitespace();
			if(!nodeLimit)
			{
				(Node.visible())?Node.hide():Node.show();
				if(Node.visible())
					setMoreNode(moreNode,moreType,'less');
				else
					setMoreNode(moreNode,moreType,'more');
			}
			else
			{
				tempCount=Node.childNodes.length;
				if(moreNode.firstChild.className=='LinkStyle_close00 LinkStyle_color03 LinkAction_line03' ){
					for(var i=tempCount-1;i>=nodeLimit;i--)
						$(Node.childNodes[i]).hide();
					setMoreNode(moreNode,moreType,'more');
				}
				else if (moreNode.firstChild.className=='LinkStyle_open00 LinkStyle_color03 LinkAction_line03' ){
					for(var i=0 ; i<tempCount ; i++)
						$(Node.childNodes[i]).show();
					setMoreNode(moreNode,moreType,'less');
				}
			}
		});
	}
}
CyBlock.prototype.putLoadingNode=function(){
		if($(this.blockName+'_loading'))
			this.removeLoadingNode();
		this.tabClick.hideTabContent();
		var loadingNode=document.createElement('div');
		loadingNode.className="LoadingBlock";
		loadingNode.setAttribute('id',this.blockName+'_loading');
		this.containNode.appendChild(loadingNode);
}
CyBlock.prototype.removeLoadingNode=function(){
		if($(this.blockName+'_loading'))
			$(this.blockName+'_loading').remove();
}
CyBlock.prototype.sendEvent=function()
{
	var url="http://st.tw.cyworld.com/stat.tiff?e_cd=["+this.tabEventCode[this.activeTab]+"]";
	var tempForm=document.createElement("form");
	var n = 'f' + new   Date().getTime() ;
	var d = document.createElement('DIV');
	d.setAttribute('id','D'+n);
	$(d).setStyle({position:'absolute',top:'0px',left:'0px'});
	d.innerHTML = '<iframe height="1px" width="1px" src="about:blank" id="'+n+'" name="'+n+'" onload="removeDynicFrameAndForm(\''+n+'\')" ></iframe>';
	document.body.appendChild(d);
	tempForm.innerHTML="<input type=hidden name=dummyField  vaule=dummy>";
	tempForm.setAttribute('method','post');
	tempForm.setAttribute('action',url);
	tempForm.setAttribute('target', n);
	d.appendChild(tempForm);
	tempForm.submit();
	return false;
}
function removeDynicFrameAndForm(id)
{
	return ;
	var i = document.getElementById(id);
	if (i.contentDocument)
		var d = i.contentDocument;
    else if (i.contentWindow)
		var d = i.contentWindow.document;
	else
		var d = window.frames[id].document;
	if (d.location.href == "about:blank")
			return;
	$('D'+id).remove();
}
var fg=document.createDocumentFragment();
