jQuery(window).load(function(){
    if(jQuery('#slideshow IMG').length >1)play();
});


function play() {
        jQuery('#slideshow IMG:last').delay(4000).animate({opacity: 0.0}, 2000, function (){jQuery('#slideshow IMG:last').remove(); if(jQuery('#slideshow IMG').length >1)play();});
}
/////////////
function displayProducts(modality) {
    jQuery("#productForm").css({"display":"block", "position": "fixed", "top": "40px", "left": leftMargin })
    jQuery("#background").css("display", "block").addClass("opaque");
    jQuery("#error, #success").css("display", "none");
    jQuery("#products").load("http://energetic-medicine.com/products.php", {modality: modality});
}
////////////
function showProducts(){
	if(jQuery("#modalityFilter option:selected").val() != "")
	{
            var modality = jQuery("#modalityFilter option:selected").val();
            displayProducts(modality);
	}	
}
////////
function insertTA( _sna ){
	if( arguments.length > 0){
		document.write("<textarea name=\"" + _sna + "\" cols=\"44\" rows=\"4\"></textarea>");
	} else {
		document.write("<textarea name=\"xfield-MESSAGE\" cols=\"44\" rows=\"4\"></textarea>");
	}
}
////////////
var leftMargin;
jQuery(document).ready(function(){
    leftMargin = (jQuery(window).width() - jQuery("#productForm").width() ) / 2 + jQuery(window).scrollLeft() + "px";
    
    jQuery("div.entry_author_image").click(function(){jQuery(this).css("position") == "absolute" ? jQuery(this).css({'position' : 'relative'}).children("img").css({'width' : '70px'}) : jQuery(this).css({'position' : 'absolute'}).children("img").css({'width' : 'auto'}); });
    
    jQuery("a[href^='http:']").not("[href*='energetic-medicine.com']").attr('target','_blank');
    
    jQuery("#modalityFilter").change(showProducts);
    
});
