//JavaScript Document

var navegador = navigator.appName;

/* Hacemos Embed pero con chanchullo */
function creaEmbed(pelicula,ancho,alto) {
	cadena='<embed src="' + pelicula + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + ancho + '" height="' + alto + '" wmode="transparent"></embed>';
	document.write(cadena);
}

/* Le quita el borde al swf */
function miBorde(){
	theObjects = document.getElementsByTagName("object");
	for (var i = 0; i < theObjects.length; i++) {
		theObjects[i].outerHTML = theObjects[i].outerHTML;
	}
}


/* Muestra ID y oculta Class */
function mostrarID(identificador){
    oculta("submenu");
    document.getElementById(identificador).style.visibility="visible";
    var id=identificador;
    id.style.visibility="visible";
}

/* Oculta Class */
function oculta(clase){
    var menu=document.getElementById("menu");
    var misdivs=menu.getElementsByTagName("div");
    for(i=0; i<misdivs.length; i++){
    if(misdivs[i].className==clase) misdivs[i].style.visibility="hidden";
    }
}

	
/*Tamaño Fuente*/	
function fsize(size,unit,id){
	var vfontsize = document.getElementById(id);
	if(vfontsize){
		vfontsize.style.fontSize = size + unit;
	}
}
	
var textsize = 11;

function changetextsize(up){
	if(up){
		textsize = parseFloat(textsize)+3;
	}
	else{
		textsize =parseFloat(textsize)-3;
	}
}


function printpage() {
window.print();  
}

/*Random Div*/
function productoRandom(){
  var productoSmart=new Array()
  productoSmart[1]="addkeys"
  productoSmart[2]="aldion"
  productoSmart[3]="sharedzone"
  productoSmart[4]="smartdesk"
  productoSmart[5]="smartdesk"

  var ry=Math.floor(Math.random()*productoSmart.length)

  if (ry==0)
     ry=1
	 
	var random = productoSmart[ry];
	var titulo = random + "Title";
	
if ( random == "addkeys" ){ 
		var eltitulo = "Coordine y d&eacute; seguimiento a sus procesos de compra";
		var eltexto = "Sistema para automatizar todos los procedimientos que genera una orden de compra.";
		}
	
	else if ( random == "aldion" ){ 
		var eltitulo = "Seguridad y precisi&oacute;n";
		var eltexto = "Sistema para agilizar y eficientar la log&iacute;stica de distribuci&oacute;n a nivel interno.";
		}
	
	else if ( random == "sharedzone" ){ 
		var eltitulo = "Administra tus Espacios";
		var eltexto = "Gestor autom&aacute;tico del uso y reserva de instalaciones. <br />Obtenga mayor control sobre los horarios y actividades que se realicen en ella.";
		}
	
	else if ( random == "smartdesk" ){ 
		var eltitulo = "Optimiza el desempe&ntilde;o de tus recursos";
		var eltexto = "D&eacute; seguimiento preciso al cumplimiento de la planeaci&oacute;n general de su empresa o de cada proyecto individual.";
		}
	 
	
     document.write( "<a href=\"http://www."+random+".com.mx\" target=\"_blank\">"
		+"<img src=\"images/logos/"+random+".png\" title=\""+random+"\" alt=\""+random+"\" id=\"logoProducto\" /></a>"
		+"<div id=\"productos\" class=\""+random+"\" onmouseover=\"oculta('submenu');\">"
		+"<div id=\"intProductos\">"
		+"<div class=\"floatLeft\" style=\"width:344px;\">"
		+"<h2>"+eltitulo+"</h2>"
		+""+eltexto+""
		+"<br /><br /><a href=\"http://www."+random+".com.mx\" target=\"_blank\">ver m&aacute;s</a>"
		+"</div>"
		+"<div class=\"floatRight\" style=\"width:230px;\">"
		+"<h2>smartTools</h2>"
		+"<ul id=\"listaProductos\">"
		+"<li><a href=\"http://www.addkeys.com.mx\" target=\"_blank\">Addkeys</a></li>"
		+"<li><a href=\"http://www.aldion.com.mx\" target=\"_blank\">Aldion</a></li>"
		+"<li><a href=\"http://www.sharedzone.com.mx\" target=\"_blank\">Sharedzone</a></li>"
		+"<li><a href=\"http://www.smartdesk.com.mx\" target=\"_blank\">Smartdesk</a></li>"
		+"</ul>"
		+"</div>"
		+"</div>"
		+"<div id=\"tamanioFuente\"><a href=\"javascript:fsize(textsize,'px','main');\" onclick=\"changetextsize(1);\" id=\"mayus\" title=\"Aumentar Tamaño\">A</a><a href=\"javascript:fsize(textsize,'px','main');\" onclick=\"changetextsize(0);\" id=\"minus\" title=\"Disminuir Tamaño\">A</a></div>"
		+"</div>"
	)
}


