/***************************************
****************************************
    GENERAL SCRIPTS
****************************************
***************************************/
/**************************
MGZ.debug = true;
MGZ.ajax = MGZ.path + "jQueryAjax.aspx";  
MGZ.OOCSS = { TOP_CORNERS:   '<b class="top"><b class="tl"></b><b class="tr"></b></b>',
BOTTOM_CORNERS:'<b class="bottom"><b class="bl"></b><b class="br"></b></b>' };

$.ajaxSetup({
url: MGZ.ajax,
global: false,
type: "GET",
cache: false
});***/


/****check cookies enabled ***/
/*****************************/
//var testValue = Math.floor(1000 * Math.random());
//SetCookie('AreCookiesEnabled', testValue);
//if (testValue != ReadCookie('AreCookiesEnabled')) {
//    document.getElementById("cookiecheck").innerHTML = getValidationMessage("You must enable cookies to log in.", "Cookies are disabled");
//    document.getElementById("cookiecheck").style.display = "block";
//}


/***************************************
    ON DOCUMENT LOAD
    ------------------------------------
    Any code between this function
    executs when the page had loaded
    fully.
***************************************/
$(document).ready(function () {

    /*****************************/
    /******  school names    *****/
    /*****************************/
    $('marquee .pipe:last').remove();

    $('marquee').marquee('pointer').mouseover(function () {
        $(this).trigger('stop');
    }).mouseout(function () {
        $(this).trigger('start');
    }).mousemove(function (event) {
        if ($(this).data('drag') == true) {
            this.scrollLeft = $(this).data('scrollX') + ($(this).data('x') - event.clientX);
        }
    });



    //    $('.colouredBox').sifr({ path: '/fonts', font: 'font', forceSingleLine: false, preventWrap: false, color: 'white'}); 


    if (typeof $.fn.example === "function") {
        $('.example').example(function () {
            return $(this).attr('title');
        }, { className: 'example' });
    }

    /*****************************/
    /******product images    *****/
    /*****************************/
    $("#imageThumbs a").click(function (e) {
        e.preventDefault();
        $(".imgMainThumb").attr("src", $(this).attr("href"));
        $(".imgMainLink").attr("href", $(this).attr("rel"));
    });

    /*****************************/
    /****** Side Shows       *****/
    /*****************************/
    //    if (typeof $.fn.cycle === "function") {
    //        setTimeout(function () {
    //            $('.slideshow').cycle({
    //                fx: 'fade',
    //                speed: 650,     // speed of the transition (any valid fx speed value) 
    //                timeout: 4000     // milliseconds between slide transitions (0 to disable auto advance)   
    //            });
    //        }, 3000);
    //    }

    if (typeof $.fn.prettyPhoto === "function") {
        $(".lightbox").prettyPhoto();
    }


    if ($.browser.msie && $.browser.version <= 7) {
        $(".globalnav a.parent").append("<img src='/styles/skin/menuRight.png'>");
    }




    /*****************************/
    /****** Search           *****/
    /*****************************/
    var MAX_HEIGHT = 210;
    if ($(".searchResults").height() > MAX_HEIGHT) {
        $(".searchResults").css("overflow", "hidden")
                       .height(MAX_HEIGHT)
                       .after("<div class='button' id='resultExpandButton'>Expand Groups</div>")
        $("#resultExpandButton").click(expandSearchGroups);
    }
    function expandSearchGroups() {
        $(".searchResults").css({ "overflow": "visible", "height": "auto" });
        $(this).hide();
    }

    $(".btnAdvancedSearch").click(function (e) {
        e.preventDefault();
        $(".advancedSearch").show();
        $(this).hide();
    });
    if (window.location.hash.indexOf("#advanced") != -1)
        $(".btnAdvancedSearch").trigger("click");

});





function getValidationMessage(msg, title) {
    return '<div class="mod simple validation validationbg clear">' +
                 MGZ.OOCSS.TOP_CORNERS  +
                '<div class="inner">' +
                    '<div class="hd">' +
                        '<h4>' + title.replace("<", "&lt;") + '</h4>' +
                    '</div>' +
                    '<div class="bd"><p>' + msg.replace("<", "&lt;") + '</p></div>' +
                '</div>' +
                 MGZ.OOCSS.BOTTOM_CORNERS +
           '</div>';
}

function format(str)
{
    for (var i = 1; i < arguments.length; i++) {
        str = str.replace("{" + (i - 1) + "}", arguments[i]);
    }
    return str;
}


function startMod(el, className, head, headClass) {
    className   = typeof className  == "undefined" ? "" : className;
    head        = typeof head       == "undefined" ? "" : head;
    headClass = typeof headClass == "undefined" ? "" : headClass;
	return format("<{0} class='mod {1}'>\
								{2} \
								<div class='inner'> \
								{3}\
							<div class='bd'>", el, className, MGZ.OOCSS.TOP_CORNERS,
                            !head.length  ? "" : "<div class='hd " + headClass + "'>" + head + "</div>\n");
}

function endMod(el, foot, footClass) {
    foot        = typeof foot       == "undefined" ? "" : foot;
    footClass   = typeof footClass == "undefined" ? "" : footClass;
    
    return format("</div>\
				    {0}   \
				</div>\
				{1}\
			</{2}>", 
				   !foot.length ? "" : "<div class='ft " + footClass + "'>" + foot + "</div>\n", 
				   MGZ.OOCSS.BOTTOM_CORNERS, el);
}





//Shortcut to Firebug's console.log. Also doesn't break code browsers without Firebug/console
// usage: log('inside coolFunc',this,arguments);
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
window.log = function() {
    log.history = log.history || [];   // store logs to an array for reference
    log.history.push(arguments);
    if (this.console) {
        console.log(Array.prototype.slice.call(arguments));
    }
};
 

    $(document).ready(function (e) {

    /*****************************/
    /******product images    *****/
    /*****************************/
        $("#ctl00_ctl00_Main_Body_uiThumbs a").click(function (e) {
        e.preventDefault();
        $(".productThumbs").attr("src", $(this).attr("href"));
        $(".mainProductImage").attr("href", $(this).attr("rel"));
    });
});

//$(document).ready(function () {
//    // toggles the slickbox on clicking the noted link
//    $('#News-toggle').click(function () {
//        var ele = document.getElementById('lifenews');
//        var text = document.getElementById('News-toggle');
//        if (ele.style.display == "block") {
//            $('#lifenews').toggle(400);
//            text.innerHTML = "+";
//            return false;
//        }
//        else {
//            $('#lifenews').toggle(400);
//            text.innerHTML = "-";
//            return false;
//        }
//    });
//});

/*******************************/
/*****Placeholder IE n FF ****/
/*****************************/

/**function activatePlaceholders() {
    var detect = navigator.userAgent.toLowerCase();
    if (detect.indexOf("safari") > 0) return false;
    var inputs = document.getElementsByTagName("input");
    for (var i = 0; i < inputs.length; i++) {
        if (inputs[i].getAttribute("type") == "text") {
            if (inputs[i].getAttribute("title") && inputs[i].getAttribute("title").length > 0 && inputs[i].value.length < 1) {
                inputs[i].value = inputs[i].getAttribute("title");
                inputs[i].onclick = function () {
                    if (this.value == this.getAttribute("title")) {
                        this.value = "";
                    }
                    return false;
                }
                inputs[i].onblur = function () {
                    if (this.value.length < 1) {
                        this.value = this.getAttribute("title");
                    }
                }
            }
        }
    }
}
window.onload = function () {
    activatePlaceholders();
}   **/             
