

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}


//positionIt = function() {
function positionIt() {
	if( document.getElementById ) {
		// Get a reference to divCentrado and measure its width and height.
		var div = document.getElementById( "contenedor" );
		var divWidth = div.offsetWidth ? div.offsetWidth : div.style.width ? parseInt( div.style.width ) : 0;
		var divHeight = div.offsetHeight ? div.offsetHeight :  div.style.height ? parseInt( div.style.height ) : 0;
		
		// Calculating setX and setX so the div will be centered in the viewport.
		var setX = ( getViewportWidth() - divWidth ) / 2;
		var setY = ( getViewportHeight() - divHeight ) / 2;

		// If setX or setY have become smaller than 0, make them 0.
		if( setX < 0 ) setX = 0;
		if( setY < 0 ) setY = 0;
		
		// Position the div in the center of the page and make it visible.
		div.style.left = setX + "px";
		div.style.top = setY + "px";
		div.style.visibility = "visible";
		
		var ma = document.getElementById("menuA");
		var mb = document.getElementById("menuB");
		var mc = document.getElementById("menuC");
		var md = document.getElementById("menuD");

		ma.style.left = (setX+10) + "px";
		mb.style.left = (setX+10) + "px";
		mc.style.left = (setX+10) + "px";
		md.style.left = (setX+10) + "px";
		
		ma.style.top = "220px";
		mb.style.top = "220px";
		mc.style.top = "220px";
		md.style.top = "220px";



		//alert("setX");

	}
};



getViewportWidth = function() {
	var width = 0;
	if( document.documentElement && document.documentElement.clientWidth ) {
		width = document.documentElement.clientWidth;
	}
	else if( document.body && document.body.clientWidth ) {
		width = document.body.clientWidth;
	}
	else if( window.innerWidth ) {
		width = window.innerWidth - 18;
	}
	return width;
};

getViewportHeight = function() {
	var height = 0;
	if( document.documentElement && document.documentElement.clientHeight ) {
		height = document.documentElement.clientHeight;
	}
	else if( document.body && document.body.clientHeight ) {
		height = document.body.clientHeight;
	}
	else if( window.innerHeight ) {
		height = window.innerHeight - 18;
	}
	return height;
};


// --------------------------------


function vacio(q) {
        for ( i = 0; i < q.length; i++ ) {
                if ( q.charAt(i) != " " ) {
                        return true
                }
        }
        return false
}

function validar()
{
    if (vacio(document.frm_presupuesto.telefono.value) == false || vacio(document.frm_presupuesto.persona_contacto.value) == false) {
	    alert("Atención: Debe ingresar teléfono y persona de contacto.");
	    return false;
	}
		else
	{
		document.frm_presupuesto.submit();
	}
}

	function DisplayElement ( elt, displayValue ) {
		elt = document.getElementById( elt );
		elt.style.display = displayValue;
	}

	function MostrarFormImpresora () {
	if (document.forms.length==1 && document.forms[0].name=='frm_presupuesto')
	{
		v_formulario=document.frm_presupuesto
		v_valor_tipo=v_formulario.frm_pto_tipo_producto.value

		if (v_valor_tipo=="TARJETAS PVC")
		{
			DisplayElement ( "marca", "none" )
			DisplayElement ( "articulo", "none" )
			DisplayElement ( "grosor", "block" )
			DisplayElement ( "unidades", "block" )
			DisplayElement ( "nro_tintas", "block" )
			DisplayElement ( "tinta_especial", "block" )
			DisplayElement ( "personalizacion", "block" )
			DisplayElement ( "foto", "block" )
			DisplayElement ( "banda_magnetica", "block" )
			DisplayElement ( "codigo_barras", "block" )
			DisplayElement ( "paneles_esp", "block" )
			DisplayElement ( "agujero", "block" )
		}
		else if (v_valor_tipo=="IMPRESORAS DE TARJETAS")
		{
				DisplayElement ( "marca", "block" )
				DisplayElement ( "articulo", "none" )
				DisplayElement ( "grosor", "none" )
				DisplayElement ( "unidades", "none" )
				DisplayElement ( "nro_tintas", "none" )
				DisplayElement ( "tinta_especial", "none" )
				DisplayElement ( "personalizacion", "none" )
				DisplayElement ( "foto", "none" )
				DisplayElement ( "banda_magnetica", "none" )
				DisplayElement ( "codigo_barras", "none" )
				DisplayElement ( "paneles_esp", "none" )
				DisplayElement ( "agujero", "none" )
		}
		else
		{
				DisplayElement ( "marca", "none" )
				DisplayElement ( "articulo", "block" )
				DisplayElement ( "grosor", "none" )
				DisplayElement ( "unidades", "none" )
				DisplayElement ( "nro_tintas", "none" )
				DisplayElement ( "tinta_especial", "none" )
				DisplayElement ( "personalizacion", "none" )
				DisplayElement ( "foto", "none" )
				DisplayElement ( "banda_magnetica", "none" )
				DisplayElement ( "codigo_barras", "none" )
				DisplayElement ( "paneles_esp", "none" )
				DisplayElement ( "agujero", "none" )
		}
	}
	}

	function varios () {
        positionIt();
        MostrarFormImpresora();
	}

// --------------------------------


//window.onload = positionIt;
window.onload = varios;
window.onresize = positionIt;

