function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}

/*-------- Custom Drop Down List START-----*/
function dropDownList(id, name, value, height,listHeight,nodeHeight, width, left, top, layer)
{            
    this.left=left;
    this.top=top;
    this.id = id;
    this.height = height;
    this.listHeight = listHeight;
    this.nodeheight = nodeHeight;
    this.width = width;
    this.name = name;            
    this.selectedValue = value;            
    this.selectedText;
    this.selectedIndex = -1;
    this.nodes = Array();                                    
    this.length = _ddlGetLength;
    this.toString = _ddlToString;
    this.appendChild = _ddlAppendChild;            
    this.draw = _ddlDrawOptions;
    this.pageUp = _ddlPageUp;
    this.pageDown = _ddlPageDown;
    this.expand = _ddlExpand;
    this.update = _ddlUpdate;
	this.mousewheel = _ddlMouseWheel;
    this.layer = layer;
    this.onchange='';            
	this.getSelectedNode = _ddlgetSelectedNode;
}

function _ddlgetSelectedNode()
{
	with (this)
	{
		for(var i=0;i<nodes.length;i++)
        { 
        	if(nodes[i].value == selectedValue)
			{
				selectedIndex = nodes[i].index;
				return nodes[i];
			}
        }       		 
	}   	
}

function _ddlMouseWheel()
{
	with (this)
	{
        var objDdl = document.getElementById('ddlOptionList'+id);

		var delta = event.wheelDelta;
		if (delta > 0)
		{
			objDdl.scrollTop = objDdl.scrollTop - nodeheight;
		}
		else
		{
			objDdl.scrollTop = objDdl.scrollTop + nodeheight;				
		}

	}
}

function _ddlGetLength()
{
    with (this) return nodes.length;
}
        
function _ddlAppendChild(child)
{            
    with (this) {child.index = nodes.length; nodes[nodes.length]=child; child.parent = this;}
}

function _ddlToString() 
{
    with (this) 
    {
        return ('id='+id+'; name='+name+'; value='+selectedValue+'; length ='+length()+'; height = '+height +'; listHeight='+listHeight+'; nodeHeight='+nodeheight+'; width='+width+'; left='+left+'; top='+top)
    }
}               


function _ddlUpdate()
{
    with (this)
    {
        var objText = document.getElementById('ddlValue'+id);
        objText.innerHTML = selectedText;
        
        var objValue = document.getElementById(id);
        objValue.value = selectedValue;
    }
}

