/*
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.

*/


/**
 * ui.checkbox plugin
 * @author alexander.farkas
 * @version 1.4.1
 */
(function(a){var b=/ui-checkbox|ui-radio/;a.widget("ui.checkBox",{options:{hideInput:true,addVisualElement:true,addParentClass:false,addLabel:true,_delegated:false},_create:function(){var b=this,c=this.options;if(!this.element.is(":radio,:checkbox")){if(a.nodeName(this.element[0],"input")){return false}this._addDelegate();this.updateContainer();return false}this.labels=a([]);this.checkedStatus=false;this.disabledStatus=false;this.hoverStatus=false;this.radio=this.element.is(":radio");this.visualElement=a([]);if(c.hideInput){this.element.addClass("ui-helper-hidden-accessible");if(c.addVisualElement){this.visualElement=a("<span />").addClass(this.radio?"ui-radio":"ui-checkbox");this.element.after(this.visualElement[0])}}if(c.addLabel){this.labels=a("label[for="+this.element.attr("id")+"]").addClass(this.radio?"ui-radio":"ui-checkbox")}if(!c._delegated){this._addEvents()}this.initialized=true;this.reflectUI({type:"initialReflect"});return undefined},updateContainer:function(){if(!this.element.is(":radio,:checkbox")&&!a.nodeName(this.element[0],"input")){a("input",this.element[0]).filter(function(){return!a.data(this,"checkBox")}).checkBox(a.extend({},this.options,{_delegated:true}))}},_addDelegate:function(){var c=this.options,d=function(a,b){if(!b){return}b.hover=!!(a.type=="focus"||a.type=="mouseenter"||a.type=="focusin"||a.type=="mouseover");b._changeStateClassChain.call(b);return undefined};this.element.bind("click",function(b){if(!a.nodeName(b.target,"input")){return}var c=(a.data(b.target)||{}).checkBox;if(!c){return}c.reflectUI.call(c,b.target,b)}).bind("focusin.checkBox focusout.checkBox",function(b){if(!a.nodeName(b.target,"input")){return}var c=(a.data(b.target)||{}).checkBox;d(b,c)});if(c.hideInput){this.element.bind("usermode",function(b){if(!b.enabled){return}a("input",this).each(function(){var b=(a.data(this)||{}).checkBox;b&&b.destroy.call(b,true)})})}if(c.addVisualElement){this.element.bind("mouseover.checkBox mouseout.checkBox",function(b){if(!a.nodeName(b.target,"span")){return}var c=(a.data(a(b.target).prev()[0])||{}).checkBox;d(b,c)}).bind("click.checkBox",function(c){if(!a.nodeName(c.target,"span")||!b.test(c.target.className||"")){return}a(c.target).prev()[0].click();return false})}if(c.addLabel){this.element.delegate("label.ui-radio, label.ui-checkbox","mouseenter.checkBox mouseleave.checkBox",function(b){var c=(a.data(document.getElementById(a(this).attr("for")))||{}).checkBox;d(b,c)})}},_addEvents:function(){var b=this,c=this.options,d=function(a){if(b.disabledStatus){return false}b.hover=a.type=="focus"||a.type=="mouseenter";b._changeStateClassChain();return undefined};this.element.bind("click.checkBox",a.proxy(this,"reflectUI")).bind("focus.checkBox blur.checkBox",d);if(c.hideInput){this.element.bind("usermode",function(a){a.enabled&&b.destroy.call(b,true)})}if(c.addVisualElement){this.visualElement.bind("mouseenter.checkBox mouseleave.checkBox",d).bind("click.checkBox",function(a){b.element[0].click();return false})}if(c.addLabel){this.labels.bind("mouseenter.checkBox mouseleave.checkBox",d)}},_changeStateClassChain:function(){function e(){var b=this.className.split(" "),e=false;a.each(b,function(a,f){if(f.indexOf(d)===0){e=true;b[a]=c;return false}return undefined});if(!e){b.push(c)}this.className=b.join(" ")}var b=this.labels.add(this.visualElement),c="",d="ui-"+(this.radio?"radio":"checkbox");if(this.checkedStatus){c+="-checked";b.addClass(d+"-checked");this.element.parent().addClass("ACTIVE")}else{b.removeClass(d+"-checked");this.element.parent().removeClass("ACTIVE")}if(this.disabledStatus){c+="-disabled";b.addClass(d+"-disabled")}else{b.removeClass(d+"-disabled")}if(this.hover){c+="-hover";b.addClass(d+"-hover")}else{b.removeClass(d+"-hover")}d+="-state";if(c){c=d+c}this.labels.each(e);this.visualElement.each(e)},destroy:function(a){this.element.removeClass("ui-helper-hidden-accessible");this.visualElement.addClass("ui-helper-hidden");if(!a){var b=this.options;this.element.unbind(".checkBox");this.visualElement.remove();this.labels.unbind(".checkBox").removeClass("ui-state-hover ui-state-checked ui-state-disabled")}},disable:function(){this.element[0].disabled=true;this.reflectUI({type:"manuallyDisabled"})},enable:function(){this.element[0].disabled=false;this.reflectUI({type:"manuallyenabled"})},toggle:function(a){this.changeCheckStatus(this.element.is(":checked")?false:true,a)},changeCheckStatus:function(a,b){if(b&&b.type=="click"&&this.element[0].disabled){return false}this.element.attr({checked:a});this.reflectUI(b||{type:"changeCheckStatus"});return undefined},propagate:function(b,c,d){if(!c||c.type!="initialReflect"){if(this.radio&&!d){a(document.getElementsByName(this.element.attr("name"))).checkBox("reflectUI",c,true)}return this._trigger(b,c,{options:this.options,checked:this.checkedStatus,labels:this.labels,disabled:this.disabledStatus})}return undefined},reflectUI:function(a){var b=this.checkedStatus,c=this.disabledStatus;this.disabledStatus=this.element.is(":disabled");this.checkedStatus=this.element.is(":checked");if(this.disabledStatus!=c||this.checkedStatus!==b){this._changeStateClassChain();this.disabledStatus!=c&&this.propagate("disabledChange",a);this.checkedStatus!==b&&this.propagate("change",a)}}})})(jQuery);


/* 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();}}}}


var $GLOBAL = {
	radioButtons : $('.ui-radios')
};

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

/////// radio button prettiyfier
	if ($GLOBAL.radioButtons.length > 0) {
		$GLOBAL.radioButtons.find('label:last').addClass('last-child');
		$GLOBAL.radioButtons.find('label:first').addClass('first-child');
		$GLOBAL.radioButtons.delegate('input', 'change', function() {
			//alert();
		});
		$GLOBAL.radioButtons.find('input').checkBox({ addVisualElement: false });
	}
	
	
	// add all your scripts here

 
}); /* end of as page load scripts */
