function size_div()
	{
		
	var ns4=document.layers?1:0
var ie4=document.all
var ns6=document.getElementById&&!document.all?1:0


	
	
	}
function cambia_color_titulo(Ly)
	{
//	var menu=document.getElementById(Ly);
//	alert(Ly);
//	var fragmentoTexto = menu.id.split('_');
	menu=window.document.getElementById(Ly);
	menu.style.color="#000"; 	
	}

//var allHTMLTags = new Array();

function cerrar_menu(theClass,contenedor) {


//MenuD('div_2','0','menu_2');
//Create Array of All HTML Tags

var allHTMLTags=document.getElementsByTagName("*");
var cadena="";
//Loop through all tags using a for loop
for (i=0; i<allHTMLTags.length; i++) {

//Get all tags with the specified class name.
if (allHTMLTags[i].className==theClass) {

//Place any code you want to apply to all
//pages with the class specified.
//In this example is to “display:none;” them
//Making them all dissapear on the page.
if (contenedor!=allHTMLTags[i].id)
	{
	//alert("cerrando: "+allHTMLTags[i].id)
	var fragmentoTexto = allHTMLTags[i].id.split('_');
	var menu=window.document.getElementById('titulo_'+fragmentoTexto[1]);
	menu.style.color="#666"; 	
	allHTMLTags[i].style.display='none';
	}
}
}
}

function cerrar_menu2(theClass,contenedor) {


//MenuD('div_2','0','menu_2');
//Create Array of All HTML Tags

var allHTMLTags=document.getElementsByTagName("*");
var cadena="";
//Loop through all tags using a for loop
for (i=0; i<allHTMLTags.length; i++) {

//Get all tags with the specified class name.
if (allHTMLTags[i].className==theClass) {

//Place any code you want to apply to all
//pages with the class specified.
//In this example is to “display:none;” them
//Making them all dissapear on the page.
if (contenedor==allHTMLTags[i].id)
	{
	alert("cerrando: "+allHTMLTags[i].id)
	var fragmentoTexto = allHTMLTags[i].id.split('_');
	var menu=window.document.getElementById('titulo_'+fragmentoTexto[1]);
	menu.style.color="#666"; 	
	allHTMLTags[i].style.display='none';
	}
}
}
}

function cargarano(tipo){	
	var d1,contenedor,str;	
	
	contenedor = document.getElementById('contenedor_ciudades');	
	
	d1 = eval("document.QForm."+tipo+".options[document.QForm."+tipo+".selectedIndex].value");

	ajax=nuevoAjax();
	ajax.open("GET", "modulos/ciudad.php?"+tipo+"="+d1,true);
	ajax.onreadystatechange=function() {
	
	if (ajax.readyState==4) {
		contenedor.innerHTML = ajax.responseText;
	} else {
		contenedor.innerHTML="<img src='uploads/cargando2.gif'>";
	}			
	}
	ajax.send(null);	
		
}


function cargarAjax(contenedor,pagina,variable){
	
	
	var contenedor;	
	
	contenedor = document.getElementById(contenedor);	
	//contenedor = document.getElementById('contenidos');
	//d1 = eval("document.QForm."+tipo+".options[document.QForm."+tipo+".selectedIndex].value");

	ajax=nuevoAjax();
	//ajax.open("GET", "modulos/det_departamento.php?mod="+variable,true);
	ajax.open("GET", pagina+"?"+variable,true);
	ajax.onreadystatechange=function() {
	
	if (ajax.readyState==4) {
		contenedor.innerHTML = ajax.responseText;
	} else {
		contenedor.innerHTML="<img src='../uploads/cargando2.gif'>";
	}			
	}
	ajax.send(null);	
		
}

function nuevoAjax(){
	var xmlhttp=false;
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");  		// Creación del objeto ajax para navegadores diferentes a Explorer
	} catch (e) {
		try {								// o bien
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");		// Creación del objet ajax para Explorer
		} catch (E) {
			xmlhttp = false;
		}
	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}





function abrir_ventana_noscroll(name,ancho,alto){
                ventana2 = window.open(name, "ventana", "width=" + ancho + ",height=" + alto + ",dependent=yes,screenX=0,screenY=0,titlebar=no,directories=no,menubars=no,status=no,scrollbars=no,resizable=no");
}


