
var myWidth = null;
var myHeight = null;
var bodyWidth = null;
var bodyHeight = null;

// devuelve el tamaño del documento
function getBodySize() {
	if ( typeof( window.innerWidth || window.innerHeight) == 'number' ) {
    	//Non-IE
    	myWidth = window.innerWidth;
    	myHeight = (window.innerHeight/2)+window.pageYOffset;
		bodyWidth = document.body.scrollWidth;
		c = Math.abs(document.documentElement.clientHeight - document.body.scrollHeight);
		bodyHeight = window.innerHeight + c;
		//bodyHeight = document.body.scrollHeight;
	} else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight) ) {
    	//IE 6+ in 'standards compliant mode'
    	myWidth = document.documentElement.clientWidth;
    	myHeight = (document.documentElement.clientHeight/2)+document.documentElement.scrollTop;
		bodyWidth = document.body.scrollWidth;
		c = Math.abs(document.documentElement.clientHeight - document.body.scrollHeight);
		bodyHeight = document.documentElement.clientHeight + c;
		//bodyHeight = document.body.scrollHeight;
	}
	// ancho y alto exacto para la mascara
	document.getElementById(mask).style.width = bodyWidth+'px';
	document.getElementById(mask).style.height = bodyHeight+'px';
}

// devuelve el estilo indicado
function getStyle(el,styleProp) {
	var x = document.getElementById(el);
	if (x.currentStyle)	var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle) var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
}

// funcion levantada del sitio de Apple
function getStyleObject(objectId) {
	if(document.getElementById && document.getElementById(objectId)) {
		return document.getElementById(objectId).style;
	} else if (document.all && document.all(objectId)) {
		return document.all(objectId).style;
	} else if (document.layers && document.layers[objectId]) {
		return getObjNN4(document,objectId);
	} else {
		return false;
	}
} 

// funcion de fade con alpha
function fade(id, start, end, duration) {
	// creo un objeto de opacidad con los siguientes parametros
	opacityTween = new OpacityTween(document.getElementById(id),Tween.regularEaseOut, start, end, duration);
	opacityTween.start();
	// si lo estoy haciendo aparecer arranco con el objeto en display = "block" (no sé por qué razón, display = "" no me da bola)
	if (start < end) {
		document.getElementById(id).style.display = "block";
	// si lo estoy desapareciendo le digo que al final del tween me lo oculte
	} else {
		opacityTween.onMotionFinished = function() {
			document.getElementById(id).style.display = "none";
		};
	}
}

// get mouse position
function mouseX(evt) {
	if (!evt) evt = window.event;
	if (evt.pageX) return evt.pageX;
	else if (evt.clientX) return evt.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft);
	else return 0;
}
function mouseY(evt) {
	if (!evt) evt = window.event;
	if (evt.pageY) return evt.pageY;
	else if (evt.clientY) return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
	else return 0;
}
// funcion que hace seguir el mouse al objeto indicado
function follow(element, evt) {
	var obj = element.style;
	obj.visibility = 'visible';
	obj.left = (parseInt(mouseX(evt))+15) + 'px';
	obj.top = (parseInt(mouseY(evt))+15) + 'px';
}

// browser detection from Quirksmode.com
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};