function _ddlDrawOptions(placeHolder)
{
    with (this)
    {            
        var objBody = document.getElementById(placeHolder);
        /*
        var temp = findPos(objBody);
        top = temp[1];
        left = temp[0];
        */
        var objWrapper = document.createElement('div');		
            	                
        objWrapper.setAttribute('id','ddlWrapper'+id);
        objWrapper.setAttribute('name',name);
        objWrapper.style.top = top+'px';
        objWrapper.style.left = left+'px';
        objWrapper.style.height = height+'px';
        objWrapper.style.width = width+5+'px';
        objWrapper.className = 'ddlWrapper';            
        objWrapper.style.display = 'block';
        objWrapper.style.zIndex = 189+layer;
//		objWrapper.onclick = function(){expand(this);return false;};
        objBody.appendChild(objWrapper);

        var objSelect = document.createElement('div');		
        objSelect.setAttribute('id','ddlSelect'+id);
/*      objSelect.setAttribute('name',name);
        objWrapper.style.top = top+'px';
        objWrapper.style.left = left+'px';*/
        objSelect.style.height = height+'px';
        objSelect.style.width = width+'px';
        objSelect.className = 'ddlSelect';
        objSelect.style.display = 'block';        
        objSelect.style.zIndex = 190+layer;
        objWrapper.appendChild(objSelect);

		var objIsValid = document.createElement('div');                	                
        objIsValid.setAttribute('id','ddlIsValid'+id);
        objIsValid.className = 'ddlIsValid';
		objIsValid.innerHTML = '*';
        objIsValid.style.height = height+'px';
        objIsValid.style.left = (width+2)+'px';
		objIsValid.style.display = 'none';
        objWrapper.appendChild(objIsValid);

        var objSelectedValue = document.createElement('input');
        objSelectedValue.setAttribute('type','hidden');
        objSelectedValue.setAttribute('id',id);
        objSelectedValue.setAttribute('name',name);        
        objSelect.appendChild(objSelectedValue);
                    
        var objValue = document.createElement('div');                	                
        objValue.setAttribute('id','ddlValue'+id);
        objValue.className = 'ddlValue';
        objValue.style.height = height-2+'px';
        objValue.style.width = (width-24)+'px';          
        objValue.style.backgroundColor = 'white';
        objValue.onclick = function(){expand(this);};
        objValue.style.zIndex = 191+layer;
        objSelect.appendChild(objValue);            
                    
        var objExpander = document.createElement('div');
        objExpander.setAttribute('id','ddlExpander'+id);
        objExpander.className = 'ddlExpander';
        objExpander.style.height = height+'px';
        objExpander.style.width = 14+'px';   
        objExpander.style.left = (width-14)+'px';   
        objExpander.style.zIndex = 192+layer;
        objExpander.onclick = function(){expand(this)};
        objSelect.appendChild(objExpander);            
                    
        //var optionListheight = 200;
        
        
                    
        var objOptionListScroll = document.createElement('div');                	                
        objOptionListScroll.setAttribute('id','ddlOptionListScroll'+id);
        objOptionListScroll.className = 'ddlOptionListScroll';
        objOptionListScroll.style.height = listHeight+'px';
        objOptionListScroll.style.width = width+'px';            
        objOptionListScroll.style.top = height+'px';
        objOptionListScroll.style.display = 'none';
        objOptionListScroll.style.zIndex = 1200+layer;
        //alert(objOptionListScroll.style.zIndex);
        objSelect.appendChild(objOptionListScroll);                
                    
        var objOptionList = document.createElement('div');                	                
        objOptionList.setAttribute('id','ddlOptionList'+id);
        objOptionList.className = 'ddlOptionList';
        objOptionList.style.height = listHeight+'px';
        objOptionList.style.width = width-((listHeight>nodes.length*nodeheight)?0:12)+'px';            
        objOptionList.style.top = '0px';
        objOptionList.style.zIndex = 201+layer;
		objOptionList.onmousewheel = function() {mousewheel(this);return false;};
        objOptionListScroll.appendChild(objOptionList);
        
        var objScrollArrowDownP = document.createElement("div");
        objScrollArrowDownP.setAttribute('id','ddlScrollArrowDown'+id);
        objScrollArrowDownP.className = 'scrollArrowDown';
        objScrollArrowDownP.style.backgroundColor = 'transparent';
        objScrollArrowDownP.style.width = '10px';
        objScrollArrowDownP.style.position = 'absolute';
        objScrollArrowDownP.style.height = '11px';
        objScrollArrowDownP.style.top = listHeight-10+'px';
        objScrollArrowDownP.style.left = width-12+'px';	        
        objScrollArrowDownP.style.display = (listHeight>nodes.length*nodeheight)?'none':'';
        objScrollArrowDownP.style.zIndex = 210+layer;
        objScrollArrowDownP.onclick = function () {pageDown(this); return false;} 	
        objOptionListScroll.appendChild(objScrollArrowDownP);	
    	
        var objScrollArrowUpP = document.createElement("div");
        objScrollArrowUpP.setAttribute('id','ddlScrollArrowUp'+id);	
        objScrollArrowUpP.className = 'scrollArrowUp';
        objScrollArrowUpP.style.backgroundColor = 'transparent';	
        objScrollArrowUpP.style.width = '10px';
        objScrollArrowUpP.style.position = 'absolute';
        objScrollArrowUpP.style.height = '11px';
        objScrollArrowUpP.style.top = listHeight-25+'px';
        objScrollArrowUpP.style.left = width-12+'px';
        objScrollArrowUpP.style.display = (listHeight>nodes.length*nodeheight)?'none':'';;
        objScrollArrowUpP.style.zIndex = 250+layer;
        objScrollArrowUpP.onclick = function () {pageUp(this); return false;} 	
        objOptionListScroll.appendChild(objScrollArrowUpP);
        for(i=0;i<nodes.length;i++)
        { 
             nodes[i].draw();
        }
    }            
}

function _ddlExpand()
{
    with (this)
    {
        var objOptionList = document.getElementById('ddlOptionListScroll'+id);
		//alert(objOptionList.style.display);
        objOptionList.style.display = (objOptionList.style.display==''?'none':'');
        var objExpander =  document.getElementById('ddlExpander'+id);
        objExpander.className = (objOptionList.style.display==''?'ddlExpanderU':'ddlExpander');
    }
}

function _ddlPageUp()
{
    with (this)
    {
        var objDdl = document.getElementById('ddlOptionList'+id);
        pageSize = listHeight;    
        objDdl.scrollTop = objDdl.scrollTop - pageSize; 
    }
}

function _ddlPageDown()
{    
    with (this)
    {
        var objDdl = document.getElementById('ddlOptionList'+id);
        pageSize = listHeight;                
        objDdl.scrollTop = objDdl.scrollTop + pageSize; 
    }
}

/*
function ddlScrollDown()
{
    var objLightBox = document.getElementById("lightbox");    
    objLightBox.scrollTop = objLightBox.scrollTop + 5;
    slbTimeoutD = window.setTimeout('scrollLightBoxDown()',30);
}

function ddlScrollUp()
{
    var objLightBox = document.getElementById("lightbox");    
    objLightBox.scrollTop = objLightBox.scrollTop - 5;        
    slbTimeoutD = window.setTimeout('scrollLightBoxUp()',30);
}

function ddlStopScrollDown()
{
    window.clearTimeout(ddlTimeoutD);
}

function ddlStopScrollUp()
{
    window.clearTimeout(ddlTimeoutD);
}
*/
        