function moverPublicidad()
{	
	
	var element=document.getElementById('flecha_sup');
	var movible=document.getElementById('c1');
	var movible2=document.getElementById('c2');
	
    var lugar_x = 0;
    var lugar_y = 0;
	do{
	 	lugar_y+=element.offsetTop;
		lugar_x+=element.offsetLeft;
	}while(element=element.offsetParent);
	
//	alert(total1+' '+total2)
	movible.style.left=lugar_x-444;
	movible.style.top=lugar_y;
	movible2.style.left=lugar_x-444;
	movible2.style.top=lugar_y;
	
	}


function menu_set(){
 var i,d='',h="<sty"+"le type=\"text/css\">",tA=navigator.userAgent.toLowerCase();if(window.opera){
 if(tA.indexOf("opera 5")>-1||tA.indexOf("opera 6")>-1){return;}}if(document.getElementById){
 for(i=1;i<20;i++){d+='ul ';h+="\n#menunav "+d+"{position:absolute;left:-9000px;width:11em;}";}
 document.write(h+"\n<"+"/sty"+"le>");}}menu_set();
/* modifica caracteristicas de apertura de menus */
function menu_init(){
 var i,g,tD,tA,tU,pp,lvl,tn=navigator.userAgent.toLowerCase();if(window.opera){
 if(tn.indexOf("opera 5")>-1||tn.indexOf("opera 6")>-1){return;}}else if(!document.getElementById){return;}
 menup=arguments;menuct=new Array;tD=document.getElementById('menunav');
if(tD){tA=tD.getElementsByTagName('A');
 for(i=0;i<tA.length;i++){tA[i].menucl=menuct.length;
menuct[menuct.length]=tA[i];g=tA[i].parentNode.getElementsByTagName("UL");
 tA[i].menusub=(g)?g[0]:false;ev=tA[i].getAttribute("onmouseover");
if(!ev||ev=='undefined'){tA[i].onmouseover=function(){
 menu_trig(this);};}ev=tA[i].getAttribute("onfocus");
if(!ev||ev=='undefined'){tA[i].onfocus=function(){menu_trig(this);};}
 if(tA[i].menusub){pp=tA[i].parentNode;
lvl=0;while(pp){if(pp.tagName&&pp.tagName=="UL"){lvl++;}pp=pp.parentNode;}
 tA[i].menulv=lvl;}}tD.onmouseout=menu_close;menu_open();}
}
function menu_trig(a){
 var b,t;if(document.menut){clearTimeout(document.menut);}document.menua=1;
b=(a.menusub)?'menu_show(':'menu_tg(';
 t='document.menut=setTimeout("'+b+a.menucl+')",160)';eval (t);
}
/*muestra los menus */
function menu_show(a,bp){
 var u,lv,oft,ofr,uw,uh,pp,aw,ah,adj,mR,mT,wW=0,
wH,w1,w2,w3,sct,pw,lc,pwv,xx=0,yy=0,wP=true;
 var iem=(navigator.appVersion.indexOf("MSIE 5")>-1)?true:false,dce=document.documentElement,dby=document.body;
document.menua=1;
 if(!bp){menu_tg(a);}u=menuct[a].menusub;
if(u.menuax&&u.menuax==1){return;}u.menuax=1;
lv=(menup[0]==1&&menuct[a].menulv==1)?true:false;
menuct[a].className=menuct[a].className.replace("menutrg","menuon");oft=parseInt(menup[3]);
ofr=parseInt(menup[4]);
 uw=u.offsetWidth;uh=u.offsetHeight;pp=menuct[a];aw=pp.offsetWidth;ah=pp.offsetHeight;while(pp){xx+=(pp.offsetLeft)?pp.offsetLeft:0;
 yy+=(pp.offsetTop)?pp.offsetTop:0;if(window.opera||navigator.userAgent.indexOf("Safari")>-1){
 if(menuct[a].menulv!=1&&pp.nodeName=="BODY"){yy-=(pp.offsetTop)?pp.offsetTop:0;}}pp=pp.offsetParent;}
 if(iem&&navigator.userAgent.indexOf("Mac")>-1){yy+=parseInt(dby.currentStyle.marginTop);}adj=parseInt((aw*ofr)/100);mR=(lv)?0:aw-adj;
 adj=parseInt((ah*oft)/100);mT=(lv)?0:(ah-adj)*-1;w3=dby.parentNode.scrollLeft;if(!w3){w3=dby.scrollLeft;}w3=(w3)?w3:0;
 if(dce&&dce.clientWidth){wW=dce.clientWidth+w3;}else if(dby){wW=dby.clientWidth+w3;}if(!wW){wW=0;wP=false;}wH=window.innerHeight;
 if(!wH){wH=dce.clientHeight;if(!wH||wH<=0){wH=dby.clientHeight;}}sct=dby.parentNode.scrollTop;if(!sct){sct=dby.scrollTop;if(!sct){
 sct=window.scrollY?window.scrollY:0;}}pw=xx+mR+uw;if(pw>wW&&wP){mR=uw*-1;mR+=10;if(lv){mR=(wW-xx)-uw;}}lc=xx+mR;if(lc<0){mR=xx*-1;}
 pw=yy+uh+ah+mT-sct;pwv=wH-pw;if(pwv<0){mT+=pwv;}u.style.marginLeft=mR+'px';u.style.marginTop=mT+'px';
 if(menup[2]==1){if(!iem){menu_anim(a,20);}}u.className="menushow";
}
/* oculta los menus */
function menu_hide(u){
 var i,tt,ua;u.menuax=0;u.className="menuhide";
ua=u.parentNode.firstChild;ua.className=ua.className.replace("menuon","menutrg");
}
function menu_tg(a,b){
 var i,u,tA,tU,pp;tA=menuct[a];pp=tA.parentNode;while(pp){if(pp.tagName=="UL"){break;}pp=pp.parentNode;}if(pp){
 tU=pp.getElementsByTagName("UL");for(i=tU.length-1;i>-1;i--){if(b!=1&&tA.menusub==tU[i]){continue;}else{menu_hide(tU[i]);}}}
}
function menu_close(evt){
 var pp,st,tS,m=true;evt=(evt)?evt:((event)?event:null);st=document.menua;if(st!=-1){if(evt){
 tS=(evt.relatedTarget)?evt.relatedTarget:evt.toElement;if(tS){pp=tS.parentNode;while(pp){if(pp&&pp.id&&pp.id=="menunav"){m=false;
 document.menua=1;break;}pp=pp.parentNode;}}if(m){document.menua=-1;if(document.menut){clearTimeout(document.menut);}
 document.menut=setTimeout("menu_clr()",360);}}}

}
function menu_clr(){
 var i,tU,tUU;document.menua=-1;tU=document.getElementById('menunav');if(tU){tUU=tU.getElementsByTagName("UL");if(tUU){
 for(i=tUU.length-1;i>-1;i--){menu_hide(tUU[i]);}}}
}
/* crea la animación */
function menu_anim(a,st){
 var g=menuct[a].menusub,sp=30,inc=20;st=(st>=100)?100:st;g.style.fontSize=st+"%";if(st<100){st+=inc;setTimeout("menu_anim("+a+","+st+")",sp);}
}
function menu_mark(){document.menuop=arguments;}
function menu_open(){
 var i,x,tA,op,pp,wH,tA,aU,r1,k=-1,kk=-1,mt=new Array(1,'','');if(document.menuop){mt=document.menuop;}op=mt[0];if(op<1){return;}
 tA=document.getElementById('menunav').getElementsByTagName("A");wH=window.location.href;r1=/index\.[\S]*/i;for(i=0;i<tA.length;i++){
 if(tA[i].href){aU=tA[i].href.replace(r1,'');if(op>0){if(tA[i].href==wH||aU==wH){k=i;kk=-1;break;}}if(op==2){if(tA[i].firstChild){
 if(tA[i].firstChild.nodeValue==mt[1]){kk=i;}}}if(op==3 && tA[i].href.indexOf(mt[1])>-1){kk=i;}if(op==4){for(x=1;x<mt.length;x+=2){
 if(wH.indexOf(mt[x])>-1){if(tA[i].firstChild&&tA[i].firstChild.data){if(tA[i].firstChild.data==mt[x+1]){kk=i;break;}}}}}}}k=(kk>k)?kk:k;
 if(k>-1){pp=tA[k].parentNode;while(pp){if(pp.nodeName=="LI"){pp.firstChild.className="menumark"+" "+pp.firstChild.className;}
 pp=pp.parentNode;}}
}

