function mycarousel_initCallback(carousel){
	// Disable autoscrolling if the user clicks the prev or next button.
	carousel.buttonNext.bind('click', function() {
			carousel.startAuto(0);
		});
	
	carousel.buttonPrev.bind('click', function() {
			carousel.startAuto(0);
		});
	
	// Pause autoscrolling if the user moves with the cursor over the clip.
	carousel.clip.hover(function() {
			carousel.stopAuto();
		}, function() {
			carousel.startAuto();
		});
};
function slideSwitch() {
	var $active = $('#publicacoes-slide li.active');
	
	if ( $active.length == 0 ) $active = $('#publicacoes-slide li:last');
	
	var $next =  $active.next().length ? $active.next()
	: $('#publicacoes-slide li:first');
	
	$active.addClass('last-active');
	
	$next.css({opacity: 0.0})
	.addClass('active')
	.animate({opacity: 1.0}, 2000, function() {
			$active.removeClass('active last-active');
		});
}

jQuery(document).ready(function() {
	jQuery('#mycarousel').jcarousel({
		auto: 2,
		wrap: 'last',
		initCallback: mycarousel_initCallback
	});
	$('#publicacoes-slide').css({
		'overflow'	:'hidden',
		'height'	: '242px',
		'width'		: '165px'
	});
	$('#publicacoes-slide li:first').addClass('active');
	$(function() {
		setInterval( "slideSwitch()", 5000 );
	});
	$('#video').youTubeChannel({ 
		loadingText: 'Carregando',
		userName: 'intermidiariopreto'
	});
	$("#acc1").accordion({
		alwaysOpen: false,
		collapsible: true,
		active: false,
		autoheight: false,
		header: 'a.acc1',
		clearStyle: true
	});
	$("#acc2").accordion({
		alwaysOpen: false,
		collapsible: true,
		active: false,
		autoheight: false,
		header: 'a.acc2',
		clearStyle: true
	});
	if($('#map_canvas').val() != undefined){
		initialize();
	}
	$('#como_conheceu').change(function(){
		if(($(this).val() == 'Feiras/Eventos')||($(this).val() == 'Outros')){
			if($('#como_encontrou_div').length == 0){
				$(this).after('<div id="como_encontrou_div" style="float: left;border: 0;padding: 0;margin: 0"><label>Qual?</label><input name="como_encontrou" type="text" /></div>');
			}
		}
		else{
			if($('#como_encontrou_div').length == 1){
				$('#como_encontrou_div').remove();
			}
		}
	})
});
function flash(file, width, height){
	document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='" + width + "' height='" + height + "'>");
	document.write("<param name='wmode' value='transparent'>");
	document.write("<param name='movie' value='" + file + "'>");
	document.write("<param name='quality' value='high'>");
	document.write("<embed wmode='transparent' src='" + file + "' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='" + width + "' height='" + height + "'></embed>");
	document.write("</object>");
}
//	GOOGLE MAPS
var map;
var geocoder;
function initialize() {
  if (GBrowserIsCompatible()) {
	var map = new GMap2(document.getElementById("map_canvas"));
	var point = new GLatLng(-20.814612122993086, -49.37656044960022);
	map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());
	map.setCenter(point, 15);
	map.addOverlay(new GMarker(point));
	map.openInfoWindow(map.getCenter(),"<div class='gmapinfowindow'><p>Rua C&acirc;ndido Carneiro, 236<br /> Bairro: Sta Cruz<br />CEP: 15014-200<br />São José do Rio Preto, SP</p></div>");
  }
}