function dropDownListOption(id, name, value, text, selected)
{   
    this.id = id;
    this.name = name;            
    this.parent; 
    this.value=value;
    this.text=text;           
    this.selected = selected;            
    this.index;
    this.draw = _ddlOptionDraw;
    this.select = _ddlOptionSelect;
    this.mouseover = _ddlOptionMouseOver;
    this.mouseout = _ddlOptionMouseOut;
    this.disabled = false;
    /*this.showChildren = _showChildren;
    this.hideChildren = _hideChildren;*/
}

function _ddlOptionDraw()
{        
    with (this)
    {
        var objOptionList = document.getElementById('ddlOptionList'+parent.id);
        var objOption = document.createElement('div');                	                
        objOption.setAttribute('id','ddlOption'+parent.id+'_'+id);                   
        objOption.innerHTML = text;
        objOption.style.height = parent.nodeheight+'px';
        objOption.style.lineHeight = parent.nodeheight+'px';
        if(!disabled)
		{
			objOption.className = 'ddlOption';
			objOption.onclick = function() {select(this);eval(parent.onchange);return false;};
			objOption.onmouseover = function() {mouseover(this)};
			objOption.onmouseout = function() {mouseout(this)};
        }
        else
        {
			objOption.className = 'ddlOptionDisabled';
        }
        
        if( parent.selectedValue == value)
        {
            selected = true;
        } 
            
        if(selected == true)
        {
            objOption.className = 'ddlSelectedOption';
            parent.selectedValue = value;
            parent.selectedText = text;
            parent.selectedIndex = index;
            parent.update();                        
        }
        objOptionList.appendChild(objOption);
    }
}

function _ddlOptionSelect()
{        
    with (this)
    {   
        if(parent.selectedIndex!=-1)
        {
            parent.nodes[parent.selectedIndex].selected = false;
            parent.nodes[parent.selectedIndex].mouseout();
        }
        parent.selectedText = text;
        parent.selectedValue = value;
        parent.selectedIndex = index;
        selected = true;
        mouseover();
        parent.update();
        parent.expand();
        /*var objOptionList = document.getElementById('ddlOptionListScroll'+parent.id);
        objOptionList.style.display = 'none';*/
        
    }
}

function _ddlOptionMouseOut()
{        
    with (this)
    {
        if(!selected)
        {
            var objOption = document.getElementById('ddlOption'+parent.id+'_'+id);
            objOption.className = 'ddlOption';
        }
    }
 }
 
function _ddlOptionMouseOver()
{        
    with (this)
    {                   
        var objOption = document.getElementById('ddlOption'+parent.id+'_'+id);
        objOption.className = 'ddlSelectedOption';
    }
 }

/*-------- Custom Drop Down List END-----*/

/*-------- Tree menu START-----*/
function menuNode(id, name, value, hasChildren)
{            
    this.left=0;
    this.top=0;
    this.isRoot = true;
    this.parent;
    this.id = id;
    this.name = name;            
    this.value = value;            
    this.nodes = Array();            
    this.hasChildren = _hasChildren;           
    this.length = _getLength;
    this.toString = menuNodeToString;
    this.appendChild = _appendChild;            
    this.draw = _drawMenuNode;
    this.showChildren = _showChildren;
    this.hideChildren = _hideChildren;
 	this.offset = 200;
	this.offsetx = 150;
	this.description='';
	this.index=0;

}  

function _showChildren()
{
    with(this)
    {
    
        for(var i=0;i<parent.nodes.length;i++)
        {
            var temp = parent.nodes[i];
            if(temp.id!=id)
            {   
                for(k in temp.nodes)
                {                             
                    temp.nodes[k].hideChildren();
                }
            }     
            var objWrapper = document.getElementById('objParentWrapper'+temp.id);
                objWrapper.className = 'treemenu_lastnode';           
        }       
                        
        if(nodes.length>0)
            {
                var objWrapper = document.getElementById('objParentWrapper'+id);
                objWrapper.className = 'treemenu_parentnode';
                var temp;                       
                
                for(i=0;i<nodes.length;i++)
                {                            
                    temp = document.getElementById(nodes[i].id);
                    temp.style.display = '';                            
                }                        
            }
    }
}        

function _hideChildren()
{
    with(this)
    {           
        document.getElementById(id).style.display = 'none';
        var objWrapper = document.getElementById('objParentWrapper'+id);
                objWrapper.className = 'treemenu_lastnode';
        for(n in nodes)
        {       
            nodes[n].hideChildren();
        }
    }
}    


