/*
Bones Scripts File
Author: Eddie Machado

This file should contain any js scripts you want to add to the site.
Instead of calling it in the header or throwing it inside wp-head()
this file will be called automatically in the footer so as not to 
slow the page load.

*/

/* imgsizer (flexible images for fluid sites) */
var imgSizer={Config:{imgCache:[],spacer:"/path/to/your/spacer.gif"},collate:function(aScope){var isOldIE=(document.all&&!window.opera&&!window.XDomainRequest)?1:0;if(isOldIE&&document.getElementsByTagName){var c=imgSizer;var imgCache=c.Config.imgCache;var images=(aScope&&aScope.length)?aScope:document.getElementsByTagName("img");for(var i=0;i<images.length;i++){images[i].origWidth=images[i].offsetWidth;images[i].origHeight=images[i].offsetHeight;imgCache.push(images[i]);c.ieAlpha(images[i]);images[i].style.width="100%";}
if(imgCache.length){c.resize(function(){for(var i=0;i<imgCache.length;i++){var ratio=(imgCache[i].offsetWidth/imgCache[i].origWidth);imgCache[i].style.height=(imgCache[i].origHeight*ratio)+"px";}});}}},ieAlpha:function(img){var c=imgSizer;if(img.oldSrc){img.src=img.oldSrc;}
var src=img.src;img.style.width=img.offsetWidth+"px";img.style.height=img.offsetHeight+"px";img.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"', sizingMethod='scale')"
img.oldSrc=src;img.src=c.Config.spacer;},resize:function(func){var oldonresize=window.onresize;if(typeof window.onresize!='function'){window.onresize=func;}else{window.onresize=function(){if(oldonresize){oldonresize();}
func();}}}}



// as the page loads, cal these scripts
jQuery(document).ready(function() {

	setHeight('.equal');

	jQuery('.fitted').fitted();	

	var userAgent = window.navigator.userAgent;

	if (userAgent.match(/iPad/i) || userAgent.match(/iPhone/i) || userAgent.match(/Mobile/i)) {
		//force new window for mobile devices; bypass prettyPhoto action
		$("a[rel^='prettyPhoto']").attr("target","_blank");
	} else { 
		// prettyphoto
		jQuery("a[rel^='prettyPhoto']").prettyPhoto({
				hideflash: true,
				theme: 'facebook',
				show_title: false,
				social_tools: ''
		});
	}




	// Shortcode Toggle
	jQuery(".toggle_content").hide(); 
	jQuery("h3.toggle").toggle(function(){
		jQuery(this).addClass("active");
	}, function () {
		jQuery(this).removeClass("active");
	});
	
	jQuery("h3.toggle").click(function(){
		jQuery(this).next(".toggle_content").slideToggle();
	});


	// Shortcode Tabs
	jQuery("ul.tabs").tabs("> .tab-content");
	jQuery(function() {
		jQuery(".tabs-container ul.tabs").tabs("> .tab-content",{
			effect: 'slide'
		});
	});


	// apply qtip style to .more-info class
	jQuery('a.more-info[title],a.more-rss[title]').qtip({ 
		
		style: { 
			background: '#000000',
			color: '#ffffff',
			textAlign: 'center',
			tip: true,
			border: {
 				width: 1,
 				radius: 5,
 				color: '#000000'
			}
		},
		position: {
			corner: {
 				target: 'rightMiddle',
 				tooltip: 'leftMiddle'
			}
	   }
	});
	

	// apply qtip style to .more-info class
	jQuery('div.telephone[title]').qtip({ 
		
		style: { 
			background: '#000000',
			color: '#ffffff',
			textAlign: 'center',
			tip: true,
			border: {
 				width: 1,
 				radius: 5,
 				color: '#000000'
			}
		},
		position: {
			corner: {
 				target: 'bottomMiddle',
 				tooltip: 'topMiddle'
			}
	   }
	});

	// use animate to scroll to #top
    jQuery('a[href=#top]').click(function(){
        jQuery('html, body').animate({scrollTop:0}, 'slow');
        return false;
    });
    

	jQuery('.fade').innerfade({
		speed: 'slow',
		timeout: 5000,
		type: 'sequence',
		containerheight: '40px'
	});


	jQuery('#content-launcher').tinycarousel({

		display: 5,
		pager: true,
		interval: false

	});
	
	
	jQuery('.tooltip').qtip({
		style: {
			background: '#000000',
			color: '#ffffff',
			textAlign: 'center',
			tip: true,
			border: {
 				width: 1,
 				radius: 5,
 				color: '#000000'
			}
		},
		position: {
			corner: {
 				target: 'topMiddle',
 				tooltip: 'bottomMiddle'
			}
	   }
	});
	
	jQuery('blockquote').quovolver();
		
}); /* end of as page load scripts */


jQuery(window).load(function(){  
  
}); 

jQuery(function(){ 
	jQuery('ul.sf-menu').superfish({
		 autoArrows:    false
		
	}); 
	
	// hide skype buttons
	window.setTimeout(function() {
		jQuery('.skype_pnh_container').html('');
		jQuery('.skype_pnh_print_container').removeClass('skype_pnh_print_container');
	}, 800);
	
});


var maxHeight = 0;
function setHeight(column) {
    //Get all the element with class = col
    column = jQuery(column);
    //Loop all the column
    column.each(function() {       
        //Store the highest value
        if(jQuery(this).height() > maxHeight) {
            maxHeight = jQuery(this).height();
        }
    });
    //Set the height
    column.height(maxHeight);
}

