﻿function gologinpopup(panel, position){
	
	openDialogBox(panel, [position]); 

} 



function openDialogBox ( dialogBoxId, startupInfo, closeType ){
	
    var dlg = $(dialogBoxId);
    var alphaDiv = $('alphaDiv');
    
    //var alphaDiv = document.alphaDiv;
    //selectbox_hidden('alphaDiv');

    if (!dlg||!alphaDiv) return;
  
    // drawing semitransparent layer(alphaDiv)
    var alphaDiv_opacity = 50;
    var alphaDiv_color = '#FFFFFF';

    alphaDiv.style.background = alphaDiv_color;
	setOpacity(alphaDiv,alphaDiv_opacity);
    

    alphaDiv.style.left = 0;
    alphaDiv.style.top = 0;
  // alert("test");  
	

	setSize(alphaDiv, document.getElementById("bodyContents").scrollWidth,  document.getElementById("bodyContents").scrollHeight);

    var dlgPos = new Array(2);
    var dlgSize = new Array(2);

    if ( !startupInfo || !startupInfo[0] ) startupInfo = new Array('center', new Array(2), new Array(2));
    if ( !startupInfo[1] ) startupInfo[1] = new Array(2);

    // set size
    
    if ( !startupInfo[2] || startupInfo[2][0] < 1 || startupInfo[2][1] < 1 || startupInfo[2][0] == 'undefined' || startupInfo[2][1] == 'undefined' || !startupInfo[2][0] || !startupInfo[2][1] )
    {
        dlg.style.display = 'block';
        var tmp=Element.getDimensions(dlg);
        dlgSize[0]=tmp.width; dlgSize[1]=tmp.height;
        dlg.style.display = 'none';
    }
    else
    {
        dlgSize=startupInfo[2];
    }

    Position.prepare();
        // set position

    	 var scrPos=new Array(Position.deltaX, Position.deltaY);
    	if(navigator.appVersion.indexOf("MSIE 6.0") == -1){
			 scrPos=new Array(Position.deltaX, Position.deltaY);
		}else{
			scrPos=new Array(Position.deltaX,document.getElementById("bodyContents").scrollTop);
		}
       
        
		var scrSize=getViewport();

        startupInfo[1][0]=scrPos[0]+scrSize[0]/2-dlgSize[0]/2;
        startupInfo[1][1]=scrPos[1]+scrSize[1]/2-dlgSize[1]/2;

    // drawing dialogBox
    if ( startupInfo[1] && startupInfo[1][0] && startupInfo[1][1] )
    {
        dlgPos=startupInfo[1];

        dlg.style.left=dlgPos[0]+'px';
        dlg.style.top=dlgPos[1]+'px';
        if(dlgSize[0]>0 && dlgSize[1]>0)
        {
            dlg.style.width=dlgSize[0]+'px';
            dlg.style.height=dlgSize[1]+'px';
        }
    }

    // display divs
    alphaDiv.style.display='block';
    dlg.style.display='block';

    // connect close event
   
}


function setPosition ( obj, x, y )
{
	obj.style.left = x+'px';
	obj.style.top = y+'px';
}

function setSize ( obj, w, h )
{
	var w1 = w + 20;
	var h1 = h + 20;
	obj.style.width = w1+'px';
	
	obj.style.height = h1 +'px';
	//alert(h);
}

function setOpacity(obj,value)
{
	if(typeof(obj)=='string') obj=document.getElementById(obj);
	obj.style.opacity = (value / 100);
	obj.style.MozOpacity = (value / 100);
	obj.style.KhtmlOpacity = (value / 100);
	obj.style.filter = "alpha(opacity=" + value + ")";	
}
function getViewport(){
	var w=0;
	var h=0;

	if(window.innerWidth) w=window.innerWidth;
	if(document.documentElement.clientWidth){
		var w2 = document.documentElement.clientWidth;
		if(!w || w2 && w2 < w) w=w2;
	}else if(document.body){
		w=document.body.clientWidth;
	}

	if(window.innerHeight) h=window.innerHeight;
	if(document.documentElement.clientHeight) h=document.documentElement.clientHeight;
	else if(document.body) h=document.body.clientHeight;

	return [w,h];
}
function closeDialogBox ( dialogBoxId )
{
    var dlg=$(dialogBoxId);
    if(dialogBoxId!='alphaDivOnly'&&!dlg) return;
    var alphaDiv=$('alphaDiv');
    if(dlg)dlg.style.display='none';
    if(alphaDiv)alphaDiv.style.display='none';
    //selectbox_visible()
}