function _drawMenuNode()
{
    with (this) 
    {   
        if(!isRoot)               
        {   
            var nodeHeight = 68;
            var nodeWidth = 230;
            var nodeHalfHeight = nodeHeight/2;
            var objBody = document.getElementsByTagName('body').item(0);
            var objWrapper = document.createElement('div');
            
            objWrapper.setAttribute('id',id);            
            /*objWrapper.onmouseover = function () {showChildren(this)};
            if(value!='')
                objWrapper.onclick = function() {eval(value);}*/
            //objWrapper.onmouseout = function () {hideChildren(this)};
            //alert(id);
			
			if(parent.isRoot)
			{
				top = parent.top+index*nodeHeight;//+offset;
				left = parent.left;
			}
			else
			{
				if(index > 0)
				{
					top = parent.nodes[index-1].top + nodeHeight;
					left = parent.nodes[index-1].left;
				}
				else
				{					
					var freeSpace = parent.top - offset;
					var neededSpace = (parent.length()*nodeHeight)/2-nodeHalfHeight;
					//alert(id+' : '+freeSpace+'-'+neededSpace);
					if(freeSpace > neededSpace)
					{
						top = parent.top - neededSpace;
					}
					else
					{
						top = parent.top-parseInt(freeSpace/nodeHeight)*nodeHeight;
					}
					left = parent.left + nodeWidth;
				}
				objWrapper.style.display = 'none'; 
			}
			objWrapper.style.zIndex = 20*parseInt(left/nodeWidth)+parseInt(top/nodeHeight);
            /*
            if((y == 0)&&(q>1)&&(x>1))
                objWrapper.className = 'treemenu_childnode_ontop';
            else
                objWrapper.className = 'treemenu_childnode_oncenter';
            
            if((y == q-1)&&(q>1)&&(x>1))
                objWrapper.className = 'treemenu_childnode_onbottom';	                    
            if (q==1)
                objWrapper.className = 'treemenu_childnode';
                
            if (x==1) 
                objWrapper.className = 'treemenu_1childnode';
            */  
              
            if((index==0) && (parent.length()>1))
                objWrapper.className = 'treemenu_childnode_ontop';
            else
                objWrapper.className = 'treemenu_childnode_oncenter';
            
            if((index+1 == parent.length())&& (parent.length()>1))
                objWrapper.className = 'treemenu_childnode_onbottom';	                    
                
            if (parent.length()==1)
                objWrapper.className = 'treemenu_childnode';
                
            if (parent.isRoot) 
                objWrapper.className = 'treemenu_1childnode';
                
            objWrapper.style.left=left+'px';//(x*230+offsetx)+'px';
            
            /*var temp = 0;
            if(x>1)	                    
            {
                temp = (po!=null?po:0)-nodeHeight-offset;
                
                if((temp+offset) < ((nodeHeight * q / 2) - nodeHalfHeight))
                {	                        
                    temp = (offset+nodeHeight)+ ((temp - (offset+nodeHeight)));
                    temp = temp - (parseInt( (temp+offset)/nodeHeight)*nodeHeight-nodeHalfHeight);
                }
                else
                {
                    temp = temp - ((nodeHeight * q / 2) - nodeHalfHeight);
                }	                    
            }
            else
            {
                temp = 0;	                    
            }
            var topOffset = (parseInt(y)+1)*nodeHeight+temp+offset;*/
            objWrapper.style.top=top + 'px';//topOffset+'px';
            objWrapper.style.height = nodeHeight+'px';	                
            /*
            if(x>1)                
                objWrapper.style.display = 'none'; */
                
            objBody.appendChild(objWrapper);
            
            var objParentWrapper = document.createElement('div');
            objParentWrapper.setAttribute('id','objParentWrapper'+id);
            objParentWrapper.className='treemenu_lastnode'; 
            objParentWrapper.style.height = nodeHeight+'px';
            objWrapper.appendChild(objParentWrapper);
            	                
            var objShadow = document.createElement('div');
            objShadow.className = 'treemenu_node_shadow';
            objShadow.style.top = 27+'px';
            objParentWrapper.appendChild(objShadow)
            var strDesc = '&nbsp;';
            var strAction = '';
            if(description.length>0)
            {
            
				var objDescription = document.createElement('div');
				objDescription.className = 'treemenu_description';
				objDescription.setAttribute('id','objDescription'+id);
				objDescription.style.zIndex = 600+10*parseInt(left/nodeWidth)+parseInt(top/nodeHeight);
				objDescription.style.top=top+9+'px';
				objDescription.style.left=(left+220)+'px';
				objDescription.style.display = 'none';
				
				var objDescriptionHeader = document.createElement('div');
				objDescriptionHeader.className = 'treemenu_bold';
				objDescriptionHeader.setAttribute('id','objDescriptionHeader'+id);
				objDescriptionHeader.innerHTML = name;
				objDescription.appendChild(objDescriptionHeader);
				
				var objDescriptionImage = document.createElement('img');
				objDescriptionImage.setAttribute('src','/images/blank.gif'+id);
				objDescriptionImage.style.width = '1px';
				objDescriptionImage.style.height = '5px';
				objDescription.appendChild(objDescriptionImage);
				
				var objDescriptionValue = document.createElement('div');
				objDescriptionValue.className = 'treemenu_description_padding';
				objDescriptionValue.setAttribute('id','objDescriptionValue'+id);
				objDescriptionValue.innerHTML = description;
				objDescription.appendChild(objDescriptionValue);
				
				objBody.appendChild(objDescription);
				strDesc = '<img src="/images/v6/ico_question_silver.gif" alt="" border="0"/>';
				strAction = 'onmouseout="document.getElementById(\'objDescription'+id+'\').style.display=\'none\';" onmouseover="document.getElementById(\'objDescription'+id+'\').style.display=\'\';"';
            }
            var objNodeHeader = document.createElement('div');
            objNodeHeader.className = 'treemenu_node treeheader';
            objNodeHeader.style.top = 9+'px';
            objNodeHeader.onmouseover = function () {showChildren(this)};
            if(value!='')
                objNodeHeader.onclick = function() {eval(value);}
            objParentWrapper.appendChild(objNodeHeader);	                
            var strTable = '<table cellpadding="0" cellspacing="0" border="0" class="treemenu_nodevalue"><tr><td class="treemenu_nodecenter agito_header" rowspan="2">'+name+'</td>';
            strTable = strTable + '<td align="center"'+strAction+'>'+strDesc+'</td>';
            var temp = '&nbsp;';
            if(length()>0)
				temp = '&gt;';
			strTable = strTable + '</tr><tr><td class="treemenu_parentsign">'+temp+'</td>';
			strTable = strTable +'</tr></table>';
            objNodeHeader.innerHTML = strTable;
            
            //document.write(name+'---'+x+'---'+y+'<br/>');                
        }
        /*else
        {
			nodes[0].left = left;
			nodes[0].top = top;
        }*/
        for(n in nodes)
        {                
            //nodes[n].draw(x+1,n,length(),topOffset);
            nodes[n].draw();
        }
    }
                
}        

