// JavaScript Document

positionIt = function() {
	if( document.getElementById ) {
		// Get a reference to divCentrado and measure its width and height.
		var div = document.getElementById( "general" );
	
		var divWidth = div.offsetWidth ? div.offsetWidth : div.style.width ? parseInt( div.style.width ) : 0;
		var divHeight = div.offsetHeight ? div.offsetHeight :  div.style.height ? parseInt( div.style.height ) : 0;
		
		// Calculating setX and setX so the div will be centered in the viewport.
		var setX = ( getViewportWidth() - divWidth ) / 2;
		var setY = ( getViewportHeight() - divHeight ) / 2;
		
		// If setX or setY have become smaller than 0, make them 0.
		if( setX < 0 ) setX = 0;
		if( setY < 0 ) setY = 0;
		
		// Position the div in the center of the page and make it visible.
		div.style.left = setX + "px";
		div.style.top = setY + "px";
		div.style.visibility = "visible";
	}
};

getViewportWidth = function() {
	var width = 0;
	if( document.documentElement && document.documentElement.clientWidth ) {
		width = document.documentElement.clientWidth;
	}
	else if( document.body && document.body.clientWidth ) {
		width = document.body.clientWidth;
	}
	else if( window.innerWidth ) {
		width = window.innerWidth - 18;
	}
	return width;
};

getViewportHeight = function() {
	var height = 0;
	if( document.documentElement && document.documentElement.clientHeight ) {
		height = document.documentElement.clientHeight;
	}
	else if( document.body && document.body.clientHeight ) {
		height = document.body.clientHeight;
	}
	else if( window.innerHeight ) {
		height = window.innerHeight - 18;
	}
	return height;
};
window.onresize = positionIt;

/*var x;
var pos_left_obert;
var pos_left_tancat;
var pos_top;*/

/*function getObj(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 init(){
 
 
 x = document.getElementById("nov");
 x2= document.getElementById("nov_negre");
 //Detectem resolució


if(screen.height==600){
difv=65;
difh=150;
x2.style.top=160;
x2.style.left=600;
}
else{
difv=0;
difh=0;
x2.style.top=160;
x2.style.left=1035;
}
if(screen.height==768){
difv=40;
difh=72;
x2.style.top=160;
x2.style.left=905;
}
else{
difv=0;
difh=0;
x2.style.top=160;
x2.style.left=1035;
}
pos_top=((screen.height*160)/1024)+difv;
pos_left_tancat=((screen.width*1005)/1280)+difh;
pos_left_obert=((screen.width*830)/1280)+difh;



//difh=0;





document.getElementById("nov").style.top=pos_top;
document.getElementById("nov").style.left=pos_left_tancat;



 
}*/


function slide(){

pos_actual=parseInt(x.style.left);

if(pos_actual==pos_left_tancat) slide_esquerre();
if(pos_actual==pos_left_obert) slide_dreta();
}


function slide_esquerre(){

pos_actual=parseInt(x.style.left);

if(pos_actual>pos_left_obert){
	pos_actual-=5;
    x.style.left = pos_actual+'px';
	setTimeout("slide_esquerre()",5);
}
}

function slide_dreta(){

pos_actual=parseInt(x.style.left);
if(pos_actual<pos_left_tancat){
	pos_actual+=5;
    x.style.left = pos_actual+'px';
	setTimeout("slide_dreta()",5);
}
}