// JavaScript Document

var z='';

function email_link(name, domain, end, alias){
	email = '<a href="mailto:' + name + '&#64;' + domain + '.'+ end +'">';
	email += (alias ? alias : name + '&#64;' + domain + '.'+ end);
	email += '</a>';
	document.write(email);
}

function email_link2(name, domain, end){
	email = '<a href="mailto:' + name + '&#64;' + domain + '.'+ end +'">';
	document.write(email);
}

function email_link3(name, domain, end){
	email = name + '&#64;' + domain + '.'+ end;
	document.write(email);
}



/*
========= ФУНКЦИЯ ПРОВЕРКИ ПОЛЕЙ ФОРМЫ =========

fields - двумерный массив с id полей и человеческим названием для юзверей
Пример:
var fields = [
	["id1", "Поле 1"],
	["id2", "Поле 2"]
];
fields[1][1] будет иметь значение "Поле 2".
*/
function check_fields(fields){
	ok = true;
	len = fields.length;

	if(len > 0){
		a = 0;
		empty = new Array();
		for(n = 0; n < len; n++){
			if(document.getElementById(fields[n][0]) && document.getElementById(fields[n][0]).value == ''){
				ok = false;
				empty[a] = fields[n][1];
				a++;
			}
		}
		
		emptylen = empty.length;
		if(emptylen > 0){
			list ="";
			for(b = 0; b < emptylen; b++){
				list += '\t-  " ' + empty[b] + ' "\n\n';
			}
			alert('Заполните следующие поля:\n\n'+list);
		}
		return ok;
	}else{
		alert("Не заданы поля для проверки!");
		return false;
	}
}

// анонс тв программы
function tvanons(day, no){
	$("#descr"+no).load("../phpajax/tvanons.php?day="+day+"&id="+no);
	$("#descr"+no).fadeIn("slow");
	$("#descr"+no).css("display", "table");
}

function hidetv(no){
	$("#descr"+no).fadeOut("slow");
}

// голосование
function vote(idvote){
	$("#votebody").load("phpajax/vote.php?act=vote&idvote="+idvote+"&idanswr="+$("input.vote:checked").attr("value"));
}
// результаты голосования
function vote_res(idvote){
	$("#votebody").load("phpajax/vote.php?act=res&idvote="+idvote);
}
// вопрос голосования
function vote_ask(idvote){
	$("#votebody").load("phpajax/vote.php?act=ask&idvote="+idvote);
}

function get_news(id){
	$("#news"+id).load("phpajax/getnews.php?id="+id);
	$("#news"+id).slideToggle("slow").siblings(".ncont").slideUp("slow");
}

function get_horo(day){
	$("#horo").load("../phpajax/gethoro.php?day="+day);
}

function show_screen(){
	$("#td_scr").attr("class", "triger act");
	$("#td_clip").attr("class", "triger");
	$("#td_review").attr("class", "triger");
	$("#td_clip2").attr("class", "triger");
	$("#clip").fadeOut("fast");
	$("#review").fadeOut("fast");
	$("#screen").fadeIn("fast");
	$("#clip2").fadeOut("fast");
}

function show_clip(){
	$("#td_clip").attr("class", "triger act");
	$("#td_scr").attr("class", "triger");
	$("#td_review").attr("class", "triger");
	$("#td_clip2").attr("class", "triger");
	$("#clip").fadeIn("fast");
	$("#review").fadeOut("fast");
	$("#screen").fadeOut("fast");
	$("#clip2").fadeOut("fast");
}

function show_review(){
	$("#td_clip").attr("class", "triger");
	$("#td_scr").attr("class", "triger");
	$("#td_review").attr("class", "triger act");
	$("#td_clip2").attr("class", "triger");
	$("#clip").fadeOut("fast");
	$("#review").fadeIn("fast");
	$("#screen").fadeOut("fast");
	$("#clip2").fadeOut("fast");
}

