function Inner(result)
{
	if(result[1]!=0){ if(document.getElementById(result[0])) {document.getElementById(result[0]).innerHTML = result[1]; }}
	if(result[2])	{	code=eval(result[2]); code; }
}

function close_div(id) {
	if(document.getElementById(id)) {
	//document.getElementById(id).style.visibility="hidden"
	InnerHtml(id,'')
	if(document.getElementById("Shadow")){
	document.getElementById("Shadow").style.visibility="hidden"
	InnerHtml("Shadow",'') }
	}
	document.body.style.overflow='';
	document.onmousewheel =function(){} ;
}

function GetValue(ident)
{
	if(document.getElementById(ident).value!=false){
return document.getElementById(ident).value; }
return "";
}
function StopScroll(ID){
document.getElementById(ID).onmousewheel =function(){return false;} ;
}

function inner_value(ident,value)
{
document.getElementById(ident).value=value;
}

function InnerHtml(ident,value)
{
if(document.getElementById(ident))document.getElementById(ident).innerHTML=value
}

function GetInnerHtml(ident)
{
return document.getElementById(ident).innerHTML;
}

function InnerHtmlWithShadow(result){////////// OK
	if(result[1]!=""){
var height = document.body.scrollHeight-5;
var ShadowID=(result[3])?result[3]:"Shadow";
var ZIndex=(result[4])?"z-index:"+result[4]+";":"";
var div="<DIV id="+ShadowID+"  style=\""+ZIndex+"border:#ffffff 1px double;LEFT: 0px;background-color:#999999;POSITION: absolute; TOP: 0px;width:99%;height:"+height+"px;filter:alpha(opacity=50);opacity: 0.5\"></div>";
InnerHtml(result[0],div+result[1]);
//InnerHtml("o",result[1]); 
	}
//ShadowFun("Shadow",10);
if(result[2]!=""){cod=eval(result[2]);
cod ;}
//if(getNameBrouser()=="opera") {document.onmousewheel=function(){return false}; }
}


function result_innerhtml(result)
{ 
   if(result[1]!="error"){   InnerHtml(result[0],result[1]);  
   if(result[2]!=""){cod=eval(result[2]);}
cod ;
   }
}


function ShadowFun(ID,Opacity)
{
	Opacity+=3; ;
	if(Opacity>100) return false;
	
	//document.getElementById(ID).style.filter = "alpha(opacity="+Opacity+")";
	//document.getElementById(ID).style.opacity = Opacity/100;
	document.getElementById("o").style.opacity = Opacity/100;
	
	setTimeout("ShadowFun('" + ID + "'," + Opacity+ ")",1);
}

function GoToPosition(ID,flag,margin_top,Top,Left)
{
	if(flag==undefined) { setTimeout("GoToPosition('"+ID+"',1,"+margin_top+","+Top+","+Left+")",200); return ; }
	var X=GetWidth();	
	var Y=GetHeight();
	var Z=getScrollY();
	var Obj=document.getElementById(ID);
	var Width=document.getElementById(ID).offsetWidth ;
	var Height=document.getElementById(ID).offsetHeight ;

	var DivX=(X-Width)/2;
	var DivY=(Y-Height)/2;
	if(margin_top){DivY=DivY+margin_top;}
	if(Top!=undefined){ DivY=(Top!=0)?Top:DivY; }

	document.getElementById(ID).style.left=DivX+"px";
	document.getElementById(ID).style.top=DivY+"px";
	document.getElementById(ID).style.visibility="visible";
	//Obj.style.height="0px";
	//ResizeDiv(0,Height,ID);
}

function GoToBottomPosition(ID)
{
	var Y=GetHeight();	
	document.getElementById(ID).style.top=(Y-20)+"px";
}


function ResizeDiv(Start,End,ID,SpeedTime,SpeedPx)
{
	if(Start>=End) return;
	//if(Start<End-30){	Start+=7; }
//	else if(Start<End-10) {	Start+=2; }
	//else  {	Start+=1; }
		Start+=SpeedPx;
	document.getElementById(ID).style.height=Start+"px"; 

	setTimeout("ResizeDiv(" + Start + "," + End + ",'" + ID + "',"+SpeedTime+","+SpeedPx+")",SpeedTime);
}

