
$(document).ready (function() {
	$('textarea.expanding').each(function(){ $(this).autogrow(); });
	var chatDiv = document.getElementById("chatscrollList");
	//if(chatDiv != null)
	//	setTimeout(function(){ fleXcrollTo("chatscroll","0px",(chatDiv.scrollHeight-195)+"px",false);},10);
	$('#gallery li a').lightBox();
	
	if ($.browser.msie && $.browser.version.substr(0,1)=="6") {
		var lofasz = 0;
		$("img").each(function(){
			var starPng = 'Images/Lists/VIP.png',
				thisSrc = $(this).attr("src"),
		    	thisSrcCropped = thisSrc.substring(thisSrc.length-starPng.length);
			if (thisSrcCropped==starPng) { $(this).replaceWith('<div class="vipstar"></div>'); } 
		});
	}

	/* kedvezmenykartya */
	if ($('div#kedvezmenykartya').length > 0) {
		$('div#kedvezmenykartya').click(function() {
			i = $(this).find('img').attr('src') || '';
			n = $(this).find('p').text() || '';
			kedvezmenykartya(i, n);
	 });
	}
	/* /kedvezmenykartya */
	
	/* bannercontainerek */
	
	$("div.bannercontainer").each(function() {
										  
		if ($(this).find("span#adverticum_bannercontainer").length>0 || $(this).find("#ad_flash").length>0 ||  $(this).find("iframe").length>0) { 
			if ($(this).hasClass("bc_billboard")) {
				$(this).closest("td").find("table td.latests_msgs").each(function(i){
					$(this).find("table tr:not(.SquaredGradientList)").each(function(j){
						if (j>0) { $(this).hide(); }
					});
				});
			}
		} else { 
	 	   $(this).hide();
		}
	});	

});



/* kedvezmenykartya */
var popup = null;
function kedvezmenykartya(i, n) {
	var w = 482;
	var h = 312;
	if ((popup) && (!popup.closed)) {
		popup.close();
	}
//	popup = window.open('','vu','directories=0,location=0,menubar=0,personalbar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0,width='+w+',height='+h+',left='+String(Math.floor((screen.width-w)/2))+',top='+String(Math.floor((screen.height-h)/2)-22));
	popup = window.open('','vu','directories=0,location=0,menubar=0,personalbar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0,width='+(w+2)+',height='+(h+2)+',left='+String(Math.floor((screen.width-w)/2))+',top='+String(Math.floor((screen.height-h)/2)-22));
	with (popup.document) {
		open('text/html');
		writeln('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">');
		writeln('<html xmlns="http://www.w3.org/1999/xhtml">');
		writeln('<head>');
		writeln('<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />');
		writeln('<title>Kedvezménykártya</title>');
		writeln('<style>');
		writeln('body {position: relative; width: '+(w+2)+'px; height: '+(h+2)+'px; margin: 0px; padding: 0px; overflow: hidden; background-color: #ffffff;}');
		writeln('div.kartya {position: absolute; display: block; left: 0px; top: 0px; width: '+w+'px; height: '+h+'px; overflow: hidden; margin: 0px; padding: 0px; border: solid 1px #000000;}');
		writeln('div.kartya img {position: relative; display: block; width: '+w+'px; height: '+h+'px; overflow: hidden; margin: 0px; padding: 0px;}');
		writeln('div.user {position: absolute; display: block; left: 260px; top: 50px; margin: 0px; padding: 0px;}');
		writeln('div.user img {position: absolute; display: block; left: 50px; top: 0px; width: 100px; height: 100px; overflow: hidden; margin: 0px; padding: 0px; border: solid 1px #000000;}');
		writeln('div.user p {position: absolute; display: block; left: 0px; top: 110px; width: 200px; height: auto; margin: 0px; padding: 0px; font-family: verdana, tahoma, arial, sans-serif; font-size: 17px; font-weight: bold; color: #8fbd16; line-height: 19px; text-align: center;}');
		writeln('div.print {position: absolute; display: block; right: 7px; top: 7px; margin: 0px; padding: 4px; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; font-weight: bold; color: #000000; background: #cccccc; border: solid 1px #666666; cursor: pointer; }');
		writeln('@media print {div.print {display: none;}}');
		writeln('</style>');
		writeln('</head>');
		writeln('<body>');
		writeln('<div class="kartya"><img src="/Images/kedvezmenykartya_print.jpg" /></div>');
		if ((i!='') && (n!='')) {
			writeln('<div class="user"><img src="'+i+'" /><p>'+n+'</p></div>');
			writeln('<div class="print" onclick="window.print();">Nyomtatás</div>');
		} else {
			writeln('<div class="user"><p>A kedvezményhez<br/>lépj be!</p></div>');
		}
		writeln('</body>');
		writeln('</html>');
		close();
	}
	popup.focus();
}
/* /kedvezmenykartya */




