
$(document).ready(function() {
	
	$.fn.equalCols = function(){ //Asignamos la nueva función equalCols
	    var tallestHeight = 0; //Reinicia la variable que guarda la mayor altura
	    $(this).each(function(){ //Comprueba uno por uno los elementos con el selector indicado
	        var thisHeight = $(this).height(); //Guarda la altura del elemento
	        if (thisHeight > tallestHeight){ // Si la altura es mayor que la anterior altura guardada, se asigna a la variable tallesHeight
	            tallestHeight = thisHeight;
	        }
	    });
	    $(this).height(tallestHeight); //Se asigna la mayor altura a los elementos con el selector indicado
	}
	
	//Se aplica el método con el selector '.column'
	$('.column').equalCols();	

})

function open_modal(id) {
	var jqIdRef = "#"+id;	
	
	var bgdiv = $('<div>').attr({
		className: 'bgtransparent',
		id: 'bgtransparent'
	});

	$('body').append(bgdiv);
	
	var wscr = $(window).width();
	var hscr = $(window).height();
			
	$('#bgtransparent').css("width", wscr);
	$('#bgtransparent').css("height", hscr);
	
	$(jqIdRef).show();
}

function close_modal(id) {
	var jqIdRef = "#"+id;	
	
	$(jqIdRef).hide();
	$('#bgtransparent').remove();
}

function sendForm1(form_name) {
	
	var form = document.getElementById(form_name);
	
	// valido campos
	email = document.getElementById("email");
	if (!isValidEmail(email.value)) {
		alert(html2Hex("Debes poner tu e-mail correctamente."));
		email.focus();
		return false;		
	}
	
	client = document.getElementById("client");
	if (!isValidText(client.value)) {
		alert(html2Hex("Debes escribir tu nombre."));
		client.focus();
		return false;
	}
	
	company = document.getElementById("company");
	if (!isValidText(company.value)) {
		alert(html2Hex("Debes escribir el nombre de tu compa&ntilde;ia."));
		company.focus();
		return false;		
	}	
	
	//alert("Enviando...");
	form.submit();
}

function hide(id) {
	document.getElementById(id).style.display = "none";
}

function show(id) {
	document.getElementById(id).style.display = "";
}

function show_service(id) {
	arr_ul_services = new Array("ul_serv_estrategia","ul_serv_tecnologia","ul_serv_diseno","ul_serv_promocion");
	show(id);
	for (i=0; i<arr_ul_services.length; i++) {
		if (arr_ul_services[i] != id) {
			hide(arr_ul_services[i]);
		}
	}	
}

index_img = parseInt(0);

function load_img_proy(idCircleImg,numImgProy,imgName) {
	document.getElementById("contImgProy").style.background = "transparent url('http://www.t4xi.com/files/projects/images/big/"+imgName+"') no-repeat top left";
	
	for (i = 0; i < numImgProy; i++) {
		if (i == idCircleImg) {
			document.getElementById("circleImg_"+i).src = "http://www.t4xi.com/images/yellow-circle.jpg";
		} else {
				document.getElementById("circleImg_"+i).src = "http://www.t4xi.com/images/gray-circle.jpg";
		}
	}
	
	index_img = idCircleImg;	
}

function openYoxviewGallery() {
	index_img = parseInt(index_img);
	yoxviewApi.openGallery(0,index_img);
}

var arr_ref = new Array(
new Array('1','Ascat','Aseguradoras','20100415210646_116891.jpg','20100415210646_269299.jpg'),new Array('2','Caser','Aseguradoras','20100415210710_480209.jpg','20100415210710_102197.jpg'),new Array('3','Banc Sabadell','Banca','20100415210746_365676.jpg','20100415210746_133782.jpg'),new Array('4','la Caixa','Banca','20100415210755_911587.jpg','20100415210755_181793.jpg'),new Array('5','Betfair','Betting & Gamming','20100415210809_108953.jpg','20100415210809_205661.jpg'),new Array('6','PAF','Betting & Gamming','20100415210816_858111.jpg','20100415210816_245101.jpg'),new Array('7','Compex','Gran Consumo','20100415210828_701309.jpg','20100415210828_323956.jpg'),new Array('8','Conceptronic','Gran Consumo','20100415210837_626684.jpg','20100415210837_585183.jpg'),new Array('9','Eva Professional','Gran Consumo','20100415210845_985250.jpg','20100415210845_420471.jpg'),new Array('10','Fisherman&#039;s Friend','Gran Consumo','20100415210852_652062.jpg','20100415210852_707681.jpg'),new Array('11','Knorr','Gran Consumo','20100415210901_728665.jpg','20100415210901_549505.jpg'),new Array('12','Nespresso','Gran Consumo','20100415210909_223129.jpg','20100415210909_205468.jpg'),new Array('13','Nocilla','Gran Consumo','20100415210916_438131.jpg','20100415210916_409484.jpg'),new Array('14','OKI','Gran Consumo','20100415210921_185308.jpg','20100415211458_842675.jpg'),new Array('15','San Miguel','Gran Consumo','20100415210929_965612.jpg','20100415210929_347109.jpg'),new Array('16','Turisme de Formentera','Institucional','20100415210939_568759.jpg','20100415210939_416625.jpg'),new Array('17','Generalitat de Catalunya','Institucional','20100415210948_718722.jpg','20100415210949_731384.jpg'),new Array('18','Turisme de Lleida','Institucional','20100415211025_766375.jpg','20100415211025_764645.jpg'),new Array('19','Amics de la Gent Gran','ONGs','20100415211043_999148.jpg','20100415211043_444696.jpg'),new Array('20','Pallapupas','ONGs','20100415211049_177755.jpg','20100415211049_941003.jpg'),new Array('21','Almirall','Pharma','20100415211100_501577.jpg','20100415211100_715728.jpg'),new Array('22','Bristol-Myers Squibb','Pharma','20100415211108_620999.jpg','20100415211108_738909.jpg'),new Array('23','Esteve','Pharma','20100415211130_898266.jpg','20100415211130_937625.jpg'),new Array('24','Grupo Ferrer','Pharma','20100415211137_828063.jpg','20100415211137_879287.jpg'),new Array('25','Urgo','Pharma','20100415211145_462384.jpg','20100415211145_423300.jpg'),new Array('26','Hotel Condes de Barcelona','Turismo','20100415211154_312365.jpg','20100415211154_805679.jpg'),new Array('27','Finnair','Turismo','20100415211200_711224.jpg','20100415211200_490646.jpg'));

function emphasize_ref(cat) {
	for (i = 0; i < arr_ref.length; i++) {
		if (arr_ref[i][2] != cat) {
			document.getElementById("ref_"+arr_ref[i][0]).src = "http://www.t4xi.com/files/clients/images/big/"+arr_ref[i][4];
		} else {
				document.getElementById("ref_"+arr_ref[i][0]).src = "http://www.t4xi.com/files/clients/images/big/"+arr_ref[i][3];
		}
	}
}


function change_view_state(id_str,id_img){

	var img = document.getElementById(id_img);
	var img_path = img.src;
	if (img_path.indexOf("plus.gif") > 0) {
		img.src = "http://www.t4xi.com/images/minus.gif";
	} else {
			img.src = "http://www.t4xi.com/images/plus.gif";
	}

	var el = document.getElementById(id_str);
	if (el.style.display == "none") {
		el.style.display = "block";
	} else {
			el.style.display = "none";
	}
	
}