function _hasChildren()
{
    with (this) return (length()>0?true:false);            
}

function _getLength()
{
    with (this) return nodes.length;
}
        
function _appendChild(child)
{            
    with (this) {child.index=nodes.length; nodes[nodes.length]=child; child.isRoot = false; child.parent = this;}
}

function menuNodeToString() 
{
    with (this) document.write(name+','+value+',has '+(hasChildren()?'':'no')+' children, '+length()+'<BR/>');
}               

/*-------- Tree menu END-----*/

/*-------- Custom Dialog START-----*/

var dialogScrollTimeout;
var dialogWidth;
var dialogHeight;
var currentDialogElement;

function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

function getPageSize(){
//	alert(document.body.scrollHeight);
	var xScroll, yScroll;
	var pageWidth,pageHeight,windowWidth,windowHeight;

	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}
/*
function results()
{	
	var arrPS = getPageSize();		
	alert(arrPS[0]+' '+arrPS[1]+' '+arrPS[2]+' '+arrPS[3]);
	var arrSC = getPageScroll();
	alert(arrSC[0]+' '+arrSC[1]);
}
*/

function dialogResize(width,height)
{
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 15);

    var wHeight=arrayPageSize[3];

	if (arrayPageScroll[1]>0)
		height=height+arrayPageScroll[1];

    var objOverlay = document.getElementById("overlay");
	var objLightBox = document.getElementById("lightbox");
	var objScrollArrowDown = document.getElementById("dialogScrollArrowDown");
	var objScrollArrowUp = document.getElementById("dialogScrollArrowUp");
	var objScrollArrowDownP = document.getElementById("dialogDoubleScrollArrowDown");
	var objScrollArrowUpP = document.getElementById("dialogDoubleScrollArrowUp");
	var objCloseButton = document.getElementById("closeDialogButton");
	var objCloseButton1 = document.getElementById("closeDialogButton1");
	var objcancelDialogButton = document.getElementById("cancelDialogButton");	
	var objDialogWrapper = document.getElementById("dialogWrapper");	

	dialogWidth = width;
	dialogHeight = height;
	
	if(objOverlay!=null)
	{
		objOverlay.style.top = '0px';
		objOverlay.style.left = '0px';
		wWidth = arrayPageSize[2];
		if(arrayPageSize[2] < dialogWidth)
		    wWidth = dialogWidth;
		objOverlay.style.width = (wWidth)+'px';
		//alert(wHeight+'---'+dialogHeight);
		if(wHeight < dialogHeight+25)
		    wHeight = dialogHeight + 50;
		objOverlay.style.height = (wHeight)+'px';
		
		//alert(objOverlay.style.height);
		
	}
	
	objLightBox.style.top = '0px';
	/*objLightBox.style.left = (arrayPageSize[2]/2-100)+'px';*/
	var BottomPanelHeight = 35;
	objLightBox.style.width = (dialogWidth-25)+'px';
	objLightBox.style.height = (dialogHeight-2-BottomPanelHeight)+'px';
	
	objDialogWrapper.style.top = lightboxTop+'px';
	objDialogWrapper.style.left = (arrayPageSize[2]/2-dialogWidth/2)+'px';
	objDialogWrapper.style.width = dialogWidth+'px';
	objDialogWrapper.style.height = dialogHeight+'px';
	
	
	objScrollArrowDown.style.top = (dialogHeight - 25-BottomPanelHeight)+'px';
	objScrollArrowDown.style.left = (dialogWidth -15)+'px';
	
	objScrollArrowUp.style.top = (dialogHeight - 40-BottomPanelHeight)+'px';
	objScrollArrowUp.style.left = (dialogWidth -15)+'px';
	
	objScrollArrowDownP.style.top = (dialogHeight - 15-BottomPanelHeight)+'px';
	objScrollArrowDownP.style.left = (dialogWidth -15)+'px';
	
	objScrollArrowUpP.style.top = (dialogHeight - 55-BottomPanelHeight)+'px';
	objScrollArrowUpP.style.left = (dialogWidth -15)+'px';
	
	objCloseButton.style.top = (5)+'px';
	objCloseButton.style.left = (dialogWidth -15)+'px';
	
	objCloseButton1.style.top = (dialogHeight - BottomPanelHeight + 10)+'px';
	objCloseButton1.style.left = (dialogWidth/2 - 55)+'px';

	objcancelDialogButton.style.top = (dialogHeight - BottomPanelHeight + 10)+'px';
	objcancelDialogButton.style.left = (dialogWidth/2 + 5)+'px';                  

	
}

