// JavaScript Document
function iniciarmenu(){
	//menu	
	$('#topnav li').prepend('<span></span>');
	
	$("#topnav li").each(function() {
		var linkText = $(this).find("a").html();
		$(this).find("span").show().html(linkText);
	}); 
	
	var pageID = $("body").attr("id");
	
	$("#topnav li").hover(function() {
		var navClass = $(this).attr("class");
		if (pageID != navClass) {
			$(this).find("span").stop().animate({ 
				marginTop: "-44"
			}, 250);
		}
	} , function() {
		var navClass = $(this).attr("class");
		if (pageID != navClass) {
			$(this).find("span").stop().animate({
				marginTop: "0"
			}, 250);
		}
		
	});// end menu
}
function iniciarfacybox(){
//fancybox
	
		$('a[rel=localgallery]').fancybox({
			'titlePosition' 	: 'inside',
			'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
			    return '<span id="fancybox-title-inside">Foto ' +  (currentIndex + 1) + ' de ' + currentArray.length + ' - '+title+'</span>';
			}
		});//end facybox	
}
function iniciarcoda(elnumero){
	//coda
//$().ready(function() {
       $('#coda-slider-1').codaSlider({
	   //autoHeightEaseDuration: 0,
        //autoHeightEaseFunction: "easeInBounce",
        slideEaseDuration: 1000,
        //slideEaseFunction: "easeInBounce",
           dynamicArrows: true,
           dynamicTabs: false,
		   autoSlide: false,
		   crossLinking: false,
		   firstPanelToLoad: elnumero
	    });
//   });//end coda
	}

function carregar(){
		$('.loading').show();	
		$(window).load(function() {	
			//$('#loading').slideUp('slow', function() {
			$('.loading').fadeTo(1000, 0, function() {
				$('.loading').remove();
				$('.jqloaded').slideDown('fast');
       			//$('#jq').fadeTo(1000,1); 
            }); 				   
		});		   
}

//------------------
//specialdays

var specialDays = {
				   
			'2010': {
				'1': {
					'1': {tooltip: "Cap d'Any"},
					'6': {tooltip: "Reis"}
					},
				'4': {
					'2': {tooltip: "Divendres Sant"}, 
					'5': {tooltip: "Dilluns de Pasqua Florida"}
				},
				'5': {
					'1': {tooltip: "Festa del Treball"}					
				},
				'6': {
					'24': {tooltip: "Sant Joan"}					
				},

				'9': {
					'11': {tooltip: "Diada Nacional de Catalunya"}					
				},
				'10': {
					'12': {tooltip: "Festa Nacional d'Espanya"}					
				},
				'11': {
					'1': {tooltip: "Tots Sants"}					
				},

				'12': {
					'6': {tooltip: "Dia de la Constitució"},
					'8': {tooltip: "la Immaculada"},
					'25': {tooltip: "Nadal"},
					'26': {tooltip: "Sant Esteve"}
				}
			}
		}; 

function calendari(){
$("#calendariselect").datepicker({
				dateFormat: 'dd/mm/yy',				  
				numberOfMonths: 3,
				//defaultDate: new Date ( "" ),
				beforeShowDay: function(date) {
			var d = date.getDate(),
				m = date.getMonth()+1,
				y = date.getFullYear();
				
			if (specialDays[y] && specialDays[y][m] && specialDays[y][m][d]) {
				var s = specialDays[y][m][d];
				return [true, "ui-state-active", s.tooltip];
			}
			return [true,'']; // no change
		}
			
	//		});
		
		
		
		
	});
}

//specialdayscat

var specialDayscat = {
				   
			'2010': {
				'1': {
					'1': {tooltip: "Cap d'Any"},
					'6': {tooltip: "Reis"}
					},
				'4': {
					'2': {tooltip: "Divendres Sant"}, 
					'5': {tooltip: "Dilluns de Pasqua Florida"}
				},
				'5': {
					'1': {tooltip: "Festa del Treball"}					
				},
				'6': {
					'24': {tooltip: "Sant Joan"}					
				},

				'9': {
					'11': {tooltip: "Diada Nacional de Catalunya"}					
				},
				'10': {
					'12': {tooltip: "Festa Nacional d'Espanya"}					
				},
				'11': {
					'1': {tooltip: "Tots Sants"}					
				},

				'12': {
					'6': {tooltip: "Dia de la Constitució"},
					'8': {tooltip: "la Immaculada"},
					'25': {tooltip: "Nadal"},
					'26': {tooltip: "Sant Esteve"}
				}
			}
		}; 

function calendaricat(){
$("#calendariselect").datepicker({
				dateFormat: 'dd/mm/yy',				  
				numberOfMonths: 3,
				//defaultDate: new Date ( "" ),
				beforeShowDay: function(date) {
			var d = date.getDate(),
				m = date.getMonth()+1,
				y = date.getFullYear();
				
			if (specialDayscat[y] && specialDayscat[y][m] && specialDayscat[y][m][d]) {
				var s = specialDayscat[y][m][d];
				return [true, "ui-state-active", s.tooltip];
			}
			return [true,'']; // no change
		}
			
	//		});
		
		
		
		
	});
}

//specialdayses

var specialDayses = {
				   
			'2010': {
				'1': {
					'1': {tooltip: "Año Nuevo"},
					'6': {tooltip: "Epifanía"}
					},
				'4': {
					'2': {tooltip: "Viernes Santo"}, 
					'5': {tooltip: "Lunes de Pascua Florida"}
				},
				'5': {
					'1': {tooltip: "Fiesta del Trabajo"}					
				},
				'6': {
					'24': {tooltip: "San Juan"}					
				},

				'9': {
					'11': {tooltip: "Fiesta Nacional de Cataluña"}					
				},
				'10': {
					'12': {tooltip: "Fiesta Nacional de España"}					
				},
				'11': {
					'1': {tooltip: "Todos los Santos"}					
				},

				'12': {
					'6': {tooltip: "Día de la Constitución"},
					'8': {tooltip: "La Inmaculada"},
					'25': {tooltip: "Natividad"},
					'26': {tooltip: "San Esteban"}
				}
			}
		}; 

function calendaries(){
$("#calendariselect").datepicker({
				dateFormat: 'dd/mm/yy',				  
				numberOfMonths: 3,
				//defaultDate: new Date ( "" ),
				beforeShowDay: function(date) {
			var d = date.getDate(),
				m = date.getMonth()+1,
				y = date.getFullYear();
				
			if (specialDayses[y] && specialDayses[y][m] && specialDayses[y][m][d]) {
				var s = specialDayses[y][m][d];
				return [true, "ui-state-active", s.tooltip];
			}
			return [true,'']; // no change
		}
			
	//		});
		
		
		
		
	});
}
//------------------------------
function validarform (nomdelform){
	
  $('#formcontacte').ketchup();
	
	}
//-----------------------------------	
function obrefinestra(pagina){
aviswindow=window.open(pagina,"avis","location=1,status=0,toolbar=no,scrollbars=yes,width=850,height=400");
//aviswindow.moveTo(40,40);
}
//-------------------------------
