// adds iPhone css for iPhones or Android Phones and BlackBerrys
if( (navigator.userAgent.indexOf('iPhone') != -1) ||
(navigator.userAgent.indexOf('iPod') != -1) ||
(navigator.userAgent.indexOf('Android') != -1) ||
( navigator.userAgent.indexOf('BlackBerry') != -1 ) ) {
// iPhone layout
var cssNode = document.createElement('link');
cssNode.setAttribute('rel', 'stylesheet');
cssNode.setAttribute('type', 'text/css');
cssNode.setAttribute('href', 'http://cadistrict38.org/wp/wp-content/themes/seams3/iPhone1.css');
cssNode.setAttribute('media', 'all');
document.getElementsByTagName('head')[0].appendChild(cssNode);
// iPhone fonts
var cssNode = document.createElement('link');
cssNode.setAttribute('rel', 'stylesheet');
cssNode.setAttribute('type', 'text/css');
cssNode.setAttribute('href', 'http://cadistrict38.org/wp/wp-content/themes/seams3/fonts_iphone.css');
cssNode.setAttribute('media', 'all');
document.getElementsByTagName('head')[0].appendChild(cssNode);
} // end if
jQuery().ready(function($){
// if blackberry hide switcher
if( navigator.userAgent.indexOf('BlackBerry') != -1 ) {
$('#switcher').hide();
} // end if
// put all links in headerbar to target=_blank unless specified
$('#headerbar a').each(
function(i) {
if($(this).html() != 'Site Admin' && $(this).html() != 'Log out' && $(this).html() != 'Log in') {
$(this).attr('target', '_blank');
}
} // end function
); // end each
// animates links in pages menu
$('.pages a').hover(
function() {
// $(this).animate({marginLeft: '-25px'}, 750);
}, // end function
function() {
// $(this).animate({marginLeft: '0px'}, 750);
} // end function
); // end hover
// removes background and padding from img links in posts
// css adds background and padding to some via attribute selectors
$('.post p a img').parent().css({'background-image' : 'none', 'padding-right' : '0px'});
// adds microformat classes to each league in sidebar_b
$('.leagues a').addClass('fn org url');
$('#email_subscribe').focus(
function(){
if( $(this).val() == 'enter your e-mail address' )
$(this).val('');
} // end function
); // end focus
$('#email_subscribe').blur(
function(){
if( $(this).val() == '' || $(this).val() == null)
$(this).val('enter your e-mail address');
} // end function
); // end blur
/*
feedburner's inline javascript repurposed for jQuery
-------------------------------------------------------------------------------- */
$('#subscribe_form').attr('target', 'popupwindow');
$('#subscribe_form').submit(
function() {
window.open('http://feedburner.google.com/fb/a/mailverify?uri=CaliforniaDistrict38', 'popupwindow', 'scrollbars=yes,width=550,height=520');
return true;
} // end function
); // end submit
/*
end feedburner's inline javascript repurposed for jQuery
-------------------------------------------------------------------------------- */
// adds iPhone css switcher for iPhones and Android
if( (navigator.userAgent.indexOf('iPhone') != -1) ||
(navigator.userAgent.indexOf('iPod') != -1) ||
(navigator.userAgent.indexOf('Android') != -1) ) {
// iPhone css switcher
$('#switcher').click(
function() {
// styles switcher link for mobile and classic look of site
$('#switcher').css({'display' : 'block', 'font-size' : '34pt', 'line-height' : '115%', 'text-align' : 'center', 'display' : 'block', 'background-color' : '#dddddd'});
// grabs all of the link tags
linkTags = $('link');
// cycles through all of the link tags
for(i=0; i';
if(league) {
if(url) {
leagueMini += '
';
}//
else {
leagueMini += '' + league + '
';
} // end else
} // end if league
leagueMini += '';
if(street)
leagueMini += '' + street + '';
if(city)
leagueMini += '' + city + ', CA ';
if(zip)
leagueMini += '' + zip + '
';
leagueMini += '';
if(zip)
leagueMini += 'how to get here';
// leagueMini += 'get directions from here';
leagueMini += '';
// if lgSnapshot exists remove it
if( $('#lgSnapshot').length > 0 ) {
$('#lgSnapshot').remove();
} // end if
// append league snapshot to league select container
$(this).parent().append( leagueMini );
$('#lgSnapshot').animate({opacity: 'show'}, 1000);
// set originatingLeague cookie to current league so visitor's league always appears
setCookie('originatingLeague',league,365);
// string for ajax request
var dataString = 'league=' + league;
$.ajax({
// type of form submission
type: "POST",
// url of server file
url: "http://cadistrict38.org/wp/wp-content/themes/seams3/originatingLeague.php",
// data to be sent
data: dataString,
// function on submission (i is param echoed back)
success: function(i) {
// alert(i);
} // end success
}); // end ajax
} // end function
); // end change event
$('#s').focus(
function() {
if( $('#s').val() == 'search' ) {
$('#s').val('');
} // end if
} // end function
); // end focus
$('#s').blur(
function() {
if( $('#s').val() == 'search' || $('#s').val() == null || $('#s').val() == '' ) {
$('#s').val('search');
} // end if
} // end function
); // end focus
// for each upb_title append add to calendar link
$(".upb_title").each(
// i is reference to current spot in array of upb_title
function (i) {
// add to calendar link
exportLink = 'add to calendar';
// append export link to each upcoming event
$(this).next().append(exportLink);
} // end function
); // end each
// forces the first staff member (usually DA) to have css like the rest
$('.staffMember:first').css({
'clear' : 'none',
'border-top-width' : '1px'
}); // end css
// returns content of cookie
// from http://www.w3schools.com/JS/js_cookies.asp
function getCookie(c_name) {
if (document.cookie.length>0) {
c_start=document.cookie.indexOf(c_name + "=");
if (c_start!=-1) {
c_start=c_start + c_name.length+1 ;
c_end=document.cookie.indexOf(";",c_start);
if (c_end==-1) c_end=document.cookie.length
return unescape(document.cookie.substring(c_start,c_end));
} // end if
} // end if
return ""
} // end function
// sets cookie
// from http://www.w3schools.com/JS/js_cookies.asp
function setCookie(c_name,value,expiredays) {
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : "; expires="+exdate.toGMTString());
} // end function
// checks for cookie's existence and if found changes #lgSelect
// from http://www.w3schools.com/JS/js_cookies.asp
function checkCookie() {
// gets cookie value
originatingLeague = getCookie('originatingLeague');
// if cookie has a value
if (originatingLeague != null && originatingLeague != "") {
// change value in #lgSelect to cookie value
$('#lgSelect').val(originatingLeague);
// trigger the change event for #lgSelect
$('#lgSelect').trigger('change');
} // end if
else {
// blank out league select
$('#lgSelect').val(' ');
} // end else
} // end function
// check for cookie
checkCookie();
// animated scroll to page anchor
// comment #23 here: http://www.learningjquery.com/2007/09/animated-scrolling-with-jquery-12
$('a[href*=#]:not([href=#])').click(
function() {
if ( location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname ) {
var $target = $(this.hash);
$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
if ($target.length) {
var targetOffset = $target.offset().top;
$('html,body').animate({scrollTop: targetOffset}, 250);
return false;
} // end if
} // end if
} // end function
); // end click
}); // end onload