﻿/// <reference path="jquery-1.3.2-vsdoc.js" />

function CheckImage(pic,id) {
    if (pic == '') {
        var imge = document.getElementById('imgpaper' + id);
        var aimg = document.getElementById('newsimage' + id);
        if (imge!=null && aimg!=null) {
            aimg.removeChild(imge);
        }
        return;
    } 
    if (pic!=''){
        var imge = document.getElementById('imgpaper' + id);
        var dive = document.getElementById('newsabs' + id);
        if (dive!=null && imge!=null) {
            dive.style.height = imge.style.height+20;
        }
    }

}


(function($) {

    $.fn.easyTooltip = function(options) {

        // default configuration properties
        var defaults = {
            xOffset: 10,
            yOffset: 25,
            tooltipId: "easyTooltip",
            clickRemove: false,
            content: "",
            useElement: ""
        };

        var options = $.extend(defaults, options);
        var content;

        this.each(function() {
            var title = $(this).attr("title");
            $(this).hover(function(e) {
                content = (options.content != "") ? options.content : title;
                content = (options.useElement != "") ? $("#" + options.useElement).html() : content;
                $(this).attr("title", "");
                if (content != "" && content != undefined) {
                    $("body").append("<div id='" + options.tooltipId + "'>" + content + "</div>");
                    $("#" + options.tooltipId)
						.css("position", "absolute")
						.css("top", (e.pageY - options.yOffset) + "px")
						.css("left", (e.pageX + options.xOffset) + "px")
						.css("display", "none")
						.fadeIn("fast")
                }
            },
			function() {
			    $("#" + options.tooltipId).remove();
			    $(this).attr("title", title);
			});
            $(this).mousemove(function(e) {
                $("#" + options.tooltipId)
					.css("top", (e.pageY - options.yOffset) + "px")
					.css("left", (e.pageX + options.xOffset) + "px")
            });
            if (options.clickRemove) {
                $(this).mousedown(function(e) {
                    $("#" + options.tooltipId).remove();
                    $(this).attr("title", title);
                });
            }
        });

    };

})(jQuery);

$(document).ready(function() {
    $("a").easyTooltip();
});

/*
*
*	jQuery Timer plugin v0.1
*		Matt Schmidt [http://www.mattptr.net]
*
*	Licensed under the BSD License:
*		http://mattptr.net/license/license.txt
*
*/

jQuery.timer = function(interval, callback) {
    /**
    *
    * timer() provides a cleaner way to handle intervals  
    *
    *	@usage
    * $.timer(interval, callback);
    *
    *
    * @example
    * $.timer(1000, function (timer) {
    * 	alert("hello");
    * 	timer.stop();
    * });
    * @desc Show an alert box after 1 second and stop
    * 
    * @example
    * var second = false;
    *	$.timer(1000, function (timer) {
    *		if (!second) {
    *			alert('First time!');
    *			second = true;
    *			timer.reset(3000);
    *		}
    *		else {
    *			alert('Second time');
    *			timer.stop();
    *		}
    *	});
    * @desc Show an alert box after 1 second and show another after 3 seconds
    *
    * 
    */

    var interval = interval || 100;

    if (!callback)
        return false;

    _timer = function(interval, callback) {
        this.stop = function() {
            clearInterval(self.id);
        };

        this.internalCallback = function() {
            callback(self);
        };

        this.reset = function(val) {
            if (self.id)
                clearInterval(self.id);

            var val = val || 100;
            this.id = setInterval(this.internalCallback, val);
        };

        this.interval = interval;
        this.id = setInterval(this.internalCallback, this.interval);

        var self = this;
    };

    return new _timer(interval, callback);
};