function dialogMouseWheel()
{
	var objLightbox = document.getElementById('lightbox');	
	var delta = event.wheelDelta;
	if (delta > 0)
	{
		objLightbox.scrollTop = objLightbox.scrollTop - 20;
	}
	else
	{
		objLightbox.scrollTop = objLightbox.scrollTop + 20;				
	}
}

function dialogInit(parent, closeaction, cancelaction)
{

	//var objBody = document.getElementsByTagName("body").item(0);
	var objBody = document.getElementById(parent);
	
	var objOverlay = document.createElement("div");
	objOverlay.setAttribute('id','overlay');
	objOverlay.style.display = 'none';
	//objOverlay.onclick = function() { dialogCloseEffect(); return false; }
	objBody.appendChild(objOverlay);
	
	var objWrapper = document.createElement("div");
	objWrapper.setAttribute('id','dialogWrapper');
	objWrapper.style.display = 'none';
	objBody.appendChild(objWrapper);
	
	var objLightbox = document.createElement("div");
	objLightbox.setAttribute('id','lightbox');
	objLightbox.style.display = 'none';
	//objLightbox.innerHTML = 'IBM приобрела вчера частную компанию AptSoft с целью расширения своего портфолио по процессигну бизнес-событий. Коммерческие детали сделки остались неразглашенными.IBM, одна из крупнейших в мире компьютерных корпораций, заявляет, что технологии AptSoft помогут систематизировать работу предприятия и разобраться в причинно-следственных связях между казалось бы несвязанными бизнес-событиями.Также было замечено, что AptSoft будет придерживаться сервис-ориентированной архитектуры (SOA) в разработке ПО. Это поможет при интеграции разработок в софт IBM.';
	//objWrapper.onkeyup = function(event){var e = (!event)?window.event:event;handleKeyUp(e);};
	objWrapper.onmousewheel = function() {dialogMouseWheel();return false;};
	objWrapper.appendChild(objLightbox);
	
	var objScrollArrowDown = document.createElement("div");
	objScrollArrowDown.setAttribute('id','dialogScrollArrowDown');
	objScrollArrowDown.style.backgroundColor = 'transparent';	
	objScrollArrowDown.style.position = 'absolute';
	objScrollArrowDown.style.width = '10px';
	objScrollArrowDown.style.height = '6px';
	/*objScrollArrowDown.style.top = '200px';
	objScrollArrowDown.style.left = '200px';*/
	objScrollArrowDown.style.display = '';
	objScrollArrowDown.style.zIndex = 1100;
	objScrollArrowDown.onmousedown = function () {scrollLightBoxDown(); return false;} 
	objScrollArrowDown.onmouseup = function () {stopLightBoxScroll(); return false;} 
	objScrollArrowDown.onmouseout = function () {stopLightBoxScroll(); return false;} 
	objWrapper.appendChild(objScrollArrowDown);	
	
	var objScrollArrowUp = document.createElement("div");
	objScrollArrowUp.setAttribute('id','dialogScrollArrowUp');	
	objScrollArrowUp.style.backgroundColor = 'transparent';	
	objScrollArrowUp.style.position = 'absolute';
	objScrollArrowUp.style.width = '10px';	
	objScrollArrowUp.style.height = '6px';
	/*objScrollArrowUp.style.top = '170px';
	objScrollArrowUp.style.left = '200px';*/
	objScrollArrowUp.style.display = '';
	objScrollArrowUp.style.zIndex = 1110;
	objScrollArrowUp.onmousedown = function () {scrollLightBoxUp(); return false;} 
	objScrollArrowUp.onmouseup = function () {stopLightBoxScroll(); return false;} 
	objScrollArrowUp.onmouseout = function () {stopLightBoxScroll(); return false;} 
	objWrapper.appendChild(objScrollArrowUp);    
	
	var objScrollArrowDownP = document.createElement("div");
	objScrollArrowDownP.setAttribute('id','dialogDoubleScrollArrowDown');
	objScrollArrowDownP.style.backgroundColor = 'transparent';
	objScrollArrowDownP.style.width = '10px';
	objScrollArrowDownP.style.position = 'absolute';
	objScrollArrowDownP.style.height = '11px';
	/*objScrollArrowDownP.style.top = '200px';
	objScrollArrowDownP.style.left = '200px';*/
	objScrollArrowDownP.style.display = '';
	objScrollArrowDownP.style.zIndex = 1100;
	objScrollArrowDownP.onclick = function () {dialogPageDown(); return false;} 	
	objScrollArrowDownP.ondblclick = function () {dialogPageDown(); return false;}
	objWrapper.appendChild(objScrollArrowDownP);	
	
	var objScrollArrowUpP = document.createElement("div");
	objScrollArrowUpP.setAttribute('id','dialogDoubleScrollArrowUp');	
	objScrollArrowUpP.style.backgroundColor = 'transparent';	
	objScrollArrowUpP.style.width = '10px';
	objScrollArrowUpP.style.position = 'absolute';
	objScrollArrowUpP.style.height = '11px';
	/*objScrollArrowUpP.style.top = '170px';
	objScrollArrowUpP.style.left = '200px';*/
	objScrollArrowUpP.style.display = '';
	objScrollArrowUpP.style.zIndex = 1150;
	objScrollArrowUpP.onclick = function () {dialogPageUp(); return false;}
	objScrollArrowUpP.ondblclick = function () {dialogPageUp(); return false;}
	objWrapper.appendChild(objScrollArrowUpP);    
	
	var objCloseButton = document.createElement("div");
	objCloseButton.setAttribute('id','closeDialogButton');	
	objCloseButton.style.backgroundColor = 'transparent';	
	objCloseButton.style.width = '10px';
	objCloseButton.style.position = 'absolute';
	objCloseButton.style.height = '10px';
	/*objCloseButton.style.top = '170px';
	objCloseButton.style.left = '200px';*/
	objCloseButton.style.display = '';
	objCloseButton.style.zIndex = 1160;	
	objCloseButton.onclick = function() {dialogCloseEffect(cancelaction);}
	objWrapper.appendChild(objCloseButton);

	var objCloseButton = document.createElement("div");
	objCloseButton.setAttribute('id','closeDialogButton1');	
	objCloseButton.style.backgroundColor = 'transparent';	
	objCloseButton.style.width = '50px';
	objCloseButton.style.position = 'absolute';
	//objCloseButton.style.height = '10px';
	objCloseButton.innerHTML = 'Ok';
	/*objCloseButton.style.top = '170px';
	objCloseButton.style.left = '200px';*/
	objCloseButton.style.display = '';
	objCloseButton.style.zIndex = 1160;	
	objCloseButton.onclick = function() {dialogCloseEffect(closeaction);}
	objWrapper.appendChild(objCloseButton);

	var objCloseButton = document.createElement("div");
	objCloseButton.setAttribute('id','cancelDialogButton');	
	objCloseButton.style.backgroundColor = 'transparent';	
	objCloseButton.style.width = '60px';
	objCloseButton.style.position = 'absolute';
	//objCloseButton.style.height = '10px';
	objCloseButton.innerHTML = 'Cancel';
	/*objCloseButton.style.top = '170px';
	objCloseButton.style.left = '200px';*/
	objCloseButton.style.display = '';
	objCloseButton.style.zIndex = 1160;	
	objCloseButton.onclick = function() {dialogCloseEffect(cancelaction);}
	objWrapper.appendChild(objCloseButton);

	
}

