// JavaScript Document
//floating tagbar //////////////////////////////////////////////



var IE=document.all?true:false;
if (!IE){
	window.captureEvents(Event.MOUSEMOVE);
} 
document.onmousemove=updatebox;
function updatebox(event) {
	var divc=document.getElementById('tagbar')
	if(IE){
		if(document.body.scrollWidth-(window.event.x+20)>divc.scrollWidth){
               divc.style.left=window.event.x+20;
			   		} else {
			divc.style.left=window.event.x-divc.scrollWidth-20;
				}
		if(document.documentElement.clientHeight-window.event.clientY>divc.scrollHeight){
               divc.style.top=window.event.y+20;
			   		} else {
			divc.style.top=window.event.y-divc.scrollHeight-20;
				}
			   } else {
		if(document.body.scrollWidth-(event.pageX+20)>divc.scrollWidth){
               divc.style.left=event.pageX+20+'px';
			   		} else {
			divc.style.left=event.pageX-divc.scrollWidth-20+'px';
				}
		if(document.documentElement.clientHeight-(event.pageY-window.pageYOffset)>divc.scrollHeight){
               divc.style.top=event.pageY+20+'px';
			   		} else {
			divc.style.top=event.pageY-divc.scrollHeight-20+'px';
				}
			   }

 }

 //remark tagbox on mouse over/out ///////////////////////////////////////////////
function tagbartxt(displaystatus,tagtitle,width,style){

 document.getElementById('tagbar').style.display=displaystatus;
 document.getElementById('tagbar').style.width='inherit';
 if(style!=undefined){
	 document.getElementById('tagbar').style.backgroundColor='';
	 document.getElementById('tagbar').style.border='none';
 } else {
	 document.getElementById('tagbar').style.backgroundColor='#000000';
	 document.getElementById('tagbar').style.border='1px solid #333333';
 }
 if(tagtitle!=undefined){
	 document.getElementById('tagbar').innerHTML = tagtitle;	
 }
 
 if(width!=undefined){
	document.getElementById('tagbar').style.width=width+'px';
 }
}

//css switching///////////////////////////////////////////
function loadcss(ccode,gcode)
{
	var today = new Date();
	today.setTime(today.getTime());

	var expires_date = new Date(today.getTime()+(365*24*60*60*60*60));

	document.cookie = "uonlive_css_cookie = " + ccode + ";expires = " + expires_date.toGMTString() ;
	document.cookie = "uonlive_css_cookie_gen = " + gcode + ";expires = " + expires_date.toGMTString() ;	
	//site_style_common.css
	document.getElementById('calendarcsslink').href=csspath+'calendar_'+gcode+'.css';
	document.getElementById('commoncsslink').href=csspath+'site_style_'+gcode+'.css';
	if(typeof(css_color_folder)!="undefined"){
	document.getElementById('csslink').href=csspath+css_color_folder+'site_style_'+ccode+'.css';
	} else {
	document.getElementById('csslink').href=csspath+'site_style_'+ccode+'.css';
	}
}

//my menu on header //////////////////////////////////////////
function mymenulist(display){
	if(display==1){
	document.getElementById('mymenu').style.left=(document.documentElement.clientWidth-document.getElementById('mheader').scrollWidth)/2+455+'px';
	//document.getElementById('mymenu').style.left=(document.documentElement.clientWidth-document.getElementById('mheader').scrollWidth)/2+210+'px';
	document.getElementById('mymenu').style.display='block';
	} else {
	document.getElementById('mymenu').style.display='none';
	}
}

//peeling //////////////////////////////////////////////// - no use for new version - no peel animation on login
function peelsize(hlstatus){
if(hlstatus==1){
document.getElementById('peeldiv').style.zIndex="13";
//document.getElementById('promo_banner').style.zIndex="12";
document.getElementById('peeldiv').style.width=1000+"px";
document.getElementById('peeldiv').style.height=700+"px";
} else {
document.getElementById('peeldiv').style.zIndex="12";
//document.getElementById('promo_banner').style.zIndex="13";
document.getElementById('peeldiv').style.width=400+"px";
document.getElementById('peeldiv').style.height=300+"px";
}

}

// player layer ///////////////////////////////////////////// - no use for new version - old player on top moved to bottom
function playerdiv(hlstatus){
if(hlstatus==1){

document.getElementById('uplayer').style.height='100px';
} else {
document.getElementById('uplayer').style.height='50px';
}
}


//top layer ///////////////////////////////////////////////// - no use for new version - "MY" layer removed
function mynav(hlstatus,newstatus){
if(hlstatus==1){
	document.getElementById('mydiv').style.zIndex=5;
}
if(hlstatus==0){
	document.getElementById('mydiv').style.zIndex=3;
}
if(hlstatus==2){
	document.getElementById('mydiv').style.height='150px';
//	document.getElementById('mydiv').style.height='220px';
}
}

//top thumb //////////////////////////////////////////////
function mheadresize(hlstatus){
if(hlstatus==1){
document.getElementById('mheaddiv').style.width=160+"px";
//document.getElementById('mheaddiv').style.height=80+"px";
} else {
document.getElementById('mheaddiv').style.width=80+"px";
//document.getElementById('mheaddiv').style.height=80+"px";
}

}

//show and hide
function showhidediv(divname,action)
	{
		document.getElementById(divname).style.display=action;
	}

//popup ///////////////////////////////////////////////
	function popup(url, w, h)
	{
		window.open(url,"_blank","width="+w+",height="+h+",resizble=no,scrollbars=yes,toolbar=no,top=100, left=100, menubar=no," )
	}




