﻿function hoverTopMenu(table,first,tableID)
{
    if(table.className=='hover' || table.className=='firsthover')
    {
    }
    else
    {
        if(first)
        {
            table.className='firsthover';
        }
        else
        {
            table.className='hover';
        }
        rightmenu(tableID+1)
    }
}
function rightmenu(id)
{
    var table=document.getElementById('topmenu'+id);
    if(table!=null)
    {
        if(table.className!='right')
        {
            table.className='right';
        }
    }
}
function topMenu(table,first,tableID,checked,checkedRight)
{
    if(table.className=='hover' || table.className=='firsthover')
    {
        if(!checked)
        {
            if(first)
            {
                table.className='first';
            }
            else
            {
               if(!checkedRight)
               {
                    table.className='';
               }
               else
               {
                    table.className='right';
               }
                
            }
            
            returnRightMenu(tableID+1);
        }
        else
        {
        
        }
    }
    else
    { 
    }
}
function returnRightMenu(id)
{
    var table=document.getElementById('topmenu'+id);
    if(table!=null)
    {
        if(table.className=='right')
        {
            table.className='';
        }
    }
}

function showMenu(id,first)
{
	var top = document.getElementById('topmenu'+id);
	hoverTopMenu(top,first,id);
	var width = top.clientWidth;
	var menu=document.getElementById('childmenu'+id);
	var aX=0;
	var a  = top;
    while (a)
    {
        aX += a.offsetLeft;
        a = a.offsetParent;
    }
    if(menu!=null)
	{   
	        menu.className ="menu_drop";
	        menu.style.width=(width-1)+'px';
	        menu.style.marginLeft = (aX+1)+'px';
	}
	
}
	function hideMenu(id,checked,checkedRight)
	{
	    var top = document.getElementById('topmenu'+id);
	    var first = false;
	    if(top.className=='firsthover')
        {
        first=true;
        }
	    topMenu(top,first,id,checked,checkedRight);
		    var menu=document.getElementById('childmenu'+id);
		    
	        if(menu!=null)
	        {
	            menu.className ="menu_dropHide";
	        }
	        
	}

var clipTop = 0;
var clipRight = 950;
if (screen.width <=800)
{
clipRight = 727;
}


var clipBottom = 50;
var clipLeft = 0;
var topper = 27;
var lyrheight = 0;
var lyrwidth = 0;
var time,amount,theTime,theHeight,DHTML;

function init()
{
	DHTML = (document.getElementById || document.all || document.layers)
	if (!DHTML) return;
	var x = new getObj('archive');
	if(x.obj!=null)
	{
	//var x2 = document.getElementById('ctl00_ContentPlaceHolder3_JournalArchiveControl1_DataGrid1');
//	    if (document.layers)
//	    {
//		    lyrheight = x.style.clip.bottom;
//		    lyrheight += 20;
//		    x.style.clip.top = clipTop;
//		    x.style.clip.left = clipLeft;
//		    x.style.clip.right = clipWidth;
//		    x.style.clip.bottom = clipBottom;
//	    }
	    //else 
	    if (document.getElementById || document.all)
	    {
	        lyrwidth = x.obj.scrollWidth;
	        if(lyrwidth<clipRight)
	        {
	        document.getElementById('to_left').style.display='none';
	        document.getElementById('to_right').style.display='none';
	        }
		    lyrheight = x.obj.offsetHeight;
		    var tableHeight= document.getElementById('tableheight');
		   
		    tableHeight.style.height = lyrheight+'px';
		    x.style.clip = 'rect(auto,'+clipRight+'px,auto,'+clipLeft+'px)';
		    srollToRight();
		    
	    }
	}
}

function scrollayer(layername,amt,tim)
{
	if (!DHTML) return;
	thelayer = new getObj(layername);
	if (!thelayer) return;
	amount = amt;
	theTime = tim;
	realscroll();
}

function realscroll()
{
	if (!DHTML) return;
	clipLeft += amount;
	clipRight += amount;
	topper -= amount;
//	if (clipTop < 0 || clipBottom > lyrheight)
//	{
//		clipTop -= amount;
//		clipBottom -= amount;
//		topper += amount;
//		return;
//	}
	if (clipLeft < 0 || clipRight > lyrwidth)
	{
		clipLeft -= amount;
		clipRight -= amount;
		topper += amount;
		return;
	}
	if (document.getElementById || document.all)
	{
		clipstring = 'rect(auto,'+clipRight+'px,auto,'+clipLeft+'px)';
		thelayer.style.clip = clipstring;
		thelayer.style.left = topper + 'px';
	}
//	else if (document.layers)
//	{
//		thelayer.style.clip.top = clipTop;
//		thelayer.style.clip.bottom = clipBottom;
//		thelayer.style.top = topper;
//	}
	time = setTimeout('realscroll()',theTime);
}
function srollToRight()
{
 if (!DHTML) return;
thelayer = new getObj('archive');
    while(true)
    {
    
   
	clipLeft += 1;
	clipRight += 1;
	topper -= 1;
	
        if ( clipRight > lyrwidth)
	    {
		    clipLeft -= 1;
		    clipRight -= 1;
		    topper += 1;
		    clipstring = 'rect(auto,'+clipRight+'px,auto,'+clipLeft+'px)';
		thelayer.style.clip = clipstring;
		thelayer.style.left = topper + 'px';
		    return;
	    }
	    
	}
	
}
function stopScroll()
{
	if (time) clearTimeout(time);
}

function getObj(name)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
  	if(document.getElementById(name) !=null)
  	{
	    this.style = document.getElementById(name).style;
	}
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
	this.obj = getObjNN4(document,name);
	this.style = this.obj;
  }
}