/**

 * Libreria www.zipvisual.com.<br />

 * <br />

 * Script basicos de zipvisual derechos resrvados

 * Requiere Prototype 1.6

 * <br />

 */

if(typeof Zipvisual == "undefined") Zipvisual = {};



var Zipvisual = {

	writeEmail: function(element, title, cssname) {

		element = $(element);

	    this.email = "contacto@zipvisual.com";

		var a = new Element('a', { title: title + ' ' + this.email, 'class': cssname, href: 'mailto:' + this.email }).update(this.email);

		element.appendChild(a);

	}

};



/*

Widget.Fader.imageBuilder = function(fader, item, loaded) {

	var img = new Element("img", fader.options.attributes);

	img.observe("load", loaded);

	img.src = fader.options.dir + item;

	return img;

};



Widget.Fader.textBuilder = function(fader, item, loaded) {

	var div = new Element("div", fader.options.attributes).update(item);

	loaded.defer();

	return div;

};

*/

function chat() {
	window.open('http://www.zipvisual.com/phplive/request_email.php?l=root&x=1&deptid=0',null,"height=360,width=460,status=yes,toolbar=no,menubar=no,location=no");
}

var inicio = 1;
var ciclo;
function ver_imagen(id, img) {
	jQuery.each(jQuery('.button-pictures'), function() {
		jQuery(this).attr('src', 'img/button-layer-out.jpg');
	});
	jQuery(id).attr('src', 'img/button-layer-in.jpg');
	
	jQuery.each(jQuery('#main-profile-picture img'), function() {
		jQuery(this).fadeOut("slow");
	});
	var nombre = '#img'+img;
	jQuery(nombre).fadeIn("slow");
	inicio = img;
}

function ver_imagen2(id, img) {
	jQuery.each(jQuery('.button-pictures'), function() {
		jQuery(this).attr('src', 'img/button-layer-out.jpg');
	});
	jQuery(id).attr('src', 'img/button-layer-in.jpg');
	
	jQuery.each(jQuery('#main-profile-fotos img'), function() {
		jQuery(this).fadeOut("slow");
	});
	var nombre = '#img'+img;
	jQuery(nombre).fadeIn("slow");
	inicio = img;
}

function automatico() {
	var imgMov = 0;
	jQuery.each(jQuery('.button-pictures'), function(index) {
		imgMov = index;
	});
	ciclo = setInterval(function(){
				if(inicio <= imgMov) {
					var anterior = '#img'+inicio;
					inicio++;
					var bullet = '#pic'+inicio;
					var siguiente = '#img'+inicio;
				} else {
					var anterior = '#img'+inicio;
					inicio = 1;
					var bullet = '#pic'+1;
					var siguiente = '#img'+inicio;
				}
				
				jQuery.each(jQuery('.button-pictures'), function() {
					jQuery(this).attr('src', 'img/button-layer-out.jpg');
				});
				jQuery(bullet).attr('src', 'img/button-layer-in.jpg');
				jQuery(anterior).fadeOut("slow");
				jQuery(siguiente).fadeIn("slow");
			},6000);
}

function ver_destacado(id, tipo, nombre) {
	clearInterval(ciclo);
	jQuery.post("proyecto.php", { id: id, tipo: tipo }, function(data) {
		jQuery('.empresa-title').html(nombre);
     	jQuery('#detalle').html(data);
		inicio = 1;
		automatico();
   });
}

function ver_proyecto(id, tipo) {
	clearInterval(ciclo);
	jQuery.post("proyecto.php", { id: id, tipo: tipo }, function(data) {
     	jQuery('#detalle').html(data);
		inicio = 1;
		automatico();
   });
}

var pag = 1;
function pagina(total, numero, seccion, tipo) {
	pag = numero;
	jQuery.post("proyectos.php", { numero: numero, seccion: seccion, tipo: tipo }, function(data) {
     	jQuery('#proyectos').html(data);
   });
   
   jQuery('.backward').hide();
   jQuery('.forward').hide();
   if(pag >= 2) {
	  jQuery('.backward').show(); 
   }
   if(pag <= total-1) {
	   jQuery('.forward').show();
   }
}

function siguiente(total, seccion, tipo) {
	pag++;
	if(pag >= total) {
		pag = total;
	}
	
	jQuery.post("proyectos.php", { numero: pag, seccion: seccion, tipo: tipo }, function(data) {
     	jQuery('#proyectos').html(data);
   });
   
   jQuery('.backward').hide();
   jQuery('.forward').hide();
   if(pag >= 2) {
	  jQuery('.backward').show(); 
   }
   if(pag <= total-1) {
	   jQuery('.forward').show();
   }
}

function anterior(total, seccion, tipo) {
	pag--;
	if(pag <= 1) {
		pag = 1;
	}
	
	jQuery.post("proyectos.php", { numero: pag, seccion: seccion, tipo: tipo }, function(data) {
     	jQuery('#proyectos').html(data);
   });
   
   jQuery('.backward').hide();
   jQuery('.forward').hide();
   if(pag >= 2) {
	  jQuery('.backward').show(); 
   }
   if(pag <= total-1) {
	   jQuery('.forward').show();
   }
}