function addDialogPanel(parent,id)
{    
    var objPanel = document.createElement("div");
	objPanel.setAttribute('id',id);
	objPanel.style.display = 'none';	
	parent.appendChild(objPanel);
	return objPanel;
}
/*
function handleKeyUp(e)
{
    //alert(e.keyCode);
    if(e.keyCode==33){dialogPageUp();} 
    if(e.keyCode==34){dialogPageDown();}
}
*/
function dialogPageUp()
{
    var objLightBox = document.getElementById("lightbox");
    pageSize = dialogHeight;    
    objLightBox.scrollTop = objLightBox.scrollTop - pageSize; 
}
function dialogPageDown()
{    
    
    var objLightBox = document.getElementById("lightbox");
    pageSize = dialogHeight;    
    objLightBox.scrollTop = objLightBox.scrollTop + pageSize; 
}

function dialogClear(parent)
{
    var objDialogElement = document.getElementById(currentDialogElement);
    if(objDialogElement != null)
        objDialogElement.style.display = 'none';
        parent.style.display = '';//innerHTML = '';
    currentDialogElement = parent.id;
}

function addElement(parent,id, name, type, value, text)
{    
    var objChild;    
    
    //Creation of DOM element accocding to it's type
    switch(type)
    {
        case 'button':            
        case 'checkbox':            
        case 'hidden':
		case 'text':
            objChild = document.createElement('input');
            break;        
        default:            
            objChild = document.createElement(type);
            break;
    }
    
    addAttribute(objChild,'id',id);
    addAttribute(objChild,'name',name);    
    
    //Addition of required Attributes to the element
    switch(type)
    {
            case 'checkbox':
                addAttribute(objChild,'type','checkbox');
                addAttribute(objChild,'value',value);                
            break;
            case 'a':
                addAttribute(objChild,'href',value);
                objChild.innerHTML = text;
            break;
            case 'button':
                addAttribute(objChild,'type','button');
                addAttribute(objChild,'value',text);
                addAttribute(objChild,'onclick',value );                
            break;
            case 'hidden':
                addAttribute(objChild,'type','hidden');
                addAttribute(objChild,'value',text);                
            break;
            case 'text':
                addAttribute(objChild,'type', type);
            break;
            case 'span':
            case 'p':
            case 'b':
                objChild.innerHTML = value;
            break;
    }    
    
    parent.appendChild(objChild);    
	return objChild;
}