function CheckAllCheckbox(obj,CheckList)
{
	if(obj.checked == true){for (i = 0; i < CheckList.length; i++) CheckList[i].checked = true ; }
	else {for (i = 0; i < CheckList.length; i++) CheckList[i].checked = false ;  }
}

function GetWidth()
{
        var x = 0;
        if (self.innerHeight)
        {
                x = self.innerWidth;
        }
        else if (document.documentElement && document.documentElement.clientHeight)
        {
                x = document.documentElement.clientWidth;
        }
        else if (document.body)
        {
                x = document.body.clientWidth;
        }
        return x;
}
 
function GetHeight()
{
        var y = 0;
        if (self.innerHeight)
        {
                y = self.innerHeight;
        }
        else if (document.documentElement && document.documentElement.clientHeight)
        {
                y = document.documentElement.clientHeight;
        }
        else if (document.body)
        {
                y = document.body.clientHeight;
        }
        return y;
}






function AutoMenu(event,UserID,Name,Photo,Type,PhotoServerPrefix)
{

	var x=event.clientX;
    var y=event.clientY+getScrollY()+5;
	var Width=GetWidth();
	var Height=GetHeight()+getScrollY();
	if((x+200)>Width){x=Width-300;}
	if((y+300)>Height){y=y-200;if(Type==1)y=y+100;}

	inner_value("uid",Name);
	setTimeout("AutoMenuAction("+UserID+",'"+Name+"','"+Photo+"',"+Type+","+x+","+y+",'"+PhotoServerPrefix+"')",300);
}

function unLoadFnc(evt)
{
  var e = (window.event) ? window.event : evt;
  return e;
}

function AutoMenuAction(UserID,Name,Photo,Type,x,y,PhotoServerPrefix)
{
	if(GetValue("uid")!=Name) return;
	
	System.AutoMenu(x,y,Name,UserID,Photo,Type,PhotoServerPrefix,function (result){Inner(result);});
}

function HidAutoMenu()
{
	inner_value("uid",0);inner_value("cuid",0);
	setTimeout("HidAutoMenuAction()",300);
	
}

function HidAutoMenuAction()
{
	if(GetValue("cuid")!=0) return;
	inner_value("cuid",0);
	InnerHtml("AutoMain","");

}

function OnMenu()
{
	inner_value("cuid",1);
	
}

function OffMenu(event)
{
	var x=document.getElementById("menu21").offsetLeft;
	var y=document.getElementById("menu21").offsetTop;
		
	var DivHeight=document.getElementById("menu21").offsetHeight;
	var DivWidth=document.getElementById("menu21").offsetWidth;
		
	var Mx=event.clientX;
	var My=event.clientY+getScrollY();
	

	if(Mx<x+2 || Mx>x+DivWidth-5){inner_value("cuid",0);InnerHtml("AutoMain","");}
	if(My<y+2 || My>y+DivHeight-5){inner_value("cuid",0);InnerHtml("AutoMain","");}
	
}




function getScrollY() 
{
    scrollY = 0;   
    if (typeof window.pageYOffset == "number") { 
        scrollY = window.parent.pageYOffset;
    } else if (document.documentElement && document.documentElement.scrollTop) {
        scrollY = document.documentElement.scrollTop;
    }  else if (document.body && document.body.scrollTop) {
        scrollY = document.body.scrollTop; 
    } else if (window.scrollY) {
        scrollY = window.scrollY;
    }
    return scrollY;
}


function LoadScript(URL)
{
	    var script = document.createElement('script'); 
        script.type = 'text/javascript'; 
        script.src = URL; 
        document.getElementsByTagName('head')[0].appendChild(script); 
}


function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}



function HelpMenu(parent,ID,text)
{
	var placement = findPos(parent);
	var pos = screen.width-placement[0];
		
	 var html = "<div style=\"width:250px;LEFT: "+(placement[0]+20)+"px; VISIBILITY: visible; ";
		 html+= " POSITION: absolute; TOP: "+(placement[1]+15)+"px;background-color:#FFFFCC;font-size:12px;";
		 html+= "border:0px;border:1px solid orange;border-style: dashed;border-style: 1;padding:10px \">" + text + "</div>";

		 InnerHtml(ID,html);
}


