jQuery(document).ready(function(){
	$('.hover').pngfix();
	$('.plain_ul li img').pngfix();
	$('.roundtop577,.roundbottom577,.roundtop449,.roundbottom449').pngfix();
	$('.image-slider').simpleSlide();
	
	$('.twtr-bd').change(twitterStyle);
	
	setTimeout(twitterStyle, 5000);	
	 
	$('a[rel*=facebox]').facebox();
	
	$('#flickr-ul').jflickrfeed({
		limit: 3,
		qstrings: {
			id: '39099611@N04'
		},
		useTemplate: false,
		itemCallback: function(item){
			$(this).append("<li><a href='" + item.image_b + "' rel='fancybox'><img class='flickrimg' src='" + item.image_m + "' alt=''/></a></li>");
		}
		
	},function(){
			$('a[rel*=fancybox]').fancybox();
		});

	
	$.fn.qtip.styles.mystyle = { 
		border: {
			width: 7,
			radius: 5
		},
		title: {
			'font-size': 11,
			'padding-left':10,
			'padding-top':3,
			'padding-bottom':3,
			'font-weight':'bold',
			'font-family': 'Helvetica, Arial,sans-serif'
		},
		'font-size': 10,
		'font-family': 'Helvetica, Arial,sans-serif',
		tip: 'topLeft',
		name: 'dark' 
	}
	$.fn.qtip.styles.newStyle = { 
		border: {
			width: 7,
			radius: 5
		},
		title: {
			'font-size': 11,
			'padding-left':10,
			'padding-top':3,
			'padding-bottom':3,
			'font-weight':'bold',
			'font-family': 'Helvetica, Arial,sans-serif'
		},
		'font-size': 10,
		'font-family': 'Helvetica, Arial,sans-serif',
		tip: 'bottomRight',
		name: 'dark' 
	}
	
	/*
	 $('#antofagasta').qtip({
		content: {
			text: 'Pronto más información',
			title: { text: 'Próximamente...' }
		},
		show: 'mouseover',
		hide: 'mouseout',
		position: { target: 'mouse' },
		style: 'mystyle'
	});
	*/
	
	$('.championship_vinadelmar').qtip({
		content: {
			text: 'Torneo Masculino:<br />3 y 4 de Octubre.<br /><br />Torneo Femenino:<br />3 y 4 de Octubre.',
			title: { text: 'Próximamente...' }
		},
		show: 'mouseover',
		hide: 'mouseout',
		position: { target: 'mouse' },
		style: 'mystyle'
	});
	$('.championship_santiago').qtip({
		content: {
			text: 'Torneo Masculino:<br />5 de Septiembre al 24 de Octubre.<br /><br />Torneo Femenino:<br />22 y 23 de Agosto.',
			title: { text: 'Próximamente...' }
		},
		show: 'mouseover',
		hide: 'mouseout',
		position: { target: 'mouse' },
		style: 'mystyle'
	});
	$('.championship_concepcion').qtip({
		content: {
			text: 'Torneo Masculino:<br />24 y 25 de Octubre.<br /><br />Torneo Femenino:<br />24 y 25 de Octubre.',
			title: { text: 'Próximamente...' }
		},
		show: 'mouseover',
		hide: 'mouseout',
		position: { target: 'mouse' },
		style: 'mystyle'
	});
	$('.championship_puertomontt').qtip({
		content: {
			text: 'Torneo Masculino:<br />8 y 9 de Agosto.<br /><br />Torneo Femenino:<br />8 y 9 de Agosto.',
			title: { text: 'Próximamente...' }
		},
		show: 'mouseover',
		hide: 'mouseout',
		position: { target: 'mouse' },
		style: 'mystyle'
	});
	$('.championship_final').qtip({
		content: {
			text: 'Torneo Masculino:<br />7 y 8 de Noviembre.',
			title: { text: 'Próximamente...' }
		},
		show: 'mouseover',
		hide: 'mouseout',
		position: { target: 'mouse' },
		style: 'mystyle'
	});
	$('.soon').qtip({
		content: {
			text: 'Mas información',
			title: { text: 'Próximamente...' }
		},
		show: 'mouseover',
		hide: 'mouseout',
		position: { target: 'mouse' },
		style: 'mystyle'
	});
	$('.news1').qtip({
		content: {
			text: $('.news1').attr('rel'),
			title: { text: $('.news1').attr('reltitle')}
		},
		show: 'mouseover',
		hide: 'mouseout',
		style: 'newStyle',
		position: { target: 'mouse',corner: {					 
					 tooltip: 'bottomRight'
				  }}
	});
	$('.news2').qtip({
		content: {
			text: $('.news2').attr('rel'),
			title: { text: $('.news2').attr('reltitle') }
		},
		show: 'mouseover',
		hide: 'mouseout',
		style: 'newStyle',
		position: { target: 'mouse' ,corner: {					 
					 tooltip: 'bottomRight'
				}}
	});
	
	HoverBehave = $.klass({
	  initialize: function(hoverClass) {
	    this.hoverClass = hoverClass;
	  },
	  onmouseover: function() {
	    this.element.addClass(this.hoverClass);
	  },
	  onmouseout: function() {
	    this.element.removeClass(this.hoverClass);
	  }
	});
	
	Zebralizer = $.klass({
	  initialize: function(zebralizerElement) {
			//this.element = id;
	    this.zebralizerElement = zebralizerElement;
			$(this.element)
				.find(zebralizerElement)
					.removeClass('odd')
				.end()
				.find(zebralizerElement+':odd')
					.addClass('odd');
				//hover
	  },
	  onmouseover: function() {
	  },
	  onmouseout: function() {
	  }
	});  	
	
	ToggleBehavior = $.klass({
		initialize: function(ToggleElement) {
			$(this.element).toggle(function(){
				$(ToggleElement).fadeIn('fast');
			},function(){
				$(ToggleElement).fadeOut('fast');
			});
		},
		onclick: function() {    
			return false;
		} 
	});
	
	jQuery(function($) {
		$('.side-menu ul li').attach(HoverBehave,'hover');
	});   
 
	$('.flash').fadeOut(8000);
	$('.alert').fadeOut(8000);   
	
	$('.pointer').click(function(){
		$('.map-image').attr('src',$(this).attr('relmap'));
		$('.map-description').attr('src',$(this).attr('reldesc'));
	})
});

function twitterStyle(){
	$("#twtr-widget-1 h3").html("COPA COPEC 2010");
	$("#twtr-widget-1 h4").html("Información Oficial");
	$("#twtr-widget-1 h4").attr("style","font-size: 14px !important");
	$(".twtr-tweet:first").attr("style","background-color: #E1081E !important");
	$(".twtr-tweet:first .twtr-tweet-text p").attr("style","color:#FFFFFF !important");
}