function limpiar_input(f) {
	f.value = "";
}

var popupStatus = 0;
var popupStatus3 = 0;
var popupStatus4 = 0;

function loadPopup1()
{
	//loads popup only if it is disabled
	if(popupStatus==0)
	{
		$("#backgroundPopup1").css({
			"opacity": "0.7"
		});
		$("#backgroundPopup1").fadeIn("slow");
		$("#popupContact1").fadeIn("slow");
		popupStatus = 1;
	}
}

function loadPopup2()
{
	//loads popup only if it is disabled
	if(popupStatus==0)
	{
		$("#backgroundPopup2").css({
			"opacity": "0.7"
		});
		$("#backgroundPopup2").fadeIn("slow");
		$("#popupContact2").fadeIn("slow");
		popupStatus = 1;
	}
}

function loadPopup3()
{
	//loads popup only if it is disabled
	if(popupStatus3==0)
	{
		$("#backgroundPopup3").css({
			"opacity": "0.7"
		});
		$("#backgroundPopup3").fadeIn("slow");
		$("#popupContact3").fadeIn("slow");
		popupStatus3 = 1;
	}
}
function loadPopup4()
{
	//loads popup only if it is disabled
	if(popupStatus4==0)
	{
		$("#backgroundPopup4").css({
			"opacity": "0.7"
		});
		$("#backgroundPopup4").fadeIn("slow");
		$("#popupContact4").fadeIn("slow");
		popupStatus4 = 1;
	}
}
function disablePopup1()
{
	//disables popup only if it is enabled
	if(popupStatus==1)
	{
		$("#backgroundPopup1").fadeOut("slow");
		$("#popupContact1").fadeOut("slow");
		popupStatus = 0;
	}
}