function addAttribute(element, name, value)
{
    if(name == 'onclick')
        element.onclick = function(){eval(value);};
    else
        element.setAttribute(name,value);
}

function scrollLightBoxDown()
{
    var objLightBox = document.getElementById("lightbox");    
    objLightBox.scrollTop = objLightBox.scrollTop + 5;
    dialogScrollTimeout = window.setTimeout('scrollLightBoxDown()',30);
}

function scrollLightBoxUp()
{
    var objLightBox = document.getElementById("lightbox");    
    objLightBox.scrollTop = objLightBox.scrollTop - 5;        
    dialogScrollTimeout = window.setTimeout('scrollLightBoxUp()',30);
}

function stopLightBoxScroll()
{
    window.clearTimeout(dialogScrollTimeout);
}

function pausecomp(millis)
{
    var date = new Date();
    var curDate = null;

    do { curDate = new Date(); }
    while(curDate-date < millis);
} 

function dialogShow()
{
	var objOverlay = document.getElementById("overlay");
	var objLightBox = document.getElementById("lightbox");
	var objDialogWrapper = document.getElementById("dialogWrapper");
    dialogResize(dialogWidth,dialogHeight);
	objOverlay.style.display = '';
//	alert(document.styleSheets[0].cssRules[1].style.opacity);
//	alert(document.styleSheets[0].cssRules[1].style.opacity);
	objOverlay.style.opacity = 0;
	objOverlay.style.filter = 'alpha(opacity=0)';
	dialogEffect(1);                    
	objDialogWrapper.style.display = '';
	objLightBox.style.display = '';
}

function dialogEffect(mode)
{
	var currentFrame = 0;
	if (mode==1)
	for(var i=0;i<6;i=i+0.1)
	{
      var frame = Math.round(i * 10 * 0.2);		
      if(frame > currentFrame) 		
		{
			window.setTimeout('dialogEffectFade('+currentFrame/20+')',i*75);	
			currentFrame=currentFrame+1;
		}		
	}
	else
	for(var i=0;i<6;i=i+0.1)
	{
      var frame = Math.round(i * 10 * 0.2);		
      if(frame > currentFrame) 
		{	
			window.setTimeout('dialogEffectFade('+(0.6-currentFrame/20)+')',i*75);	
			currentFrame=currentFrame+1;
		}		
	}
	//alert(objOverlay.style.opacity);
	/*'filter:alpha(opacity=10)';
	objOverlay.style=objOverlay.style+'-moz-opacity: 0.1';
	objOverlay.style=objOverlay.style+'opacity: 0.1';*/
}

function dialogEffectFade(opacity)
{
	var objOverlay = document.getElementById("overlay");
	objOverlay.style.opacity = opacity;
	objOverlay.style.filter = 'alpha(opacity='+(opacity*100)+')';
}

function dialogCloseEffect(closeaction)
{
    var objLightBox = document.getElementById("lightbox");
    var objDialogWrapper = document.getElementById("dialogWrapper");

	objLightBox.style.display = 'none';
	objDialogWrapper.style.display = 'none';

    dialogEffect(-1);
	window.setTimeout('dialogClose('+closeaction+')',6*75);	
}
function dialogClose(closeaction)
{
   	var objOverlay = document.getElementById("overlay");
	objOverlay.style.display = 'none';
	eval(closeaction);
}

/*-------- Custom Dialog END-----*/