/***
Implementaciones
*/
Element.implement({
	 show: function() { 
      this.setStyle('display',''); 
	  this.setStyle('visibility','visible'); 

    }, 
    hide: function() { 
      this.setStyle('display','none'); 
	  this.setStyle('visibility','hidden'); 
    },
	sendAjaxForm:function(fn,validate){
		this.set("send",{
			"onSuccess":fn,
			"onFailure":function(){
				alert("hubo en error el en envio del formulario");
			}
		});
		this.addEvent("submit",function(e){
			e.preventDefault();
			
			if(validate==true){
				var ret = Spry.Widget.Form.validate(this); //solo para spry
				if(ret){
					this.send();
				}else{
					
				}
			}else{
				this.send();
			}
		});
		
		
		return false;
	}

});
/**
Class Exe

require class.Carrusel
**/



var Exe= new Class({
	initialize:function(){},
	activateCarruselCustomers:function(){
	
		if($('mainCarruselCustomers')){
			//window.addEvent("load",function(){
				var flow1 = new imageFlow('imagesFlow_1');
				var flow2 = new imageFlow('imagesFlow_2');
				var flow3 = new imageFlow('imagesFlow_3');
			//})
			
			
			new ACarrusel("mainCarruselCustomers",{
					avanze:1,
					ver:1,
					siguiente:'fSiguiente',
					anterior:'fAnterior',
					duracion:1.2,
					transicion:'back:in:out', /**sine , quad , linear , cubic ,back**/
					anchoItem : 880,
					altoItem : 219,
					onComplete:function(){
						//flow1.reset();
						//flow2.reset();
						//flow3.reset();
					}
			});
		}
	},
	animateLogos:function(){
		$$("ul.logoTipos li").
		addEvents({
			"mouseenter":function(){
				this.setStyles({'z-index' : '10'});
				image=this.getElement("img");
				image.set("morph",{duration:200});
				image.addClass("hover");
				image.morph({
					marginTop: '-65px', 
					marginLeft: '-80px',
					top: '50%', 
					left: '50%', 
					width: '211px', 
					height: '98px'
				});
				this.setStyles("border-color","#FFF");
			},
			"mouseleave":function(){
				this.setStyles({'z-index' : '0'});
				image=this.getElement("img");
				image.removeClass("hover");
				image.morph({
					marginTop: '0', 
					marginLeft: '0',
					top: '0', 
					left: '0', 
					width: '156px', 
					height: '72px',
					padding: '5px'
				});
				this.setStyles("border-color","#CBECFF");
			}
		});
	},
	openPpto:function(){
		new Ventana({
			titulo:"",
			url: "cotizacion.php",
			modal:true,
			fondo:"",
			alto:700,
			ancho:680,
			borde:0,
			separacion:0,
			btnCerrar:"btn_cerrar"	
		}).render();
	},
	createToolsTips:function(){
		allClientes=$$('#lista_clientes li');
			allClientes.each(function(e,k){
				new Tooltips({
					div:e.get("id"),
					ancho:247,
					alto:51,
					fondo:"images/tooltip_1.png",
					posicion:"centroArriba",
					html:e.get("title"),
					estiloInterior:"txtToolTip",
					offsetX:150,
					offsetY:30
				});
				e.set("title","");
		});
	},
	openWorks:function(){
		$$('#ofertasTrabajo a').each(function(el){
			el.addEvent("click",function(e){
				e.stop();
				new Ventana({
					titulo:"",
					url: this.get("href"),
					modal:true,
					fondo:"",
					alto:650,
					ancho:700,
					borde:0,
					separacion:0,
					btnCerrar:"bn_cerrar",
					onLoad:function(){
					
					}
				}).render();
			});
		});
	},
	thanksWork:function(){
		$('conte__moo').load('confirmacion_trabaja.html');
	},
	requiredCV:function(msg){
		$('msgCV').set("html",msg).show();
	},
	filterService:function(value){
		var val=value;
		
		if(val==""){
			alert("Debes elegir un rubro correcto.Gracias"); 
			return false;
		}
		
		$('listaServices').load("_services.php?id="+value);	
	},
	isIE6:function(){
		var I6= new Element("div",{
			'id':'errorI6',
			styles:{
				"top":-100,
				"width":450,
				"height":100,
				"position":'absolute',
				"margin": "0 auto",
				"opacity":0.9,
				"z-index":3500,
				"display":"none",
				"left":(window.getWidth()/2).toInt() -225
				
			},
			"class":'ie6error'
		});
		var closeIe6=new Element("div",{
			"html":"X",
			"class":"closeIe6",
			styles:{
				"width":15,
				"height":15,
				"position":'relative',
				"top":0,
				"left":430,
				"cursor":"pointer"
			}
		});
		
		closeIe6.addEvent("click",function(){
			I6.tween("margin-top",-450);
		});
		
		closeIe6.injectInside(I6);
		
		 var contenido=new Element("div",{
			styles:{
				"width":"auto",
				"height":"auto",
				"position":'relative',
				"top":0
			},
			"html":""
		});
		 
		contenido.set("html",'Usted est&aacute; utilizando un navegador obsoleto Para una mejor experiencia de uso de este sitio, por favor,'
					   +' actualice a un navegador moderno.<div align="center">'+
						'<ul>'+
						'<li><a target="_blank" href="http://www.firefox.com/"><img src="images/navegadores/firefox.png" border="0" / ></a>'+
						'<li><a target="_blank" href="http://www.microsoft.com/windows/internet-explorer/default.aspx"><img src="images/navegadores/ie.png" border="0" / ></a>'+
						'<li><a target="_blank" href="http://www.apple.com/safari/"><img src="images/navegadores/safari.png" border="0" / ></a>'+
						'<li><a target="_blank" href="http://www.google.com/chrome?hl=es"><img src="images/navegadores/google.png" border="0" / ></a>'+
						'</ul></div>'
						);
		contenido.injectInside(I6);
		$$('body').grab(I6);
		$tope=I6.getCoordinates();
		
		I6.set("tween",{
			  "onStart":function(){
				  I6.show();
			  },
			  "duration":1000
		})
		.tween("margin-top",[0, 195]);

	},
	viewVideo:function(id){
		new Ventana({
			titulo:"",
			url: "pop_video.php?id="+id,
			modal:true,
			fondo:"",
			alto:470,
			ancho:651,
			borde:0,
			separacion:0,
			btnCerrar:"bn_cerrar",
			html:"asasas"
		}).render();
	},
	showPortfolio:function (){
		$$('#b_paginas a,#b_comercio a,#b_intranet a,#b_corpo a').set("tween",{duration:600,transition:'back:in:out'})
		
		$$('#b_paginas a')
		.addEvent("click",function(e){
			e.preventDefault();
			resetButtons();
			this.setStyle('background-position','-74px -91px');
		});
		
		$$('#b_comercio a')
		.addEvent("click",function(e){
			e.preventDefault();
			resetButtons();
			this.setStyle('background-position','-172px -3px');
		});
			
		$$('#b_redes a')
		.addEvent("click",function(e){
			e.preventDefault();
			resetButtons();
			this.setStyle('background-position','-322px -4px');
		});
		
	
		$$('#b_intranet a')
		.addEvent("click",function(e){
			e.preventDefault();
			resetButtons();
			this.setStyle('background-position','-427px -93px');
		});
		
		$$('#b_corpo a')
		.addEvent("click",function(e){
			e.preventDefault();
			resetButtons();
			this.setStyle('background-position','-501px -92px');
		});
	},
	showGrettings:function(){
		new Ventana({
			titulo:"",
			url: "pop_navidad.html",
			modal:true,
			fondo:"",
			alto:520,
			ancho:680,
			borde:0,
			separacion:0,
			btnCerrar:"bn_cerrar"	
		}).render();
	},
	viewCompleteProfiles:function(id){
		if(id==0){
			$('listPortafolio').load("scripts/pagPortafolio.php");
		}else{
			$('listPortafolio').load("scripts/pagPortafolio.php?ir="+id);
		}
		
	},
	pagProfile:function(url){
		$('listPortafolio').load(url);
	},
	viewTypes:function(id,ir){
		if(ir==0){
			$('listPortafolio').load("scripts/pagTipos.php?tp="+id);
		}else{
			$('listPortafolio').load("scripts/pagTipos.php?tp="+id+"&ir="+ir);
		}
		
	},
	viewBriefcase:function(id){
		$('listPortafolio').load("scripts/detallePortafolio.php?id="+id);
	}
});
var exe= new Exe();

function resetButtons(){
	//$$('#b_paginas a,#b_comercio a,#b_intranet a,#b_corpo a').setStyle('background-position','0 0');
	$$('#b_paginas a').setStyle('background-position','-77px -53px');
	$$('#b_comercio a').setStyle('background-position','-176px -53px');
	$$('#b_redes a').setStyle('background-position','-322px -54px');
	$$('#b_intranet a').setStyle('background-position','-427px -142px');
	$$('#b_corpo a').setStyle('background-position','-501px -54px');
	
}

window.addEvent("domready",function(){
	$$('body').addEvent('contextmenu',function(e) {	e.stop();	return false;});
	if(Browser.Engine.trident4){exe.isIE6();};
});

