$(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
});

// dropdown fix for IE7

$('#sidebar').css('zIndex', 1);
$('#nav').css('zIndex', 2);
$('#content_right').css('zIndex', 0);

// table.alternate

$('table.alternate tr').each(function(i) {
var even = (i%2 == 0) ? true : false;
if (even) {
$(this).addClass('even');
}
});


});
