var tmp=0;
var qwe=0;
var myTop=0;
var flag=0;


function gettop(id)
{
	height=window.document.getElementById(id).offsetHeight;
	width=window.document.getElementById(id).offsetWidth;
	posit=window.document.getElementById(id).style.position;

    window.document.getElementById(id).style.position="absolute";

    var top = window.document.getElementById(id).offsetTop;

	window.document.getElementById(id).style.position=posit;
	window.document.getElementById(id).style.width = width + "px";
	window.document.getElementById(id).style.height = height + "px";

	return top;
}

function move(event,myTop)
{
	if(flag==1)
    {
        window.document.getElementById('scroller').style.top = (event.clientY - myTop)+ "px";
		if(gettop("scroller")<0) window.document.getElementById('scroller').style.top = 0 + "px";
		if(gettop("scroller") + window.document.getElementById('scroller').offsetHeight> window.document.getElementById('scrollbox').offsetHeight)
        	window.document.getElementById('scroller').style.top = window.document.getElementById('scrollbox').offsetHeight -window.document.getElementById('scroller').offsetHeight + "px";

        rch = window.document.getElementById('scrollbox').offsetHeight - window.document.getElementById('scroller').offsetHeight;
        window.document.getElementById('scroll').scrollTop=(qwe/rch)*gettop("scroller");
    }
}

function divscroll(event)
{
		flag=1;
		myTop = event.clientY - gettop("scroller");

        window.document.onmouseup = function()
        {
        		flag=0;
                window.document.onselectstart = "";
        }
        document.onselectstart = function()
        {
        	return false;
        }
}
function hv()
{
	/*if(window.document.getElementById('scroll').scrollTop==0)
		window.document.getElementById('upbutton').style.display="none";
    else window.document.getElementById('upbutton').style.display="block";

	if(window.document.getElementById('scroll').scrollTop==qwe)
		window.document.getElementById('downbutton').style.display="none";
    else window.document.getElementById('downbutton').style.display="block";*/
}
function scrolldown()
{
	window.document.getElementById('scroll').scrollTop=window.document.getElementById('scroll').scrollTop+70;
    hv();
}

function scrollup()
{
	window.document.getElementById('scroll').scrollTop=window.document.getElementById('scroll').scrollTop-70;
    hv();
}