function ActivityLineBox(parent,ID,Body)
{
	var placement = findPos(parent);
	var pos = screen.width-placement[0];
		
	 var html = "<div style=\"LEFT: "+(placement[0]+20)+"px; VISIBILITY: visible; ";
		 html+= " POSITION: absolute; TOP: "+(placement[1]+15)+"px;background-color:#ffffff;font-size:12px;";
		 html+= "border:0px;border:1px solid black;padding:10px \" id=slMenu  >" + Body + "</div>";

		 InnerHtml(ID,html);
}

function getContentFromIframe(iFrameName)
{
    var myIFrame = document.getElementById(iFrameName);
    var content = myIFrame.contentWindow.document.body.innerHTML;
    return content;
}



function ShowBar()
{
	var Html="<img src='images/vista.gif' width=70% >";
	InnerHtml("bar",Html);
	document.getElementById("submit").style.visibility="hidden";
	document.getElementById("photocomment").style.visibility="hidden";
	document.getElementById("submit_c").style.visibility="hidden";
	document.getElementById("upimg").style.visibility="hidden";
	return true;
}

function ShowBar2()
{
	var Html="<img src='images/vista.gif' width=70% >";
	InnerHtml("bar",Html);
	document.getElementById("img1").style.visibility="hidden";
	document.getElementById("img2").style.visibility="hidden";
	document.getElementById("img3").style.visibility="hidden";
	document.getElementById("submit").style.visibility="hidden";
	document.getElementById("cancel").style.visibility="hidden";
	return true;
}

var MenuType=0;
var Type=0;
var MenuOver=0;
var MouseP=new Array();

function ShowTopMenu(obj,Type,Body)
{
	//if(MenuOver==1){MenuOver=0; return; }

	if(Body==undefined) { System.GetContentMenu(Type,function (result){ ShowTopMenu(obj,Type,result) });return ;}
	//if(MenuType==Type) return;
	
		MenuType=Type;
		
		var placement = findPos(obj);
		var pos = screen.width-placement[0];
		var width=parent.offsetWidth;
	
	 var html = "<div id=slMenu style=\"width:"+width+"px;LEFT: "+(placement[0])+"px; VISIBILITY: visible; ";
		 html+= "  POSITION: fixed; TOP: "+(placement[1]+43)+"px;font-size:12px;overflow:hidden;";
		 html+= "border:0px;border:0px solid orange;border-style: dashed;border-style: 1;height:0px;overload:hidden;z-index:5\" ";
		 html+= "onmouseout='MenuOut()' >";
		 html+= "<div id=mth >";
		 html+=""+Body+"";
		 html+= "</div>";
		 html+= "</div>";

		 InnerHtml("MessageBox",html);
		 var y=document.getElementById("mth").offsetHeight;
		 ResizeDiv(0,y,"slMenu",0,10);

}

function MenuOut(Evt)
{
	
	if(Evt==undefined) { setTimeout("AddEventHandler()",200); return ; }
	//alert();
	var ID="slMenu";
	
	var obj=document.getElementById(ID);
	if(obj==null) {MenuType=0; RemoveEventHandler (); return ;}

	var Width=obj.offsetWidth;
	var Height=obj.offsetHeight; 
	var x=obj.offsetLeft;
	
	var y=getScrollY()+obj.offsetTop;
	
	var Ex=Evt[0];
	var Ey=Evt[1];

	if(Ex>(Width+x-2) || Ex<(x+2)) {MenuType=0;	close_div(ID);	}
	if(Ey>(Height+y-2) || Ey<(y+2)) {MenuType=0; 	close_div(ID)	;	}
	RemoveEventHandler ();
}



