/* /sites/GaucherCare/_resources/js/global.js*/ /*
	
	Genzyme Global Javascript Functions
	By christoph saxe and will moore - ISITE Design

*/

//start the jQuery functions
$j(document).ready(function() {

	$j("a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:'fast',slideshow:10000, social_tools:'', show_title:false, overlay_gallery:false});
	
    // IE6 flickering
    try { document.execCommand("BackgroundImageCache", false, true); }
    catch (err) { }

    //set up buttons
    $j('button').addClass('btn');
    $j("a.btn, button").addClass("tl").wrapInner('<span class="tl"><span class="br"><span class="tr"><span class="bl"></span></span></span></span>');
	// add class "last" to the last li in any list.  Used as a styling hook since :last-child isn't widely supported via css.  thank you jquery.
    $j("div.section:last-child").addClass("last");
	
    // add class to drop downs and buttons for IE <6
    if (document.all) {
        $j("#nav li, button, a span.tl").hover(
			function() { $j(this).addClass("over"); },
			function() { $j(this).removeClass("over"); }
	    );
    } // if document.all

    // move the lanugage dropdown to inside #wrapper for positioning, and apply dropdown behavior
    if ($j("#international-genzyme").length > 0) {
        var langMarkup = '<div id="lang"><a href="#international-genzyme" id="lang-select"></a><ul id="lang-list"></ul></div><!-- /language selector -->';
        $j("#wrapper").prepend(langMarkup)
        $j("#lang-select").html($j("#international-genzyme span.label").html());
        $j("#international-genzyme span.label").remove();
        var $langUL = $j("#lang ul");
        $langUL.attr("id", "lang-list");
        $langUL.html($j("#international-genzyme ul").html());
        $j("#lang-select").click(function() {
            pullDownLang();
            return false;
        });
        $j("#lang > ul > li > a").click(function() {
            pullDownLang();
        });
    }

    // add print this page link
    $j("#page-functions ul").append('<li><a id="print-page" href="#">' + STRINGS.PAGE_UTILITY_STRINGS.PrintThisPage + '</a></li>');
    $j("#print-page").click(function() {
        printCall();
        return false;
    });


});        // document ready / end jquery functions

// language pulldown function from MPSI; this might be moved to a .toggle based function up in document.ready
function pullDownLang(){
	if($j("#lang-list").attr('class').indexOf('pulled-out') != -1){
		$j("#lang-list").slideUp("slow").removeClass('pulled-out');
	} else {
		$j("#lang-list").slideDown("slow").addClass('pulled-out');
	}
}


// clean console.log
function cl(logit){ if(window.console&&window.console.firebug) { console.log(logit) } };//cl()
// example: cl("If you use cl() instead of console.log(), it won't break IE when you forget to take it out.");

function resize(size, units) { 
	size = (size) ? size : 200; 
	units = (units) ? units : "%"; 
	var resized = ($j("#textsize").length > 0) ? true : false;
	if (size > -1) {
		if (!resized) $j("body").wrapInner("<div id='textsize'></div>"); 
		$j("#textsize").css("font-size", size+units);
	} else {
		if (!resized) return false;
		var content = $j("#textsize").html();
		$j("#textsize").remove();
		$j("body").html(content);
	}
}

function printCall(obj) {
//    if (typeof (s_gi) == 'function') {
//        var s = s_gi(s_account);
//        if (s && typeof s.tl == 'function')
//            s.tl(obj, "o", STRINGS.PAGE_UTILITY_STRINGS.PrintThisPage);
//    }
    window.print();
}

