/*
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
var $j = jQuery.noConflict();

$j(function(){
  
  /* create imageFlow instance */
  var instanceOne = new ImageFlow();
	instanceOne.init({ ImageFlowID:'myImageFlow',  onClick: function() { window.open($j(this).attr('data-link'), '_self');  }  });
  
  /* fix for fading in transparent images with shadows in IE */
  var i;
  for(i in document.images){
    if(document.images[i].src){
      var imgSrc = document.images[i].src;
      if(imgSrc.substr(imgSrc.length-4) === '.png' || imgSrc.substr(imgSrc.length-4) === '.PNG'){
          document.images[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true',sizingMethod='crop',src='" + imgSrc + "')";
      }
    }
  }
	
	if(navigator.userAgent.match(/android/i)||navigator.userAgent.match(/webos/i)||navigator.userAgent.match(/iphone/i)||navigator.userAgent.match(/ipod/i)||navigator.userAgent.match(/ipad/i)){
		//bad empty condition : (
	}else{
    $j('#banners').cycle();
  
		$j('#slideShow1').cycle({
			fx: 'scrollHorz',
			prev:   '#prev1', 
			next:   '#next1', 
			timeout: 0 
		});
		
		$j('#slideShow2').cycle({
			fx: 'scrollHorz',
			prev:   '#prev2', 
			next:   '#next2', 
			timeout: 0 
		});
		
		$j('#slideShow3').cycle({
			fx: 'scrollHorz',
			prev:   '#prev3', 
			next:   '#next3', 
			timeout: 0 
		});
		
		$j('#slideShow4').cycle({
			fx: 'scrollHorz',
			prev:   '#prev4', 
			next:   '#next4', 
			timeout: 0 
		});
		
		$j('#slideShow5').cycle({
			fx: 'scrollHorz',
			prev:   '#prev5', 
			next:   '#next5', 
			timeout: 0 
		});
		
		$j('#slideShow6').cycle({
			fx: 'scrollHorz',
			prev:   '#prev6', 
			next:   '#next6', 
			timeout: 0 
		});
		
		$j('#slideShow7').cycle({
			fx: 'scrollHorz',
			prev:   '#prev7', 
			next:   '#next7', 
			timeout: 0 
		});
		
		$j('#slideShow8').cycle({
			fx: 'scrollHorz',
			prev:   '#prev8', 
			next:   '#next8', 
			timeout: 0 
		});
		
		$j('#slideShow9').cycle({
			fx: 'scrollHorz',
			prev:   '#prev9', 
			next:   '#next9', 
			timeout: 0 
		});
		
		$j('#slideShow10').cycle({
			fx: 'scrollHorz',
			prev:   '#prev10', 
			next:   '#next10', 
			timeout: 0 
		});
		
		$j('#slideShow11').cycle({
			fx: 'scrollHorz',
			prev:   '#prev11', 
			next:   '#next11', 
			timeout: 0 
		});
		
		$j('#slideShow12').cycle({
			fx: 'scrollHorz',
			prev:   '#prev12', 
			next:   '#next12', 
			timeout: 0 
		});
		
		$j('#slideShow13').cycle({
			fx: 'scrollHorz',
			prev:   '#prev13', 
			next:   '#next13', 
			timeout: 0 
		});
		
		$j('#slideShow14').cycle({
			fx: 'scrollHorz',
			prev:   '#prev14', 
			next:   '#next14', 
			timeout: 0 
		});
		
		$j('#slideShow15').cycle({
			fx: 'scrollHorz',
			prev:   '#prev15', 
			next:   '#next15', 
			timeout: 0 
		});
		
		
		$j("a").hoverFadeColor();
		
		$j('div.fade').hover(function() {
			 var fade = $j('> div', this);
			 if(fade.is(':animated')) {
				 fade.stop().fadeTo(250, 1);
			 }else{
				 fade.fadeTo(250, 1);
			 }
		 }, function(){
			 var fade = $j('> div', this);
			 if(fade.is(':animated')) {
			 fade.stop().fadeTo(300, 0);
			 }else{
			 fade.fadeTo(300, 0);
			 }
		 });
  }
  
}); /* end of as page load scripts */