function ShowBottomMenu(obj,Type,Body)
{

	if(Body==undefined) { System.GetBottomMenu(Type,function (result){ ShowBottomMenu(obj,Type,result); Type=0; });return ;}
	//if(MenuType==Type) { return; }
	
		MenuType=Type;
		
		var placement = findPos(obj);
		var pos = screen.width-placement[0];
		var width=parent.offsetWidth;
	
		 
	 var html = "<div id=slMenu style=\"width:"+width+"px;LEFT: "+(placement[0])+"px; VISIBILITY: visible; ";
		 html+= " POSITION: fixed; TOP: "+(placement[1]-65)+"px;font-size:12px;overflow:hidden;";
		 html+= "border:0px;border:0px solid orange;border-style: dashed;border-style: 1;height:auto;overload:hidden;\" ";
		 html+= "onmouseout='MenuOut()' >";
		 html+= "<div id=mth >";
		 html+=""+Body+"";
		 html+= "</div>";
		 html+= "</div>";

		 InnerHtml("MessageBox",html);
		 var y=document.getElementById("mth").offsetHeight;
		 document.getElementById("slMenu").style.top=(placement[1]-y)+"px";
		 
		// 
		// ResizeDiv(0,y,"slMenu",0,3);

}

function getMousePosition(event) {

var posX = 0;
var posY = 0;

posX = event.clientX + document.body.scrollLeft;
posY = event.clientY + getScrollY();

var position = new Array(2);
position[0] = posX;
position[1] = posY;

return position;
}

function calculatePos(event) { 
				var mousePosition = getMousePosition(event);
				MenuOut(mousePosition);
}

        function ScrollListener()
        {
        
        if(window.addEventListener) document.addEventListener('DOMMouseScroll', as, false);
  
  document.onmousewheel =as ;
        }
        function as(event)
        {
	
        	return false;
        }

        function AddEventHandler () {
            var redButton = document;
            if (redButton.addEventListener) {        
                redButton.addEventListener ("mousemove", calculatePos, false);
            } 
            else {
                if (redButton.attachEvent) {     
                    redButton.attachEvent ('onmousemove', calculatePos);
                }
            }
        }

        function RemoveEventHandler () {
            var redButton = document;
            if (redButton.removeEventListener) {
                redButton.removeEventListener ("mousemove", calculatePos, false);
            }
            else {
                if (redButton.detachEvent) {
                    redButton.detachEvent ('onmousemove', calculatePos);
                }
            }
        }


function ButtonActivate(obj,valid,ID)
{
	
	if(obj.value.length<valid) {document.getElementById(ID).disabled="enabled";  }
	else {document.getElementById(ID).disabled=false; }
}


  function MoveStatus(ID,PosLeft)
{

	if(PosLeft==undefined) {
		PosLeft=0;
		if(ActionStID==ID) {return ;} 
		ActionStID=ID;
	}
	if(document.getElementById(ID)){
	
			var obj=document.getElementById(ID);
		var width=obj.offsetWidth;
		if(width<130) { ActionStID=0; return;}
		
		PosLeft=PosLeft-1/2;
		obj.style.left=PosLeft+"px";
		if((width+PosLeft)<0) {obj.style.left="5px"; ActionStID=0; return;}
		if(ActionStID!=ID) {obj.style.left="0px"; return;}
		setTimeout("MoveStatus('" + ID + "'," + PosLeft+ ")",10); 
	}
}
var ActionStID=0;





function CloseListener()
{if(getNameBrouser()!="opera") return;
   document.onmousewheel =function(){} ;
}


var scrollID="";


function LoadListener(N){
	if(getNameBrouser()!="opera") return;
	CloseListener();
	if(scrollID==N) return;
scrollID=N;
  if(window.addEventListener) document.addEventListener('DOMMouseScroll', moveObject, false);
  
  document.onmousewheel =moveObject ;

}
function moveObject(event)
{
	if(scrollID=="" || scrollID=="stop") { return false; }
	var el = document.getElementById(scrollID); 
 
var h = el.scrollHeight; 
var y = el.scrollTop; 
var c = el.clientHeight;

  if (!event) event = window.event;
  
  if (event.wheelDelta)
  {
     delta = event.wheelDelta / 120;
  }
  else if (event.detail) 
  {
    delta = -event.detail / 3;
  }
  
if(delta<0){el.scrollTop+=30; }
else { el.scrollTop-=30;  }


return false;
}

