File: /home/eatingdisordersadvice.co.uk/public_html/wp-content/themes/presstige/js/custom_ver-1.0.js
//jQuery.noConflict();
jQuery(document).ready(function(){
// Main Menu
mainMenu();
// Toggles
toggleMenu();
// Tabs
tabPanel();
// rounded images
roundImages();
// gallery image hover
// galleryHoverfx();
styleTags();
// sticky footer
stickyFooter();
});
function stickyFooter() {
// Window load event used just in case window height is dependant upon images
jQuery(window).bind("load", function() {
var footerHeight = 0,footerTop = 0, jQueryfooter = jQuery("#footer");
positionFooter();
function positionFooter() {
footerHeight = jQueryfooter.height();
footerTop = (jQuery(window).scrollTop()+jQuery(window).height()-footerHeight)+"px";
if ( (jQuery(document.body).height()+footerHeight) < jQuery(window).height()) {
jQueryfooter.css({ position: "absolute" }).animate({ top: footerTop })
} else {
jQueryfooter.css({ position: "static" }) } }
jQuery(window) .scroll(positionFooter) .resize(positionFooter) });
};
function mainMenu() {
jQuery('#menu ul.menu')
.find('li.current_page_item,li.current_page_parent,li.current_page_ancestor,li.current-cat,li.current-cat-parent,li.current-menu-item')
.addClass('active')
.end()
.superfish({});
}
function galleryHoverfx() {
// fading images
jQuery(".gallery-item img").fadeTo("slow", 0.6); // This sets the opacity of the thumbs to fade down to 60% when the page loads
jQuery(".gallery-item img").hover(function(){
jQuery(this).fadeTo("400", 1.0); // This should set the opacity to 100% on hover
},function(){
jQuery(this).fadeTo("400", 0.6); // This should set the opacity back to 60% on mouseout
});
}
function roundImages() {
// rounded images
jQuery("img.round").imgr({radius:"8px"});
// jQuery(".gallery-item img").captify({});
}
function styleTags() {
jQuery('p.tags a')
.wrap('<span class="st_tag" />');
}
// TAB PANEL
function tabPanel(){
//Default Action
jQuery(".tabcontent").hide(); //Hide all content
jQuery(".tabcontentwide").hide(); //Hide all content
jQuery("#tabnav li:first").addClass("active").fadeIn('fast'); //Activate first tab
jQuery(".tabcontent:first").show(); //Show first tab content
jQuery(".tabcontentwide:first" ).show(); //Show first tab content
//On Click Event
jQuery("#tabnav li").click(function() {
jQuery("#tabnav li").removeClass("active"); //Remove any "active" class
jQuery(this).addClass("active"); //Add "active" class to selected tab
jQuery(".tabcontent").hide(); //Hide all content
jQuery(".tabcontentwide").hide() //Hide all content
var activeTab = jQuery(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
jQuery(activeTab).stop().fadeIn(200); //Fade in the active content
return false;
});
}
// TOGGLE
function toggleMenu(){
jQuery(".toggle_container").hide();
//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
jQuery("p.trigger").click(function(){
jQuery(this).toggleClass("active").next().slideToggle("normal");
return false; //Prevent the browser jump to the link anchor
});
}
// OPEN LINKS IN NEW WINDOW
jQuery(function() {
jQuery('a[rel*=external]').click( function() {
window.open(this.href);
return false;
});
});
// JavaScript Document
/*
* Cross-browser event handling, by Scott Andrew
*/
function addEvent(element, eventType, lamdaFunction, useCapture) {
if (element.addEventListener) {
element.addEventListener(eventType, lamdaFunction, useCapture);
return true;
} else if (element.attachEvent) {
var r = element.attachEvent('on' + eventType, lamdaFunction);
return r;
} else {
return false;
}
}
/*
* Clear Default Text: functions for clearing and replacing default text in
* <input> elements.
*
* by Ross Shannon, http://www.yourhtmlsource.com/
*/
addEvent(window, 'load', init, false);
function init() {
var formInputs = document.getElementsByTagName('input');
for (var i = 0; i < formInputs.length; i++) {
var theInput = formInputs[i];
if (theInput.type == 'text' && theInput.className.match(/\bcleardefault\b/)) {
/* Add event handlers */
addEvent(theInput, 'focus', clearDefaultText, false);
addEvent(theInput, 'blur', replaceDefaultText, false);
/* Save the current value */
if (theInput.value != '') {
theInput.defaultText = theInput.value;
}
}
}
}
function clearDefaultText(e) {
var target = window.event ? window.event.srcElement : e ? e.target : null;
if (!target) return;
if (target.value == target.defaultText) {
target.value = '';
}
}
function replaceDefaultText(e) {
var target = window.event ? window.event.srcElement : e ? e.target : null;
if (!target) return;
if (target.value == '' && target.defaultText) {
target.value = target.defaultText;
}
}
// Reverses the z-indexing for correcting ie7 z-index issues
/*jQuery(function() {
var zIndexNumber = 1000;
jQuery('div').each(function() {
jQuery(this).css('zIndex', zIndexNumber);
zIndexNumber -= 10;
});
});*/