function fleXcrollTo(id,x,y,relative) {
 var scrollDiv = document.getElementById(id);
 if (scrollDiv == null) return;
 if(scrollDiv.contentScroll) { scrollDiv.contentScroll(x,y,relative); }
}		
		
			
			
/* 
 * Auto Expanding Text Area (1.2.2)
 * by Chrys Bader (www.chrysbader.com)
 * chrysb@gmail.com
 *
 */
 
(function(jQuery) {
		  
	var self = null;
 
	jQuery.fn.autogrow = function(o)
	{	
		return this.each(function() {
			new jQuery.autogrow(this, o);
		});
	};
	

    /**
     * The autogrow object.
     *
     * @constructor
     * @name jQuery.autogrow
     * @param Object e The textarea to create the autogrow for.
     * @param Hash o A set of key/value pairs to set as configuration properties.
     * @cat Plugins/autogrow
     */
	
	jQuery.autogrow = function (e, o)
	{
		this.options		  	= o || {};
		this.dummy			  	= null;
		this.interval	 	  	= null;
		this.line_height	  	= this.options.lineHeight || parseInt(jQuery(e).css('line-height'));
		this.min_height		  	= this.options.minHeight || parseInt(jQuery(e).css('min-height'));
		this.max_height		  	= this.options.maxHeight || parseInt(jQuery(e).css('max-height'));;
		this.textarea		  	= jQuery(e);
		
		if(this.line_height == NaN)
		  this.line_height = 0;
		
		// Only one textarea activated at a time, the one being used
		this.init();
	};
	
	jQuery.autogrow.fn = jQuery.autogrow.prototype = {
    autogrow: '1.2.2'
  };
	
 	jQuery.autogrow.fn.extend = jQuery.autogrow.extend = jQuery.extend;
	
	jQuery.autogrow.fn.extend({
						 
		init: function() {			
			var self = this;			
			this.textarea.css({overflow: 'hidden', display: 'block'});
			this.textarea.bind('focus', function() { self.startExpand() } ).bind('blur', function() { self.stopExpand() });
			this.checkExpand();	
		},
						 
		startExpand: function() {				
		  var self = this;
			this.interval = window.setInterval(function() {self.checkExpand()}, 400);
		},
		
		stopExpand: function() {
			clearInterval(this.interval);	
		},
		
		checkExpand: function() {
			
			var that = this;
			if (this.dummy == null)
			{
				this.dummy = jQuery('<div></div>');
				this.dummy.css({
												'font-size'  : this.textarea.css('font-size'),
												'font-family': this.textarea.css('font-family'),
												'width'      : this.textarea.css('width'),
												'padding'    : this.textarea.css('padding'),
												'line-height': this.line_height + 'px',
												'overflow-x' : 'hidden',
												'position'   : 'absolute',
												'top'        : 0,
												'left'		 : -9999
												}).appendTo('body');
			}
			
			// Strip HTML tags
			var html = this.textarea.val().replace(/(<|>)/g, '');
			
			// IE is different, as per usual
			if ($.browser.msie)
			{
				html = html.replace(/\n/g, '<BR>new');
			}
			else
			{
				html = html.replace(/\n/g, '<br>new');
			}
			
			if (this.dummy.html() != html)
			{
				this.dummy.html(html);	
				
				if (this.max_height > 0 && (this.dummy.height() + this.line_height > this.max_height))
				{
					this.textarea.css('overflow-y', 'auto');	
				}
				else
				{
					this.textarea.css('overflow-y', 'hidden');
					if (this.textarea.height() < this.dummy.height() + this.line_height || (this.dummy.height() < this.textarea.height()))
					{	
						this.textarea.animate({height: (this.dummy.height() + this.line_height) + 'px'}, 100);	
					}
				}
			}
		}
						 
	 });
})(jQuery);