/*Contacto*/
function elcontacto(){
     document.write( "<div id=\"popupcontent\"></div>"
		+"<div id=\"divInterior\">"
		+"<div id=\"contacto\">"
		+"<div id=\"logoSmart\"><a href=\"http://www.smartcomtec.com.mx\"><img src=\"images/logos/smart.png\" title=\"Smartcomtec\" alt=\"Smartcomtec\" id=\"topLogo\" /></a></div>"
		+"<h2 style=\"margin-top:-50px;margin-left:20px; position:relative;z-index:1000;\">Contacto</h2>"
		+"<div style=\"margin-top:30px; overflow:auto;\">"
		+"<form id=\"contform\" action=\"javascript: procesaForm('contform','contacto','content/contactoman.php');\" method='get'><table class=\"floatLeft\"><tr>"
		+"<td>Nombre</td><td><input type='text' name='nombre' /></td><td></td></tr><tr>"
		+"<td>Empresa</td><td><input type='text' name='empresa' /></td><td class=\"puntosContacto\" rowspan=\"5\"></td></tr><tr>"
		+"<td>Tel&eacute;fono</td><td><input type='text' name='telefono'/></td></tr><tr>"
		+"<td>Email</td><td><input type='text' name='email' /></td></tr><tr>"
		+"<td>Comentario</td><td><textarea name='comentario'></textarea></td></tr><tr>"
		+"<td>Dirigido a</td><td><select name='destinatario'><option value='1'>Atenci&oacute;n a Clientes</option><option value='2'>Ventas</option><option value='3'>Soporte</option><option value='4'>Directora</option></select></td><td></td></tr>"
		+"<tr><td></td><td><input type=\"submit\" value=\"Enviar\" class=\"enviar\" ></td><td></td></tr>"
		+"</table></form>"
		+"<div class=\"floatRight\" style=\"margin-right:25px;\"><h3>Ventas</h3>Nayeli Villar<br />5999-5533 ext.91101<h3>Soporte</h3>Fernando Cervantes<br />5999-5533 ext.91102<h3>Smartcomtec</h3>Norte 45 No.940-A<br />Col. Industrial Vallejo</div>"
		+"</div>"
		+"<div style=\"margin:auto; margin-top:15px; width:399px;\">"
		+"<iframe width='399' height='169' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='http://maps.google.com/maps/ms?ie=UTF8&amp;hq=&amp;hnear=Ciudad+de+M%C3%A9xico,+Distrito+Federal,+M%C3%A9xico&amp;hl=es&amp;msa=0&amp;ll=19.494276,-99.1594&amp;spn=0.006362,0.011973&amp;msid=101209377047705005837.00047f700f486518aede6&amp;output=embed'></iframe><br /><small>Ver <a href='http://maps.google.com/maps/ms?ie=UTF8&amp;hq=&amp;hnear=Ciudad+de+M%C3%A9xico,+Distrito+Federal,+M%C3%A9xico&amp;hl=es&amp;msa=0&amp;ll=19.494276,-99.1594&amp;spn=0.006362,0.011973&amp;msid=101209377047705005837.00047f700f486518aede6&amp;source=embed' style='color:#0000FF;text-align:left'>www.smartcomtec.com.mx</a> en un mapa m‡s grande</small>"
		+"</div>"
		+"</div>"
		+"<div id=\"botonCerrar\"><a href=\"#\" onclick=\"hidePopup('divInterior');\">Cerrar</a></div>"
		+"</div>"
	);
}


function elboletin(){
     document.write( "<div id=\"popupcontent\"></div>"
		+"<div id=\"divBoletin\">"
		+"<div id=\"contacto\">"
		+"<div id=\"interiorBoletin\">"
		
		+"<div id=\"logoSmart\"><a href=\"http://www.smartcomtec.com.mx\"><img src=\"images/logos/smart.png\" title=\"Smartcomtec\" alt=\"Smartcomtec\" id=\"topLogo\" /></a></div>"
		+"<h2 style=\"margin-top:-50px;margin-left:20px; position:relative;z-index:1000;\">Suscripci&oacute;n a boletines</h2>"
		+"<div style=\"margin-top:30px;\">"
				+"<form id=\"bolform\" action=\"javascript: procesaForm('bolform','interiorBoletin	','content/boletinesman.php');\" method='get'>"
				+"<table id=\"tablaBoletin\" style=\"margin-top:10px;\">"
						+"<tr><td>Nombre</td><td><input name='nombre' /></td></tr>"
						+"<tr><td>E-mail</td><td><input name='email' /></td></tr>"
						+"<tr><td></td><td><input type='submit' value='enviar' class=\"enviar\" /></td></tr>"

				+"</table>"
		+"</form>"
		+"</div>"
		+"</div>"
		+"</div>"
		+"<div id=\"botonCerrar\"><a href=\"#\" onclick=\"hidePopup('divBoletin');\">Cerrar</a></div>"
		+"</div>"
	);
}



