var minAncho = 1000;
var minAlto = 495;

var winName = "titulo";
var win = null;

function AbreN( theURL, ancho, alto )
{
    var h = (screen.width-ancho)/2;
    var v = (screen.height-alto)/2;
    var windowprops = "top=0,left=0,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes, resizable=no,width="+ancho+",height="+alto+",left="+h+", top="+v;
    
    if (win)
    {
        win.close();
    }
    
    win = window.open(theURL, winName, windowprops);
}

function Actualiza ()
{
    w = document.getElementById ('flash');
    ancho = alto = 0;
    if (typeof (window.innerWidth) == 'number') {
        ancho = window.innerWidth;
        alto = window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        ancho = document.documentElement.clientWidth;
        alto = document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        ancho = document.body.clientWidth;
        alto = document.body.clientHeight;
    }
    w.style.width = ancho < minAncho ? minAncho + "px" : "100%";
    w.style.height = alto < minAlto ? minAlto + "px" : "100%";
}

function CambiaOpacidad( cual, cuanto )
{
	$("#"+cual ).stop().animate( { opacity: cuanto }, 200 );
}

function Inicia(ancho, alto, img, ver)
{
    if (ver==0) {
        w = document.getElementById ('noFlash');
        w.innerHTML = "<img src=\""+img+"\" alt=\"logotipo\" border=\"0\"><br /><br />" +
            "Necesitas flash player para ver esta p&aacute;gina. " +
            "Desc&aacute;rgalo desde <a href=\"http://www.adobe.com/es/products/flashplayer/\" " +
            "target=\"_blank\">adobe.com</a>.<br>Need flash player to view this page. Please download it in " +
            "<a href=\"http://www.adobe.com/products/flashplayer/\" target=\"_blank\">" +
            "adobe.com</a>.";
    }
   
    minAncho = ancho;
    minAlto = alto;
    window.onresize=function(){Actualiza ();}
    Actualiza();
}


function CambiaImg( idElemento, imagen )
{
    document.getElementById( idElemento ).src = imagen;
}


function CmpIE()
{
	if( navigator.appName == "Microsoft Internet Explorer" )
	{
		version = parseFloat( navigator.appVersion.split( "MSIE" )[ 1 ] );
		
		if( version < 8 )
		{
			document.getElementById( 'avisoIE' ).innerHTML = "<img src=\"imagenes/error.png\" ><b>Su Internet Explorer est&aacute; desactualizado.</b><br>Para lograr la mejor experiencia posible usando nuestro sitio web y <b>evitar problemas de seguridad</b>, le recomendamos actualizar a una nueva <a href=\"http://www.microsoft.com/spain/windows/internet-explorer/\" target=\"_blank\" style=\"color: #333\" >versi&oacute;n de Internet Explorer</a>.";
			document.getElementById( 'avisoIE' ).className = "avisoJS";
		}
	}
}


var timeout = null;
var increment = 30;
var speed = 10;

function goto_anchor_up(name) {
	clearTimeout(timeout);
	var anchor = document.getElementById(name);
	var container = document.getElementById("cabecera");
	var ot = anchor.offsetTop;
	var st = container.scrollTop;
	if(st < ot) {
		container.scrollTop += (((st + increment) > ot)? (ot - st): increment);
		timeout = setTimeout("goto_anchor_up('" + name + "');", speed);
	}
}

function goto_anchor_down(name) {
	clearTimeout(timeout);
	var anchor = document.getElementById(name);
	var container = document.getElementById("cabecera");
	var ot = anchor.offsetTop;
	var st = container.scrollTop;
	if(st > ot) {
		container.scrollTop -= (((st - increment) < ot)? (st - ot): increment);
		timeout = setTimeout("goto_anchor_down('" + name + "');", speed);
	}
}

function goto_anchor(name) {
	clearTimeout(timeout);
	var ot = document.getElementById(name).offsetTop;
	var st = document.getElementById("cabecera").scrollTop;
	if(st < ot) {
		timeout = setTimeout("goto_anchor_up('" + name + "');", speed);
	} else if(st > ot) {
		timeout = setTimeout("goto_anchor_down('" + name + "');", speed);
	}
	return false;
}

function FormuContacto( error1, error2)
{
	var campo1 = document.getElementById( 'nombre' ).value;
	var campo2 = document.getElementById( 'ciudad' ).value;
	var campo3 = document.getElementById( 'pais' ).value;
	var campo4 = document.getElementById( 'email' ).value;
	var campo5 = document.getElementById( 'asunto' ).value;
	var campo6 = document.getElementById( 'consulta' ).value;
	
	var tipo = document.getElementById( 'tipoConsulta' ).value;
	var campoTipo = document.getElementById( 'empresa' ).value;
	
	
	if(tipo =="empresa" && campoTipo == "") {
		alert( error1 );
		return false;
	}
	
	if( campo1 == "" || campo2 == "" || campo3 == "" || campo4 == "" || campo5 == "" || campo6 == "" || campo7 == "")
	{
		alert( error1 );
		return false;
	}
	else if( campo4.length <  8 || campo4.indexOf('@',0)==-1 || campo4.indexOf('@',0)==0 || campo4.indexOf('.',0)==-1 || campo4.indexOf('.',0)==0 )
	{
		alert( error2 );
		return false;
	}
	else
	{
		return true;
	}
}

function Limpia()
{
	document.getElementById( 'nombre' ).value = "";
	document.getElementById( 'email' ).value = "";
	document.getElementById( 'asunto' ).value = "";
	document.getElementById( 'consulta' ).value = "";
	document.getElementById( 'empresa' ).value = "";
	document.getElementById( 'ciudad' ).value = "";
	document.getElementById( 'pais' ).value = "";
	
}


//CAMBIO DE NOTICIAS...

function CambiaNoticia( estado )
{
	if( estado == "over" )
	{
		$(".tituloNoticia" + numero ).stop().animate( { backgroundColor: "#EF4611" }, 200 );
	}
	else
	{
		$(".tituloNoticia" + numero ).stop().animate( { backgroundColor: "#0492d0" }, 200 );
	}
}

