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

// Prepend span elements for GForm styling
    $('.ginput_left, .ginput_right, .ginput_container, .ginput_full').prepend('<span></span>');
	$('.sfile .ginput_container').append('<div class="fakefile"><input value=""/><a class="sUpload">Upload</a></div>');
	
	$("#input_1_19").change(function() {
        var fileValue=$(this).val();
        $("#field_1_19 .fakefile input").attr('value', fileValue);
    });
    
    $("#input_1_21").change(function() {
        var fileValue=$(this).val();
        $("#field_1_21 .fakefile input").attr('value', fileValue);
    });  
        
    $("#input_1_23").change(function() {
        var fileValue=$(this).val();
        $("#field_1_23 .fakefile input").attr('value', fileValue);
    });
    
    $("#input_1_24").change(function() {
        var fileValue=$(this).val();
        $("#field_1_24 .fakefile input").attr('value', fileValue);
    });
    
    $("#input_1_25").change(function() {
        var fileValue=$(this).val();
        $("#field_1_25 .fakefile input").attr('value', fileValue);
    });
	
	$("#input_1_27").change(function() {
        var fileValue=$(this).val();
        $("#field_1_27 .fakefile input").attr('value', fileValue);
    });

// as the page loads, cal these scripts
$(document).ready(function() {
  
	$("a.popup").fancybox( {
			'autoDimensions'	: false,
			'width'         		: '800',
			'height'			: 'auto',
			'overlayOpacity'		: '0.6',
			'overlayColor'		:  '#000',
			'titleShow'		: false,
			'titlePosition' : 'inside'
		  }
	);
	
	//When page loads...
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content

	//On Click Event
	$("ul.tabs li").click(function() {

		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});
		
}); /* end of as page load scripts */
