jQuery(document).ready(function(){
	 //START SITE SPECIFIC FUNCTIONS HERE//
	 
	//ReplaceValues = function(){
//jQuery('#shareform input').each(function(){
//var labelValue = jQuery(this).parent().find('label').text(); 
//jQuery(this).val(labelValue);
//});
//};
//ReplaceValues();
   
    //jQuery(this).value = 'testing';
/*jQuery('#shareform input:text').each(function() {
    var default_value = this.value;
    jQuery(this).focus(function() {
        if(this.value == default_value) {
            this.value = '';
        }
    });
    jQuery(this).blur(function() {
        if(this.value == '') {
            this.value = default_value;
        }
    });
});
*/
//jQuery("#random ul").randomize("#random ul li");
//jQuery('#random ul').shuffle();
jQuery("#shareform input:text").focus(function() {
										 // alert('huh?');
						//jQuery('#sharebox').slideDown(500);
						var cssObj = {
							'height' : 'auto'
							}
jQuery('#shareform').parent().css(cssObj);
});


/*
jQuery('#shareform').ajaxForm(function() { 
                alert("Thank you for your comment!"); 
            }); 
*/
/*
jQuery("#sharereply").hide();
jQuery('#shareform').ajaxForm({ 
        // target identifies the element(s) to update with the server response 
        target: '#sharereply', 
 
        // success identifies the function to invoke when the server response 
        // has been received; here we apply a fade-in effect to the new content 
        success: function() { 
            jQuery('#sharereply').fadeIn('slow'); 
        } 
    }); */





jQuery.fn.shuffle = function() {
		return this.each(function(){
			var items = jQuery(this).children().clone(true);
			return (items.length) ? jQuery(this).html(jQuery.shuffle(items)) : this;
		});
	}
	
	jQuery.shuffle = function(arr) {
		for(var j, x, i = arr.length; i; j = parseInt(Math.random() * i), x = arr[--i], arr[i] = arr[j], arr[j] = x);
		return arr;
	}
//jQuery('#rndbuttons ul').shuffle();
jQuery('.random').shuffle();
});

  
  
window.onscroll = function()
{
	var sidebarHeight = jQuery('#header').height() + jQuery('#access').height() + jQuery('#primary').height() - jQuery('#stationaryAd').height() + 300;
	//alert('sidebar height' + sidebarHeight);
    if( window.XMLHttpRequest ) {
        if (document.documentElement.scrollTop > sidebarHeight || self.pageYOffset > sidebarHeight) {
            jQuery('#stationaryAd').css('position','fixed');
            jQuery('#stationaryAd').css('top','40px');
        } else if (document.documentElement.scrollTop < sidebarHeight || self.pageYOffset < sidebarHeight) {
            jQuery('#stationaryAd').css('position','absolute');
            jQuery('#stationaryAd').css('top',sidebarHeight + 'px');
        }
    }
}