function show_clip2(){
	$("#td_clip").attr("class", "triger");
	$("#td_scr").attr("class", "triger");
	$("#td_review").attr("class", "triger");
	$("#td_clip2").attr("class", "triger act");
	$("#clip").fadeOut("fast");
	$("#review").fadeOut("fast");
	$("#screen").fadeOut("fast");
	$("#clip2").fadeIn("fast");
}

function rating(id, grade, type){
	$("#rating").load('../phpajax/frating.php?id='+id+'&grade='+grade+'&type='+type);	
}

function pc_vote(idphoto, vote){
	$("#voteinfo").load('../phpajax/pcvote.php?idphoto='+idphoto+'&vote='+vote);
}

$(document).ready(function(){ 
	
	// спрятать анонсы после 3
	$("div.anons").hide();
	
	// показать весь список анонсов
	$(".show_all").click(function(){
		$(this).hide();
		$(".show_recent").show();
		$("div.anons").slideDown("slow");
		return false;
	});
	
	// показать краткий список анонсов
	$(".show_recent").click(function(){
		$(this).hide();
		$(".show_all").show();
		$("div.anons").slideUp("slow");
		return false;
	});
	
	// наведение мыши на превьюшную фотку
	$("table.block div.news table td img").hover(function(){
		$(this).next("div.preinfo").css("left", $(this).parents("table.block").offset().left)
		.css("top", $(this).offset().top+$(this).height()+10 )
		.css("width", $(this).parents("table.block").width()-20 )
		.css("display", "block")
		.animate({opacity:"0.8"}, "fast");
		
		$(this).animate({opacity:"1"}, "fast");
		$(".ugol").css("top", $(this).offset().top+$(this).height()+2)
		.css("left", $(this).offset().left+($(this).width()-8)/2)
		.css("display", "block")
		.animate({opacity:"0.8"}, "fast");
	}, function(){
		$(this).next("div.preinfo").animate({opacity:"hide"}, "fast");
		$(this).animate({opacity:"0.7"}, "fast");
		$(".ugol").css("display", "none");
	});
	
	// наведение мыши на превьюшную фотку (вариант 2)
	$("table.block div.news1 table td img").hover(function(){
		$("div.preinfo1").hide();
		$(".ugol").hide();
		
		$(this).parents("a").next("div.preinfo1").css("left", $(this).parents("table.block").offset().left)
		.css("top", $(this).offset().top+$(this).height()+5 )
		.css("width", $(this).parents("table.block").width()-20 )
		.css("display", "block")
		.animate({opacity:"0.8"}, "fast");
		
		$(this).animate({opacity:"1"}, "fast");
		$(".ugol").css("top", $(this).offset().top+$(this).height()-3)
		.css("left", $(this).offset().left+($(this).width()-8)/2)
		.css("display", "block")
		.animate({opacity:"0.8"}, "fast");
	}, function(){
		//$(this).next("div.preinfo1").animate({opacity:"hide"}, "fast");
		$(this).animate({opacity:"0.7"}, "fast");
		//$(".ugol").css("display", "none");
	});
	
	// наведение на preinfo1
	$("div.preinfo1").hover(function(){
		$(this).css("display", "block");
		$(".ugol").animate({opacity:"0.7"}, "fast");
	}, function(){
		$(this).animate({opacity:"hide"}, "fast");
		$(".ugol").animate({opacity:"hide"}, "fast");
	});
	
	/*
	// сварачивание/разворачивание блоков при клике на заголовке
	$(".block h1").click(function(){
		if( $(this).attr("class") == 'open' ) $(this).attr("class", "close");
		else $(this).attr("class", "open");
		$(this).next("div").slideToggle("slow");
		return false;
	});
	*/
	
	$("div.list").hover(function(){
		$(this).css('background', '#f9f9f9');
	}, function(){
		$(this).css('background', 'none');
	});
	
	$("table.complist").hover(function(){
		$(this).css('background', '#f9f9f9');
	}, function(){
		$(this).css('background', 'none');
	});
	
	$("tr.over").hover(function(){
		$(this).css('background', '#f9f9f9');
	}, function(){
		$(this).css('background', 'none');
	});
	
	$("div.stars").hover(function(){
		var star_index = $("div.stars").index(this);
		
		$("div.star").hover(function(){
			var index = $("div.star").index(this);
			$("div.star").empty();
			for( a = (star_index*5); a <= index; a++ )
				$("div.star").eq(a).append('<img src="../images/design/star2.gif" />');
		}, function(){
			//$("div.star").empty();
		});
	}, function(){
		$("div.star").empty();
	});
	
});

