// VARIABLES ////////////////////////////////////////////////////////////////////////////////////////

var windowId = "";

// FUNCIONS /////////////////////////////////////////////////////////////////////////////////////////

function initWinParams (winWidth, winHeight, isResizable, isScrollable) {
	xDist = parseInt ((screen.width - winWidth) /2);
	yDist = parseInt ((screen.height - winHeight) /2);
	winCfg = "width="+winWidth+",height="+winHeight+",left="+xDist+",top="+yDist+",resizable="+isResizable+",scrollbars="+isScrollable+",directories=no,dependent=no,alwaysRaised=yes,location=no,menubar=no,status=no,titlebar=no,toolbar=no";

	return winCfg;
}

function openWin (targetUrl, winWidth, winHeight, isResizable, isScrollable) {
	if (windowId.closed == false) {
		windowId.close ();
	}

	windowId = window.open(targetUrl, 'guasch', initWinParams (winWidth, winHeight, isResizable, isScrollable));
}

function confirmDelete (link) {
	if (confirm("Desea eliminar este registro?")) {
		location = link;
	}	
}

//FLASH /////////////////////////////////////////////////////////////////////////////////////////
//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}
/////////* inicio formulario contacto */
	// MOSTRAR FORMULARIO
	if(navigator.appName == "Netscape"){
		function mostrar_ocultar(){
			if(urlActual().match("contacto") != null || urlActual().match("informacion-de-contacto") != null || urlActual().match("ayuda-y-soporte") != null || urlActual().match("diseno-web") != null || urlActual().match("dominios-tel") != null){
				cargarVacio();
				document.location.href="/corporativo/contacto";
				return;
			}
			
			maxInterval=0;
			minInterval=0;
			if(document.getElementById('micontactoform').style.display == "none"){
				opfx = 0.1;
				document.getElementById('micontactoform').style.opacity = opfx;
				document.getElementById('micontactoform').style.display = "";
				maxInterval=window.setInterval("maxOpacidad()", 100);
			}else{
				opfx = 1;
				minInterval=window.setInterval("minOpacidad()", 100);
			}
			
		}
		function maxOpacidad(){
			if(opfx <= 1){
				opfx = opfx + 0.25;
				document.getElementById('micontactoform').style.opacity = opfx;
			}else{
				maxInterval=window.clearInterval(maxInterval);
			}
		}
		function minOpacidad(){
			if(opfx >= 0){
				opfx = opfx - 0.25;
				document.getElementById('micontactoform').style.opacity = opfx;
			}else{
				minInterval=window.clearInterval(minInterval);
				document.getElementById('micontactoform').style.display="none";
			}
		}
	} // if Netscape
	if(navigator.appName == "Microsoft Internet Explorer"){
		function mostrar_ocultar(){
			if(urlActual().match("contacto") != null || urlActual().match("informacion-de-contacto") != null || urlActual().match("ayuda-y-soporte") != null || urlActual().match("diseno-web") != null || urlActual().match("dominios-tel") != null){
				cargarVacio();
				document.location.href="/corporativo/contacto";
				return;
			}

			cadena_version = navigator.appVersion;
			pos_version = navigator.appVersion.indexOf("MSIE");
			cadena_version = cadena_version.substr(pos_version,8);
			version = cadena_version.substr(5,3);
			if(version == "8.0"){ // sin efecto Alpha // Explorer 8.0
				if(document.getElementById('micontactoform').style.display == "none"){
					document.getElementById('micontactoform').style.display = "";
				}else{
					document.getElementById('micontactoform').style.display = "none";
				}
			}else{
				maxInterval=0;
				minInterval=0;
				if(document.getElementById('micontactoform').style.display == "none"){
					opie = 10;
					document.getElementById("micontactoform").filters.item("DXImageTransform.Microsoft.Alpha").Opacity = opie;
					document.getElementById('micontactoform').style.display = "";
					maxInterval=window.setInterval("maxOpacidad()", 100);
				}else{
					opie = 100;
					minInterval=window.setInterval("minOpacidad()", 100);
				}
			}
		}
		function maxOpacidad(){
			if(opie <= 100){
				opie = opie + 25;
				document.getElementById("micontactoform").filters.item("DXImageTransform.Microsoft.Alpha").Opacity = opie;
			}else{
				maxInterval=window.clearInterval(maxInterval);
			}
		}
		function minOpacidad(){
			if(opie >= 0){
				opie = opie - 25;
				document.getElementById("micontactoform").filters.item("DXImageTransform.Microsoft.Alpha").Opacity = opie;
			}else{
				minInterval=window.clearInterval(minInterval);
				document.getElementById('micontactoform').style.display="none";
			}
		}
	} // Explorer 6.0 - 7.0
	// FIN MOSTRAR FORMULARIO
	
	// rollovers campos formulario
	function over(id){
		document.getElementById(id).style.background="#fff";
		document.getElementById(id).style.color="#3e8313";
	}
	function out(id){
		document.getElementById(id).style.background="#e0e0e0";
		document.getElementById(id).style.color="#666";
	}
	// fin rollovers campos formulario
	
	// vaciar campos al pulsar en ellos y llenarlos al soltarlos vacios
	function vaciar(id){
		switch (id){
			case "nombre":
				if(document.getElementById(id).value == "Nombre y Apellidos...")document.getElementById(id).value="";
				break;
			case "email":
				if(document.getElementById(id).value == "Email...")document.getElementById(id).value="";
				break;
			case "telefono":
				if(document.getElementById(id).value == "Telefono...")document.getElementById(id).value="";
				break;
			case "empresa":
				if(document.getElementById(id).value == "Empresa...")document.getElementById(id).value="";
				break;
			case "provincia":
				if(document.getElementById(id).value == "Provincia...")document.getElementById(id).value="";
				break;
			case "cargo":
				if(document.getElementById(id).value == "Cargo...")document.getElementById(id).value="";
				break;
			case "cp":
				if(document.getElementById(id).value == "CP...")document.getElementById(id).value="";
				break;
			case "direccion":
				if(document.getElementById(id).value == "Direccion...")document.getElementById(id).value="";
				break;
			case "ciudad":
				if(document.getElementById(id).value == "Ciudad...")document.getElementById(id).value="";
				break;
			case "pais":
				if(document.getElementById(id).value == "Pais...")document.getElementById(id).value="";
				break;
			case "fax":
				if(document.getElementById(id).value == "Fax...")document.getElementById(id).value="";
				break;
			
			
			case "form_email_alta":
				if(document.getElementById(id).value == "Email...")document.getElementById(id).value="";
				break;
			case "form_email_baja":
				if(document.getElementById(id).value == "Email...")document.getElementById(id).value="";
				break;
		}
		//document.getElementById(id).value="";
	}
	function llenar(id,valor){
		if(document.getElementById(id).value==""){
			document.getElementById(id).value=valor;
		}
	}
	// fin vaciar campos al pulsar en ellos y llenarlos al soltarlos vacios
	
	function ValidarForm(form) {
		var form = document.forms[form.id];
		var errors='';
		var nom = form.nombre.value;
		var com = form.comentarios.value;
		var nom_valido=nom.match(/[^a-zA-Z áéíóúüÁÉÍÓÚÜÑñÇç·.]/);
		var com_valido=com.match(/[^a-zA-Z0-9 áéíóúüÁÉÍÓÚÜÑñÇç·.()-_\n][\n]/);
		
		if (form.nombre.value == "" || nom_valido != null || form.nombre.value == "Nombre y Apellidos..."){
			document.getElementById("f_nombre").style.background = "#fec141";
			errors = true;
		}else{
			document.getElementById("f_nombre").style.background = "";
		}
		if ((form.email.value == "")||(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(form.email.value)))){
			document.getElementById("f_email").style.background = "#fec141";
			errors = true;
		}else{
			document.getElementById("f_email").style.background = "";
		}
		if ((form.comentarios.value == "")||(com_valido != null)){
			document.getElementById("f_comentarios").style.background = "#fec141";
			document.getElementById("f_comentarios").style.color = "#ffffff";
			errors = true;
		}else{
			document.getElementById("f_comentarios").style.background = "";
			document.getElementById("f_comentarios").style.color = "";
		}
		
		if (form.acepta.checked == false){
			document.getElementById("f_acepta").style.background = "#fec141";
			document.getElementById("f_acepta").style.color = "#ffffff";
			errors = true;
		}else{
			document.getElementById("f_acepta").style.background = "";
			document.getElementById("f_acepta").style.color = "";
		}

		if (errors) {
			return false;
		}else{
			cargarContenidoContactoOk(form);
		}
	}
	function nuevoAjax(){
		var xmlhttp=false;
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
				xmlhttp = false;
			}
		}
		if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
			xmlhttp = new XMLHttpRequest();
		}
		return xmlhttp;
	}
	function cargarContenidoContactoOk(form){
	
		t2 = document.getElementById("nombre").value;
		t3 = document.getElementById("email").value;
		t4 = document.getElementById("telefono").value;
		t5 = document.getElementById("empresa").value;
		t7 = document.getElementById("comentarios").value;
		t8 = document.getElementById("direccion").value;
		t9 = document.getElementById("cp").value;
		t10 = document.getElementById("ciudad").value;
		t11 = document.getElementById("pais").value;
		t12 = document.getElementById("fax").value;
		
		t14 = form.acepta.checked;
		t15 = document.getElementById("formulario").value;
		if(document.getElementById("formulario").value == "Cabecera"){
			id = document.getElementById('contaj_cab');
		}else{
			id = document.getElementById('contaj');
			if(document.getElementById("formulario").value == "Legal"){
				t16 = document.getElementById("cargo").value;
				t17 = form.chk_mcomunitaria.checked;
				t18 = form.chk_mnacional.checked;
				t19 = form.chk_minternacional.checked;
				t20 = form.chk_pdatos.checked;
				t21 = form.chk_psoftware.checked;
				t22 = form.chk_pweb.checked;
				t23 = form.chk_auditoria.checked;
			}else if(document.getElementById("formulario").value == "Dominios tel"){
				t16 = document.getElementById("dominio").value;
			}
		}
		ajax=nuevoAjax();
		ajax.open("POST", "/marketing/formContactHome/f_contactoOk.php",true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
				id.innerHTML = ajax.responseText
			}
		}
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; text/html; charset=iso-8859-1");
		
		if(document.getElementById("formulario").value == "Legal"){
			ajax.send("motivo="+t1+"&nombre="+t2+"&email="+t3+"&telefono="+t4+"&empresa="+t5+"&provincia="+t6+"&comentarios="+t7+"&codigo="+t8+"&agente="+t9+"&seccion="+t10+"&idioma="+t11+"&charset="+t12+"&dpto="+t13+"&acepta="+t14+"&formulario="+t15+"&cargo="+t16+"&chk_mcomunitaria="+t17+"&chk_mnacional="+t18+"&chk_minternacional="+t19+"&chk_pdatos="+t20+"&chk_psoftware="+t21+"&chk_pweb="+t22+"&chk_auditoria="+t23);
		}else if(document.getElementById("formulario").value == "Dominios tel"){
			ajax.send("motivo="+t1+"&nombre="+t2+"&email="+t3+"&telefono="+t4+"&empresa="+t5+"&provincia="+t6+"&comentarios="+t7+"&codigo="+t8+"&agente="+t9+"&seccion="+t10+"&idioma="+t11+"&charset="+t12+"&dpto="+t13+"&acepta="+t14+"&formulario="+t15+"&dominio="+t16);
		}else{
			ajax.send("motivo="+t1+"&nombre="+t2+"&email="+t3+"&telefono="+t4+"&empresa="+t5+"&provincia="+t6+"&comentarios="+t7+"&codigo="+t8+"&agente="+t9+"&seccion="+t10+"&idioma="+t11+"&charset="+t12+"&dpto="+t13+"&acepta="+t14+"&formulario="+t15);
		}
		
	}
	function cargarContenidoContactoError(){
		t1 = document.getElementById("motivo").value;
		t2 = document.getElementById("nombre").value;
		t3 = document.getElementById("email").value;
		t4 = document.getElementById("telefono").value;
		t5 = document.getElementById("empresa").value;
		t7 = document.getElementById("comentarios").value;
		t8 = document.getElementById("seccion").value;
		t8 = document.getElementById("direccion").value;
		t9 = document.getElementById("cp").value;
		t10 = document.getElementById("ciudad").value;
		t11 = document.getElementById("pais").value;
		t12 = document.getElementById("fax").value;
		
		if(document.getElementById("formulario").value == "Cabecera"){
			id = document.getElementById('contaj_cab');
		}else{
			id = document.getElementById('contaj');
		}
		ajax=nuevoAjax();
		ajax.open("POST", "/marketing/formContactHome/f_contacto.php",true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
				id.innerHTML = ajax.responseText
			}
		}
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; text/html; charset=iso-8859-1");
		ajax.send("motivo="+t1+"&nombre="+t2+"&email="+t3+"&telefono="+t4+"&empresa="+t5+"&provincia="+t6+"&comentarios="+t7+"&seccion="+t8);
	}
	function cargarContenidoContacto(){
		id = document.getElementById('contaj_cab');
		ajax=nuevoAjax();
		ajax.open("POST", "/marketing/formContactHome/f_contacto.php",true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
				id.innerHTML = ajax.responseText
			}
		}
		ajax.send(null);
	}
	function cargarVacio(){	
		id = document.getElementById('contaj_cab');
		ajax=nuevoAjax();
		ajax.open("POST", "/marketing/formContactHome/f_contactoVacio.php",true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
				id.innerHTML = ajax.responseText
			}
		}
		ajax.send(null);
	}
	random_img=0;
	function cargarContenidoImgSec(){
	   id = document.getElementById('img-php');
		random_img++;
	   ajax=nuevoAjax();
	   ajax.open("POST","/marketing/formContactHome/f_contactoImgSec.php",true);
	   ajax.onreadystatechange=function() {
		  if (ajax.readyState==4) {
			 id.innerHTML = ajax.responseText;
		   }
	   }
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; text/html; charset=iso-8859-1");
		ajax.send("random_img="+random_img);
	}
//-->
