var path = "/wp-content/themes/gallo";
var map;
var counter = 1;

Cufon.replace('ul#nav', {hover: true});
Cufon.replace('ul.sub-nav a', {hover: true});
Cufon.replace('ul.logos a', {hover: true});
Cufon.replace('.fancy-sans', {hover: true});
Cufon.replace('.project-grid-view li .text', {hover: true});
Cufon.replace('h1', {hover: true});
Cufon.replace('h2', {hover: true});
Cufon.replace('h3', {hover: true});
Cufon.replace('h4', {hover: true});
Cufon.replace('h5', {hover: true});
Cufon.replace('h6', {hover: true});
Cufon.replace('dl dt', {hover: true});

$(function(){
	$("ul.logos a").hover(function(){
		var _tmp = $(this).attr("rel");
		$("ul.logos").css("background-image", "url(" + path + _tmp + ")");
	}, function(){
//		$("ul.logos").css("background-image", "");
	});
	
	var mainHeight = parseInt(($("#primary").outerHeight(true)) , 10);
	var sidebarHeight = 345;
	if($(".sub-nav").length){
		sidebarHeight += parseInt($(".sub-nav").outerHeight(true), 10);
	}
	
	// console.log(sidebarHeight);
	if(mainHeight <= 600 && sidebarHeight <= 600){
		$("#sidebar-left").css("height", 600);
		$("#primary").css("height", 600);
	}// else if(mainHeight < sidebarHeight){
	// 		$("#sidebar-left").css("height", sidebarHeight);
	// 		// console.log(sidebarHeight);
	// 	}else if(sidebarHeight < mainHeight){
	// 		$("#sidebar-left").css("height", mainHeight);
	// 	} 
	
	$(".fancybox").fancybox({
		centerOnScroll: true,
		hideOnContentClick: true,
		overlayColor: '#000'
	});
	
	$(".bio-content h4").each(function(){
		$(this).html(replaceRSign($(this).html()));
	});
	
	$(".sub-nav a").each(function(){
		$(this).html(replaceRSign($(this).html()));
	});
	
	$("#post-1267	dl dt").each(function(){
		$(this).html(replaceRSign($(this).html()));
	});
	
	$("#primary p").each(function(){
		$(this).html(replaceRSign($(this).html()));
	});
	
	Cufon.now();
	
	if($("#map_canvas").length){
		initialize();
	}
	
	
	$(".project-grid-view li").each(function(){
		//do it here
		if(counter == 2){
			$(this).addClass("middle");
		}
		//manage the counter
		if(counter == 3){ counter = 1; }else{ counter ++; }
		
	});
	
});


function initialize() {
	if (GBrowserIsCompatible()){
	  map = new GMap2(document.getElementById("map_canvas"));
	  map.setCenter(new GLatLng(26.300177, -80.127347), 12);
		var point = new GLatLng(26.300177, -80.127347);
    map.addOverlay(new GMarker(point));
		// map.disableDragging()
		map.setUIToDefault();
	}
}

function replaceRSign(value){
	var ouput = value.replace('&reg;', '<span class="reg">&reg;</span>');
	var ouput = ouput.replace('®', '<span class="reg">&reg;</span>');
	return(ouput);
}