function loaded()
{
	if(window.document.getElementById('scroll'))
	{
		tmp=window.document.getElementById('scroll').scrollTop;
		for(i=0;i<20;i++)
			window.document.getElementById('scroll').scrollTop=window.document.getElementById('scroll').scrollTop+300;
		qwe=window.document.getElementById('scroll').scrollTop;
		window.document.getElementById('scroll').scrollTop=tmp;
		window.document.getElementById('scroll').onscroll = function()
		{
			rch = window.document.getElementById('scrollbox').offsetHeight - window.document.getElementById('scroller').offsetHeight;
			window.document.getElementById('scroller').style.top = window.document.getElementById('scroll').scrollTop/qwe*rch;
			hv();
		}
	}
}
function scrollfind(event)
{
	st = event.clientY - gettop('scrollbox');
    window.document.getElementById('scroller').style.top = st- window.document.getElementById('scroller').offsetHeight/2
    if(gettop("scroller")<0) window.document.getElementById('scroller').style.top = 0 + "px";
    if(gettop("scroller") + window.document.getElementById('scroller').offsetHeight> window.document.getElementById('scrollbox').offsetHeight)
        window.document.getElementById('scroller').style.top = window.document.getElementById('scrollbox').offsetHeight -window.document.getElementById('scroller').offsetHeight + "px";

    rch = window.document.getElementById('scrollbox').offsetHeight - window.document.getElementById('scroller').offsetHeight;
    window.document.getElementById('scroll').scrollTop=(qwe/rch)*gettop("scroller");


    window.status=st;


}







   function windowSize()
	{
       var myWidth = 0, myHeight = 0;
       if( typeof( window.innerWidth ) == 'number' )
	   {
         //Non-IE
         myWidth = window.innerWidth;
         myHeight = window.innerHeight;
       } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
         //IE 6+ in 'standards compliant mode'
         myWidth = document.documentElement.clientWidth;
         myHeight = document.documentElement.clientHeight;
       } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
         //IE 4 compatible
         myWidth = document.body.clientWidth;
         myHeight = document.body.clientHeight;
       }
         return new Array(myWidth, myHeight);
    }
    
    function getPageSize() {
	        
	     var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = window.innerWidth + window.scrollMaxX;
			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
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth; 
			} else {
				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 = xScroll;		
		} else {
			pageWidth = windowWidth;
		}

		return [pageWidth,pageHeight];
	}
    
    function resizeOverlay()
    {
    	var arrayPageSize = getPageSize();
    	$('overlay').setStyle({ width: arrayPageSize[0] + 'px', height: arrayPageSize[1] + 'px' });
    }
    
    function resizeFlashBG()
    {
     /*  var sizeArray = windowSize();
       document.getElementById("flash_background").style.width = sizeArray[0] + "px";
	   document.getElementById("flash_background").style.height = (sizeArray[1]+350) + "px";
	  */ 
	  	/*var str=navigator.userAgent;
		var firefox=/Firefox/;
		var result1=reg1.test(str) ;
		var reg2=/Windows/;
		var windows=reg2.test(str) ;*/
		

		var segment = 0;
		var WinFirefoxsegment = 0;
		var Firefoxsegment = 0;
		if (Prototype.Browser.Gecko && (navigator.platform == 'Win32')) WinFirefoxsegment = 1;	
		if (Prototype.Browser.Gecko) Firefoxsegment = 30;	
	  	if(!Prototype.Browser.IE) segment = 15;
		var sizeArray = windowSize();
	   //alert('windowWidth='+sizeArray[0]+' windowHeight='+sizeArray[1]+' contentWidth='+$('content').getWidth()+' contentHeight='+$('content').getHeight());
		//alert('windowWidth='+myWidth+' windowHeight='+myHeight+' contentWidth='+$('content').getWidth()+' contentHeight='+$('content').getHeight());
		if((sizeArray[0] - segment - WinFirefoxsegment) >= ($('content').getWidth() + 407))
		{
			$("flash_background").setStyle({ width: (sizeArray[0] - segment - WinFirefoxsegment) + "px"});
			$("flash_background").width = (sizeArray[0] - segment - WinFirefoxsegment) + "px";
		}else
		{
			$("flash_background").setStyle({ width: ($('content').getWidth()+ 407) + "px"});
			$("flash_background").width = ($('content').getWidth()+ 407) + "px";
		}
		if((sizeArray[1] + 20) >= ($('content').getHeight()+230))
		{
			$("flash_background").setStyle({ height: (sizeArray[1] + 30 + Firefoxsegment)+ "px"});//20
			$("flash_background").height = (sizeArray[1] + 30 + Firefoxsegment) + "px";
		}
		else
		{
			$("flash_background").setStyle({ height: ($('content').getHeight()+ 240) + "px"});//230
			$("flash_background").height = ($('content').getHeight()+ 240) + "px";
		}
		//alert('windowWidth='+sizeArray[0]+' windowHeight='+sizeArray[1]+' contentWidth='+$('flash_background').getWidth()+' contentHeight='+$('flash_background').getHeight());
	   
	   //alert();
		/*var fh = $('content').getHeight()+300;	
		
		var myWidth = 0, myHeight = 0;
		if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myHeight = window.innerHeight;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myHeight = document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myHeight = document.body.clientHeight;
		}
		
		if(fh>=myHeight){
			$('flash_background').height = fh+'px';
			$('flash_background').setStyle({height: fh+'px'});
	}*/
	
    }
	
