

$(document).ready(function(){
	resizeCos();

	jQuery(window).resize(resizeCos);



});


function resizeCos(){
/*	var height = $(document).height();
	$(".columna").height(height);
	
	*/
	var ample = $(window).width();
	ample=ample-350;
	$("#contingut").width(ample);
	
	if(ample>900){
		ample=900;
		$(".proj_content").css({'margin':'20px auto 20px auto'});
	}else{
		$(".proj_content").css({'margin':'20px auto 20px 20px'});
	}
	
	$(".proj_content").width(ample-80);
	$("#imatgeGran").width(ample-80);
	tmp = (ample-80)/10*6
	$("#imatgeGran").height(tmp);
}


function setCookie( name, value, expires, path, domain, secure )

{

	var today = new Date();

	today.setTime( today.getTime() );

	

	if ( expires )

	{

	expires = expires * 1000 * 60 * 60 * 24;

	}

	var expires_date = new Date( today.getTime() + (expires) );

	

	document.cookie = name + "=" +escape( value ) +

	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +

	( ( path ) ? ";path=" + path : "" ) +

	( ( domain ) ? ";domain=" + domain : "" ) +

	( ( secure ) ? ";secure" : "" );

}



function getCookie( check_name ) {



	var a_all_cookies = document.cookie.split( ';' );

	var a_temp_cookie = '';

	var cookie_name = '';

	var cookie_value = '';

	var b_cookie_found = false; 



	for ( i = 0; i < a_all_cookies.length; i++ )

	{

		a_temp_cookie = a_all_cookies[i].split( '=' );



		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');



		if ( cookie_name == check_name )

		{

			b_cookie_found = true;

			if ( a_temp_cookie.length > 1 )

			{

				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );

			}



			return cookie_value;

			break;

		}

		a_temp_cookie = null;

		cookie_name = '';

	}

	if ( !b_cookie_found )

	{

		return null;

	}

}



var claimActiu=0;



function ShowClaim(id){

	$(".publiInfo").stop().animate({"height": 0},{duration:500, easing:"easeOutExpo",

		complete: function() {

		  $(this).hide();

		}});

		pubActiu=0;

	if(id!=claimActiu){

		$("#claim"+id).slideDown(200);	

		//$(".claimInfo:not(#claim"+id+")").slideUp(200);

				

		$(".claimInfo:not(#claim"+id+")").stop().animate({"height": 0},{duration:500, easing:"easeOutExpo",

		complete: function() {

		  $(this).hide();

		}});	

		

		var alcadaActual = $("#claim"+id).css('height');

		$("#claim"+id).css({'height': ''})

		var alcada = $("#claim"+id).css('height');

		$("#claim"+id).css({'height': alcadaActual})

		

		$("#claim"+id).stop().show().animate({"height": alcada},{duration:500, easing:"easeOutExpo"});

		claimActiu=id;

	}else{

		$(".claimInfo").stop().animate({"height": 0},{duration:500, easing:"easeOutExpo",

		complete: function() {

		  $(this).hide();

		}});

		claimActiu=0;

	}

	

}



var pubActiu=0;



function ShowPub(id){

	

	$(".claimInfo").stop().animate({"height": 0},{duration:500, easing:"easeOutExpo",

		complete: function() {

		  $(this).hide();

		  

		}});

	claimActiu=0;

	if(id!=pubActiu){

		$("#publi"+id).slideDown(200);	

		//$(".publiInfo:not(#publi"+id+")").slideUp(200);

				

		$(".publiInfo:not(#publi"+id+")").stop().animate({"height": 0},{duration:500, easing:"easeOutExpo",

		complete: function() {

		  $(this).hide();

		}});	

		

		var alcadaActual = $("#publi"+id).css('height');

		$("#publi"+id).css({'height': ''})

		var alcada = $("#publi"+id).css('height');

		$("#publi"+id).css({'height': alcadaActual})

		

		$("#publi"+id).stop().show().animate({"height": alcada},{duration:500, easing:"easeOutExpo"});

		pubActiu=id;

	}else{

		$(".publiInfo").stop().animate({"height": 0},{duration:500, easing:"easeOutExpo",

		complete: function() {

		  $(this).hide();

		}});

		pubActiu=0;

	}

	

}



var ImatgeActiva=0;



function ShowThumb(id){



	var frase=$("#imatgeth"+id).attr("alt");

	$("#imatgeGran").attr({'src': 'imatges/projectes/'+id+'.jpg'});

	$("#frase").html(frase);

	window.location.hash=id;

	

	var idi;

	

	idi	= $("#ca").attr("href");

	if(idi.indexOf("#") > -1){

		idi = idi.substr(0, idi.length - (idi.length - idi.indexOf("#")));

	}

	idi = idi + "#" + id;

	$("#ca").attr({"href": idi});

	

	

	idi	= $("#es").attr("href");

	if(idi.indexOf("#") > -1){

		idi = idi.substr(0, idi.length - (idi.length - idi.indexOf("#")));

	}

	idi = idi + "#" + id;

	$("#es").attr({"href": idi});

	

	

	idi	= $("#en").attr("href");

	if(idi.indexOf("#") > -1){

		idi = idi.substr(0, idi.length - (idi.length - idi.indexOf("#")));

	}

	idi = idi + "#" + id;

	$("#en").attr({"href": idi});

	

	

	

	$("#imatge"+ImatgeActiva).removeClass("actiu");

	$("#imatge"+id).addClass("actiu");
	
	$(".boletaCentral:not(#boletaCentral"+id+")").attr({"src": 'img/bolapetita.png'});
	
	$("#boletaCentral"+id).attr({"src": 'img/bolagran.png'});

	ImatgeActiva=id;

	

}



function enviarConsulta(){

	

		$("#btnEnviar").hide();

		$("#resultat").html(_enviant);

		$.post("php_aux/enviarMail.php", { nom: document.formulari.nom.value, telefon: document.formulari.tel.value, email: document.formulari.mail.value,  assumpte: document.formulari.assumpte.value},

	   	function(data) {

	   		if(data=="ok"){

				$("#resultat").html(_enviat);

	   		}else{

				$("#resultat").html(_noEnviat);

	   		}

	   		setTimeout("reiniciarForm()", 3000);

	   	});	

}



function reiniciarForm(){

	$("#resultat").html('');

	$("#btnEnviar").show();

}



function entrarText(caixa, text){

	//$(caixa).css({'color':'#f60'});

	if(caixa.value == text){

		caixa.value="";

	}

}

function sortirText(caixa, text){

	if(caixa.value == ""){

		caixa.value=text;

		//$(caixa).css({'color':'#666'});

	}

}