//uchat box ////////////////////////////////////////////////////////////////
function replybox(currenttype, votingactive, wallid, topicid)
{
	if (wallid != "" && topicid != "")	//add topic uchat wouldn't run
	{
		if (currenttype == 'msg')
		{
			document.getElementById('reply_msgtab_'+wallid+'_'+topicid).className='reply_tab_pointer';
			document.getElementById('div_msg_'+wallid+'_'+topicid).style.display='block';
		}else
		{
			document.getElementById('reply_msgtab_'+wallid+'_'+topicid).className='reply_tab_nopointer';
			document.getElementById('div_msg_'+wallid+'_'+topicid).style.display='none';
		}
	}

	if (currenttype == 'photo')
	{
		document.getElementById('reply_phototab_'+wallid+'_'+topicid).className='reply_tab_pointer';
		document.getElementById('div_photo_'+wallid+'_'+topicid).style.display='block';
	}else
	{
		document.getElementById('reply_phototab_'+wallid+'_'+topicid).className='reply_tab_nopointer';
		document.getElementById('div_photo_'+wallid+'_'+topicid).style.display='none';
	}

	if (currenttype == 'sound')
	{
		document.getElementById('reply_soundtab_'+wallid+'_'+topicid).className='reply_tab_pointer';
		document.getElementById('div_sound_'+wallid+'_'+topicid).style.display='block';
	}else
	{
		document.getElementById('reply_soundtab_'+wallid+'_'+topicid).className='reply_tab_nopointer';
		document.getElementById('div_sound_'+wallid+'_'+topicid).style.display='none';
	}

	if (currenttype == 'link')
	{
		document.getElementById('reply_linktab_'+wallid+'_'+topicid).className='reply_tab_pointer';
		document.getElementById('div_link_'+wallid+'_'+topicid).style.display='block';
	}else
	{
		document.getElementById('reply_linktab_'+wallid+'_'+topicid).className='reply_tab_nopointer';
		document.getElementById('div_link_'+wallid+'_'+topicid).style.display='none';
	}

	if (currenttype == 'video')
	{
		document.getElementById('reply_videotab_'+wallid+'_'+topicid).className='reply_tab_pointer';
		document.getElementById('div_video_'+wallid+'_'+topicid).style.display='block';
	}else
	{
		document.getElementById('reply_videotab_'+wallid+'_'+topicid).className='reply_tab_nopointer';
		document.getElementById('div_video_'+wallid+'_'+topicid).style.display='none';
	}

	if (votingactive)
	{
		if (currenttype == 'voting')
		{
			document.getElementById('reply_votingtab_'+wallid+'_'+topicid).className='reply_tab_pointer';
			document.getElementById('div_voting_'+wallid+'_'+topicid).style.display='block';
		}else
		{
			document.getElementById('reply_votingtab_'+wallid+'_'+topicid).className='reply_tab_nopointer';
			document.getElementById('div_voting_'+wallid+'_'+topicid).style.display='none';
		}
	}
}


function replybaractive(wallid,topicid){
	document.getElementById('replybar_'+wallid+'_'+topicid).style.display='block';
	document.getElementById('msg_reply_'+wallid+'_'+topicid).style.display='block';	
	document.getElementById('textarea_'+wallid).innerHTML='';
	document.getElementById('textarea_'+wallid).style.height='30px';	
}


//used in registration /////////////////////////////////////
	function display_only(id)
	{
		if (document.getElementById(id).style.display == "none")
		{
			document.getElementById(id).style.display = "block";
		}else
		{
			document.getElementById(id).style.display = "none";
		}
	}
	
//used in advance search ///////////////////////////////////////////
	function display(id, arrow_expand, arrow_collapse)
	{
		if (document.getElementById(id).style.display == "none")
		{	
			showhidediv(arrow_expand,"block");
			showhidediv(arrow_collapse,"none");
			document.getElementById(id).style.display = "block";
		}else
		{
			showhidediv(arrow_expand,"none");
			showhidediv(arrow_collapse,"block");		
			document.getElementById(id).style.display = "none";
		}
	}



//used in mprofile ////////////////////////////////////////////
	function hidden_all_show(id)
	{
		var columns = new Array("column_1","column_2","column_3","column_4","column_5","column_6","column_7","column_8","column_9","column_10","column_11");

		for (i in columns)
		{
			if (id == columns[i])
			{
				document.getElementById(id).style.display = "block";
			}else
			{
				document.getElementById(columns[i]).style.display = "none";
			}
		}
	}


// component /////////////////////////////////////////////
function optchange(ref){
	ref=new Function(ref);
	ref();
}

function appspan_visual(appsname,apps_h,display){
	//	alert(appsname+","+document.documentElement.clientHeight+","+document.getElementById(appsname).style.bottom+","+apps_h);
	if(display==1){
		if(document.getElementById(appsname).style.bottom<"0px"){
//	t1 = new Tween(document.getElementById(appsname).style,'top',Tween.elasticEaseOut,document.documentElement.clientHeight,document.documentElement.clientHeight-apps_h,1,'px');t1.start();
	t1 = new Tween(document.getElementById(appsname).style,'bottom',Tween.elasticEaseOut,(0-apps_h),0,1,'px');t1.start();
		}
	} else {
		if(document.getElementById(appsname).style.bottom=="0px"){
//	t1 = new Tween(document.getElementById(appsname).style,'top',Tween.elasticEaseOut,document.documentElement.clientHeight-apps_h,document.documentElement.clientHeight,1,'px');t1.start();
	t1 = new Tween(document.getElementById(appsname).style,'bottom',Tween.elasticEaseOut,0,(0-apps_h),1,'px');t1.start();
		}
	}
}