function disablePopup2()
{
	//disables popup only if it is enabled
	if(popupStatus==1)
	{
		$("#backgroundPopup2").fadeOut("slow");
		$("#popupContact2").fadeOut("slow");
		popupStatus = 0;
	}
}

function disablePopup3()
{
	//disables popup only if it is enabled
	if(popupStatus3==1)
	{
		$("#backgroundPopup3").fadeOut("slow");
		$("#popupContact3").fadeOut("slow");
		popupStatus3 = 0;
	}
}
function disablePopup4()
{
	//disables popup only if it is enabled
	if(popupStatus4==1)
	{
		$("#backgroundPopup4").fadeOut("slow");
		$("#popupContact4").fadeOut("slow");
		popupStatus4 = 0;
	}
}
function centerPopup1(IDN){
	$.ajax({
		url: '../../site/modulos/m_det_noticia.php?idn='+IDN,
	  success: function(data) {
		$('#contactArea1').html(data);
		
		var pagina = getWindowData();
		//request data for centering
		var windowWidth = document.documentElement.clientWidth;
		var windowHeight = document.documentElement.clientHeight;
		var popupHeight = $("#popupContact1").height();
		var popupWidth = $("#popupContact1").width();
		
		//centering
		$("#popupContact1").css({
			"position": "absolute",
			"top": (pagina[1]/2)-(popupHeight/2)+pagina[3]+"px",
			"left": (windowWidth/2)-(popupWidth/2) + "px"
		});
		
		//only need force for IE6
		$("#backgroundPopup1").css({
			"height": windowHeight
		});
		
		loadPopup1();	
		$("#backgroundPopup1").click(disablePopup1);	
		$("#popupContactClose1").click(disablePopup1);
	
	  }
	});
}

function centerPopup2(Idp){
	var pagina = getWindowData();
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupContact2").height();
	var popupWidth = $("#popupContact2").width();
	
	//centering
	$("#popupContact2").css({
		"position": "absolute",
		"top": (pagina[1]/2)-(popupHeight/2)+pagina[3]+"px",
		"left": (windowWidth/2)-(popupWidth/2) + "px"
	});
	
	Previo = "<div id='imagen_ampliada'><img src='../upload/productos/" + Idp + "'></div>";
	
	$("#contactArea2").html(Previo);
	//only need force for IE6
	
	$("#backgroundPopup2").css({
		"height": windowHeight
	});
	
	loadPopup2();
	$("#backgroundPopup2").click(disablePopup2);	
	$("#popupContactClose2").click(disablePopup2);

}

