
//*******************************************************
//******************** FUNCIONES LINKZ ******************
//*******************************************************
function cambio(idCapa){
  if (document.layers) capa = eval("document." + idCapa);
  if (document.all) capa = eval(idCapa + ".style");
  if (document.getElementById) capa = eval('document.getElementById("' + idCapa + '").style');if ((capa.visibility == "hidden") || (capa.visibility == "hide")){
  capa.visibility = (document.layers) ? "show" : "visible" ;
  }
  else{
  capa.visibility = (document.layers) ? "hide" : "hidden" ;
	}	
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function hoverField(me) {
	if (me.className != 'formInputFieldSelected') {
		if (me.className == 'formInputField') me.className='formInputFieldHover';
		else me.className = 'formInputFieldFilledHover';
	}
}
			
			
function hoverOffField(me) {
	if (me.className != 'formInputFieldSelected') {
		if (me.className == 'formInputFieldHover') me.className='formInputField';
		else me.className = 'formInputFieldFilled';
	}
}


			
function focusField(me) {
	if ((me.className == 'formInputFieldHover')||(me.className == 'formInputField')) me.value='';
	me.className = 'formInputFieldSelected';
}


function blurField(me) {
	me.className = 'formInputFieldFilled';
	var d=document.getElementById(me.id+'_h');		
	/*Al dejar el foco de la autentificación intranet */
	if (me.value=='' && d!=null){
		me.value=d.value;
		me.className = 'formInputField';	
	};
}



function showMenu(){
	statusMenu = document.getElementById('hiddenStatusMenu');
	if(statusMenu.value==0){
		statusMenu.value=1;
		Effect.toggle('searchmenu','appear'); return false;
	}			
}
			


function hideMenu(){
	statusMenu = document.getElementById('hiddenStatusMenu');
	if(statusMenu.value==1){
		statusMenu.value=0;
		Effect.toggle('searchmenu','appear'); return false;
	}
}



var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false


/***********************************************
* Cool DHTML tooltip script II- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************

var offsetfromcursorX=12 //Customize x offset of tooltip
var offsetfromcursorY=10 //Customize y offset of tooltip

var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

document.write('<div id="dhtmltooltip"></div>') //write out tooltip DIV
document.write('<img id="dhtmlpointer" src="../images/flecha_tooltip.gif">') //write out pointer image

var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

var pointerobj=document.all? document.all["dhtmlpointer"] : document.getElementById? document.getElementById("dhtmlpointer") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thewidth, thecolor){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var nondefaultpos=false
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20

var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY

var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth){
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=curX-tipobj.offsetWidth+"px"
nondefaultpos=true
}
else if (curX<leftedge)
tipobj.style.left="5px"
else{
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
pointerobj.style.left=curX+offsetfromcursorX+"px"
}

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight){
tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
nondefaultpos=true
}
else{
tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
pointerobj.style.top=curY+offsetfromcursorY+"px"
}
tipobj.style.visibility="visible"
if (!nondefaultpos)
pointerobj.style.visibility="visible"
else
pointerobj.style.visibility="hidden"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
pointerobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip


//*******************************************************/

function llamacondiciones(idioma)
{

showWindow('../shared/condiciones.php?idioma='+idioma,'www.actiu.com','607','732','8001')
	
}



//********************************************************************
//******************** FUNCIONES ESPECIALES DE AJAX ******************
//********************************************************************

//** Carga paginas en elementos <div> 		
	function getHTML(midiv,url){
				
        var url 
        var pars = 'param=ABC';
        var midiv
        var myAjax = new Ajax.Updater(midiv, url, 
        { method: 'get', parameters: pars,
        	onCreate: function() {
        		if ($("reloj")!=null) $("reloj").innerHTML="<img id='relogito' src='../images/loader1.gif' class='load'>";
        		if ($("reloj1")!=null) $("reloj1").innerHTML="<img id='relogito1' src='../images/loader1.gif' class='load'>";
        	},
	        onComplete: function() {
	        	if ($("reloj")!=null) 
	        	{
	        		$("relogito").remove(); 
	        		$("reloj").remove();
	        	}
	        	if ($("reloj1")!=null) 
	        	{
	        		$("relogito1").remove(); 
	        		$("reloj1").remove();
	        	}
	        }
        }
        );
        
        return true
	}
	
		
	function cambia_img(id,new_img)
	{
		$(id).src=new_img		
	}
	
	
	function showWindow(pagina,titulo,alto,ancho,zindex)
	{
		if (zindex==0 || zindex==null) zindex=8000;
    	win = new Window({className: 'spread', title: titulo, 
        	              width: ancho, height: alto, 
        	              url: pagina, showEffectOptions: {duration:0}})
  		win.setZIndex(zindex)
		win.showCenter();
	}
	
	function object_window(url_in,top_in,left_in,width_in,height_in,titulo)
	{
			if (titulo=="")	
				titulo="www.actiu.com";
			win = new Window({className: 'spread', title: titulo, 
        	              top: top_in, left: left_in, width: width_in, height: height_in, 
            	          url: url_in, showEffectOptions: {duration:1.5}})
			win.show();   
							
	}
	function object_window2(url_in,top_in,left_in,width_in,height_in,titulo)
	{
			if (titulo=="")	
				titulo="www.actiu.com";
			win = new Window({className: 'spread2', title: titulo, 
        	              top: top_in, left: left_in, width: width_in, height: height_in, 
            	          url: url_in, showEffectOptions: {duration:0}})
			win.show();   
							
	}

// Victor	

// insertar html dentro de una etiqueta
function insertar_html(id,etiqueta){
    $(id).innerHTML = etiqueta;
    
}


// Realiza una carga de una capa en Ajax, requiere Prototype
// parametros:
//        -- id: id de la capa que deseamos cargar
//        -- url: url que cargaremos en el div, le pasaremos los parametros que queramos por url
//        -- logo: [0] mostrará el logo de carga dentro del div, [1] no mostrará el logo
//        -- insertar:
//                [0] dentro del div
//                [1] antes del div
//                [2] arriba dentro del div
//                [3] abajo dentro del div
//                [4] después del div.
                    
function cargadiv(id,url,logo,insertar){
	    
    if(logo == 0){
        insertar_html(id,'<img id="logo" src="../images/loader1.gif" border="0" />');        
    }
    
    switch(insertar){
        case 0:    
            new Ajax.Updater($(id),url,{
                                    method: 'get'
            });            

        break;
        case 1:
            new Ajax.Updater($(id),url,{
                                    method: 'get',
                                    insertion:Insertion.Before
                                   
            });
        
        break;
        case 2:
            new Ajax.Updater($(id),url,{
                                    method: 'get',
                                    insertion:Insertion.Top
                                   
            });
        
        break;
        case 3:
            new Ajax.Updater($(id),url,{
                                    method: 'get',
                                    insertion:Insertion.Bottom
                                   
            });
        
        break;
        case 4:
            new Ajax.Updater($(id),url,{
                                    method: 'get',
                                    insertion:Insertion.After
                                   
            });
        
        break;
        default:
            new Ajax.Updater($(id),url,{
                                    method: 'get'
            });      
        break;
    }
}

function redireccionar(pagina){	
	//document.location.href=pagina;
	window.open(pagina);
}





function checkemail(email){
	var resultado;
    var str=email;    
    var filtro=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
    //indow.alert(email);
    if (filtro.test(str)){
        resultado=true
    }else{        
        resultado=false
    }
    return (resultado)
}


function form_curriculum(id,idioma){
		
	var campos = new Array();
	var campo_inc = '';
    campos = $(id).getElements();
    
    for(i=0;i<campos.length;i++){    	
        if (campos[i].value == '' && campos[i].name!='datos_destacar' && campos[i].title!='experiencia' && campos[i].title!='empresa'){       	
        	
        	if (campos[i].type == "file"){
        		campo_inc = campos[i].title;
        	}else{
        		campo_inc = campos[i].name;
        	}
                
                
                break;   
        } 
    }
    
    // comprobar tipo imagen en foto
    tam_foto = $('userfile1').value.length; 
    ext = $('userfile1').value.substring(tam_foto-3);   
    ext = ext.toLowerCase();    
    if((campo_inc == '') && (ext != 'jpg') && (ext != 'gif') && (ext != 'png')){
    	cargadiv('mensaje_curriculum','curriculum.php?proceso=3&idioma='+idioma,0,0);
	    $('mensaje_curriculum').show();    	
	    $('mensaje_curriculum').scrollTo();    	 
	    
    }else{
    	tam_curri = $('userfile2').value.length;
    	ext = $('userfile2').value.substring(tam_curri-3);   
	    ext2 = $('userfile2').value.substring(tam_curri-4);   
	    ext = ext.toLowerCase(); 
	    ext2 = ext2.toLowerCase(); 
	    //window.alert('ext:'+ext);
	    //window.alert('ext2:'+ext2);
    
    	if((campo_inc == '') && (ext != 'pdf') && (ext != 'doc') && (ext2 != 'docx')){	        	
	    	cargadiv('mensaje_curriculum','curriculum.php?proceso=6&idioma='+idioma,0,0);
		    $('mensaje_curriculum').show();    	
		    $('mensaje_curriculum').scrollTo();    	
    	}else{
    		if (campo_inc != ''){ // mensaje campos vacios
		    	cargadiv('mensaje_curriculum','curriculum.php?proceso=2&incompleto='+campo_inc+'&idioma='+idioma,0,0);
		    	$('mensaje_curriculum').show();    	
		    	$('mensaje_curriculum').scrollTo();    	
		    }else{ // realizamos el envío del formulario	    	
		    	// comprobamos el email
		    	if (checkemail($('email').value) == true){	// comprobamos email
		    		if($('movil').value.length > 8){    	
			    		$('mensaje_curriculum').hide();			    		
			    		
			    		// reemplazamos todos los ' que puedan aparecer
			    		 campos = $(id).getInputs('text');			    		    
			    		 for(i=0;i<campos.length;i++){			    			
			    			 campos[i].value = campos[i].value.replace(/'+/, '');			    			 
			    		 }
			    		 if ($('acepto_condiciones').checked){							 
			    			 $('curriculum').submit();
 							 $('contenidoCompleto').scrollTo();
							 $('datos_curriculum').replace('<div style="text-align:center"><img src="../images/conoceactiu/enviando.gif" border="0" /></div>');	
			    		 }else{
			    			 window.alert('Debe de leer y aceptar las Condiciones Generales');			    			 
			    		 }
			    		 
		    		}else{
		    			cargadiv('mensaje_curriculum','curriculum.php?proceso=5&idioma='+idioma,0,0);
		    			$('mensaje_curriculum').show();    	
		    			$('mensaje_curriculum').scrollTo();    			
		    		}
		    	//cargadiv('datos_curriculum','curriculum.php?proceso=3&idioma='+idioma,0,0);    	
		    	}else{
		    		cargadiv('mensaje_curriculum','curriculum.php?proceso=4&idioma='+idioma,0,0);
		    		$('mensaje_curriculum').show();    	
		    		$('mensaje_curriculum').scrollTo();    		    		
		    	}
		    }   		
    	}
    }    
    

    
}

function clic_arq(img,campo)
{
	
	if($('opcion'+img).value == "on"){
		//alert(img+","+campo)
		$(campo).checked=true;
		$('imagen'+img).src = '../images/form_arquitectos/img'+img+'_on.jpg';
		$('opcion'+img).value = "off";
		
	}else{
		if($('opcion'+img).value == "off"){
			$(campo).checked=false;
			$('imagen'+img).src = '../images/form_arquitectos/img'+img+'.jpg';
			$('opcion'+img).value =  "on";
		}
	}

}

function form_arq(id){	
	var campos = new Array();
	var campo_inc = '';
    campos = $(id).getElements();
    vacio = 0;
    for(i=0;i<campos.length;i++){
    	//window.alert(campos[i].name);  	
    	if((campos[i].type != 'checkbox') && (campos[i].type != 'radio') && (campos[i].type != 'hidden') && (campos[i].type != 'button') && (campos[i].type != 'reset')){
	        if (campos[i].value == ''){
	        	//window.alert('entra');
	        	$('err_'+campos[i].name).show();                
	        	//$(campos[i].name).focus();                
	        	vacio = 1;	        	
	           	break;   
	        }else{
	        	if(campos[i].name == "email"){
	        		if (!checkemail($('email').value)){
	        			$('err_'+campos[i].name).show();	        			
	        		}else{
	        			//window.alert('email'+campos[i].name);
	        			$('err_'+campos[i].name).hide();                	        			
	        		}
	        	}else{
	        		//window.alert(campos[i].name);	        		
	        		$('err_'+campos[i].name).hide();                
	        	}
	        }
    	}
    }
    
    if(!($('newsletter_si').checked) && (!($('newsletter_no').checked) && (vacio == 0))){
    	$('err_newsletter').show();
    	vacio = 1;
    }else{
    	$('err_newsletter').hide();    	
    }
    
    if(($('condiciones').checked) && (vacio == 0)){
    	$('f_arquitectos').submit();    	
    }else{
    	if(vacio == 0 && !($('condiciones').checked)){
    		window.alert('Debe de leer y aceptar las Condiciones Generales.');    	
    	}
    }
}

function mostrar(id){
	$(id).show();	
}

function ocultar(id){
	$(id).hide();	
}


function mas_empresa(id,url){
	
	$('nexp').value = parseInt($('nexp').value) + 1;	
	cargadiv(id,url+'&exp='+$('nexp').value,1,3);
	
}


	
	

	
//********************************************************************
