$(document).ready(function() {
						   
// search
$('#s').focus(function() {	
if ($(this).attr('value') == 'Search') {
$(this).attr('value','');
}
});

$('#s').blur(function() {
if ($(this).attr('value') == '') {
$(this).attr('value','Search');
}
});

// email encode

$('.encode').each(function() {
var link_html = '';
$(this).children('span').each(function() {
link_html += $(this).html();	
$(this).remove();
});
var address = $(this).html();
address = address.replace(/\(at\)/g,'@');
address = address.replace(/\(dot\)/g,'.');
link_html = (!link_html) ? address : link_html;
$(this).replaceWith('<a href="mailto:'+ address +'">'+ link_html +'</a>');
});

// modal
$('a.iframe').each(function() { // for each a tag with class iframe
var defaultWidth = 768;
var defaultHeight = 512;
var customWidth = 0;
var customHeight = 0;
var classes = $(this).attr("class").split(" ");
for (var i = 0; i < classes.length; i++) { // for each class
var thisClass = classes[i];
var splitClass = thisClass.split("_");
var customValue = Number(splitClass[1]); 
switch (splitClass[0]) { // check for w or h
case 'w':
customWidth = customValue;
break;
case 'h':
customHeight = customValue;
break;
} // end check for w or h
} // end for each class
var boxWidth = (customWidth) ? customWidth : defaultWidth;
var boxHeight = (customHeight) ? customHeight : defaultHeight;
$(this).fancybox({
width: boxWidth,
height: boxHeight,
overlayColor: '#000',
overlayOpacity: 0.7,
type: 'iframe'
});
}); // end for each a tag with class iframe

$('img.modal').each(function() {
var src = $(this).attr('src');					 
$(this).wrap('<a href="'+ src +'" class="modal"></a>');
});

$('a.modal').fancybox({
overlayColor: '#000',
overlayOpacity: 0.7,
'titlePosition' : 'inside',
'cyclic' : true
});


// initialize googlMap
googleMap();

});

// google map
function googleMap() {
if (document.getElementById("map_canvas")) {
var latlng = new google.maps.LatLng(48.432991, -89.221108);
var myOptions = {
zoom: 15,
center: latlng,
panControl: false,
zoomControl: true,
scaleControl: false,
streetViewControl: false,
overviewMapControl: false,
mapTypeControl: false,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var image = new google.maps.MarkerImage('/library/images/google_map_icon.png',
new google.maps.Size(94, 55),
new google.maps.Point(0,0),
new google.maps.Point(0, 55));
var marker = new google.maps.Marker({
position: latlng,
map: map,
icon: image
});   

}
}