function elloading(){
     document.write( "<div id=\"loading\" style=\"visibility:hidden; height:100px!important; width:200px!important; position:absolute; top:50%; left:50%; z-index:998; margin:-100px 0 0 -50px; background-image:url('images/general/loading.gif'); background-repeat:no-repeat!important;\"></div>"
	);
}

// cosa para firefox

function chaless(){
	var chales = document.getElementById("main");
	chales.style.position = "relative";
	chales.style.zindex = "1";
}


//Tamaño Ventana Popup
var baseText = null;

function showPopup(escogidots){
	var myWidth = 0, myHeight = 0;
	if ( typeof(window.innerWidth) == 'number'){
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
		eldivdeesto = document.getElementById("container");
		alturaDiv = eldivdeesto.offsetHeight;
		} 
	else if (document.documentElement&&(document.documentElement.clientWidth || document.documentElement.clientHeight)){
		//IE6+in'standardscompliantmode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
		eldivdeesto = document.getElementById("container");
		alturaDiv = eldivdeesto.offsetHeight;
		} 
	else if (document.body && (document.body.clientWidth || document.body.clientHeight)){
		//IE4compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
		eldivdeesto = document.getElementById("container");
		alturaDiv = eldivdeesto.offsetHeight;
		}

	var popUp = document.getElementById("popupcontent");
	
	popUp.style.top = "0px";
	popUp.style.left = "0px";
	popUp.style.width = myWidth + "px";
	popUp.style.height = alturaDiv + "px";
	
	var divOculto = document.getElementById("popupcontent");
	var divDos = document.getElementById(escogidots);
	var divTres = document.getElementById("loading");
	
	
	if (navegador=='Microsoft Internet Explorer') { 
		divOculto.style.filter = "alpha(opacity='0')";
		divOculto.style.visibility = "visible";
		setTimeout('ecsplourer1()',50);
		setTimeout('ecsplourer2()',100);
		setTimeout('ecsplourer3()',150);
		setTimeout('ecsplourer4()',200);
		setTimeout('ecsplourer5()',250);
		setTimeout("nowloading('"+escogidots+"');",260);
		//divDos.style.visibility="visible";
	}
	
	
	else {
		divOculto.style.opacity = ".0";
		setTimeout('opac1()',50);
		setTimeout('opac2()',100);
		setTimeout('opac3()',150);
		setTimeout('opac4()',200);
		setTimeout('opac5()',250);
		setTimeout("nowloading('"+escogidots+"');",260);
		divOculto.style.visibility="visible";
		//divDos.style.visibility="visible";
	}
 }	
 
 function nowloading(hey) {
	var popUpTres = document.getElementById("loading");
	popUpTres.style.visibility = "visible";
	setTimeout("apareceelotro('"+hey+"');",2000);
	}

function apareceelotro(ultimo) {
	var popUpDos = document.getElementById(ultimo);
	popUpDos.style.visibility = "visible";
	}


//Esconder el javascript Popup
function hidePopup(escogidots){
	var popUp = document.getElementById("popupcontent");
	var popUpDos = document.getElementById(escogidots);
	var popUpTres = document.getElementById("loading");
	popUp.style.visibility = "hidden";
	popUp.style.filter = "alpha(opacity='0')";
	popUpDos.style.visibility = "hidden";
	popUpTres.style.visibility = "hidden";
}

//Los pasos graduales
function opac1(){ var divOculto=document.getElementById("popupcontent"); divOculto.style.opacity=".12"; }
function opac2(){ var divOculto=document.getElementById("popupcontent"); divOculto.style.opacity=".24"; }
function opac3(){ var divOculto=document.getElementById("popupcontent"); divOculto.style.opacity=".36"; }
function opac4(){ var divOculto=document.getElementById("popupcontent"); divOculto.style.opacity=".48"; }
function opac5(){ var divOculto=document.getElementById("popupcontent"); divOculto.style.opacity=".60"; }

function ecsplourer1(){ var divOculto=document.getElementById("popupcontent"); divOculto.style.filter="alpha(opacity='12')"; }
function ecsplourer2(){ var divOculto=document.getElementById("popupcontent"); divOculto.style.filter="alpha(opacity='24')"; }
function ecsplourer3(){ var divOculto=document.getElementById("popupcontent"); divOculto.style.filter="alpha(opacity='36')"; }
function ecsplourer4(){ var divOculto=document.getElementById("popupcontent"); divOculto.style.filter="alpha(opacity='48')"; }
function ecsplourer5(){ var divOculto=document.getElementById("popupcontent"); divOculto.style.filter="alpha(opacity='60')"; }	


