/* #On Document Ready
================================================== */
jQuery(document).ready(function() {
jQuery(".scalevid").fitVids();
jQuery(".blogdivider:last").remove();
jQuery(".fh-pagination a:last").css("margin-right","0");
jQuery("a[data-rel^='prettyPhoto']").prettyPhoto({overlay_gallery: false,social_tools:false});
jQuery('.wpcf7 input[type="submit"]').wrap('
');
/* Responsive Select Menu */
jQuery("#responsive-menu select").change(function() {
window.location = jQuery(this).find("option:selected").val();
});
/* INIT THE RESPONSIVE MENU HANDLING */
menuHandler();
/* NAVIGATION INITALISATION */
initNav();
/* INIT SOCIALS */
initSocial();
/* Init Twitter */
initTwitter();
/* Init Testimonials */
initTestimonials();
/* INIT GO TO TOP */
initGoToTop();
/* INIT THE HOVERDIR ANIMATIONS */
if(jQuery(".square_portfolio").length || jQuery(".square_teaser").length || jQuery(".square").length )
initHoverSquares();
/* INIT PORTFOLIO */
initPortfolio();
/* INIT SEARCH FIELD */
initSearchField();
/* CALL AUDIO,VIDEO HTML5 PLAYER */
initAudio();
/* CALL THE MEDIARESIZER */
jQuery(window).resize(function() {
initMediaResize();
});
initMediaResize();
/* INIT THE RATING SYSTEM */
jQuery('.rating-star').each(function() {
var el=jQuery(this);
el.hover(function() {
if (jQuery(this).closest('ul').hasClass('nonrated')) {
jQuery(this).prevAll().each(function() {
var pre=jQuery(this);
if (pre.hasClass('nop')) pre.data('preclass','nop');
if (pre.hasClass('yop')) pre.data('preclass','yop');
pre.addClass('yop').removeClass('nop');
});
}
},
function() {
if (jQuery(this).closest('ul').hasClass('nonrated')) {
jQuery(this).prevAll().each(function() {
var pre=jQuery(this);
pre.removeClass('yop').removeClass('nop');
pre.addClass(pre.data('preclass'));
});
}
});
el.click(function() {
if (jQuery(this).closest('ul').hasClass('nonrated')) {
jQuery(this).prevAll().each(function() {
var pre=jQuery(this);
pre.addClass('yop').removeClass('nop');
pre.data('preclass','yop');
});
jQuery(this).addClass('yop').removeClass('nop');
jQuery(this).data('preclass','yop');
jQuery(this).parent().removeClass('nonrated').addClass('rated');
}
});
});
});
///////////////////
// MEDIA RESIZER //
///////////////////
function initMediaResize() {
jQuery('.tp-resizemedia').each(function() {
var media=jQuery(this);
var iframe=media.find('iframe:first');
var flv=media.find('.video-wrapper .video-container a');
//alert(jQuery(this).width()+" "+jQuery(this).data('width'));
var prop= media.width() / media.data('width');
if (iframe.length>0) iframe.height(media.data('height')*prop);
if (flv.length>0) flv.height(media.data('height')*prop);
});
}
function initAudio(){
jQuery('audio,video').mediaelementplayer({
pluginPath: 'http://www.integrityperformance.net/wp-content/themes/integrity/js/',
// name of flash file
flashName: 'flashmediaelement.swf',
// name of silverlight file
silverlightName: 'silverlightmediaelement.xap',
success: function(player, node) {
jQuery('#' + node.id + '-mode').html('mode: ' + player.pluginType);
}
});
}
///////////////////////////////////////
// FUNCTION HOVER ON SQUARE ELEMENTS //
///////////////////////////////////////
function initHoverSquares() {
jQuery('.hoverpart.square').hoverdir();
}
function initPortfolio(){
//////////////////////////////////////////
// - CALL THE PORTFOLIO PLUGIN - //
//////////////////////////////////////////
if (jQuery('.portfolio').length) {
var row_items=4;
if(jQuery('.container-with-sidebar').length)
var row_items=3;
jQuery('body').tpportfolio({
speed:500,
row:row_items,
nonSelectedAlpha:0,
portfolioContainer:'.portfolio'
});
}
}
//////////////////////
// INIT GO TO TOP //
/////////////////////
function initGoToTop() {
var orig_scroll_height = jQuery(".footer").position().top - jQuery(window).height()-200;
// fade in #top_button
jQuery(function () {
jQuery(window).scroll(function () {
if (jQuery(this).scrollTop() > 100) {
jQuery('#backtotop').addClass("showme");
} else {
jQuery('#backtotop').removeClass("showme");
}
});
// scroll body to 0px on click
jQuery('#backtotop').click(function () {
jQuery('body,html').animate({
scrollTop: 0
}, 400);
return false;
});
});
if (jQuery(window).scrollTop() > 100)
jQuery('#backtotop').addClass("showme");
}
///////////////////////
// INIT SEARCH FIELD //
//////////////////////
function initSearchField() {
// Check the Search value on Standard
jQuery(".reply-form .inputbox, #Form_Search, #commentfields .inputbox, #commentfields .InputBox, #commentfields .TextBox").each(function() {
var field=jQuery(this);
field.data('standard',field.val());
});
jQuery(".reply-form .inputbox, #Form_Search, #commentfields .inputbox,#commentfields .InputBox, #commentfields .TextBox").focus(function(){
var $this = jQuery(this);
$this.val($this.val()== $this.data('standard') ? "" : $this.val());
});
jQuery(".reply-form .inputbox, #Form_Search, #commentfields .inputbox,#commentfields .InputBox, #commentfields .TextBox").blur(function(){
var $this = jQuery(this);
$this.val($this.val()== "" ? $this.data('standard') : $this.val());
});
}
//////////////////////////////
// NAVIGATION INITALISATION //
//////////////////////////////
function initNav() {
var nav = jQuery('#nav');
nav.find('ul li ul').each(function() {
var li=jQuery(this).find('>li').last();
});
nav.find('ul li ul').each(function(i) {
var ul =jQuery(this);
ul.parent().addClass('withchilds');
ul.data('height',ul.height());
ul.animate({'height':'0px'},{duration:230,queue:false});
//ul.slideUp(0);
});
/* NAVIGATION */
nav.find('li').each(function() {
jQuery(this).hover(
function() {
jQuery(this).addClass('hovered');
var ul=jQuery(this).find('ul:first');
ul.stop();
clearTimeout(ul.data('timeout'));
clearTimeout(ul.data('timeout2'));
ul.css({'display':'block'});
setTimeout(function() {
var newh=0;
ul.find('>li').each(function() {
newh=newh+jQuery(this).outerHeight();
});
ul.data('height',newh);
ul.stop();
ul.animate({'height':ul.data('height')+"px",'opacity':1.0},{duration:180,queue:false});
},50);
ul.animate({'height':ul.data('height')+"px",'opacity':1.0},{duration:230,queue:false});
},
function() {
jQuery(this).removeClass('hovered');
var ul=jQuery(this).find('ul:first');
ul.stop();
//li.delay(100).slideUp(230);
//clearTimeout(li.data('timeout'));
ul.data('timeout',setTimeout(function() {
ul.animate({'height':"0px",'opacity':0},{duration:230,queue:false});
ul.data('timeout2',setTimeout(function() {ul.css({'display':'none'})},230));
},100));
});
});
}
//////////////////
// INIT TWITTER //
//////////////////
function initTwitter() {
if(jQuery('.twitter_container').length != 0){
jQuery('.twitter_container').each(function() {
jQuery(this).twitterReader({
user:jQuery(this).find('.twitter_shortcode').data('user'),
count:jQuery(this).find('.twitter_shortcode').data('count')
});
});
}
if(jQuery('.twitter-rotator').length != 0){
jQuery('.twitter-rotator').simpleTwitterReader({
user:'envato',
count:2
});
}
}
//////////////////
// INITSOCIAL //
/////////////////
function initSocial() {
var socwidth=0;
var amount = jQuery('body').find('.socials li').length;
jQuery('body').find('.socials li').each(function(i) {
socwidth = socwidth + jQuery(this).width();
});
socwidth = socwidth + ((amount)*10)
jQuery('body').find('.soc').each(function() {
var tt=jQuery(this).find(' .tooltip');
tt.css({'left':(-6-(tt.width()/2))+"px"});
setTimeout(function() {
tt.css({'left':(-6-(tt.width()/2))+"px"});
},500);
var tt = jQuery(this);
tt.hover(function() {
var tt=jQuery(this).find(' .tooltip');
tt.css({'left':(-6-(tt.width()/2))+"px"});
},function() {});
})
var socials= jQuery('body').find('.socials');
socials.width(socwidth);
socials.css({'margin':'auto'});
}
//////////////////////////
// MENU HANDLER //
//////////////////////////
function menuHandler() {
var defpar = jQuery('#nav').parents().length;
/*jQuery('#nav ul >li >a').each(function() {
jQuery(this).text(jQuery(this).text().toUpperCase());
});*/
jQuery('#nav li >a').each(function() {
var a=jQuery(this);
var par= a.parents().length-defpar -3;
if (par==0)
var newtxt=jQuery("
"+a.text()+"
").text();
else
if (par==2)
var newtxt=jQuery("
"+a.text()+"
").text();
else
if (par==4)
var newtxt=jQuery("
"+a.text()+"
").text();
jQuery('#responsive-menu select').append(new Option(newtxt,a.attr('href')) );
});
var aktmenu=jQuery('.current_page_item a:first').text();
jQuery('#responsive-menu-button').html(aktmenu);
var deviceAgent = navigator.userAgent.toLowerCase();
var agentID = deviceAgent.match(/(iphone|ipod|ipad)/);
if (agentID) {
jQuery('#responsive-menu select').addClass('apple');
}
}
//////////////////////////////
// INIT THE TESTIMONIALS //
/////////////////////////////
function initTestimonials() {
jQuery('.testimonials').each(function() {
var test=jQuery(this);
var ul=test;
var lbutton = jQuery('#'+jQuery(this).data('navigation')).find('.leftbutton');
var rbutton = jQuery('#'+jQuery(this).data('navigation')).find('.rightbutton');
pos=0;
var maxe = test.find('>li').length;
// IF WINDOW IS RESIZED, THEN SLIDES NEED TO BE MOVED INTO THE RIGHT POSITION
jQuery(window).resize(function() {
clearTimeout(test.data('resized'));
test.data('resized',setTimeout(function() {
test.find('>li').each(function(i) {
var li=jQuery(this);
if (i!=pos) {
li.animate({'opacity':0});
} else {
li.animate({'opacity':1});
ul.animate({'height':li.outerHeight()+"px"},{duration:300});
}
});
},200));
});
test.find('>li').each(function(i) {
var li=jQuery(this);
if (i!=0) {
li.animate({'opacity':0});
} else {
li.animate({'opacity':1});
ul.animate({'height':li.outerHeight()+"px"},{duration:300});
}
});
lbutton.click(function() {
pos=pos-1;
if (pos<0) pos=maxe-1;
test.find('>li').each(function(i) {
var li=jQuery(this);
li.stop();
if (i!=pos) {
li.animate({'top':'20px','opacity':0},{duration:400,queue:false});
li.data('timer1',setTimeout(function() {li.css({'display':'none'})},400));
} else {
clearTimeout(li.data('timer1'));
li.css({'top':'-20px','opacity':0,'display':'block'});
setTimeout(function() {li.animate({'top':'0px','opacity':1},{duration:300,queue:false});},100);
ul.stop();
ul.animate({'height':li.outerHeight()+"px"},{duration:300,queue:false});
}
});
});
rbutton.click(function() {
pos=pos+1;
if (pos==maxe) pos=0;
test.find(' >li').each(function(i) {
var li=jQuery(this);
li.stop();
if (i!=pos) {
li.animate({'top':'20px','opacity':0},{duration:400,queue:false});
li.data('timer1',setTimeout(function() {li.css({'display':'none'})},400));
} else {
clearTimeout(li.data('timer1'));
li.css({'top':'-20px','opacity':0,'display':'block'});
setTimeout(function() {li.animate({'top':'0px','opacity':1},{duration:300,queue:false});},100);
ul.stop();
ul.animate({'height':li.outerHeight()+"px"},{duration:300,queue:false});
}
});
});
});
}
function initAudio(){
jQuery('audio,video').mediaelementplayer({
pluginPath: 'http://www.integrityperformance.net/wp-content/themes/integrity/js/',
// name of flash file
flashName: 'flashmediaelement.swf',
// name of silverlight file
silverlightName: 'silverlightmediaelement.xap',
success: function(player, node) {
jQuery('#' + node.id + '-mode').html('mode: ' + player.pluginType);
}
});
}
/*
* Skeleton V1.1
* Copyright 2011, Dave Gamache
* www.getskeleton.com
* Free to use under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
* 8/17/2011
*/
jQuery('body').on('click', 'ul.tabs > li > a', function(e) {
//Get Location of tab's content
var contentLocation = $(this).attr('href');
//Let go if not a hashed one
if(contentLocation.charAt(0)=="#") {
e.preventDefault();
//Make Tab Active
$(this).parent().siblings().children('a').removeClass('active');
$(this).addClass('active');
//Show Tab Content & add active class
$(contentLocation).show().addClass('active').siblings().hide().removeClass('active');
}
});
function tabsInit() {
/*
* Skeleton V1.1
* Copyright 2011, Dave Gamache
* www.getskeleton.com
* Free to use under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
* 8/17/2011
*/
/* Tabs Activiation
================================================== */
var tabs = jQuery('ul.tabs');
tabs.each(function(i) {
//Get all tabs
var tab = jQuery(this).find('> li > a');
tab.click(function(e) {
//Get Location of tab's content
var contentLocation = jQuery(this).attr('href');
//Let go if not a hashed one
if(contentLocation.charAt(0)=="#") {
e.preventDefault();
//Make Tab Active
tab.removeClass('active');
jQuery(this).addClass('active');
//Show Tab Content & add active class
jQuery(contentLocation).show().addClass('active').siblings().hide().removeClass('active');
}
});
});
}
jQuery(window).load(function(){
(function(d, s, id) {
if(jQuery(".fb-like").length) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=162252937201892";
fjs.parentNode.insertBefore(js, fjs);
}
}(document, 'script', 'facebook-jssdk'));
});