/**
 * Funciones Desordenado Multimedia - http://www.desordenado.com
 *
 */

window.onresize= resizeDiv;
function resizeDiv() {
getSize();
}

myWidth = 0;
myHeight = 0;
myEtiquetaHeight = 0;
versionFlash = 8;

getSize=function(){
	limiteWidth = 1000;
	limiteHeight = 0;
	if(!FlashDetect.installed || (FlashDetect.major < versionFlash)){
		document.getElementById("etiqueta").style.overflow = 'visible';
	}else{
		alertSize();
	}
	
	var ieVer=/*@cc_on function(){ switch(@_jscript_version){ case 1.0:return 3; case 3.0:return 4; case 5.0:return 5; case 5.1:return 5; case 5.5:return 5.5; case 5.6:return 6; case 5.7:return 7; case 5.8:return 8; }}()||@*/0;
	
	if(ieVer >0  &&  ieVer<=6){	
		if(myWidth < limiteWidth && myHeight < limiteHeight){
			document.getElementById("etiqueta").style.height = limiteHeight + "px";
			document.getElementById("etiqueta").style.width = limiteWidth + "px";	
		}else if(myWidth > limiteWidth && myHeight < limiteHeight){
			document.getElementById("etiqueta").style.height = limiteHeight + "px";
			document.getElementById("etiqueta").style.width = 100 + "%";
		}else if(myWidth < limiteWidth && myHeight > limiteHeight){
			document.getElementById("etiqueta").style.height = myHeight + "px";
			//document.getElementById("etiqueta").style.height = 100 + "%";
			document.getElementById("etiqueta").style.width = limiteWidth + "px";
		}else{
			document.getElementById("etiqueta").style.height = myHeight + "px";
			//document.getElementById("etiqueta").style.height = 100 + "%";
			document.getElementById("etiqueta").style.width = 100 + "%";	
		}
	}else{
		if(myWidth < limiteWidth && myHeight < limiteHeight){
			document.getElementById("etiqueta").style.height = limiteHeight + "px";
			document.getElementById("etiqueta").style.width = limiteWidth + "px";	
		}else if(myWidth > limiteWidth && myHeight < limiteHeight){
			document.getElementById("etiqueta").style.height = limiteHeight + "px";
			document.getElementById("etiqueta").style.width = 100 + "%";
		}else if(myWidth < limiteWidth && myHeight > limiteHeight){
			//document.getElementById("etiqueta").style.height = myHeight + "px";
			document.getElementById("etiqueta").style.height = 100 + "%";
			document.getElementById("etiqueta").style.width = limiteWidth + "px";
		}else{
			//document.getElementById("etiqueta").style.height = myHeight + "px";
			document.getElementById("etiqueta").style.height = 100 + "%";
			document.getElementById("etiqueta").style.width = 100 + "%";	
		}
	}
}

function alertSize() {
  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;
  }
 
}

/*
Copyright (c) Copyright (c) 2007, Carl S. Yestrau All rights reserved.
Code licensed under the BSD License: http://www.featureblend.com/license.txt
Version: 1.0.3
*/
var FlashDetect = new function(){
	var self = this;
	self.installed = false;
	self.raw = "";
	self.major = -1;
	self.minor = -1;
	self.revision = -1;
	self.revisionStr = "";
	var activeXDetectRules = [
		{
			"name":"ShockwaveFlash.ShockwaveFlash.7",
			"version":function(obj){
				return getActiveXVersion(obj);
			}
		},
		{
			"name":"ShockwaveFlash.ShockwaveFlash.6",
			"version":function(obj){
				var version = "6,0,21";
				try{
					obj.AllowScriptAccess = "always";
					version = getActiveXVersion(obj);
				}catch(err){}
				return version;
			}
		},
		{
			"name":"ShockwaveFlash.ShockwaveFlash",
			"version":function(obj){
				return getActiveXVersion(obj);
			}
		}
	];
	var getActiveXVersion = function(activeXObj){
		var version = -1;
		try{
			version = activeXObj.GetVariable("$version");
		}catch(err){}
		return version;
	};
	var getActiveXObject = function(name){
		var obj = -1;
		try{
			obj = new ActiveXObject(name);
		}catch(err){}
		return obj;
	};
	var parseActiveXVersion = function(str){
		var versionArray = str.split(",");//replace with regex
		return {
			"raw":str,
			"major":parseInt(versionArray[0].split(" ")[1], 10),
			"minor":parseInt(versionArray[1], 10),
			"revision":parseInt(versionArray[2], 10),
			"revisionStr":versionArray[2]
		};
	};
	var parseStandardVersion = function(str){
		var descParts = str.split(/ +/);
		var majorMinor = descParts[2].split(/\./);
		var revisionStr = descParts[3];
		return {
			"raw":str,
			"major":parseInt(majorMinor[0], 10),
			"minor":parseInt(majorMinor[1], 10), 
			"revisionStr":revisionStr,
			"revision":parseRevisionStrToInt(revisionStr)
		};
	};
	var parseRevisionStrToInt = function(str){
		return parseInt(str.replace(/[a-zA-Z]/g, ""), 10) || self.revision;
	};
	self.majorAtLeast = function(version){
		return self.major >= version;
	};
	self.FlashDetect = function(){
		if(navigator.plugins && navigator.plugins.length>0){
			var type = 'application/x-shockwave-flash';
			var mimeTypes = navigator.mimeTypes;
			if(mimeTypes && mimeTypes[type] && mimeTypes[type].enabledPlugin && mimeTypes[type].enabledPlugin.description){
				var version = mimeTypes[type].enabledPlugin.description;
				var versionObj = parseStandardVersion(version);
				self.raw = versionObj.raw;
				self.major = versionObj.major;
				self.minor = versionObj.minor; 
				self.revisionStr = versionObj.revisionStr;
				self.revision = versionObj.revision;
				self.installed = true;
			}
		}else if(navigator.appVersion.indexOf("Mac")==-1 && window.execScript){
			var version = -1;
			for(var i=0; i<activeXDetectRules.length && version==-1; i++){
				var obj = getActiveXObject(activeXDetectRules[i].name);
				if(typeof obj == "object"){
					self.installed = true;
					version = activeXDetectRules[i].version(obj);
					if(version!=-1){
						var versionObj = parseActiveXVersion(version);
						self.raw = versionObj.raw;
						self.major = versionObj.major;
						self.minor = versionObj.minor; 
						self.revision = versionObj.revision;
						self.revisionStr = versionObj.revisionStr;
					}
				}
			}
		}
	}();
};
FlashDetect.release = "1.0.3";