/* EL AJAX IMPROVISADO */
/*function AjaxRef(){
	HttpRef = false;
	if (window.XMLHttpRequest){
		HttpRef=new XMLHttpRequest;

		return HttpRef;
	}
	else if(window.ActiveXObject){
		try {
			HttpRef=new ActiveXObject("Microsoft.XMLHTTP");
			if (HttpRef){
				return HttpRef;
			}
		}catch (e){}
	}
}

function procesaForm(obj,contenedor,manejador){
	var campos=document.getElementById(obj);
	var tot=campos.length;
	var cadena="";
	for(var i=0;i<tot;i++){

		var nombre=campos.elements[i].name;
		var valor=campos.elements[i].value;
		if(i==0){
		cadena+=""+nombre+"="+valor;
		}else{
		cadena+="&"+nombre+"="+valor;
		
		}
	
	
	}

	//alert(contenedor+"desde la funcion procesaform");

	llamar(manejador,contenedor,cadena);

}

function llamar(ruta, contenedor,variables){
	peticion=AjaxRef();
	if (peticion){
		URL=ruta;
		peticion.open("POST", URL, true);
		peticion.onreadystatechange=function (){
			asignardatos(contenedor);
		};
		peticion.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		peticion.send(variables);
		
	}
}


function asignardatos(contenedor){
	
	if(peticion.readyState==3){		
		var midiv=document.getElementById(contenedor);
		midiv.innerHTML="<h2>Cargando <br/>Espere un momento</h2>";
		

	}
	if(peticion.readyState==4){		
		var respuesta=peticion.responseText;
		var midiv=document.getElementById(contenedor);
		midiv.innerHTML=respuesta;
		

	}
}*/


/* EL AJAX IMPROVISADO */
function AjaxRef(){
	HttpRef = false;
	if (window.XMLHttpRequest){
		HttpRef=new XMLHttpRequest;

		return HttpRef;
	}
	else if(window.ActiveXObject){
		try {
			HttpRef=new ActiveXObject("Microsoft.XMLHTTP");
			if (HttpRef){
				return HttpRef;
			}
		}catch (e){}
	}
}

function procesaForm(obj,contenedor,manejador){
	var campos=document.getElementById(obj);
	var tot=campos.length;
	var cadena="";
	for(var i=0;i<tot;i++){

		var nombre=campos.elements[i].name;
		var valor=campos.elements[i].value;
		if(i==0){
		cadena+=""+nombre+"="+valor;
		}else{
		cadena+="&"+nombre+"="+valor;
		
		}
	
	
	}

	//alert(contenedor+"desde la funcion procesaform");

	llamar(manejador,contenedor,cadena);

}

function llamar(ruta, contenedor,variables){
	peticion=AjaxRef();
	if (peticion){
		URL=ruta;
		peticion.open("POST", URL, true);
		peticion.onreadystatechange=function (){
			asignardatos(contenedor);
		};
		peticion.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		peticion.send(variables);
		
	}
}


function asignardatos(contenedor){
	
	if(peticion.readyState==3){		
		var midiv=document.getElementById(contenedor);
		midiv.innerHTML="<h2>Cargando <br/>Espere un momento</h2>";
		

	}
	if(peticion.readyState==4){		
		var respuesta=peticion.responseText;
		var midiv=document.getElementById(contenedor);
		midiv.innerHTML=respuesta;
		showLightBox(contenedor);
		correctPNG();

	}
}

function llamarSelf(ruta, contenedor, variables){
	
	peticion=AjaxRef();
	if (peticion){
		URL=ruta;
		peticion.open("POST", URL, true);
		peticion.onreadystatechange=function (){
			asignardatosSelf(contenedor);
		};
		peticion.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		peticion.send(variables);
		
	}
}

function remplasarImagen(i){
	
		var imagen = document.getElementById('ImagenDetalle');
		imagen.src = i;
		//alert (i);
	
	}

function asignardatosSelf(contenedor){
	
	if(peticion.readyState==3){		
		var midiv=document.getElementById(contenedor);
		midiv.innerHTML="<h2>Cargando <br/>Espere un momento</h2>";
		

	}
	if(peticion.readyState==4){		
		var respuesta=peticion.responseText;
		var midiv=document.getElementById(contenedor);
		midiv.innerHTML=respuesta;
	}
}









function divscription(info){
	var mensajediv=document.getElementById(info);
	if(mensajediv.style.visibility=="visible"){ mensajediv.style.visibility="hidden";}
	else{ mensajediv.style.visibility="visible"; mensajediv.style.opacity=".9";}
}	
