(function(){
	var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
	document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

	$('#wp-calendar td a').parent().addClass('link');
	$('#wp-calendar td a').parent().hover(function(){$(this).addClass('hover')}, function(){$(this).removeClass('hover')});
	$('input.text').focus(function(){$(this).addClass('hover')});
	$('input.text').blur(function(){$(this).removeClass('hover')});
	$('textarea').focus(function(){$(this).addClass('hover')});
	$('textarea').blur(function(){$(this).removeClass('hover')});
	
	//1-33
	var numberOfImage = 1;
	if( document.cookie != true ){
		numberOfImage = Math.floor( Math.random() * 32 ) + 1;
		var img = document.createElement('img');
		img.src = '/wp-content/themes/buzzbranch/images/title/' + numberOfImage + '.png';
		img.onload = function(){
			$( '#siteName a' ).css( 'background-image', 'url(' + img.src + ')' );
			
			if( numberOfImage != 1 ){
				$( '#header' ).css( 'background-image', 'url(' + img.src + ')' );
			}
			
			document.cookie = true;
		}
	}
	
	if ($('div#map')[0] && GBrowserIsCompatible()) {
		$('div#map').css('height', '570px');
		var map = new GMap2($('div#map')[0]);
		var point = new GLatLng(35.529000,139.700100);
		map.setCenter(point, 18);
		map.addControl(new GOverviewMapControl());
		
		var icon = new GIcon();
		icon.image = "/images/logoMap.png";
		icon.iconSize = new GSize(200, 138);
		icon.iconAnchor = new GPoint(0, 0);
		var markeropts = new Object();
		markeropts.icon = icon;
		var marker = new GMarker(new GLatLng(point.lat() + 0.0005, point.lng() - 0.0005), markeropts);
		map.addOverlay(marker);
	}
	
	$( '#mailto' ).hover( function(){ $( this ).addClass( 'hover' ) }, function(){ $( this ).removeClass( 'hover' ) } );
	$( '#mailto' ).click( function(){
	    var result = "mailto:";
	    var i = 0;
	    var m = ["69", "6e", "66", "6f", "40", "42", "55", "5a", "5a", "62", "72", "61", "6e", "63", "68", "2e", "63", "6f", "6d"];
	    while(true){
	        if(i > m.length - 1) break;
	        result = result + "%" + m[i];
	        i ++;
	    }
	    location.href = result;
	} );
	
	
	function galleryPaging(){
		$.get('/galleryIndex.php?n='+$( this ).attr( 'rel' ).match( /^[0-9]+/ )+'&o='+$( this ).attr( 'rel' ).match( /[0-9]+$/ ), function( data, status ){
			$( '#gallery' ).parent().html( data );
			$( 'div.textBody a img' ).parent().lightBox();
			$( '#gallery p.pageNavi a' ).click( galleryPaging );
		});
		return false;
	}
	
	$( 'div.textBody a img' ).parent().lightBox();
	$( '#gallery p.pageNavi a' ).click( galleryPaging );
	
	var pageTracker = _gat._getTracker("UA-4805924-2");
	pageTracker._initData();
	pageTracker._trackPageview();
})(jQuery);