function win(url,wname,w,h,r) {
   newWin = open(url,wname,"toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable="+r+",width="+w+",height="+h);
}


// ---------- анонс компании ----------
function show_firm_anons(id){
	$("#anons").remove();
	
	$('body').append('<div id="anons" title="Анонс компании"></div>');
	
	$("#anons").load('page.php?idpage='+id);
	
	$("#anons").dialog({
		width:500,
		height:400,
		bgiframe: true,
		modal: true,
		closeOnEscape: false,
		buttons: {
			'Закрыть': function() {
				$(this).dialog('close').remove();
			}
		}
	});
}


// ---------- КРУТИЛКА -----------
jQuery.fn.accessNews = function(settings) {
    settings = jQuery.extend({
        newsHeadline: "Top Stories",
        newsSpeed: "normal"
    }, settings);
    return this.each(function(i) {
        aNewsSlider.itemWidth = parseInt(jQuery(".item:eq(" + i + ")",".news_slider").css("width")) + parseInt(jQuery(".item:eq(" + i + ")",".news_slider").css("margin-right"));
        aNewsSlider.init(settings,this);
        jQuery(".view_all > a", this).click(function() {
            aNewsSlider.vAll(settings,this);
            return false;
        });
    });
};
var aNewsSlider = {
    itemWidth: 0,
    init: function(s,p) {
        jQuery(".messaging",p).css("display","none");
        itemLength = jQuery(".item",p).length;
        if (jQuery(".view_all",p).width() == null) {
            //jQuery(".news_items",p).prepend("<div class='attention' style='margin-top:20px;'>" + s.newsHeadline + " (" + itemLength + ")</div>");
        }
        newsContainerWidth = itemLength * aNewsSlider.itemWidth;
        jQuery(".container",p).css("width",newsContainerWidth + "px");
        jQuery(".next",p).css("display","block");
        animating = false;
        jQuery(".next",p).click(function() {
            if (animating == false) {
                animating = true;
                animateLeft = parseInt(jQuery(".container",p).css("left")) - (aNewsSlider.itemWidth * 3);
                if (animateLeft + parseInt(jQuery(".container",p).css("width")) > 0) {
                    jQuery(".prev",p).css("display","block");
                    jQuery(".container",p).animate({left: animateLeft}, s.newsSpeed, function() {
                        jQuery(this).css("left",animateLeft);
                        if (parseInt(jQuery(".container",p).css("left")) + parseInt(jQuery(".container",p).css("width")) <= aNewsSlider.itemWidth *3) {
                            jQuery(".next",p).css("display","none");
                        }
                        animating = false;
                    });
                } else {
                    animating = false;
                }
            }
            return false;
        });
        jQuery(".prev",p).click(function() {
            if (animating == false) {
                animating = true;
                animateLeft = parseInt(jQuery(".container",p).css("left")) + (aNewsSlider.itemWidth *3);
                if ((animateLeft + parseInt(jQuery(".container",p).css("width"))) <= parseInt(jQuery(".container",p).css("width"))) {
                    jQuery(".next",p).css("display","block");
                    jQuery(".container",p).animate({left: animateLeft}, s.newsSpeed, function() {
                        jQuery(this).css("left",animateLeft);
                        if (parseInt(jQuery(".container",p).css("left")) == 0) {
                            jQuery(".prev",p).css("display","none");
                        }
                        animating = false;
                    });
                } else {
                    animating = false;
                }
            }
            return false;
        });
    },
    vAll: function(s,p) {
        var o = p;
        while (p) {
            p = p.parentNode;
            if (jQuery(p).attr("class") != undefined && jQuery(p).attr("class").indexOf("news_slider") != -1) {
                break;
            }
        }
        if (jQuery(o).text().indexOf("Показать больше") != -1) {
            jQuery(".next",p).css("display","none");
            jQuery(".prev",p).css("display","none");
            jQuery(o).text("Показать меньше");
            jQuery(".container",p).css("left","0px").css("width",aNewsSlider.itemWidth *3 + "px");
        } else {
            jQuery(o).text("Показать больше");
            aNewsSlider.init(s,p);
        }
    }
};

