﻿$(document).ready(function () {
	var errorIconHover = null;
	$('span[rel=errorIcon]').parent()
        .mouseover(function (ev) {
        	if (errorIconHover === null) {
        		errorIconHover = $('<div class="errorIconHover"><p></p></div>');
        		$('body').append(errorIconHover);
        	}
        	errorIconHover.stop(true, true);
        	errorIconHover.find('p').html('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + $(this).find('span').attr('message'));
        	errorIconHover.css({ opacity: 1, display: 'none' }).fadeIn(200, function () {
        		errorIconHover.show();
        	});
        })
        .mousemove(function (ev) {
        	if (errorIconHover === null) { return; }
        	// if the element would be off the page, then change the x
        	var xposi = ev.pageX + 15;
        	if (xposi + errorIconHover.width() > $('body').width()) {
        		xposi = ($('body').width() - errorIconHover.width()) - 15;
        	}
        	errorIconHover.css({ left: xposi, top: ev.pageY + 15 });
        })
        .mouseout(function (ev) {
        	if (errorIconHover === null) { return; }
        	errorIconHover.stop(true, true);
        	errorIconHover.fadeOut(800, function () {
        		errorIconHover.hide();
        	});
        });
});


/**
* Force Redraw
*
* Created by Pascal Beyeler (anvio.ch)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/

/**
* Sometimes the browser just does not redraw the elements after a CSS change or whatever. 
* This plugin allows you to force a redraw in your browser.
*
* @example $('#myelement').forceRedraw(); //works in most cases
* @example $('#myelement').forceRedraw(true); //use this one to force a redraw by changing the element's padding
* @desc force a browser redraw.
*
* @param brutal
* @return jQuery object
*
* @name $.fn.forceRedraw
* @cat Plugins/Browser
* @author Pascal Beyeler (anvio.ch)
*/
(function ($) {

$.fn.forceRedraw = function (brutal) {

    //this fix works for most browsers. it has the same effect as el.className = el.className.
    $(this).addClass('forceRedraw').removeClass('forceRedraw');

    //sometimes for absolute positioned elements the above fix does not work.
    //there's still a "brutal" way to force a redraw by changing the padding.
    if (brutal) {
        var paddingLeft = $(this).css('padding-left');
        var parsedPaddingLeft = parseInt(paddingLeft, 10);
        $(this).css('padding-left', ++parsedPaddingLeft);

        //give it some time to redraw
        window.setTimeout($.proxy(function () {
            //change it back
            $(this).css('padding-left', paddingLeft);
        }, this), 1);
    }

    return this;

}

})(jQuery);



// Delay Plugin for jQuery
// - http://www.evanbot.com
// - copyright 2008 Evan Byrne
/*
* Jonathan Howard
* jQuery Pause
* version 0.2
* Requires: jQuery 1.0 (tested with svn as of 7/20/2006)
* Feel free to do whatever you'd like with this, just please give credit where
* credit is do.
* pause() will hold everything in the queue for a given number of milliseconds,
* or 1000 milliseconds if none is given.
*/
// Wait Plugin for jQuery
// http://www.inet411.com
// based on the Delay and Pause Plugin
(function ($) {
	$.fn.wait = function (option, options) {
		milli = 1000;
		if (option && (typeof option == 'function' || isNaN(option))) {
			options = option;
		} else if (option) {
			milli = option;
		}
		// set defaults
		var defaults = {
			msec: milli,
			onEnd: options
		},
    settings = $.extend({}, defaults, options);

		if (typeof settings.onEnd == 'function') {
			this.each(function () {
				setTimeout(settings.onEnd, settings.msec);
			});
			return this;
		} else {
			return this.queue('fx',
        function () {
        	var self = this;
        	setTimeout(function () { $.dequeue(self); }, settings.msec);
        });
		}

	}
})(jQuery);
