var myWidth = myHeight = 0;

var mmW = 940;        // main movie width
var mmH = 610;        // main movie height  
var obj1;
var x = y = toppos1 = leftpos1 = gw = gh = nWidth= nHeight = lefpos2 = toppos2 = 0 ;

window.onload = function(){
	setpos2();
}

function setpos2(){

	
	gw = document.getElementById('main_2').offsetWidth;
	gh = document.getElementById('main_2').offsetHeight;
	var winsize = new findWinPos2();
	x=winsize.xpos;
	y=winsize.ypos;
	leftpos1= x-gw-50;
	toppos1= (y/2)+(mmH/2)-gh;
	obj1 = new getObj2('main_2');
	if(obj1.style){
		obj1.style.top=toppos1+"px";
		obj1.style.left=leftpos1+"px";
	}else{
		main_2.style.top=y1+"px";
		main_2.style.left=x1+"px";
	}
	window.onresize = function(){
		var winsize = new findWinPos2();
		nWidth=winsize.xpos;
		nHeight=winsize.ypos;
		
		if(nWidth==x ){
			obj1.style.left=leftpos1+"px";
		}else{
			leftpos2=nWidth-gw-10;
			obj1.style.left=leftpos2+"px";
		}
		
		if(nHeight==y){
			obj1.style.top=toppos1+"px";
		}else{
			toppos2=nHeight-gh-30;
			obj1.style.top=toppos2+"px";
		}
	}
	window.onscroll=function(){
		var scroll_x = scroll_posx() ;
		var scroll_y = scroll_posy();
		if(nWidth==0){
			nWidth=x;
		}
		if(nHeight==0){
			nHeight=y;
		}
		var x_new = scroll_x+nWidth-gw-17;
		var y_new = scroll_y+nHeight-gh-10;
		obj1.style.left=x_new+"px";		
		obj1.style.top=y_new+"px";
	}
}
function getObj2(name)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	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 = document.layers[name];
   	this.style = document.layers[name];
  }
}

function findWinPos2() {
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    this.xpos = window.innerWidth;
    this.ypos= window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    this.xpos= document.documentElement.clientWidth;
    this.ypos = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    this.xpos = document.body.clientWidth;
    this.ypos = document.body.clientHeight;
  } 
}

function scroll_posx() {
	return f_filterResults (window.pageXOffset ? window.pageXOffset : 0, document.documentElement ? document.documentElement.scrollLeft : 0, document.body ? document.body.scrollLeft : 0 );
}
function scroll_posy() {
	return f_filterResults (window.pageYOffset ? window.pageYOffset : 0, document.documentElement ? document.documentElement.scrollTop : 0, document.body ? document.body.scrollTop : 0 );
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}
