var quickLoad = true,
slider2 = null, // Large image slider
slider = null, // scrollable slider
init = false,
animate = true,
ie = (function(){
var undef, v = 3, div = document.createElement('div'), all = div.getElementsByTagName('i');
while(div.innerHTML = '', all[0]);
return v > 4 ? v : undef;
}());
// Enable or disable animations
if(ie == 6 || ie == 7 || $.cookie('noanimate') == 1 || qstring('noanimate')) {animate = false;}
if(qstring('animate') == 1) {animate = true;$.cookie('noanimate', null);}
if(!animate) {$.cookie('noanimate', 1, {expires: 7, path: '/'});}
if(window.location.pathname == '/search/') {animate = false;}
// Redirect to hash url if no hash to prevent long, redundant url's
if(!window.location.hash && window.location.pathname != '/' && animate) {
var path = window.location.pathname.replace(".",'\\.').replace('/', '\\/');
var href = window.location.href.replace(new RegExp(path + '$'), '/#' + window.location.pathname);
window.location.href = href;
}
function initSliders() {
if(!slider2) {
slider2 = new slider4way();
slider = new scrollslider();
slider2.setScrollSlider(slider);
}
font_replace();
}
$('body').live('loadsub', function() {
if(window.location.hash) {
$('body').hide();
}
});
function slider4way() {
var slider = $('#main-slider');
var items = {current: {}, next: {}, prev: {}, parent: {}, child: {}};
var options = {
slides: {current: '.current', prev: '.prev', next: '.next', parent: '.parent', child: '.child'},
nav: {prev: '.arrow-prev', next: '.arrow-next', parent: '.arrow-parent', child: '.arrow-child'},
speed: 200
};
var dimensions = {height: 0, width: 0};
var scrollslider = null;
var animating = false;
var ishovered = false;
function init() {
// Swap nav arrows on hover
slider.parent().hover(
function() {
$(this).addClass('hover');
$(this).children('.active').fadeIn(200);
ishovered = true;
},
function() {
$(this).removeClass('hover');
$(this).children('.active').fadeOut(200);
ishovered = false;
}
);
$('#main').height($('#content2').height());
$('body').delegate('.box', 'click touchup', function(e) {
if(scrollslider.slider.data('dragging')) return false;
var link = $(this).find('a:first');
var href = link.attr('href');
var rel = link.attr('rel');
if(typeof rel != 'undefined' && rel.length){
rel = $.parseJSON(rel);
if(rel.a != '' && typeof rel.a != 'undefined'){
if(rel.a.match(/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$/i)){
href = 'mailto:'+rel.a;
}else{
href = 'mailto:'+rel.a+'@comandsolutions.com';
}
link.attr('href',href);
window.location.href = href;
return true;
}
if(!animate || e.ctrlKey || e.shiftKey) {
window.location.href = href;
} else {
items.child = $('
').text('{"link":"' + href + '"}');
slideFromBottom();
}
}
return false;
});
$('body').delegate('.box', 'click touchup', function(e) {
if(scrollslider.slider.data('dragging')) return false;
var link = $(this).find('a:first').attr('href');
if(!animate || e.ctrlKey || e.shiftKey) {
window.location.href = link;
} else {
items.child = $('').text('{"link":"' + link + '"}');
slideFromBottom();
}
return false;
});
if(animate) {
//Remove all arrows
slider.parent().children('.arrows').remove();
// Add the navigation links but hide them for now.
var navlink = $('').attr('href', '#').addClass('arrows').text('navigation');
$.each(options.nav, function() {
slider.parent().append(navlink.clone().addClass(this.replace('.', '')));
});
// Bind our events to the navigation
$(options.nav.prev, slider.parent()).bind('click touchup', slideFromLeft);
$(options.nav.next, slider.parent()).bind('click touchup', slideFromRight);
$(options.nav.parent, slider.parent()).bind('click touchup', slideFromTop);
$(options.nav.child, slider.parent()).bind('click touchup', slideFromBottom);
$('body').delegate('#slider-mini a', 'click touchup', slideFromSlide);
var from_bottom = '.subnav a, .headers a, #footer .nav a, .subpage #pager a, .news a',
from_top = '#header a';
$('body').delegate(from_bottom, 'click touchup', function(e) {
if(e.ctrlKey || e.shiftKey) {return true;}
var link = $(this).attr('href');
items.child = $('').text('{"link":"' + link + '"}');
slideFromBottom();
return false;
});
$('body').delegate(from_top, 'click touchup', function(e) {
if(e.ctrlKey || e.shiftKey) {return true;}
var link = $(this).attr('href');
items.parent = $('').text('{"link":"' + link + '"}');
slideFromTop();
return false;
});
items.current = {
slide : slider.find(options.slides.current),
nav : slider.find(options.slides.current).siblings('.slide').remove()
};
dimensions.height = items.current.slide.outerHeight(true);
dimensions.width = items.current.slide.outerWidth(true);
cycle();
}
slider_mini_init();
$('
').attr('src', '/images/boxhover.png');
}
// Reconfigure slides on initial page load or when another slide is loaded into view
function cycle() {
items.next = items.prev = items.parent = items.child = {};
for(var i = 0; i < items.current.nav.length; i++) {
var item = $(items.current.nav[i]);
if(item.hasClass(options.slides.next.replace('.', ''))) {
items.next = item;
} else if (item.hasClass(options.slides.prev.replace('.', ''))) {
items.prev = item;
} else if (item.hasClass(options.slides.parent.replace('.', ''))) {
items.parent = item;
} else if (item.hasClass(options.slides.child.replace('.', ''))) {
items.child = item;
}
}
show_hide_nav();
preload();
}
// Add or remove active states on nav elements that don't belong to this slide.
function show_hide_nav() {
$.each(items, function(index) {
if(index != 'current') {
var item = $(options.nav[index], slider.parent());
if(!$.isEmptyObject(this)) {
item.addClass('active');
if(ishovered){
item.show();
}
} else {
item.removeClass('active').hide();
}
}
});
}
// slides from top to bottom
function slideFromTop() {
if(animating) return false;
slider.stopTime().everyTime(100, 'loadparent', function() {
if(typeof items.parent.status == 'undefined' && items.parent instanceof jQuery) {
loadPage('parent', $.parseJSON(items.parent.text()).link);
} else if(items.parent.status == 'loaded') {
slider.stopTime('loadparent');
animating = true;
slider.prepend(items.parent.slide).css({top: dimensions.height * -1});
slider.stop().animate({top: 0}, options.speed, function() {
items.current.slide.remove();
items.current = items.parent;
pushToGoogleAnalytics(items.current.url.replace(/index\.(html?|php)$/, ''));
quickLoad = false;
$.history.load(items.current.url.replace(/index\.(html?|php)$/, ''));
cycle();
pageSwap('current');
});
}
});
return false;
}
// slidenext slides from right to left
function slideFromRight() {
if(animating) return false;
slider.stopTime().everyTime(100, 'loadnext', function() {
if(typeof items.next.status == 'undefined' && items.next instanceof jQuery) {
loadPage('next', $.parseJSON(items.next.text()).link);
} else if(items.next.status == 'loaded') {
slider.stopTime('loadnext');
animating = true;
slider.width(dimensions.width * 2).append(items.next.slide);
items.current.slide.children().fadeOut();
slider.stop().animate({left: dimensions.width * -1}, options.speed, function() {
items.current.slide.remove();
slider.css({left: 0, width: dimensions.width});
items.current = items.next;
pushToGoogleAnalytics(items.current.url.replace(/index\.(html?|php)$/, ''));
quickLoad = false;
$.history.load(items.current.url.replace(/index\.(html?|php)$/, ''));
cycle();
pageSwap('current');
});
}
});
return false;
}
// slideprev slides from left to right
function slideFromLeft() {
if(animating) return false;
slider.stopTime().everyTime(100, 'loadprev', function() {
if(typeof items.prev.status == 'undefined' && items.prev instanceof jQuery) {
loadPage('prev', $.parseJSON(items.prev.text()).link);
} else if(items.prev.status == 'loaded') {
slider.stopTime('loadprev');
animating = true;
slider.width(dimensions.width * 2).prepend(items.prev.slide).css({left: dimensions.width * -1});
slider.stop().animate({left: 0}, options.speed, function() {
items.current.slide.remove();
slider.css({width: dimensions.width});
items.current = items.prev;
pushToGoogleAnalytics(items.current.url.replace(/index\.(html?|php)$/, ''));
quickLoad = false;
$.history.load(items.current.url.replace(/index\.(html?|php)$/, ''));
cycle();
pageSwap('current');
});
}
});
return false;
}
// slide from bottom to top
function slideFromBottom() {
if(animating) return false;
slider.stopTime().everyTime(100, 'loadchild', function() {
if(typeof items.child.status == 'undefined' && items.child instanceof jQuery) {
loadPage('child', $.parseJSON(items.child.text()).link);
} else if(items.child.status == 'loaded') {
slider.stopTime('loadchild');
animating = true;
slider.append(items.child.slide).stop().animate({top: dimensions.height * -1}, options.speed, function() {
items.current.slide.remove();
slider.css({top: 0});
items.current = items.child;
pushToGoogleAnalytics(items.current.url.replace(/index\.(html?|php)$/, ''));
quickLoad = false;
$.history.load(items.current.url.replace(/index\.(html?|php)$/, ''));
cycle();
pageSwap('current');
});
}
});
return false;
}
function slideFromSlide() {
if(animating) return false;
var href = $(this).attr('href');
if(href.indexOf('http://' + window.location.hostname) !== 0) {
return true;
}
slider.stopTime().everyTime(100, 'loadSlide', function() {
if(typeof items.child.status == 'undefined') {
loadPage('child', href);
} else if(items.child.status == 'loaded') {
slider.stopTime('loadSlide');
animating = true;
var slideshow = $('#slider-mini');
var largeSlide = $('.slide.current');
var img = $('
').attr('src', cssBackgroundImage(items.child.slide.css('background-image'))).css({
position: 'absolute',
left : slideshow.position().left,
top : slideshow.position().top,
width : slideshow.outerWidth(),
height: slideshow.outerHeight(),
zIndex: 9999
});
largeSlide.append(img);
img.animate({top: 0, left: 0, width: largeSlide.width(), height: largeSlide.height()}, 500, function() {
items.current.slide.replaceWith(items.child.slide);
items.current = items.child;
quickLoad = false;
$.history.load(items.current.url.replace(/index\.(html?|php)$/, ''));
cycle();
pageSwap('current');
});
}
});
return false;
}
// Preload the surrounding slides
function preload() {
for(var index in items) {
if(index != 'current' && !$.isEmptyObject(items[index])) {
var link = $.parseJSON(items[index].text()).link;
items[index] = {};
loadPage(index, link);
}
}
}
function loadPage(item, link) {
items[item].status = 'loading';
$.ajax(link, {
cache: true,
success: function(data) {
// $(data).find('title').text() doesnt work as expected
var title = /([^<]+)<\/title>/.exec(data)[1];
data = $(data);
var slider = data.find('#main-slider');
items[item] = {
slide : slider.find(options.slides.current),
nav : slider.find(options.slides.current).siblings('.slide'),
scrollslider: data.find('#slider-wrap'),
content: data.find('#content2'),
url : link, // so we can add it to the url history
title : title
};
items[item].slide.children().hide();
// Preload the image
var img = cssBackgroundImage(items[item].slide.css('background-image'));
$('
').attr('src', img).load(function() {
items[item].status = 'loaded';
});
}
});
}
/**
* Transition content sections. Item could be the name of an already loaded item in the items
* object such as current, prev, next, etc, or the item object itself
*/
function pageSwap(item) {
animating = true;
if(typeof item === 'string') {item = items[item];}
if($('#content2').length) {$('#content2').remove();}
if(item.slide.children().length) {
if(ie == 8) {
item.slide.children().show();
} else {
//item.slide.children().show();
item.slide.children().fadeIn(200);
}
if(item.content.length) {
item.content.hide();
$('#inner').append(item.content);
if(ie == 8) {
item.content.show();
} else {
item.content.fadeIn(200);
}
font_replace();
}
}
$('body').unbind('scrollslider.out').bind('scrollslider.out', function() {
$('#main').height($('#content2').height());
slider_mini_init();
if($('#slider').length) {
$('#slider').find('.box').each(function() {
var img = $(this).find('img');
if(typeof img != 'undefined' && img.length) {
$('
').attr('src', img.attr('src').replace(/smallnav/, 'large'));
}
});
}
font_replace();
animating = false;
});
if(item.scrollslider.length && scrollslider.slider.length) {
scrollslider.swapSlider(item.scrollslider);
} else if(item.scrollslider.length) {
scrollslider.slideIn(item.scrollslider);
} else if(scrollslider.slider.length) {
scrollslider.slideOut();
} else {
$('body').trigger('scrollslider.out');
}
document.title = item.title;
return true;
}
function slider_mini_init() {
if($('#slider-mini').length && $('#slider-mini').find('.slide-mini').length) {
var mini = $('.inner', '#slider-mini').cycle({
fx: 'fade',
speed: 2500,
autostop: 0
});
mini.hover(function() {
slider.parent().removeClass('hover');
$(this).parent().addClass('hover');
$(this).cycle('pause');
}, function() {
slider.parent().addClass('hover');
$(this).parent().removeClass('hover');
$(this).cycle('resume');
});
}
}
function cssBackgroundImage(s) {
return s.replace(/"/g,"").replace(/url\(|\)$/ig, "");
}
/**
* Track loaded page with google analytics
* Added 2012-01-20
*/
function pushToGoogleAnalytics(p){
_gaq.push(['_trackPageview', p]);
}
init();
return {
'setScrollSlider': function(ss) {scrollslider = ss;}
}
}
function scrollslider() {
var self = this;
this.init = function() {
this.slider = $('#slider');
if(!this.slider.length) {
return;
}
this.inner = $('#slider-inner');
this.slideleft = $('#slide-left');
this.slideright = $('#slide-right');
this.parent = this.slider.parent();
this.height = this.slider.outerHeight();
this.width = this.slider.outerWidth();
this.numBoxes = $('.box', this.slider).size();
this.boxWidth = $('.box:first', this.slider).outerWidth();
this.innerWidth = this.boxWidth * this.numBoxes;
this.maxLeft = (this.innerWidth - this.width);
this.inner.width(this.innerWidth);
if(this.width < this.innerWidth) {
this.slideright.filter(':hidden').fadeIn();
}
this.slider.overscroll({
showThumbs : false,
wheelDirection : 'horizontal',
direction : 'horizontal',
wheelDelta : 50,
cancelOn : '#slide-left #slide-right'
});
// Adjust box heights to fill containers
$('.box').height(this.inner.innerHeight());
$('.box', this.slider).each(function() {
// $(this).height(self.inner.innerHeight());
$(this).find('.content').height($(this).height() - $(this).find('.header').outerHeight(true) - 5);
});
this.slider.bind('scroll', scrollchanged);
this.parent.delegate('#slide-right', 'click touchup', slideRight);
this.parent.delegate('#slide-left', 'click touchup', slideLeft);
}
/**
* Handles the event when a user clicks the #slide-right icon
*/
function slideRight(e) {
var pos = self.slider.scrollLeft();
var newPos = 0, last_box = 0;
last_box = Math.ceil((pos + self.slider.width()) / self.boxWidth) - 1;
last_box = self.slider.find('.box:eq(' + last_box + ')');
newPos = (last_box.length) ? (last_box.position().left + pos) : self.maxLeft;
if(newPos > self.maxLeft) {newPos = self.maxLeft;}
self.slider.stop().animate({scrollLeft: newPos}, 1000, 'easeInOutQuart');
e.preventDefault();
return false;
}
/**
* Handles the event when a user clicks the #slide-left icon
*/
function slideLeft(e) {
var pos = self.slider.scrollLeft();
var newPos = 0, first_box = 0;
first_box = Math.ceil(pos / self.boxWidth) - 1;
first_box = self.slider.find('.box:eq(' + first_box + ')');
newPos = (first_box.length) ? (pos + first_box.position().left - self.slider.width() + self.boxWidth) : 0;
if(newPos < 0) {newPos = 0;}
self.slider.stop().animate({scrollLeft: newPos}, 1000, 'easeInOutQuart');
e.preventDefault();
return false;
}
/**
* Show or hide nav arrows on scroll
*/
function scrollchanged() {
var pos = self.slider.scrollLeft();
if(pos == 0) {
if(ie && ie < 9) {
self.slideleft.hide();
} else {
self.slideleft.fadeOut();
}
} else if(pos == self.maxLeft) {
if(ie && ie < 9) {
self.slideright.hide();
} else {
self.slideright.fadeOut();
}
} else {
if(ie && ie < 9) {
self.slideleft.filter(':hidden').show();
self.slideright.filter(':hidden').show();
} else {
self.slideleft.filter(':hidden').fadeIn();
self.slideright.filter(':hidden').fadeIn();
}
}
}
// Stop scrolling animation
this.stop = function() {
this.slider.stop();
};
/**
* Scrolls the current slider off screen before removing it from the dom and destroying all
* references to it.
*/
this.slideOut = function() {
var boxes = [];
for(var i = 0; i < 4; i++) {
boxes.push($('').addClass('box'));
}
var newWidth = boxes.length * this.boxWidth;
this.inner.width(newWidth + this.innerWidth);
$.each(boxes, function() {
self.inner.prepend(this);
});
this.slider.scrollLeft(newWidth);
this.slider.stop().animate({scrollLeft: 0}, 500, function() {
self.slider.remove();
self.parent.remove();
self.parent = self.inner = null;
self.slider.length = 0;
$('body').trigger('scrollslider.out');
});
};
/**
* Creates a new slider, initializes it, then scrolls it onto the screen.
*/
this.slideIn = function(newSlider) {
$('#inner').append(newSlider);
this.init();
this.inner.width(this.innerWidth + this.boxWidth * 4);
for(var n = 0; n < 4; n++) {
this.inner.append($('').addClass('box').addClass('oldBoxes'));
}
this.slider.scrollLeft(this.innerWidth);
this.slider.animate({scrollLeft: 0}, 500, function() {
self.slider.find('.oldBoxes').remove();
self.inner.width(self.innerWidth);
$('body').trigger('scrollslider.out');
});
};
/**
* Scrolls out the current slider while scrolling in a new slider. References to the dom elements
* are reinitialized rather than destroyed.
*/
this.swapSlider = function(newSlider) {
this.slider.find('.box').addClass('oldBoxes');
var boxes = newSlider.find('.box').clone();
var newWidth = boxes.length * this.boxWidth;
this.inner.width(newWidth + this.innerWidth)
$.each(boxes.reverse(), function() {
self.inner.prepend(this);
});
this.slider.scrollLeft(newWidth);
this.slider.stop().animate({scrollLeft: 0}, 1000, function() {
self.slider.find('.oldBoxes').remove();
self.parent.replaceWith(newSlider);
self.init();
$('body').trigger('scrollslider.out');
});
};
this.init();
}
/**
* Handles the ajax search
*/
var search = {
defaultText: '',
form: undefined,
txtField: undefined,
init: function() {
this.form = $('#SearchForm');
this.txtField = $('#Search');
// Turn off autocomplete
this.txtField.attr('autocomplete', 'off');
this.resetText(); // Add the default text
this.txtField.blur(function() {search.resetText();});
this.txtField.focus(function() { // hide default text on focus
if($(this).val() == search.defaultText) {$(this).val('');}
});
// Create an ajax manager to handle the ajax requests
$.manageAjax.create('ajaxSearch', {cacheResponse: true, queue: 'clear', abortOld: true});
$('body').delegate('#Search', 'keyup', function(e) {search.change($(this), e);})
$('body').bind('click touchup', function(event) {
if($(event.target).parents().find('#SearchForm').length == 0) {
$('#AjaxResults:visible').hide();
}
});
$('body').delegate('#SearchForm li', 'click touchup', function() {
var link = $(this).find('a');
if(link.length) {
window.location = link.attr('href');
}
});
$('.searchpage').delegate('.entry', 'click touchup', function() {
window.location = $(this).find('h2 a').attr('href');
});
$('.searchpage').delegate('.entry, .news h2', 'mouseenter', function() {
$(this).addClass('hover');
font_replace();
});
$('.searchpage').delegate('.entry, .news h2', 'mouseleave', function() {
$(this).removeClass('hover');
font_replace();
});
},
resetText: function() {
if(search.txtField.val() != search.defaultText && search.txtField.val().length == 0) {
search.txtField.val(search.defaultText);
}
},
showResults: function() {
search.form.addClass('active');
if(ie && ie < 9) {
$('#AjaxResults').show();
} else {
$('#AjaxResults').fadeIn();
}
},
hideResults: function() {
search.form.removeClass('active');
if(ie && ie < 9) {
$('#AjaxResults').hide();
} else {
$('#AjaxResults').fadeOut();
}
},
change: function(input, event) {
if(input.val().length > 0 && input.val() != search.defaultText) {
search.showResults();
// do the ajax request
$.manageAjax.add('ajaxSearch', {
url: '/search.php',
data: $('#SearchForm').serialize(),
success: function(data, status, xhr) {
$('#AjaxResults').replaceWith(data);
$('#AjaxResults').show();
}
});
} else {
search.hideResults();
}
}
};
$(document).ready(function() {
$('body').delegate('#nav a', 'mouseenter', function() {
var rel = $(this).attr('rel');
if(typeof rel != 'undefined' && rel.length) {
rel = $.parseJSON(rel);
$(this).css({color: rel.color});
}
});
$('body').delegate('#nav a', 'mouseleave', function() {
if(!$(this).hasClass('active')){
$(this).css({color: ''});
}
});
$.history.init(function(hash) {
if(hash && quickLoad) {
slider = slider2 = null;
$('body').load(hash + ' #wrap', function() {
$('body').show();
initSliders();
highlightHeaderNav(hash);
highlightFooterNav(hash);
});
} else {
initSliders();
highlightHeaderNav(hash);
highlightFooterNav(hash);
}
quickLoad = true;
}, {unescape: ',/:?=&'});
function highlightHeaderNav(hash) {
$('#nav a').css('color','');
$('#nav .active').removeClass('active');
hash = hash.split("?")[0];
var dirs = hash.split('/');
if(typeof dirs[1] != 'undefined' && dirs[1]!='') {
if(dirs[3] != undefined && dirs[3].length){ // third level page
var parentDirs = $(".headers .left a").attr("href").split('/');
hash = "/"+parentDirs[1]+"/";
} else {
hash = "/"+dirs[1]+"/";
}
var elem = $("#nav a[href='"+hash+"']");
if(typeof elem != 'undefined') {
var obj = $.parseJSON(elem.attr('rel'));
if(typeof obj != 'undefined') {
elem.css('color',obj.color).addClass('active');
}
}
}
}
function highlightFooterNav(hash) {
$('#footer a').css('color','');
hash = hash.split("?")[0];
var dirs = hash.split('/');
if(typeof dirs[1] != 'undefined' && dirs[1]!='') {
if(dirs[3] != undefined && dirs[3].length) { // third level page
var parentDirs = $(".headers .left a").attr("href").split('/');
hash = "/"+parentDirs[1]+"/"+parentDirs[2]+"/";
}
var elem = $("#footer a[href='"+hash+"']");
if(typeof elem != 'undefined') {
var obj = $.parseJSON(elem.attr('rel'));
if(typeof obj != 'undefined') {
elem.css('color',obj.color).addClass('active');
}
}
}
}
$("#nav li li").hover(
function() {$(this).addClass('hover').siblings().removeClass('hover');},
function() {$(this).removeClass('hover');}
);
if(!is_ios()) {
$('body').delegate('div.box', 'mouseenter', function() {
$(this).addClass('hover');
var href = $(this).find('h2 a');
if(typeof href.attr('rel') != 'undefined' && href.attr('rel').length) {
var rel = $.parseJSON(href.attr('rel'));
href.css({color: rel.color}).parent('h2').css({'border-color': rel.color});
$(this).find('.content').css({'background-color': rel.color});
if(ie != 6) {
Cufon.replace($(this).find('h2'), {color: rel.color});
}
}
});
$('body').delegate('div.box', 'mouseleave', function() {
$(this).removeClass('hover');
$(this).find('h2 a').css({color: ''}).parent('h2').css({'border-color': ''});
$(this).find('.content').css({'background-color': '#fff'});
if(ie != 6) {
Cufon.replace($(this).find('h2'), {color: '#666666'});
}
});
}
$('body').bind('click touchup', function(event) {
if($(event.target).parents('#SearchForm').length == 0) {
$('#AjaxResults:visible').hide();
}
});
if(!ie) {
$('#file').live('change', function(e) {
$('#filenice').val($(this).val());
});
$('.upload', '#contact').live('mousemove', function(e) {
var x = e.pageX - $(this).offset().left - ($('#file').width() / 2);
var y = e.pageY - $(this).offset().top - ($('#file').height() / 2);
$('#file').css({top: y, left: x});
});
}
// Skype formatting
var skype = $('.skype_pnh_container');
if(typeof skype != 'undefined' && skype.length) {
$('#smallnav li.last').children('span').css({padding: 0});
}
$('div#message .close').live('click', function() {
$('div#message').fadeOut();
return false;
});
search.init();
$('body').delegate('.news h2', 'mouseenter', function() {
$(this).addClass('hover');
font_replace();
});
$('body').delegate('.news h2', 'mouseleave', function() {
$(this).removeClass('hover');
font_replace();
});
$('body').delegate('#nav>li', 'mouseenter', function() {
$(this).addClass('hover');
});
$('body').delegate('#nav>li', 'mouseleave', function() {
$(this).removeClass('hover');
});
});
$(window).load(function() {
$('#main').height('auto');
});
function is_ios() {
var devices = ["iPhone", "iPad", "iPod"], i;
for (i = 0; i < devices.length; i++) {
if (navigator.platform.indexOf(devices[i]) >= 0) {
return true;
}
}
return false;
}
jQuery.fn.reverse = function() {
return this.pushStack(this.get().reverse(), arguments);
};
function font_replace() {
if(ie != 6) {
Cufon.replace('#inner h1, #inner h2, #inner h3', {hover: true});
}
// Add hidden form field to let the server know if the user has javascript enabled.
if(animate) {
var forms = $('form', '#content2');
if(typeof forms != 'undefined' && forms.length > 0) {
$.each(forms, function() {
$('').attr('type', 'hidden').attr('name', 'js').attr('value', '1').appendTo($(this));
});
}
}
if(ie) {
$('#filenice').remove();
$('.upload span.browse').remove();
$('#file').css({opacity: '100', width: '75%'});
}
}
function qstring(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.href);
if(results == null)
return "";
else
return decodeURIComponent(results[1].replace(/\+/g, " "));
}