/*
 * jQuery corner plugin
 *
 * version 1.7 (1/26/2007)
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */

/**
 * The corner() method provides a simple way of styling DOM elements.  
 *
 * corner() takes a single string argument:  $().corner("effect corners width")
 *
 *   effect:  The name of the effect to apply, such as round or bevel. 
 *            If you don't specify an effect, rounding is used.
 *
 *   corners: The corners can be one or more of top, bottom, tr, tl, br, or bl. 
 *            By default, all four corners are adorned. 
 *
 *   width:   The width specifies the width of the effect; in the case of rounded corners this 
 *            will be the radius of the width. 
 *            Specify this value using the px suffix such as 10px, and yes it must be pixels.
 *
 * For more details see: http://methvin.com/jquery/jq-corner.html
 * For a full demo see:  http://malsup.com/jquery/corner/
 *
 *
 * @example $('.adorn').corner();
 * @desc Create round, 10px corners 
 *
 * @example $('.adorn').corner("25px");
 * @desc Create round, 25px corners 
 *
 * @example $('.adorn').corner("notch bottom");
 * @desc Create notched, 10px corners on bottom only
 *
 * @example $('.adorn').corner("tr dog 25px");
 * @desc Create dogeared, 25px corner on the top-right corner only
 *
 * @example $('.adorn').corner("round 8px").parent().css('padding', '4px').corner("round 10px");
 * @desc Create a rounded border effect by styling both the element and its parent
 * 
 * @name corner
 * @type jQuery
 * @param String options Options which control the corner style
 * @cat Plugins/Corner
 * @return jQuery
 * @author Dave Methvin (dave.methvin@gmail.com)
 * @author Mike Alsup (malsup@gmail.com)
 */