function centerPopup3(Ruta){
	var pagina = getWindowData();
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupContact3").height();
	var popupWidth = $("#popupContact3").width();
	
	//centering
	$("#popupContact3").css({
		"position": "absolute",
		"top": (pagina[1]/2)-(popupHeight/2)+pagina[3]+"px",
		"left": (windowWidth/2)-(popupWidth/2) + "px"
	});
	Previo = '<script type="text/javascript">';
	Previo = Previo + '$.metadata.setType("attr", "validate");';
	Previo = Previo + '$(document).ready(function() {';	
	Previo = Previo + '$("#amigo").validate();';
	Previo = Previo + '});';
	Previo = Previo + '</script>';
		
	Previo = Previo + '<form METHOD="POST" ACTION="#" name="QForm" id="amigo">';
	Previo = Previo + '<div id="dile_amigo" >';
    Previo = Previo + '<div id="texto_amigo_form">Tu nombre: </div>';
	Previo = Previo + '<div id="input_text_amigo">';
	Previo = Previo + '<input type="text" name="nombre_amigo" id="nombre_amigo" class="required" value="" size="25">';
	Previo = Previo + '</div>';
	//Previo = Previo + '</div>';
	//Previo = Previo + '<div id="dile_amigo">';
	Previo = Previo + '<div id="texto_amigo_form">Correo de tu amigo: </div>';
	Previo = Previo + '<div id="input_text_amigo">';
	Previo = Previo + '<input type="text" name="correo_amigo" id="correo_amigo" value="" class="required email" size="35">';
	Previo = Previo + '</div>';
	Previo = Previo + '</div>';
	Previo = Previo + '<div id="dile_amigo">';
	Previo = Previo + '<div id="texto_amigo_form">Tu Mensaje: </div>';
    Previo = Previo + '<div id="input_text_amigo">';
	Previo = Previo + '<textarea cols="27" rows="3" name="comentario_amigo" class="required"></textarea>';
	Previo = Previo + '</div>';
	Previo = Previo + '</div>';
	Previo = Previo + '<div id="botones_registro_amigo">';
	Previo = Previo + '<input type="submit" id="botones_form" value="Enviar" name="enviar"><input type="hidden" name="enviaramigo" value="1"><input type="hidden" name="enviaramigo_url" value="' + Ruta + '">';
	Previo = Previo + '</div>';
	Previo = Previo + '</form>';
	
	$("#contactArea3").html(Previo);
	//only need force for IE6
	
	$("#backgroundPopup3").css({
		"height": windowHeight
	});
	
	loadPopup3();
	$("#backgroundPopup3").click(disablePopup3);	
	$("#popupContactClose3").click(disablePopup3);
}

function centerPopup4(Idp){
	var pagina = getWindowData();
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupContact4").height();
	var popupWidth = $("#popupContact4").width();
	
	//centering
	$("#popupContact4").css({
		"position": "absolute",
		"top": (pagina[1]/2)-(popupHeight/2)+pagina[3]+"px",
		"left": (windowWidth/2)-(popupWidth/2) + "px"
	});
	
	Previo = "<div id='imagen_ampliada'><img src='../upload/" + Idp + "'></div>";
	
	$("#contactArea4").html(Previo);
	//only need force for IE6
	
	$("#backgroundPopup4").css({
		"height": windowHeight
	});
	
	loadPopup4();
	$("#backgroundPopup4").click(disablePopup4);	
	$("#popupContactClose4").click(disablePopup4);
}

function getWindowData(){
    var widthViewport,heightViewport,xScroll,yScroll,widthTotal,heightTotal;
    if (typeof window.innerWidth != 'undefined'){
        widthViewport= window.innerWidth-17;
        heightViewport= window.innerHeight-17;
    }else if(typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth !='undefined' && document.documentElement.clientWidth != 0){
        widthViewport=document.documentElement.clientWidth;
        heightViewport=document.documentElement.clientHeight;
    }else{
        widthViewport= document.getElementsByTagName('body')[0].clientWidth;
        heightViewport=document.getElementsByTagName('body')[0].clientHeight;
    }
    xScroll=self.pageXOffset || (document.documentElement.scrollLeft+document.body.scrollLeft);
    yScroll=self.pageYOffset || (document.documentElement.scrollTop+document.body.scrollTop);
    widthTotal=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth,widthViewport);
    heightTotal=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,heightViewport);
    return [widthViewport,heightViewport,xScroll,yScroll,widthTotal,heightTotal];
} 
