/* 
Title:		Build Scripts

Requires:
dd-roundies.js
jquery.carousellite.js
		
*/

/* Initiate scripts */
$(document).ready(function() {

    //$("div:not('#ctl00_MainContent_uxPersonalDetails') tbody th[colspan], div:not('#ctl00_MainContent_uxPersonalDetails') tbody td[colspan]").css("width", "auto");
    //$("div.form8 td[colspan], div.form8 th[colspan]").css("width","auto");												 
    $("img.reflect").reflect({ height: 0.2, opacity: 0.5 }); // Image Reflections
    $(".news-ticker ul").newsticker(); // News Ticker
    if ($(".featured-courses .inner li").length > 3) {
        $(".featured-courses .inner").jCarouselLite({  // Carousel
            btnNext: ".next", btnPrev: ".prev", scroll: 3, speed: 1200
        });
        $(".prev, .next").show(); // show paging controls			
    }
    $('.course-search .text').emptyonclick(); // Quick search empty onclick
    clickableArea(".adverts li", "h3"); // clickable boxes
    clickableArea(".featured-courses li", "h3"); // clickable boxes
    // Login Pop Up
    //$("#login").append($("#login-popup"));
    $("#login-link").click(function() {
        $("#login-popup, #overlay").fadeIn();
        $("#login-popup input:first").focus();
        return false;
    });
    $("#login-popup-close").click(function() {
        $("#login-popup, #overlay").fadeOut();
        return false;
    });
    $("#login-popup :input").keypress(function(e) {
        var code = (e.keyCode ? e.keyCode : e.which);
        if (code == 13) {
            WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$uxLogin", "", true, "QuickLogin", "", false, true));
        }
    });
    if ($.browser.msie) {
        DD_roundies.addRule('.aside2 .featured-providers', '6px'); DD_roundies.addRule('.course-body, .content-body', '12px'); DD_roundies.addRule('.course-body2, .content-body2', '12px'); DD_roundies.addRule('.content-body .table6', '6px'); DD_roundies.addRule('.course-header .course-nav', '6px'); DD_roundies.addRule('.course-body .course-nav', '6px'); DD_roundies.addRule('.course-nav a', '3px'); DD_roundies.addRule('.featured-courses', '7px'); DD_roundies.addRule('.footer', '7px'); DD_roundies.addRule('.intro1 a', '8px'); DD_roundies.addRule('.lawyer-progress', '6px'); DD_roundies.addRule('.lawyer-progress .outer', '4px'); DD_roundies.addRule('.lawyer-progress .inner2', '4px'); DD_roundies.addRule('.nav .nav-login a', '8px'); DD_roundies.addRule('.news-ticker', '9px'); DD_roundies.addRule('.user-progress', '6px'); DD_roundies.addRule('.user-progress .outer', '4px'); DD_roundies.addRule('.user-progress .inner', '4px'); DD_roundies.addRule('.user-login fieldset', '8px');
    } else {
        if (navigator.appVersion.indexOf("Mac") != -1) {
            if ($.browser.mozilla) {
                $(".help-file").addClass("help-file-mac").removeClass("help-file")
                $(".help-file-mac").tooltip();
                $(".form td a.link").addClass("link2");
            }
        }
        $(".help").tooltip();
        $(".help-file").tooltip();
    }


    /* ### Course Edit/Upload form */



    //put spans inside thickbox titles for styling
    $("#TB_ajaxWindowTitle").wrapInner("<span></span>");


    $("#row3 input:checkbox").click(function() {
        //showHide($(this)[0]);
    })

    /* Accredited by */
    $("#accredited li").each(function() {
        disableIt($(this).find("input:checkbox"));
    });
    $("#accredited input:checkbox").click(function() {
        disableIt($(this));
    });
});
/* Equal Height Columns - http://www.cssnewbie.com/equal-height-columns-with-jquery/ */
function equalHeight(group) { tallest = 0; group.each(function() { thisHeight = $(this).height(); if (thisHeight > tallest) { tallest = thisHeight; } }); group.height(tallest); }
/*!reflection.js for jQuery v1.02 (c) 2006-2008 Christophe Beyls <http://www.digitalia.be> 	MIT-style license.	*/
(function($) { $.fn.extend({ reflect: function(options) { options = $.extend({ height: 0.33, opacity: 0.5 }, options); return this.unreflect().each(function() { var img = this; if (/^img$/i.test(img.tagName)) { function doReflect() { var reflection, reflectionHeight = Math.floor(img.height * options.height), wrapper, context, gradient; if ($.browser.msie) { reflection = $("<img />").attr("src", img.src).css({ width: img.width, height: img.height, marginBottom: -img.height + reflectionHeight, filter: "flipv progid:DXImageTransform.Microsoft.Alpha(opacity=" + (options.opacity * 100) + ", style=1, finishOpacity=0, startx=0, starty=0, finishx=0, finishy=" + (options.height * 100) + ")" })[0]; } else { reflection = $("<canvas />")[0]; if (!reflection.getContext) return; context = reflection.getContext("2d"); try { $(reflection).attr({ width: img.width, height: reflectionHeight }); context.save(); context.translate(0, img.height - 1); context.scale(1, -1); context.drawImage(img, 0, 0, img.width, img.height); context.restore(); context.globalCompositeOperation = "destination-out"; gradient = context.createLinearGradient(0, 0, 0, reflectionHeight); gradient.addColorStop(0, "rgba(255, 255, 255, " + (1 - options.opacity) + ")"); gradient.addColorStop(1, "rgba(255, 255, 255, 1.0)"); context.fillStyle = gradient; context.rect(0, 0, img.width, reflectionHeight); context.fill(); } catch (e) { return; } } $(reflection).css({ display: "block", border: 0 }); wrapper = $(/^a$/i.test(img.parentNode.tagName) ? "<span />" : "<div />").insertAfter(img).append([img, reflection])[0]; wrapper.className = img.className; $.data(img, "reflected", wrapper.style.cssText = img.style.cssText); $(wrapper).css({ width: img.width, height: img.height + reflectionHeight, overflow: "hidden" }); img.style.cssText = "display: block; border: 0px"; img.className = "reflected"; } if (img.complete) doReflect(); else $(img).load(doReflect); } }); }, unreflect: function() { return this.unbind("load").each(function() { var img = this, reflected = $.data(this, "reflected"), wrapper; if (reflected !== undefined) { wrapper = img.parentNode; img.className = wrapper.className; img.style.cssText = reflected; $.removeData(img, "reflected"); wrapper.parentNode.replaceChild(img, wrapper); } }); } }); })(jQuery);
/* News Ticker - Copyright (c) 2006/2007 Sam Collett (http://www.texotela.co.uk) Demo: http://www.texotela.co.uk/code/jquery/newsticker/*/
eval(function(p, a, c, k, e, r) { e = function(c) { return (c < a ? '' : e(parseInt(c / a))) + ((c = c % a) > 35 ? String.fromCharCode(c + 29) : c.toString(36)) }; if (!''.replace(/^/, String)) { while (c--) r[e(c)] = k[c] || e(c); k = [function(e) { return r[e] } ]; e = function() { return '\\w+' }; c = 1 }; while (c--) if (k[c]) p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]); return p } ('(1($){$.9.D=$.9.g=1(b){b=b||p;i=1(a){j(a);a.4=$("r",a);a.4.q(":o(0)").l().C();a.5=0;h(a)};h=1(a){a.m=t(1(){f(a)},b)};j=1(a){s(a.m)};8=1(a){a.3=7};d=1(a){a.3=c};f=1(a){e(a.3)6;a.3=7;$(a.4[a.5]).n("k",1(){$(2).l();a.5=++a.5%(a.4.B());$(a.4[a.5]).z("k",1(){a.3=c})})};2.y(1(){e(2.x.w()!="A")6;i(2)}).v("g").u(1(){8(2)},1(){d(2)});6 2}})(E);', 41, 41, '|function|this|pause|items|currentitem|return|true|pauseTicker|fn|||false|resumeTicker|if|doTick|newsticker|startTicker|initTicker|stopTicker|slow|hide|tickfn|fadeOut|eq|4000|not|li|clearInterval|setInterval|hover|addClass|toLowerCase|nodeName|each|fadeIn|ul|size|end|newsTicker|jQuery'.split('|'), 0, {}))
/* jQuery emptyonclick plugin - Created by Andreas Creten (andreas@madewithlove.be) on 2008-06-06. */
jQuery.fn.extend({ emptyonclick: function(options) { return this.each(function() { new jQuery.EmptyOnClick(this, options); }); } }); jQuery.EmptyOnClick = function(element, options) { var defaultValue = $(element).val(); $(element).bind("focus", function(e) { if (defaultValue == $(this).val()) $(this).val(''); }).bind("blur", function(e) { if (!$(this).val()) { $(this).val(defaultValue); } }); $("form:has(#" + element.id + ")").bind('reset', function(e) { $(element).val(defaultValue); $(element).removeClass(options.changeClass); }).bind('submit', function(e) { if ($(element).val() == defaultValue) $(element).val(''); }); };
/* Clickable Area - target & href location */
function clickableArea(target, href) { href = href + ":first a:first"; $(target).click(function() { window.location = $(this).find(href).attr("href"); }); $(target).hover(function() { $(this).addClass("hover"); }, function() { $(this).removeClass("hover"); }); }
/* jQuery Tooltip plugin 1.3 - http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/ */
(function($) {
    var helper = {}, current, title, tID, IE = $.browser.msie && /MSIE\s(5\.5|6\.)/.test(navigator.userAgent), track = false; $.tooltip = { blocked: false, defaults: { delay: 200, fade: false, showURL: true, extraClass: "", top: 15, left: 15, id: "tooltip" }, block: function() { $.tooltip.blocked = !$.tooltip.blocked; } }; $.fn.extend({ tooltip: function(settings) { settings = $.extend({}, $.tooltip.defaults, settings); createHelper(settings); return this.each(function() { $.data(this, "tooltip", settings); this.tOpacity = helper.parent.css("opacity"); this.tooltipText = this.title; $(this).removeAttr("title"); this.alt = ""; }).mouseover(save).mouseout(hide).click(hide); }, fixPNG: IE ? function() { return this.each(function() { var image = $(this).css('backgroundImage'); if (image.match(/^url\(["']?(.*\.png)["']?\)$/i)) { image = RegExp.$1; $(this).css({ 'backgroundImage': 'none', 'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='" + image + "')" }).each(function() { var position = $(this).css('position'); if (position != 'absolute' && position != 'relative') $(this).css('position', 'relative'); }); } }); } : function() { return this; }, unfixPNG: IE ? function() { return this.each(function() { $(this).css({ 'filter': '', backgroundImage: '' }); }); } : function() { return this; }, hideWhenEmpty: function() { return this.each(function() { $(this)[$(this).html() ? "show" : "hide"](); }); }, url: function() { return this.attr('href') || this.attr('src'); } }); function createHelper(settings) { if (helper.parent) return; helper.parent = $('<div id="' + settings.id + '"><h3></h3><div class="body"></div><div class="url"></div></div>').appendTo(document.body).hide(); if ($.fn.bgiframe) helper.parent.bgiframe(); helper.title = $('h3', helper.parent); helper.body = $('div.body', helper.parent); helper.url = $('div.url', helper.parent); } function settings(element) { return $.data(element, "tooltip"); } function handle(event) {
        if (settings(this).delay) tID = setTimeout(show, settings(this).delay); else
            show(); track = !!settings(this).track; $(document.body).bind('mousemove', update); update(event);
    } function save() {
        if ($.tooltip.blocked || this == current || (!this.tooltipText && !settings(this).bodyHandler)) return; current = this; title = this.tooltipText; if (settings(this).bodyHandler) { helper.title.hide(); var bodyContent = settings(this).bodyHandler.call(this); if (bodyContent.nodeType || bodyContent.jquery) { helper.body.empty().append(bodyContent) } else { helper.body.html(bodyContent); } helper.body.show(); } else if (settings(this).showBody) { var parts = title.split(settings(this).showBody); helper.title.html(parts.shift()).show(); helper.body.empty(); for (var i = 0, part; (part = parts[i]); i++) { if (i > 0) helper.body.append("<br/>"); helper.body.append(part); } helper.body.hideWhenEmpty(); } else { helper.title.html(title).show(); helper.body.hide(); } if (settings(this).showURL && $(this).url()) helper.url.html($(this).url().replace('http://', '')).show(); else
            helper.url.hide(); helper.parent.addClass(settings(this).extraClass); if (settings(this).fixPNG) helper.parent.fixPNG(); handle.apply(this, arguments);
    } function show() {
        tID = null; if ((!IE || !$.fn.bgiframe) && settings(current).fade) {
            if (helper.parent.is(":animated")) helper.parent.stop().show().fadeTo(settings(current).fade, current.tOpacity); else
                helper.parent.is(':visible') ? helper.parent.fadeTo(settings(current).fade, current.tOpacity) : helper.parent.fadeIn(settings(current).fade);
        } else { helper.parent.show(); } update();
    } function update(event) { if ($.tooltip.blocked) return; if (event && event.target.tagName == "OPTION") { return; } if (!track && helper.parent.is(":visible")) { $(document.body).unbind('mousemove', update) } if (current == null) { $(document.body).unbind('mousemove', update); return; } helper.parent.removeClass("viewport-right").removeClass("viewport-bottom"); var left = helper.parent[0].offsetLeft; var top = helper.parent[0].offsetTop; if (event) { left = event.pageX + settings(current).left; top = event.pageY + settings(current).top; var right = 'auto'; if (settings(current).positionLeft) { right = $(window).width() - left; left = 'auto'; } helper.parent.css({ left: left, right: right, top: top }); } var v = viewport(), h = helper.parent[0]; if (v.x + v.cx < h.offsetLeft + h.offsetWidth) { left -= h.offsetWidth + 20 + settings(current).left; helper.parent.css({ left: left + 'px' }).addClass("viewport-right"); } if (v.y + v.cy < h.offsetTop + h.offsetHeight) { top -= h.offsetHeight + 20 + settings(current).top; helper.parent.css({ top: top + 'px' }).addClass("viewport-bottom"); } } function viewport() { return { x: $(window).scrollLeft(), y: $(window).scrollTop(), cx: $(window).width(), cy: $(window).height() }; } function hide(event) {
        if ($.tooltip.blocked) return; if (tID) clearTimeout(tID); current = null; var tsettings = settings(this); function complete() { helper.parent.removeClass(tsettings.extraClass).hide().css("opacity", ""); } if ((!IE || !$.fn.bgiframe) && tsettings.fade) {
            if (helper.parent.is(':animated')) helper.parent.stop().fadeTo(tsettings.fade, 0, complete); else
                helper.parent.stop().fadeOut(tsettings.fade, complete);
        } else
            complete(); if (settings(this).fixPNG) helper.parent.unfixPNG();
    } 
})(jQuery);

function disableIt(x) {

    if ($(x)[0].checked) {

        x.next().next().css("opacity", "1").next().attr("disabled", false);
    } else {
        x.next().next().css("opacity", ".5").next().attr("disabled", true);
    }
}

function focusField(field, noprev) {
    $(field).parents("th, td").addClass('active')
    if (noprev != true) $(field).parents("th, td").prev("th").addClass('active');
}
function blurField(field, noprev) {
    $(field).parents("th, td").removeClass('active')
    if (noprev != true) $(field).parents("th, td").prev("th").removeClass('active');
}




