// Realizado por Josu Mora Urea
// funciones de inicio
// pintor digital, s.a. de c.v.
// fecha creacion 24-Agosto-2009
// ultima fecha de modificacion: 24-Agosto-2009

	function getScrollXY() {
	  var scrOfX = 0, scrOfY = 0;
	  if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
		scrOfY = window.pageYOffset;
		scrOfX = window.pageXOffset;
	  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
		scrOfY = document.body.scrollTop;
		scrOfX = document.body.scrollLeft;
	  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
		scrOfX = document.documentElement.scrollLeft;
	  }
	  return [ scrOfX, scrOfY ];
	}

	function putScrollXY(scrOfX,scrOfY) {
	  //var scrOfX = 0, scrOfY = 0;
	  if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
		window.pageYOffset = scrOfY;
		window.pageXOffset = scrOfX;
	  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
		document.body.scrollTop = scrOfY;
		document.body.scrollLeft = scrOfX;
	  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
		document.documentElement.scrollTop = scrOfY;
		document.documentElement.scrollLeft = scrOfX;
	  }
	  //return [ scrOfX, scrOfY ];
	}

	function getposOffset(what, offsettype){
		var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
		var parentEl=what.offsetParent;
	
		while (parentEl!=null){
			totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
			parentEl=parentEl.offsetParent;
		}
		//alert("entro axxxx "+totaloffset);
		
		return totaloffset;
	}
	
	function b_mo(obj){
		var ancho = obj.clientWidth;
		var ancho2 = ancho*2;
		if (obj.style.backgroundPosition.indexOf(''+ancho2)==-1){
				obj.style.backgroundPosition = '-'+ancho+'px 0px';
				//04/02/2009 deshabilitar texto blanco.
				//obj.style.color = 'white';
				//alert(ancho+"////"+ancho2+"/////"+obj.style.backgroundPosition);
			}
				//25/may/2008
				//pl2(obj,1);
	}

	function b_mt(obj){
		var ancho2 = obj.clientWidth * 2;
		if (obj.style.backgroundPosition.indexOf(''+ancho2)==-1){
				obj.style.backgroundPosition = '0px 0px';
				obj.style.color = document.body.style.color;
		}
				//25/may/2008
				//pl2(obj,0);
	}
	
	function b_mcg(obj){
		var objs = obj.parentNode.getElementsByTagName("*");
		//alert(objs.length);
		for (var x=0;x<objs.length;x++){
			obj.parentNode.childNodes[x].style.backgroundPosition = '0px 0px';
		}
		//obj.style.backgroundPosition = '-140px 0';
		var xancho = obj.clientWidth * 2;
		//alert(xancho);
		obj.style.backgroundPosition = '-'+xancho+'px 0px';
	}
	
	function b_mc(obj,ind){
		//if(parseInt(ind)>=5 && parseInt(ind)<=9){
			//window.location = 'http://192.168.2.49/2009/13/index.php?hj='+ind;
		//}else{
			
		if(parseInt(ind)==6){
			//sistema...
			//var w1 = window.open('index_sistema.php','','fullscreen=yes,scrollbars=1,resizable=1');
			//convertir de objeto a cadena
			var xt = myJSON.stringify(iusuario);
			xt = xt.replace(/"/g,"'"); //PARA QUE NO FALLE EL iexplorer
			//alert(xt);
			var w1 = window.open('index_sistema.php?iusuario='+xt,'sistema','fullscreen=1,scrollbars=1,resizable=1,location=0,menubar=0,status=1,toolbar=1');
			//w1.blur();
		}else if(parseInt(ind)==5){
			//nada
			//alert("nada "+parseInt(ind));
		}else{
			
			
			
			menuid=ind;
			productoid=0;
			detalle_accesar='';
			detalle_cotizacion='';
			enviamensaje='';
			val_dinamicos();
			/*
			document.fmenu.menuid.value=ind;
			document.fmenu.productoid.value=0;
			document.fmenu.detalle_accesar.value='';
			*/
		//function b_text(ind){
			//b_mcg(obj);		
			//determina la capa...
			//var capas = Array("home","productos","promociones","europrint","franquicias","ftp","contacto");
			//var capas = Array("home","productos","promociones","promociones","promociones","acceso","franquicias","europrint","ftp","contacto");
			//alert(capas[ind]);
			//barra2(capas[ind]);
			document.fmenu.submit();
		};
	}


function val_dinamicos(){
	document.fmenu.menuid.value=menuid;
	document.fmenu.productoid.value=productoid;
	document.fmenu.detalle_accesar.value=detalle_accesar;
	document.fmenu.detalle_cotizacion.value=detalle_cotizacion;
	document.fmenu.usuario_id.value=usuario_id;
	document.fmenu.usuario_nombre.value=usuario_nombre;
	document.fmenu.enviamensaje.value=enviamensaje;
	document.fmenu.izq.value=izq;
	document.fmenu.arr.value=arr;
};


function termina_carga(){
	//alert(document.fmenu.menuid.value+"/////"+document.fmenu.productoid.value+"//////javascript////////"+menuid+"////"+productoid);
			//if(parseInt(document.fmenu.menuid.value)==7){
				/*
			if(parseInt(menuid)==7){
				//euromail...
				window.location.replace('/webmail/roundcubemail-0.2.2/');
			}
	*/
	/*
			if(parseInt(menuid)==6){
				//sistema...
				//window.location.replace('/webmail/roundcubemail-0.2.2/');
				var w1 = window.open('/index.php','','fullscreen=yes,scrollbars=1,resizable=1');
				//w1.blur();
			}
	*/
			//var iobj = document.getElementById("m"+document.fmenu.menuid.value);
			var iobj = document.getElementById("m"+menuid);
			var xancho = iobj.clientWidth * 2;
			//alert(xancho);
			iobj.style.backgroundPosition = '-'+xancho+'px 0px';
			/*
			if(typeof(sistema_pasa)!='undefined'){
			//alert("entro a renvio "+typeof(sistema_pasa));
				if(parseInt(sistema_pasa)==1){
					window.location.replace('/2009/13/sistema.php');;
				};
				if(parseInt(sistema_pasa)==2){
					window.location.replace('/2009/13/');;
				};
				if(parseInt(sistema_pasa)==9){
					alert('tu password\nes incorrecto\nvuelve a intentar\ncheca minusculas y mayusculas.');
				};
			};
			*/
			/*
			alert("entro aqui "+(typeof(iusuario.usuario)=='string'));
			if(typeof(iusuario.usuario)=='string'){
			alert("entro aqui "+iusuario.usuario);
				document.getElementById('usuario_texto').innerHTML = 'hola '+iusuario.usuario+',<br/>gracias por cotizar con nosotros';
			};
			*/
			
			//if(document.fmenu.detalle_accesar.value=='1'){
			if(parseInt(detalle_accesar)==1){
				var aposicion = getScrollXY();
				//alert("entro "+aposicion[0]+"/////"+aposicion[1]);
				//putScrollXY(aposicion[0],aposicion[1]+400);
				window.scrollTo(aposicion[0],aposicion[1]+250);
			};
	
}



function producto(ind){
	productoid=ind;
	detalle_accesar='';
	detalle_cotizacion='';
	enviamensaje='';
	val_dinamicos();
	/*
	document.fmenu.productoid.value=ind;
	document.fmenu.menuid.value=menuid;
	*/
	document.fmenu.submit();
}

function irAccesar(){
	val_dinamicos();
	document.fmenu.xpass.value = document.xacc.xpass.value;
	document.fmenu.submit();
}

function irRegistrar(){
	val_dinamicos();
	document.fmenu.xpass.value = '';
	document.fmenu.email.value   = document.form1.email.value;
	document.fmenu.nombre.value  = document.form1.nombre.value;
	document.fmenu.empresa.value = document.form1.empresa.value;
	//alert("entro registrar3");
	document.fmenu.tel.value     = document.form1.tel.value;
	document.fmenu.cd.value      = document.form1.cd.value;
	document.fmenu.edo.value     = document.form1.edo.value;
	document.fmenu.pais.value    = document.form1.pais.value;
	//alert(document.fmenu.menuid.value+"/////"+document.fmenu.productoid.value+"//////javascript////////"+menuid+"////"+productoid);
	document.fmenu.submit();
}

function tmo(obj){
	//obj.style.color = "#008000";//color verde
	obj.style.color = "#d14f2a";//color naranja
	var opostit = document.getElementById("postit");
	var pizq = parseInt(getposOffset(obj, 'left')+20);
	var parr = parseInt(getposOffset(obj, 'top')+30);
	//alert(pizq+"///"+parr);
	
	opostit.style.top = parr+"px"; 
	opostit.style.left = pizq+"px"; 
	opostit.style.visibility = "visible";
	
}

function tmt(obj){
	//obj.style.color = "#464647";//color gris casi negro..
	//obj.style.color = "#FFFFFF";//color gris casi negro..
	obj.style.color = "#000000";//color gris casi negro..
	var opostit = document.getElementById("postit");
	opostit.style.visibility = "hidden";
}

function gcotiza(obj,cotizacion){
	//document.fmenu.detalle_cotizacion.value=cotizacion;
	detalle_cotizacion=cotizacion;
	//if(document.fmenu.usuario_id.value==''){
	if(usuario_id==''){
		//alert("no esta registrado");
		//document.fmenu.detalle_accesar.value='1';
		detalle_accesar='1';
		
		//document.fmenu.izq.value = parseInt(getposOffset(obj, 'left'));
		var xobj = document.getElementById("areatotal");
		//document.fmenu.izq.value = parseInt(getposOffset(xobj, 'left'));
		//document.fmenu.arr.value = parseInt(getposOffset(obj, 'top')+60);
		izq = parseInt(getposOffset(xobj, 'left'));
		arr = parseInt(getposOffset(obj, 'top')+60);
		/*
		var aposicion = getScrollXY();
		document.fmenu.sizq.value = aposicion[0];
		document.fmenu.sarr.value = aposicion[1];
		*/
		
	};
	//alert(document.fmenu.menuid.value+"/////"+document.fmenu.productoid.value+"//////javascript////////"+menuid+"////"+productoid);
	//document.fmenu.menuid.value = menuid;
	//document.fmenu.productoid.value = productoid;
	val_dinamicos();
	//alert(document.fmenu.menuid.value+"/////"+document.fmenu.productoid.value+"//////javascript////////"+menuid+"////"+productoid);
	document.fmenu.submit();
}

function ligaftp(opcion){
	if(opcion==1){
		window.open('http://sourceforge.net/project/downloading.php?groupname=filezilla&filename=FileZilla_3.0.11_win32-setup.exe&use_mirror=internap','','fullscreen=no');
	}
	if(opcion==2){
		window.open('http://update.cyberduck.ch/Cyberduck-3.0.1.dmg','','fullscreen=no');
	}
	if(opcion==3){
		window.open('http://fetchsoftworks.com/mdownload.php?filename=Fetch_5.3.dmg','','fullscreen=no');
	}
}



function env_mensaje(obj){
	//document.fmenu.enviamensaje.value = '1';
	enviamensaje = '1';
	val_dinamicos();
	document.fmenu.c_correo.value   = document.fcontacto.correo.value;
	document.fmenu.c_nombre.value  = document.fcontacto.nombre.value;
	document.fmenu.c_telefono.value  = document.fcontacto.telefono.value;
	document.fmenu.c_mensaje.value = document.fcontacto.mensaje.value;
	document.fmenu.submit();
}

function switch_contacto(obj,ventana){
	obj.style.backgroundPosition = '0px 0px';
	
	if(ventana==1){
		document.getElementById("base_index").style.display = "block";
		document.getElementById("contacto_index").style.display = "none";
	}
	if(ventana==2){
		document.getElementById("base_index").style.display = "none";
		document.getElementById("contacto_index").style.display = "block";
		/*
			menuid=9;
			productoid=0;
			detalle_accesar='';
			detalle_cotizacion='';
			enviamensaje='';
			val_dinamicos();
			document.fmenu.submit();
			*/
	};
};




function tmo2(obj){
	//alert("paso aqui");
	var pariente = obj.offsetParent;
	pariente.bgColor = "#d6e0f1";
	//alert(pariente.innerHTML);
	pariente.style.background ="url(des2009/images/cotizar.png) top left no-repeat";
	//alert(pariente.style.background);
}

function tmt2(obj){
	//alert("paso aqui");
	var pariente = obj.offsetParent;
	pariente.bgColor = "";
	//alert(pariente.innerHTML);
	pariente.style.background ="";
}

function cancelar_subirarchivo(){
	alert("cancelar subir archivo");
}

