// JavaScript Document




function incrustaFlash(ruta, ancho, alto, transp) {
	
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + ancho + '" height="' + alto + '">');
      document.write('<param name="movie" value="' + ruta + '" />');
      document.write('<param name="quality" value="high" />');
	  if(transp) {
	  	document.write('<param name="wmode" value="transparent">');
		document.write('<embed src="' + ruta + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + ancho + '" height="' + alto + '" wmode="transparent"></embed>');
	  }
	  else
     	 document.write('<embed src="' + ruta + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + ancho + '" height="' + alto + '"></embed>');
    document.write('</object>');
//	document.write('</div>');
	
	
}

function getElementsByClassName(className, tag, elm){
	var testClass = new RegExp("(^|\\s)" + className + "(\\s|$)");
	var tag = tag || "*";
	var elm = elm || document;
	var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
	var returnElements = [];
	var current;
	var length = elements.length;
	for(var i=0; i<length; i++){
		current = elements[i];
		if(testClass.test(current.className)){
			returnElements.push(current);
		}
	}
	return returnElements;
}

function findPosY(obj) {
	var curtop = 0;
    if(obj.offsetParent)
        while(1) {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
}

function findPosX(obj) {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
}

function onLoadPagina() {
	estiraCajaLateralModRandom();
}

function estiraCajaLateralModRandom() {
	if(getElementsByClassName('modColIzqProds').length > 0) {
		
		var yPie = findPosY(document.getElementById('wrapperTiendasPie'));
		var yCajaModRandom = findPosY(document.getElementById('wrapperExternoRandomprod'));
		var alturaCajaModRandom = document.getElementById('wrapperExternoRandomprod').offsetHeight;
	//	alert(yPie);
		yPie = yPie - 116;
		
		if(navigator.appName.indexOf('Explorer') != -1 && document.getElementById('wrapperColCentralAncha6')) {
			yPie = yPie - 500;
		}
		
		if((yCajaModRandom + alturaCajaModRandom) < yPie) {
			document.getElementById('wrapperExternoRandomprod').style.height = yPie - yCajaModRandom + 'px';
		}
		
	}
}

function incrustaPopInVideoFlash(ruta, ancho, alto, transp) {
	document.write('<div id="popInVideoFlash">');
	document.write('<a href="javascript:cierraPopInVideoFlash();" id="enlaceCerrarPopInVideoFlash"><img src="http://mundodependencia.com/portal/images/cerrar-video-transparente.png" border="0"></a>');
	document.write('<div id="wrapperVideoFlash">');
	
	
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="flash" width="' + ancho + '" height="' + alto + '" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">');
			document.write('<param name="movie" value="' + ruta + '" />');
			document.write('<param name="quality" value="high" />');
			document.write('<param name="wmode" value="transparent">');
			document.write('<param name="allowScriptAccess" value="sameDomain" />');
			document.write('<embed src="' + ruta + '" quality="high" width="' + ancho + '" height="' + alto + '" name="flash" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" wmode="transparent">');
			document.write('</embed>');
	document.write('</object>');
	
	
	document.write('</div>');
	document.write('</div>');
}

function abrePopInVideoFlash() {
	var popIn = document.getElementById('popInVideoFlash');
//	alert(popIn.style.top);
	if(popIn.style.top != '') {
		return;
	}
	
	else {
		var scrollY = 0;
		if(window.pageYOffset)
			scrollY = window.pageYOffset;
		 else
			scrollY = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
		popIn.style.top = ((GetWinHeight() - popIn.offsetHeight) / 2) + scrollY + 'px';
		if(GetWinHeight() < popIn.offsetHeight)
			popIn.style.top = '0px';
		popIn.style.left = (GetWinWidth() - popIn.offsetWidth) / 2 + 'px';
		if(GetWinWidth() < popIn.offsetWidth)
			popIn.style.left = '0px';
	}
}

function cierraPopInVideoFlash() {
	jQuery("#popInVideoFlash").fadeOut(300, function() { jQuery(this).remove(); });
}


function GetWinWidth() {
	var x = 0;
	if (self.innerHeight) {
		x = self.innerWidth;
    }
	else if (document.documentElement && document.documentElement.clientHeight) {
		x = document.documentElement.clientWidth;
	}
	else if (document.body) {
		x = document.body.clientWidth;
	}
	return x;
}
     
function GetWinHeight() {
	var y = 0;
	if (self.innerHeight) {
		y = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight) {
		y = document.documentElement.clientHeight;
	}
	else if (document.body) {
		y = document.body.clientHeight;
	}
	return y;
}











