
/*#####################################################################################

To Make this script run Pls put setpos() function on page body's onload event. ie.

<BODY onload="setpos(); "...........>

and You need to customize variables given below

#####################################################################################*/


//########################################################//
            /* Customize your variables here */
//########################################################//

var DivName = "divSABox" ;                 // Name of the Div containing Flash movie to move
var HPosition = "left" ;              // right - left - center //
var VPosition = "bottom" ;             // bottom - middle - top //
var HScrollMove = "yes" ;              // Move on horizontal scrolling  //
var VScrollMove = "yes" ;              // Move on Vertical scrolling  //
var ExtraMoveH =0 ;                    // set a value in (-) Minus to move left or without minus to move right //
var ExtraMoveV =0 ;                    // set a value in (-) Minus to move top or without minus to move botom //


//########################################################//
            /* Dont Change these codes */
//########################################################//


var x = y = toppos1 = leftpos1 = myWidth = myHeight = 0 ;

var obj, objH, objW;

window.onresize = pos1;
window.onscroll= pos1;

function setpos(){
	obj = getObj(DivName);
	objW = obj.offsetWidth;
	objH = obj.offsetHeight;
	pos1();
	
}

function Spos(){
	if(obj.style){
		obj.style.top=toppos1+"px";
		obj.style.left=leftpos1+"px";
	}else{
		alert("problem in Applying Syle");
	}
}


function pos1(){
	var winsize = new findWinPos2();
	x=winsize.xpos;
	y=winsize.ypos;
	leftpos1= x-objW+ExtraMoveH;
	toppos1= y-objH+ExtraMoveV;
	//if Horizontal Scrolling allowed
	if(HScrollMove=="yes"){
		var scroll_x = scroll_posx() ;
		leftpos1= leftpos1+scroll_x;
	}
	//if Verticle Scrolling allowed
	if(VScrollMove=="yes"){
		var scroll_y= scroll_posy();
		toppos1= toppos1+scroll_y;
	}
	//if Horizontal Position Center
	if(HPosition=="center"){
		leftpos1=leftpos1/2;
	} 
	//if Horizontal Position Left
	if(HPosition=="left"){ 
		leftpos1=0;
	}
	//if Verticle Position middle
	if(VPosition=="middle"){
		toppos1=toppos1/2;
	} 
	//if Horizontal Position Left
	if(VPosition=="top"){ 
		toppos1=0;
	}
	Spos();	
}

function getObj(name){
	var nObj;
	if (document.getElementById){
		nObj=eval(document.getElementById(name));
	}
	else if (document.all)	{
		nObj=eval(document.all[name]);
	}
	else if (document.layers)	{
		nObj=eval(document.layers[name]);
	}
	return(nObj);
}



function findWinPos2() {
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    this.xpos = window.innerWidth-20;
    this.ypos= window.innerHeight-5;
  } 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;
}

