/*
DFW Scripts file
Author: James "Killin' It" W. Lane

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, call these scripts
$(document).ready(function() {
	
	// Allows Fading Colors for the all <a> tags
	$('a').hoverFadeColor();
	
	/* Social icons */
    jQuery('#menu-social a span').css('opacity', '0')
    jQuery('#menu-social a').hover(

    function () {
        jQuery('span', this).stop().animate({
            opacity: 1
        }, 400);
    }, function () {
        jQuery('span', this).stop().animate({
            opacity: 0
        }, 400);
    })

	/* sidebar1 buttons */
    jQuery('#sidebar1 a span').css('opacity', '0')
    jQuery('#sidebar1 a').hover(

    function () {
        jQuery('span', this).stop().animate({
            opacity: 1
        }, 400);
    }, function () {
        jQuery('span', this).stop().animate({
            opacity: 0
        }, 400);
    })

	/* contribute widget links buttons */
    jQuery('#contribute-widget a span').css('opacity', '0')
    jQuery('#contribute-widget a').hover(

    function () {
        jQuery('span', this).stop().animate({
            opacity: 1
        }, 400);
    }, function () {
        jQuery('span', this).stop().animate({
            opacity: 0
        }, 400);
    })
    
	/* read more links buttons */
    jQuery('#post-excerpt a.read-button span').css('opacity', '0')
    jQuery('#post-excerpt a.read-button').hover(

    function () {
        jQuery('span', this).stop().animate({
            opacity: 1
        }, 400);
    }, function () {
        jQuery('span', this).stop().animate({
            opacity: 0
        }, 400);
    })

	/* view more link button */
    jQuery('.bpn-next-link a span').css('opacity', '0')
    jQuery('.bpn-next-link a').hover(

    function () {
        jQuery('span', this).stop().animate({
            opacity: 1
        }, 400);
    }, function () {
        jQuery('span', this).stop().animate({
            opacity: 0
        }, 400);
    })
    
	/* view previous link button */
    jQuery('.bpn-prev-link a span').css('opacity', '0')
    jQuery('.bpn-prev-link a').hover(

    function () {
        jQuery('span', this).stop().animate({
            opacity: 1
        }, 400);
    }, function () {
        jQuery('span', this).stop().animate({
            opacity: 0
        }, 400);
    })

//  Enabled a fading hover state on a gravity forms imput button
$("#gform_submit_button_5").wrap("<div id='btn-wrap5' class='block right'></div>");
    jQuery('#gform_submit_button_5').css('opacity', '0')
    jQuery('#btn-wrap5').hover(

    function () {
        jQuery('#gform_submit_button_5').stop().animate({
            opacity: 1
        }, 400);
    }, function () {
        jQuery('#gform_submit_button_5').stop().animate({
            opacity: 0
        }, 400);
    })

//  Enabled a fading hover state on a gravity forms imput button
$("#gform_submit_button_3").wrap("<div id='btn-wrap3' class='block right'></div>");
    jQuery('#gform_submit_button_3').css('opacity', '0')
    jQuery('#btn-wrap3').hover(

    function () {
        jQuery('#gform_submit_button_3').stop().animate({
            opacity: 1
        }, 400);
    }, function () {
        jQuery('#gform_submit_button_3').stop().animate({
            opacity: 0
        }, 400);
    })

// Add "your first name" into the #input_5_1_3 input field
$('#input_5_1_3').val("your first name");
$('#input_5_1_3').focus(function() {
    $(this).attr('value', '');
});
$("#input_5_1_3").blur(function() {
    if ($(this).val() === '') {
        $(this).val("your first name");
    }
});

// Add "your last name" into the #input_5_1_6 input field
	$('#input_5_1_6').val("your last name");
$('#input_5_1_6').focus(function() {
    $(this).attr('value', '');
});
$("#input_5_1_6").blur(function() {
    if ($(this).val() === '') {
        $(this).val("your last name");
    }
});

// Add "email address" into the #input_1_2 input field
	$('#input_5_2').val("email address");
$('#input_5_2').focus(function() {
    $(this).attr('value', '');
});
$("#input_5_2").blur(function() {
    if ($(this).val() === '') {
        $(this).val("email address");
    }
});

// Add "your first name" into the #input_1_1_3 input field
	$('#input_3_1_3').val("your first name");
$('#input_3_1_3').focus(function() {
    $(this).attr('value', '');
});
$("#input_3_1_3").blur(function() {
    if ($(this).val() === '') {
        $(this).val("your first name");
    }
});

// Add "your last name" into the #input_1_1_6 input field
	$('#input_3_1_6').val("your last name");
$('#input_3_1_6').focus(function() {
    $(this).attr('value', '');
});
$("#input_3_1_6").blur(function() {
    if ($(this).val() === '') {
        $(this).val("your last name");
    }
});

// Add "email address" into the #input_1_2 input field
	$('#input_3_2').val("email address");
$('#input_3_2').focus(function() {
    $(this).attr('value', '');
});
$("#input_3_2").blur(function() {
    if ($(this).val() === '') {
        $(this).val("email address");
    }
});

// Add "email address" into the #input_1_2 input field
	$('#input_3_3').val("phone number");
$('#input_3_3').focus(function() {
    $(this).attr('value', '');
});
$("#input_3_3").blur(function() {
    if ($(this).val() === '') {
        $(this).val("phone number");
    }
});

//  Popup window JS for the twitter widget
$('.popup').click(function(event) {
    var width  = 575,
        height = 400,
        left   = ($(window).width()  - width)  / 2,
        top    = ($(window).height() - height) / 2,
        url    = this.href,
        opts   = 'status=1' +
                 ',width='  + width  +
                 ',height=' + height +
                 ',top='    + top    +
                 ',left='   + left;

    window.open(url, 'twitte', opts);

    return false;
  });

$('<span id="gc-viewall"><a href="https://www.google.com/calendar/embed?src=ir7usfsjmetn7vkpobno36pklo@group.calendar.google.com">View all events</a></span>').appendTo('.widget_gce_widget');

$(".pullquote").each(function(index) {
    var pullQuote = $(this).html();
    $("#pullshow").html(pullQuote).show();
 });

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