jQuery.fn.corner = function(o) {
    function hex2(s) {
        var s = parseInt(s).toString(16);
        return ( s.length < 2 ) ? '0'+s : s;
    };
    function gpc(node) {
        for ( ; node && node.nodeName.toLowerCase() != 'html'; node = node.parentNode  ) {
            var v = jQuery.css(node,'backgroundColor');
            if ( v.indexOf('rgb') >= 0 ) { 
                rgb = v.match(/\d+/g); 
                return '#'+ hex2(rgb[0]) + hex2(rgb[1]) + hex2(rgb[2]);
            }
            if ( v && v != 'transparent' )
                return v;
        }
        return '#ffffff';
    };
    function getW(i) {
        switch(fx) {
        case 'round':  return Math.round(width*(1-Math.cos(Math.asin(i/width))));
        case 'cool':   return Math.round(width*(1+Math.cos(Math.asin(i/width))));
        case 'sharp':  return Math.round(width*(1-Math.cos(Math.acos(i/width))));
        case 'bite':   return Math.round(width*(Math.cos(Math.asin((width-i-1)/width))));
        case 'slide':  return Math.round(width*(Math.atan2(i,width/i)));
        case 'jut':    return Math.round(width*(Math.atan2(width,(width-i-1))));
        case 'curl':   return Math.round(width*(Math.atan(i)));
        case 'tear':   return Math.round(width*(Math.cos(i)));
        case 'wicked': return Math.round(width*(Math.tan(i)));
        case 'long':   return Math.round(width*(Math.sqrt(i)));
        case 'sculpt': return Math.round(width*(Math.log((width-i-1),width)));
        case 'dog':    return (i&1) ? (i+1) : width;
        case 'dog2':   return (i&2) ? (i+1) : width;
        case 'dog3':   return (i&3) ? (i+1) : width;
        case 'fray':   return (i%2)*width;
        case 'notch':  return width; 
        case 'bevel':  return i+1;
        }
    };
    o = (o||"").toLowerCase();
    var keep = /keep/.test(o);                       // keep borders?
    var cc = ((o.match(/cc:(#[0-9a-f]+)/)||[])[1]);  // corner color
    var sc = ((o.match(/sc:(#[0-9a-f]+)/)||[])[1]);  // strip color
    var width = parseInt((o.match(/(\d+)px/)||[])[1]) || 10; // corner width
    var re = /round|bevel|notch|bite|cool|sharp|slide|jut|curl|tear|fray|wicked|sculpt|long|dog3|dog2|dog/;

    var fx = ((o.match(re)||['round'])[0]);
    var edges = { T:0, B:1 };
    var opts = {
        TL:  /top|tl/.test(o),       TR:  /top|tr/.test(o),
        BL:  /bottom|bl/.test(o),    BR:  /bottom|br/.test(o)
    };
    if ( !opts.TL && !opts.TR && !opts.BL && !opts.BR )
        opts = { TL:1, TR:1, BL:1, BR:1 };
    var strip = document.createElement('div');
    strip.style.overflow = 'hidden';
    strip.style.height = '1px';
    strip.style.backgroundColor = sc || 'transparent';
    strip.style.borderStyle = 'solid';
    return this.each(function(index){
        var pad = {
            T: parseInt(jQuery.css(this,'paddingTop'))||0,     R: parseInt(jQuery.css(this,'paddingRight'))||0,
            B: parseInt(jQuery.css(this,'paddingBottom'))||0,  L: parseInt(jQuery.css(this,'paddingLeft'))||0
        };

        if (jQuery.browser.msie) this.style.zoom = 1; // force 'hasLayout' in IE
        if (!keep) this.style.border = 'none';
        strip.style.borderColor = cc || gpc(this.parentNode);
        var cssHeight = jQuery.curCSS(this, 'height');

        for (var j in edges) {
            var bot = edges[j];
            strip.style.borderStyle = 'none '+(opts[j+'R']?'solid':'none')+' none '+(opts[j+'L']?'solid':'none');
            var d = document.createElement('div');
            var ds = d.style;

            bot ? this.appendChild(d) : this.insertBefore(d, this.firstChild);

            if (bot && cssHeight != 'auto') {
                if (jQuery.css(this,'position') == 'static')
                    this.style.position = 'relative';
                ds.position = 'absolute';
                ds.bottom = ds.left = ds.padding = ds.margin = '0';
                if (jQuery.browser.msie)
                    ds.setExpression('width', 'this.parentNode.offsetWidth');
                else
                    ds.width = '100%';
            }
            else {
                ds.margin = !bot ? '-'+pad.T+'px -'+pad.R+'px '+(pad.T-width)+'px -'+pad.L+'px' : 
                                    (pad.B-width)+'px -'+pad.R+'px -'+pad.B+'px -'+pad.L+'px';                
            }

            for (var i=0; i < width; i++) {
                var w = Math.max(0,getW(i));
                var e = strip.cloneNode(false);
                e.style.borderWidth = '0 '+(opts[j+'R']?w:0)+'px 0 '+(opts[j+'L']?w:0)+'px';
                bot ? d.appendChild(e) : d.insertBefore(e, d.firstChild);
            }
        }
    });
};


/*
 * jQuery Tooltip plugin 1.2
 *
 * http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/
 * http://docs.jquery.com/Plugins/Tooltip
 *
 * Copyright (c) 2006 - 2008 Jorn Zaefferer
 *
 * $Id: jquery.tooltip.js 4569 2008-01-31 19:36:35Z joern.zaefferer $
 * 
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */
 
;(function($) {
	
		// the tooltip element
	var helper = {},
		// the current tooltipped element
		current,
		// the title of the current element, used for restoring
		title,
		// timeout id for delayed tooltips
		tID,
		// IE 5.5 or 6
		IE = $.browser.msie && /MSIE\s(5\.5|6\.)/.test(navigator.userAgent),
		// flag for mouse tracking
		track = false;
	
	$.tooltip = {
		blocked: false,
		defaults: {
			delay: 200,
			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", settings);
					// copy tooltip into its own expando and remove the title
					this.tooltipText = this.title;
					$(this).removeAttr("title");
					// also remove alt attribute to prevent default tooltip in IE
					this.alt = "";
				})
				.hover(save, 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) {
		// there can be only one tooltip helper
		if( helper.parent )
			return;
		// create the helper, h3 for title, div for url
		helper.parent = $('<div id="' + settings.id + '"><h3></h3><div class="body"></div><div class="url"></div></div>')
			// add to document
			.appendTo(document.body)
			// hide it at first
			.hide();
			
		// apply bgiframe if available
		if ( $.fn.bgiframe )
			helper.parent.bgiframe();
		
		// save references to title and url elements
		helper.title = $('h3', helper.parent);
		helper.body = $('div.body', helper.parent);
		helper.url = $('div.url', helper.parent);
	}
	
	function settings(element) {
		return $.data(element, "tooltip-settings");
	}
	
	// main event handler to start showing tooltips
	function handle(event) {
		// show helper, either with timeout or on instant
		if( settings(this).delay )
			tID = setTimeout(show, settings(this).delay);
		else
			show();
		
		// if selected, update the helper position when the mouse moves
		track = !!settings(this).track;
		$(document.body).bind('mousemove', update);
			
		// update at least once
		update(event);
	}
	
	// save elements title before the tooltip is displayed
	function save() {
		// if this is the current source, or it has no title (occurs with click event), stop
		if ( $.tooltip.blocked || this == current || (!this.tooltipText && !settings(this).bodyHandler) )
			return;

		// save current
		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 element has href or src, add and show it, otherwise hide it
		if( settings(this).showURL && $(this).url() )
			helper.url.html( $(this).url().replace('http://', '') ).show();
		else 
			helper.url.hide();
		
		// add an optional class for this tip
		helper.parent.addClass(settings(this).extraClass);

		// fix PNG background for IE
		if (settings(this).fixPNG )
			helper.parent.fixPNG();
			
		handle.apply(this, arguments);
	}
	
	// delete timeout and show helper
	function show() {
		tID = null;
		helper.parent.show();
		update();
	}
	
	/**
	 * callback for mousemove
	 * updates the helper position
	 * removes itself when no current element
	 */
	function update(event)	{
		if($.tooltip.blocked)
			return;
		
		// stop updating when tracking is disabled and the tooltip is visible
		if ( !track && helper.parent.is(":visible")) {
			$(document.body).unbind('mousemove', update)
		}
		
		// if no current element is available, remove this listener
		if( current == null ) {
			$(document.body).unbind('mousemove', update);
			return;	
		}
		
		// remove position helper classes
		helper.parent.removeClass("viewport-right").removeClass("viewport-bottom");
		
		var left = helper.parent[0].offsetLeft;
		var top = helper.parent[0].offsetTop;
		if(event) {
			// position the helper 15 pixel to bottom right, starting from mouse position
			left = event.pageX + settings(current).left;
			top = event.pageY + settings(current).top;
			helper.parent.css({
				left: left + 'px',
				top: top + 'px'
			});
		}
		
		var v = viewport(),
			h = helper.parent[0];
		// check horizontal position
		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");
		}
		// check vertical position
		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()
		};
	}
	
	// hide helper and restore added classes and the title
	function hide(event) {
		if($.tooltip.blocked)
			return;
		// clear timeout if possible
		if(tID)
			clearTimeout(tID);
		// no more current element
		current = null;
		
		helper.parent.hide().removeClass( settings(this).extraClass );
		
		if( settings(this).fixPNG )
			helper.parent.unfixPNG();
	}
	
	$.fn.Tooltip = $.fn.tooltip;
	
})(jQuery);



/**
 * --------------------------------------------------------------------
 * jQuery-Plugin "pngFix"
 * Version: 1.1, 11.09.2007
 * by Andreas Eberhard, andreas.eberhard@gmail.com
 *                      http://jquery.andreaseberhard.de/
 *
 * Copyright (c) 2007 Andreas Eberhard
 * Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php)
 */
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}('(s($){3.1s.1k=s(j){j=3.1a({12:\'1m.1j\'},j);8 k=(n.P=="r 10 Z"&&U(n.v)==4&&n.v.E("14 5.5")!=-1);8 l=(n.P=="r 10 Z"&&U(n.v)==4&&n.v.E("14 6.0")!=-1);o(3.17.16&&(k||l)){3(2).L("1r[@m$=.M]").z(s(){3(2).7(\'q\',3(2).q());3(2).7(\'p\',3(2).p());8 a=\'\';8 b=\'\';8 c=(3(2).7(\'K\'))?\'K="\'+3(2).7(\'K\')+\'" \':\'\';8 d=(3(2).7(\'A\'))?\'A="\'+3(2).7(\'A\')+\'" \':\'\';8 e=(3(2).7(\'C\'))?\'C="\'+3(2).7(\'C\')+\'" \':\'\';8 f=(3(2).7(\'B\'))?\'B="\'+3(2).7(\'B\')+\'" \':\'\';8 g=(3(2).7(\'R\'))?\'1d:\'+3(2).7(\'R\')+\';\':\'\';8 h=(3(2).1c().7(\'1b\'))?\'19:18;\':\'\';o(2.9.y){a+=\'y:\'+2.9.y+\';\';2.9.y=\'\'}o(2.9.t){a+=\'t:\'+2.9.t+\';\';2.9.t=\'\'}o(2.9.w){a+=\'w:\'+2.9.w+\';\';2.9.w=\'\'}8 i=(2.9.15);b+=\'<x \'+c+d+e+f;b+=\'9="13:11;1q-1p:1o-1n;O:W-V;N:1l;\'+g+h;b+=\'q:\'+3(2).q()+\'u;\'+\'p:\'+3(2).p()+\'u;\';b+=\'J:I:H.r.G\'+\'(m=\\\'\'+3(2).7(\'m\')+\'\\\', D=\\\'F\\\');\';b+=i+\'"></x>\';o(a!=\'\'){b=\'<x 9="13:11;O:W-V;\'+a+h+\'q:\'+3(2).q()+\'u;\'+\'p:\'+3(2).p()+\'u;\'+\'">\'+b+\'</x>\'}3(2).1i();3(2).1h(b)});3(2).L("*").z(s(){8 a=3(2).T(\'N-S\');o(a.E(".M")!=-1){8 b=a.X(\'1g("\')[1].X(\'")\')[0];3(2).T(\'N-S\',\'1f\');3(2).Q(0).Y.J="I:H.r.G(m=\'"+b+"\',D=\'F\')"}});3(2).L("1e[@m$=.M]").z(s(){8 a=3(2).7(\'m\');3(2).Q(0).Y.J=\'I:H.r.G\'+\'(m=\\\'\'+a+\'\\\', D=\\\'F\\\');\';3(2).7(\'m\',j.12)})}1t 3}})(3);',62,92,'||this|jQuery||||attr|var|style|||||||||||||src|navigator|if|height|width|Microsoft|function|padding|px|appVersion|margin|span|border|each|class|alt|title|sizingMethod|indexOf|scale|AlphaImageLoader|DXImageTransform|progid|filter|id|find|png|background|display|appName|get|align|image|css|parseInt|block|inline|split|runtimeStyle|Explorer|Internet|relative|blankgif|position|MSIE|cssText|msie|browser|hand|cursor|extend|href|parent|float|input|none|url|after|hide|gif|pngFix|transparent|blank|line|pre|space|white|img|fn|return'.split('|'),0,{}));





