window.jQ=jQuery.noConflict();

function removeDOMelement(id)
{
	var e=$(id);
	if (e) e.parentNode.removeChild(e);
}

String.prototype.split0=function(delimiter)
{
	var result=new Array();
	if (this.valueOf()=="") return result;
	else return this.split(delimiter);
}
var hotbar_scrolleventadded=0;
function hotbar_toggleevents(events)
{
	if(typeof($("fixedbrdiv"))!='undefined')
	{
		if ($("fixedbrdiv").style.display=="none")
		{
			
			$("fixedbrdiv").innerHTML='<ul class="styleul">'+events+'</ul>';

			$("fixedbrdiv").style.width="150px";
			$("fixedbrdiv").style.display="";

		}
		else
		{
			$("fixedbrdiv").style.display="none";
		}

		$("events").removeClassName("new");
	}
}
function hotbar_event_goto(i,h)
{
	var myAjax=new Ajax.Request(
		'headerbar.php?checkit=1&eventid='+i,
		{
			method: 'post',
			onComplete:function()
			{
				$("fixedbrdiv").style.display="none";
				Hotbar_events.unset(i);
				var sum=$('events').innerHTML*1;
				sum=sum-Hotbar_eventcounts.get(i);
				$('events').update(sum);
				if(sum==0)$('events').addClassName('inactive');
				window.location.href=h;
			}
		}
	);
}
function hotbar_save()
{
	var funcVal=$("functions").value;
	var nAjax = new Ajax.Updater(
		'headerbarfunctions',
		'hotbar.php',
		{
			method: 'post',
			evalScripts:true,
			parameters:'act=modsettings&functions='+funcVal,
			nomedian: 1,
			onComplete: function(req)
			{
				Myvippopup.close();
			}
		}
	);
}

function hotbar_updateorder()
{
	$("functions").value=Sortable.sequence("hotbar_functioncont").join(",");
}

function hotbar_togglefunction(id,checked)
{
	if (checked) $("hotbar_functioncont").innerHTML=$("hotbar_functioncont").innerHTML+"<span class='hoticon' id='hotbarfunc_"+id+"'></span>";
	else removeDOMelement("hotbarfunc_"+id);

	Sortable.create(
		"hotbar_functioncont",
		{
			scroll: false,
			tag: "span",
			containment: false,
			constraint: "horizontal",
			onUpdate: hotbar_updateorder,
			starteffect:function(element){
				element.addClassName('move');
			},
			endeffect:function(element){
				element.removeClassName('move');
			}
		}
	);

	hotbar_updateorder();
}
//	headerbar functions
String.prototype.charMatchCount = function(match) {
var res = this.match(new RegExp(match,"g"));
if (res==null) {return 0;}
return res.length;
}

function headerbar_hotbar_save()
{
	var listcount=$("baseheaderbarfunctionslist").value.charMatchCount(',');
	if ($("baseheaderbarfunctionslist").value!=$("headerbarfunctionslist").value || listcount<11){
		var myAjax=new Ajax.Request(
			"headerbar.php?setNewOrder=1",
			{
				method: "post",
				nomedian: 1,
				asynchronous: false,
				parameters:
				{
					"setNewOrderList": $("headerbarfunctionslist").value
				}
			}
		);
	}
}

function hotbar_init(params)
{
	$("functiontable").style.display="";

	try{
		var funcarr=$("functions").value.split0(",");
	}
	catch(e){
		var funcarr=params.split0(",");
	}

	for (var i=0;i<funcarr.length;i++)
	{
		var id=funcarr[i];
		$("cb_"+id).click();
	}

	$("functiontable").style.display="";
}

function setresolution(resolution)
{
	setdesignres("resolution="+resolution);
	$("globalresolution").value=resolution;
}

function setdesign(design)
{
	setdesignres("design="+design);
	$("globaldesign").value=design;
}
function buydesign(design)
{
	if (design=="fanta") {

		var myAjax=new Ajax.Request(
		'fanta_reg.php?act=checkdesign',
		{
			method: 'post',
			evalScripts: true,
			onComplete: function(req)
			{
				if(req.responseText.indexOf('#OK#')!==-1)
				{
					//$('ajax_popup_content').update("<div style='text-aling:center;padding:50px;'>Ellenőrzés folyamatban...");
					setdesign(design);
				}
				else
				{
					Myvippopup.open('/loadfile.php?f=dating_fanta_buydesign.htm','Fanta dizájn aktiválása',600,300);
				}
			}
		}
		);

	} else if(design=="coke"){

		var myAjax=new Ajax.Request(
		'coke_reg.php?act=checkdesign',
		{
			method: 'post',
			evalScripts: true,
			onComplete: function(req)
			{
				if(req.responseText.indexOf('#OK#')!==-1)
				{
					//$('ajax_popup_content').update("<div style='text-aling:center;padding:50px;'>Ellenőrzés folyamatban...");
					setdesign(design);
				}
				else
				{
					location.href="game_coke.php?cokedesignrequest=1"
				}
			}
		}
		);
	}
}
function dobuydesign(design)
{
	if (design=="fanta"){
	var myAjax=new Ajax.Request(
	'/fanta_reg.php?act=dobuydesign&fantacode='+$F('designfantacode'),
	{
		method: 'post',
		evalScripts: true,
		onComplete: function(req)
		{
			if(req.responseText.indexOf('#OK#')!==-1)
			{

				setdesign(design);
			}
			else
			{
				alert('Hibás, vagy már felhasznált Fanta kupakkód!');
			}
		}
	}
	);
	}
	else if (design=="coke"){
		var myAjax=new Ajax.Request(
		'/coke_reg.php?act=dobuydesign&cokecode='+$F('designcokecode'),
		{
			method: 'post',
			evalScripts: true,
			onComplete: function(req)
			{
				if(req.responseText.indexOf('#OK#')!==-1) setdesign(design);
			}
		}
		);
	}
}
function setdesignres(url)
{
	var myAjax=new Ajax.Request(
		"design.php?"+url,
		{
			onComplete: function(req)
			{
				window.location.reload();
				if (parent.bannerframe && logged_nobanner==0) parent.bannerframe.location.href="bottombanner.php?d="+$F("globaldesign")+"&r="+$F("globalresolution");
			}
		}
	);
}

function RefreshGemius()
{
	gemius_hit(pp_gemius_identifier.replace('USED_',''));
}

function reload_median()
{
	if(typeof ($("median")) == undefined) return;
	if(typeof sameext!='undefined' && String(sameext).length>0){	//	old one
		RefreshGemius();
		var same=Math.floor(Math.random()*1000000);
		same=same+sameext;
	}
	else{															// new one
		RefreshGemius();
		var rand =  Math.floor(Math.random()*100000000);
		var same = median_webaudit();
		same = rand + same;
	//	var same = Math.floor(Math.random()*100000000) + median_webaudit();
	}

	if(1){		//	ha kell UserAgent
		var ua = "";
		if(navigator.userAgent) ua="@ua=" + escape(navigator.userAgent);
		same = same + ua;
	}
	$("median").innerHTML='<img src="http://audit.median.hu/cgi-bin/track.cgi?uc='+mediancode+'&dc=1&mid=322'+medianuser+'&ui='+same+'" width="1" height="1">';
}


var helpdownloaded=false;
var helpvisible=false;

function downloadhelp(page)
{
	if (!helpdownloaded)
	{
		var myAjax=new Ajax.Request(
			"gethelp.php?page="+page,
			{
				method: "GET",
				onSuccess: function(req)
				{
					$("help_txt").innerHTML=req.responseText;
					helpdownloaded=true;
				}
			}
		);
	}

	if (!helpvisible)
	{
		$("help_txt").style.display="";
		helpvisible=true;
	}
	else
	{
		$("help_txt").style.display="none";
		helpvisible=false;
	}
}

function getFlashMovieObject(movieName)
{
	if(window.document[movieName])
	{
		return window.document[movieName];
	}
	if(navigator.appName.indexOf("Microsoft Internet")==-1)
	{
		if(document.embeds && document.embeds[movieName])
		{
			return document.embeds[movieName];
		}
	}
	else
	{
		return document.getElementById(movieName);
	}
}

function thisMovie(movieName)
{
    if(navigator.appName.indexOf("Microsoft") != -1)
    {
    	if(typeof window[movieName]!='undefined')
    	{
    		return window[movieName];
		}
    	else
    	{
    		return $(movieName);
    	}
    }
    else
    {
        return document[movieName];
    }
}

function imgviewer_DoFSCommand(command,args)
{
	if (command=="close")
	{
		avatarclose();
	}
}

function getPageScroll()
{
	var yScroll;

	if (self.pageYOffset) yScroll=self.pageYOffset;
	else if (document.documentElement && document.documentElement.scrollTop) yScroll=document.documentElement.scrollTop;
	else if (document.body) yScroll=document.body.scrollTop;

	arrayPageScroll=new Array('',yScroll)
	return arrayPageScroll;
}

function getPageSize(){

	var xScroll, yScroll;

	if (document.body.scrollHeight > document.body.offsetHeight)
	{
		xScroll=document.body.scrollWidth;
		yScroll=document.body.scrollHeight;
	}
	else
	{
		xScroll=document.body.offsetWidth;
		yScroll=document.body.offsetHeight;
	}

	var windowWidth, windowHeight;

	if (self.innerHeight)
	{
		windowWidth=self.innerWidth;
		windowHeight=self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{
		windowWidth=document.documentElement.clientWidth;
		windowHeight=document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		windowWidth=document.body.clientWidth;
		windowHeight=document.body.clientHeight;
	}

	if (yScroll < windowHeight) pageHeight=windowHeight;
	else pageHeight=yScroll;

	if (xScroll < windowWidth) pageWidth=windowWidth;
	else pageWidth=xScroll;

	arrayPageSize=new Array(pageWidth,pageHeight,windowWidth,windowHeight)

	return arrayPageSize;
}

function resizeAvatarWin()
{
	var avatar_bg = $("avataroverlay");
	var avatarbox = $("avatarbox");
	var avframe = $("avatariframe");

	var window_size = document.viewport.getDimensions();
// 	var winWidth = window_size.width;
	var winHeight = window_size.height;
	var windowWidth = document.body.getWidth();
	var windowHeight = document.body.getHeight();

	if(windowHeight < winHeight)
	{
	    windowHeight = winHeight;
	}
	var vpo = document.viewport.getScrollOffsets().top;

	avatarbox.style.top = Math.round(vpo+((winHeight-35-410)/2))+"px";
	avatarbox.style.left = Math.round((windowWidth-40-410)/2)+"px";
	avatarbox.style.zIndex=101;

	if(avframe)//in explorer 6
	{
		avframe.style.width = windowWidth+"px";
		avframe.style.height = windowHeight+"px";
	}

	avatar_bg.style.height = windowHeight+"px";
	avatar_bg.style.width = windowWidth+"px";
	avatar_bg.style.zIndex = 100;
}

function avatarwin(thumburl,imgurl)
{
	Event.observe(window, "resize", resizeAvatarWin,false);
	var availflash = (new Flashdetect().enabled());
	resizeAvatarWin();
	var avframe = $("avatariframe");
	if(avframe){avframe.style.display = "";}

	var flash_pic = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="400" height="400" id="imgviewer" align="middle">\n'+
	'<param name="allowScriptAccess" value="sameDomain" />\n'+
	'<param name="movie" value="/imgviewer3.swf"/>'+
	'<param name="quality" value="high" />'+
	'<param name="FlashVars" value="ver=070115a&thumburl='+escape(thumburl)+'&imgurl='+escape(imgurl)+'"/>'+
	'<param name="bgcolor" value="#000000" />'+
	'<embed src="/imgviewer3.swf?ver=070115a&thumburl='+escape(thumburl)+'&imgurl='+escape(imgurl)+'" quality="high" bgcolor="#000000" width="400" height="400" name="imgviewer" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n'+
	'</object>\n';

	var img_pic = '<img src="'+imgurl+'" onclick="avatarclose();">';

	$("avatarbox").update((availflash)?flash_pic:img_pic);

	$("avataroverlay").style.display="";
	//reload_median();
}

function avatarclose()
{
	var avframe = $("avatariframe");
	if(avframe){avframe.style.display = "none";}
	$("avataroverlay").style.display = "none";
	$("avatarbox").update("");
	Event.stopObserving(window,'resize', resizeAvatarWin);
}

function ablak(page,w,h)
{
    OpenWin = this.open(page, "CtrlWindow", "width="+w+",height="+h+",toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no");
}

function ablak_scroll(page,w,h)
{
    OpenWin = this.open(page, "CtrlWindow", "width="+w+",height="+h+",toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes");
}

function openWindow(page, width, height)
{
	var openWin = window.open(page, 'CtrlWindow', 'location=0,resizable=0,status=0,titlebar=0,toolbar=0,directories=0,menubar=0,scrollbars=0,width='+width+',height='+height);
	openWin.focus();
}

function windowOpen(parameters) {
    options = jQ.extend({
		width		: 400,
		height		: 400,
		name		: 'CtrlWindow',
		fullscreen	: 0,
		location	: 0,
		resizable	: 0,
		status		: 0,
		titlebar	: 0,
		directories	: 0,
		menubar		: 0,
		scrollbars	: 0,
		toolbar		: 0
	}, parameters || {});
	url = options.url || '';
	name = options.name || 'CtrlWindow';
	replace = options.replace !== undefined ? options.replace : null;
	delete options.url;
	delete options.name;
	delete options.replace;
	opts = [];
	jQ.each(options, function(p,v) {
		opts.push(p+'='+v);
	});
	if(replace == null) return window.open(url, name, opts.join(','));
	else return window.open(url, name, opts.join(','), replace);
}

function openAudioPlayerWindow(userid, albumid, opts) {
	var params;
	params = jQ.extend({
		url			: '/audios.php?uid='+(userid == undefined ? 0 : userid)+(albumid !== undefined ? '&albumid='+albumid : ''),
		width		: 335,
		height		: jQ.browser.webkit ? 415 : 390,
		name		: '_blank'
	}, opts || {});
	var audioWin = windowOpen(params);
	audioWin.focus();
}

function openClubAudioPlayerWindow(clubid, albumid, opts) {
	var params;
	params = jQ.extend({
		url			: '/clubaudios.php?clubid='+(clubid == undefined ? 0 : clubid)+(albumid !== undefined ? '&albumid='+albumid : ''),
		width		: 335,
		height		: jQ.browser.webkit ? 415 : 390,
		name		: '_blank'
	}, opts || {});
	var audioWin = windowOpen(params);
	audioWin.focus();
}

var QuickPopup = {
	openSettings : function(act, query) {
		popupWindow.open({
			box		: {
				'title'	: 'beállítások',
				symbol	: 'options'
			},
			height	: 560,
			width	: 980,
			ajax	: {
				'url'	: '/settings.php'+(act!==undefined ? '?act='+act : '')+(query!==undefined ? '&'+query : '')
			},
			closed	: function() {
				jQuery('.site-menu .menu-item-settings').removeClass('menu-item-settings-active')
			}
		});
	},
	openAudioPlayerWindow: function(userid, albumid) {
		window.openAudioPlayerWindow(userid, albumid);
	},
	openClubAudioPlayerWindow: function(clubid, albumid) {
		window.openClubAudioPlayerWindow(clubid, albumid);
	},
	contact: function(type, uid) {
		var titles = {
			'add'		: 'Ismerősnek jelölés',
			'sub'		: 'Jelölés visszavonása',
			'accept'	: 'Jelölés elfogadása',
			'deny'		: 'Jelölés visszautasítása',
			'del'		: 'Kapcsolat törlése'
		};
		uid*=1;

		if(titles[type] !== undefined && uid>0) {
			popupWindow.open({box:{'title':titles[type]},width:385,ajax:{'url':'/contact.php',data:'isajax=1&act='+type+'&uid='+uid}});
		}
	}
}

Myvip={

	Version: '2.0.0',

	is_array: function(param)
	{
		return(param instanceof Array);
	},

	isset: function()
	{
		var a=arguments;
		var l=a.length;
		var i=0;
		while(i!=l)
		{
			if(typeof(a[i])=='undefined')
			{
				return false;
			}
			else
			{
				i++;
			}
		}
		return true;
	},

	getCookie: function(name)
	{
		var dc = document.cookie;
		var prefix = name + "=";
		var begin = dc.indexOf("; " + prefix);
		if (begin == -1)
		{
			begin = dc.indexOf(prefix);
			if (begin != 0) return null;
		}
		else
		{
			begin += 2;
		}
		var end = document.cookie.indexOf(";", begin);
		if (end == -1)
		{
			end = dc.length;
		}
		return unescape(dc.substring(begin + prefix.length, end));
	},

	setCookie: function(name, value, expire, path, domain, secure, expireinhour)
	{
		var extraParams = "";
		var exdate = new Date();
		if(expire)
		{
			if(expireinhour)
			{
				exdate.setTime(exdate.getTime()+(3600000*expire));
			}
			else
			{
				exdate.setDate(exdate.getDate()+expire);
			}
		}
		else
		{
			exdate.setDate(exdate.getDate()+1);
		}
		extraParams = "; expires=" + exdate.toGMTString() +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
		document.cookie = name + "=" + escape(value) + extraParams;
	},

	gotourl: function(url)
	{
		location.href = url;
	},

	isImageComplete: function(img)
	{
		if(!img.complete)
		{
			return false;
		}
		if(typeof(img.naturalWidth) != "undefined" && img.naturalWidth == 0)
		{
			return false;
		}
		return true;
	}
};
/* end Myvip class */

//simulate firebug log in explorer
/*if(!window.console)
{
	var console = {
		log:function(param)
		{
			window.status = param;
		}
	}
}*/

/* start flash detect functions */

function Flashdetect()
{
	this.ver= [-1,0,0];
}

Flashdetect.prototype.getversion = function()
{
	this.ver= [-1,0,0];
	if(navigator.plugins && navigator.mimeTypes.length)
	{
		var x=navigator.plugins["Shockwave Flash"];
		if(x && x.description)
		{
			this.ver = (x.description.replace(/([a-z]|[A-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));
		}
	}
	else
	{
		try
		{
			var axObj = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			for(var i=3;axObj!=null;i++)
			{
				axObj = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);
				this.ver = [i,0,0];
			}
		}
		catch(e){}
	}
	if(axObj)axObj = null;
}

Flashdetect.prototype.version= function()
{
	if(this.ver[0] == -1)
	{
	    this.getversion();
	}
	return (this.ver[0]*1);
}

Flashdetect.prototype.enabled= function()
{
	var must_ver = 1;
	if(arguments.length==1)must_ver = arguments[0];
	if(this.ver[0] == -1)
	{
	    this.getversion();
	}
	return (this.ver[0]*1>=must_ver);
}
/* end flash detect functions */










/* start pub changer class */
//var PubChanger = Class.create();
//PubChanger.prototype =
//{
// 	initialize : function()
// 	{
// 	    this.autoload = true;
// 	    this.preclass = "vis";
// 	    this.apost = "pub_a";
// 	    this.inppost = "pubinp";
// 	    this.txt_puball = "mindenki";
// 	    this.txt_pubcontacts = "ismerősök";
// 	    this.txt_pubnobody = "senki";
// 	    this.txt_yes = "igen";
// 	    this.txt_no = "nem";
//
// 	    this.class_all = " visa_all";
// 	    this.class_nobody = " visa_nobody";
//        this.class_contacts = " visa_contacts";
//        this.class_yes = " visa_yes";
//        this.class_no = " visa_no";
//		this.types = new Array("view","read","write");
//		this.types_bi = new Array();
//		this.setdefiffgv = false;
//		Object.extend(this,arguments[0] || { });
//		if(this.autoload)Event.observe(window, "load", this.setdefault.bind(this),false);
//		Event.observe(window, "unload", this.destroy.bind(this),false);
//	 },
//
//	 setdefault: function()
//	 {
//	    var mustiffgv = (Object.isFunction(this.setdefiffgv));
//		for(var i=0;i<this.types.length;i++)
//		{
//		    if(mustiffgv)
//			{
//				if(!this.setdefiffgv(this.types[i]))continue;
//			}
//			var val = $F(this.types[i] + this.inppost);
//			var isbi = this.check_bi_types(this.types[i]);
//			this.setstate(this.types[i],val,isbi);
//		}
//	 },
//
//	 check_bi_types: function(elem)
//	 {
//	 	if(this.types_bi.length>0)
//	 	{
//	 		for(var i=0;i<this.types_bi.length;i++)
//	 		{
//	 			if(elem==this.types_bi[i])return true;
//			}
//			return false;
//		}
//		else return false;
//
//	 },
//
//	 setstate: function(elem,val,bi)
//	 {
//		var aobj = $(elem + this.apost);
//		var inpobj = $(elem + this.inppost);
//		var newval = val*=1;
//		inpobj.value = val;
//		if(bi)newval+=3;
//		switch(newval)
//		{
//		    default:
//		    case 1:{
//			aobj.className = this.preclass + this.class_contacts;
//			aobj.update(this.txt_pubcontacts);
//			}break;
//
//			case 0:{
//			aobj.className = this.preclass + this.class_nobody;
//			aobj.update(this.txt_pubnobody);
//			}break;
//
//			case 2:{
//			aobj.className = this.preclass + this.class_all;
//			aobj.update(this.txt_puball);
//			}break;
//
//			case 3:{
//			aobj.className = this.preclass + this.class_no;
//			aobj.update(this.txt_no);
//			}break;
//
//			case 4:{
//			aobj.className = this.preclass + this.class_yes;
//			aobj.update(this.txt_yes);
//			}break;
//		}
//		this.clauses(elem,val,bi);
//	 },
//
//	 change: function(type)
//	 {
//		var val = $F(type + this.inppost);
//		var isbi = this.check_bi_types(type);
//		if(!isbi)
//		{
//			val = (val<1)?2:--val;
//		}
//		else
//		{
//			val = (val<1)?1:--val;
//		}
//		this.setstate(type,val,isbi);
//	},
//
//	clauses: function()
//	{
//	},
//
//	destroy: function()
//	{
//		for(i in this)this[i]=null;
//	}
//}
/* end pub changer class */








/* start usercard class */
//
//var Usercard = Class.create();
//Usercard.prototype =
//{
//	initialize:function()
//	{
//		Event.observe(window,'load',this.init.bind(this));
//	},
//
//	init : function()
// 	{
// 		this.cardselector = /jscard_\d+/;
// 		this.enablemouseout = true;
//		this.create_card();
//		this.setevents();
//		this.hide_timer = null;
//	},
//
//	setevents: function()
//	{
//	    var arr = new Array();
//		var elems = $("base_content").getElementsByTagName("a");
//		for(var i=0;i<elems.length;i++)
//		{
//			if(elems[i].id && this.cardselector.test(elems[i].id))
//			{
//				Event.observe(elems[i],'mouseover',this.showCard.bindAsEventListener(this,elems[i]));
//				Event.observe(elems[i],'mouseout',this.setHideTimer.bindAsEventListener(this));
//			}
//		}
//	},
//
//	create_card: function()
//	{
//		var cont = document.body;
//		var divelement = document.createElement('DIV');
//	 	divelement.id = "mastercard";
//	 	divelement.className = "jscard";
//		divelement.style["position"]="absolute";
//	 	divelement.style["top"]="-200px";
//		divelement.style["left"]="-300px";
//		cont.appendChild(divelement);
//
//		var a_elem = document.createElement('A');
//		a_elem.id="mastercard_a";
//		a_elem.className = "avatar";
//		divelement.appendChild(a_elem);
//
//		var rightdiv = document.createElement('DIV');
//		divelement.appendChild(rightdiv);
//
//		var p_elem = document.createElement('P');
//		p_elem.className='pname';
//		p_elem.id="mastercard_p";
//		rightdiv.appendChild(p_elem);
//
//		var p1_elem = document.createElement('P');
//		p1_elem.id="mastercard_p1";
//		p1_elem.className='home';
//		rightdiv.appendChild(p1_elem);
//
//		var p2_elem = document.createElement('P');
//		p2_elem.id="mastercard_p2";
//		p2_elem.className = 'icons';
//		rightdiv.appendChild(p2_elem);
//
//	},
//
//	showCard: function(event,elem)
//	{
//	    this.clearHideTimer();
//		var u_avatar = "";
//		var u_home = "";
//		var u_status = 1;
//		var u_uid = 0;
//		if(elem.getAttribute("rel"))
//		{
//			var s = elem.getAttribute("rel");
//			eval(s);
//			if(typeof udata!="undefined")
//			{
//				u_avatar = udata.avatar;
//				u_home = udata.home;
//				u_status = udata.status;
//				u_uid = udata.uid;
//
//			    var container = $("wrapper");
//			    var divelement = $("mastercard");
//			    container_width = container.getWidth();
//			    container_left = container.cumulativeOffset().left;
//			    elem_left = elem.cumulativeOffset().left;
//			    elem_width = elem.getWidth();
//				//on the right
//				if(Math.round(container_width/2)>(elem_left-container_left))
//				{
//					divelement.style["left"] = (elem_left+elem_width+10)+"px";
//				}
//				//on the left
//				else
//				{
//					divelement.style["left"] = (elem_left-210)+"px";
//				}
//				divelement.style["top"] = elem.cumulativeOffset().top+"px";
//				var id = (elem.id.replace(/[^0-9]/g,'')*1);
//				divelement.style['z-index']='1000';
//				$("mastercard_a").update('<img src="'+u_avatar+'"></a>');
//
//				var tmp_a_elem = document.createElement('A');
//				tmp_a_elem.href = elem.href;
//				$("mastercard_a").href = elem.href;
//				tmp_a_elem.innerHTML = elem.innerHTML;
//		        var p_elem = $("mastercard_p");
//		        p_elem.update(tmp_a_elem);
//
//				u_status*=1;
//
//				var p1_elem = $("mastercard_p1");
//				p1_elem.update(u_home);
//
//				var p2_elem = $("mastercard_p2");
//				p2_elem.update('');
//
//					switch (u_status)
//					{
//						case -1:
//						{
//							divelement.className='jscard jscard_unknown';
//						}break;
//						case 0://unknown
//						{
//							divelement.className='jscard jscard_unknown';
//							this.createicon(p2_elem,'icon_mark','javascript:do_contact("add",'+u_uid+');');
//							this.createicon(p2_elem,'icon_contacts','search.php?act=dousercontacts&uid='+u_uid);
//							this.createicon(p2_elem,'icon_message','messages.php?act=write&uid='+u_uid);
//							this.createicon(p2_elem,'icon_clubinvite','javascript:do_clubcontact("invite",'+u_uid+');');
//						}break;
//
//						case 1://contact
//						{
//							divelement.className='jscard jscard_contact';
//							this.createicon(p2_elem,'icon_contacts','search.php?act=dousercontacts&uid='+u_uid);
//							this.createicon(p2_elem,'icon_message','messages.php?act=write&uid='+u_uid);
//							this.createicon(p2_elem,'icon_clubinvite','javascript:do_clubcontact("invite",'+u_uid+');');
//							this.createicon(p2_elem,'icon_delete','javascript:do_contact("del",'+u_uid+');');
//						}break;
//
//						case 2://pend1
//						{
//							divelement.className='jscard jscard_signed';
//							this.createicon(p2_elem,'icon_revoke','javascript:do_contact("sub",'+u_uid+');');
//							this.createicon(p2_elem,'icon_contacts','search.php?act=dousercontacts&uid='+u_uid);
//							this.createicon(p2_elem,'icon_message','messages.php?act=write&uid='+u_uid);
//							this.createicon(p2_elem,'icon_clubinvite','javascript:do_clubcontact("invite",'+u_uid+');');
//						}break;
//
//						case 3://pend2
//						{
//							divelement.className='jscard jscard_signedby';
//							this.createicon(p2_elem,'icon_accept','javascript:do_contact("accept",'+u_uid+');');
//							this.createicon(p2_elem,'icon_deny','javascript:do_contact("deny",'+u_uid+');');
//							this.createicon(p2_elem,'icon_contacts','search.php?act=dousercontacts&uid='+u_uid);
//							this.createicon(p2_elem,'icon_message','messages.php?act=write&uid='+u_uid);
//							this.createicon(p2_elem,'icon_clubinvite','javascript:do_clubcontact("invite",'+u_uid+');');
//						}break;
//
//						case 4://self
//						{
//							divelement.className='jscard jscard_self';
//						}break;
//					}
//
//					Event.observe(divelement,'mouseout',this.mouse_out.bindAsEventListener(this,divelement));
//					Event.observe(divelement,'mouseover',this.clearHideTimer.bindAsEventListener(this));
//			}
//		}
//	},
//
//    setHideTimer:function()
//    {
//        if(this.hide_timer==null) this.hide_timer = setTimeout(this.hideCard.bind(this),1000);
//	},
//
//	clearHideTimer:function()
//	{
//		if(this.hide_timer!=null)
//		{
//			clearTimeout(this.hide_timer);
//			this.hide_timer = null;
//		}
//	},
//
//	mouse_out: function(e,divelement)
//	{
//		var c=e.relatedTarget || ((e.type=="mouseover")? e.fromElement : e.toElement)
//		while (c && c!=divelement)try {c=c.parentNode} catch(e){c=divelement}
//		if(c!=divelement)
//		{
//			this.setHideTimer();
//		}
//	},
//
//	hideCard: function()
//	{
//		var divelement = $("mastercard");
//		divelement.style['top']='-200px';
//		divelement.style['left']='-300px';
//		divelement.style['z-index']='-100';
//	},
//
//	createicon: function(_target,_class,_href)
//	{
//		var _title = "";
//		switch(_class)
//		{
//			case 'icon_accept':    {_title="ismerem"}break;
//			case 'icon_deny':      {_title="nem ismerem"}break;
//			case 'icon_contacts':  {_title="ismerősei"}break;
//			case 'icon_message':   {_title="üzenet"}break;
//			case 'icon_clubinvite':{_title="meghívás klubba"}break;
//			case 'icon_delete':    {_title="törlés"}break;
//			case 'icon_revoke':    {_title="jelölést visszavon"}break;
//
//		}
//		var icon = document.createElement('A');
//		_target.appendChild(icon);
//		if(_title!="")icon.title = _title;
//		icon.className = _class;
//		icon.setAttribute('href',_href);
//	}
//}
/* end usercard class */






function debug_info(info)
{
	if($('debug_info'))
	{
	    var _top = document.viewport.getScrollOffsets().top;
	    $('debug_info').style['top']=_top+'px';
		$('debug_info').innerHTML = 'Debug info:<br>'+info;
	}
	else
	{
		var debug_info = document.createElement('DIV');
 		var _top = document.viewport.getScrollOffsets().top;
		debug_info.style['position']='absolute';
		debug_info.style['top']=_top+'px';
 		debug_info.style['z-index']='100';
 		debug_info.style['left']='10px';
 		debug_info.style['color']='red';
 		debug_info.style.cssText+='border:1px dotted red;';
 		debug_info.style.background='#ffffff';
 		debug_info.style['width']='150px';
		debug_info.id='debug_info';
		document.body.insertBefore(debug_info,document.body.firstChild);
		debug_info.innerHTML = 'Debug info:<br>'+info;
	}
}



var offsetfromcursorX = 12; //Customize x offset of tooltip
var offsetfromcursorY = 10; //Customize y offset of tooltip

var offsetdivfrompointerX = 10; //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY = 14; //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

document.write('<div id="dhtmltooltip"></div>'); //write out tooltip DIV
document.write('<img id="dhtmlpointer" src="http://static.myvip.com/static/hint_arrow.gif">'); //write out pointer image

var ie = Prototype.Browser.IE;
var ns6 = Prototype.Browser.Gecko;
var enabletip = false;
var tipobj = $("dhtmltooltip");
var pointerobj = $("dhtmlpointer");
pointerobj.style.display = "none";

function ietruebody()
{
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function ddrivetip(thetext, thewidth, thecolor)
{
	if((ns6||ie) && (thetext!=""))
	{
		tipobj.style.width=(typeof thewidth!="undefined")?thewidth+"px":"auto";
		if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor;
		tipobj.innerHTML=thetext;
		enabletip=true;
		pointerobj.style.display="";
		return false;
	}
}

function index_ddrivetip()
{
	var thetext = bubble_text;
	var thewidth = 300;
	if((ns6||ie) && (thetext!=""))
	{
		tipobj.style.width=(typeof thewidth!="undefined")?thewidth+"px":"auto";
		if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor;
		tipobj.innerHTML=thetext;
		enabletip=true;
		pointerobj.style.display="";
		return false;
	}
}

function positiontip(e)
{
	if(enabletip)
	{
		var nondefaultpos = false;
		var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
		var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
		//Find out how close the mouse is to the corner of the window
		var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20;
		var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20;

		var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX;
		var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY;

		var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000;

		//if the horizontal distance isn't enough to accomodate the width of the context menu
		if (rightedge<tipobj.offsetWidth)
		{
			//move the horizontal position of the menu to the left by it's width
			tipobj.style.left=curX-tipobj.offsetWidth+"px";
			nondefaultpos=true;
		}
		else if (curX<leftedge)
		{
			tipobj.style.left = "5px";
		}
		else
		{
			//position the horizontal position of the menu where the mouse is positioned
			tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px";
			pointerobj.style.left=curX+offsetfromcursorX+"px";
		}

		//same concept with the vertical position
		if (bottomedge<tipobj.offsetHeight)
		{
			tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px";
			nondefaultpos=true;
		}
		else
		{
			tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px";
			pointerobj.style.top=curY+offsetfromcursorY+"px";
		}

		tipobj.style.visibility="visible";
		if(!nondefaultpos)
			pointerobj.style.visibility = "visible";
		else
			pointerobj.style.visibility = "hidden";
	}
}

function hideddrivetip()
{
	if(ns6||ie)
	{
		enabletip=false;
		tipobj.style.visibility="hidden";
		pointerobj.style.visibility="hidden";
		tipobj.style.left="-1000px";
		tipobj.style.backgroundColor='';
		tipobj.style.width='';
		tipobj.innerHTML = '';
	}
}




/* start message handler */
var show_message = {

	upobj: "message_cont_up",
	downobj: "message_cont_down",
	TYPE_ERR:"err",
	TYPE_INFO:"info",
	run_effect:null,
	default_height:60,
	btn_postfix:"btn",
	txt_postfix:"txt",
	class_error:"js_error",
	class_info:"js_info",
	parentname:"parent",
	okbtnvalue:" OK ",
	_back:0,
	backlinktxt:"Vissza az előző oldalra.",

	show:function(mestxt,_type,modal,delay,init,back)
	{
		var targ;
		if(init)
		{
			targ=this.upobj;
			Event.observe(window, "load", this.show.bind(this,mestxt,_type,modal,delay,0,back),false);
			return;
		}
		else
		{
			targ = this.target_selector();
		}
		this._back = back;
		this.hide_all();

		if(targ)
		{
			this.show_prepare(targ,mestxt,_type,modal,delay);
		}
		else
		{
			mestxt = mestxt.replace("<br>","\n");
			mestxt = mestxt.replace("<br />","\n");
			alert(mestxt);
		}
	},

	show_prepare:function(targ,mestxt,_type,modal,delay)
	{
		var txtpostfix = this.txt_postfix;
		_target = $(targ);
		if(_type==this.TYPE_ERR)
		{
		    _target.className = this.class_error;
		}
		else if(_type==this.TYPE_INFO)
		{
			_target.className = this.class_info;
		}
		if(modal)
		{
		    if(this._back)
		    {
		    	this.create_backlink(targ);
			}
			else
			{
				this.create_okbutton(targ);
			}
			this.run_effect = Effect.BlindDown(_target,{beforeStart:function(){$(targ+txtpostfix).update(mestxt)}});
		}
		else
		{
			this.run_effect = Effect.BlindDown(_target,{beforeStart:function(){$(targ+txtpostfix).update(mestxt)}});
			this.run_effect = Effect.BlindUp(_target,{delay: 4.5,afterSetup:function(){$(targ+txtpostfix).update('')}});
		}
	},


	clear_effects:function()
	{
		if(this.run_effect)
		{
			this.run_effect.cancel();
		}
	},

	restore_def_height:function()
	{
		var defh = this.default_height+"px";
	    this.getallobj().each(function(elem){
	    elem = $(elem);
	 		elem.style["height"] = defh;
		});
	},

	hide_all:function()
	{
		var btnpostfix = this.btn_postfix;
		this.clear_effects();
		//this.restore_def_height(); //Ez nem tudom miert van itt. Zsiri
	    this.getallobj().each(function(elem){
		btn_elem = $(elem+btnpostfix);
		elem = $(elem);
	    elem.hide();
	    btn_elem.update('');
		});
	},

	getallobj:function()
	{
		return [this.upobj,this.downobj];
	},

	create_okbutton:function(_target)
	{
		var obj = $(_target+this.btn_postfix);
		var okbtn = document.createElement("INPUT");
		okbtn.type = "button";
		okbtn.value = this.okbtnvalue;
		Event.observe(obj, "click", this.setobserv.bindAsEventListener(this,_target),false);
		obj.appendChild(okbtn);
	},

	create_backlink:function(_target)
	{
		var obj = $(_target+this.btn_postfix);
		var bcklnk = document.createElement("A");
		bcklnk.href = "javascript:history.back();";
		bcklnk.className = "message_backlink";
		bcklnk.innerHTML = this.backlinktxt;
		obj.appendChild(bcklnk);
	},

	setobserv: function(x,t)
	{
    	Effect.BlindUp($(t));
	},

	target_selector:function()
	{
		var upobjparent = $(this.upobj+this.parentname);
		var vpo = document.viewport.getScrollOffsets().top;
		var y_up = upobjparent.cumulativeOffset().top;

		if(vpo < y_up)//up
		{
			return this.upobj;
		}
		else//down
		{
		    var downobjparent = $(this.upobj+this.parentname);
			var y_down = downobjparent.cumulativeOffset().top;
			var d_h = document.viewport.getHeight();
			if(y_down<(d_h + vpo))
			{
			    return this.downobj;
			}
			else//other
			{
				return null;
			}
		}
	}

}
/* end message handler */

function print_audioplayerflash(swffile, swfparam, swf_width, swf_height)
{
	var print_arr = new Array();
	print_arr.push('<div id="audioplayerdiv"><div id="audioplayerfavdiv"></div>');
	print_arr.push('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,124,0" id="mp3player" width="' + swf_width + '" height="' + swf_height + '" align="middle">');
	print_arr.push('<param name="allowScriptAccess" value="sameDomain">');
	print_arr.push('<param name="allowFullScreen" value="false">');
	print_arr.push('<param name="wmode" value="transparent">');
    print_arr.push('<param name="FlashVars" value="' + swfparam + '">');
	print_arr.push('<param name="movie" value="' + swffile + '">');
	print_arr.push('<param name="quality" value="high">');
	print_arr.push('<embed src="' + swffile + '" FlashVars="' + swfparam + '" wmode="transparent" quality="high" width="' + swf_width + '" height="' + swf_height + '" name="mp3player" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">');
	print_arr.push('</object>');
	print_arr.push('</div>');
	document.write(print_arr.join("\n"));
}

function get_audioplayerflash(element, swffile, swfparam, swf_width, swf_height)
{
	jQuery(element)
	.append(
		jQuery('<div></div>').attr('id','audioplayerdiv')
		.append(jQuery('<div></div>').attr('id','audioplayerfavdiv'))
		.append(
			jQuery('<div></div>').addClass('audioplayerswfdiv')
		)
	)
	;

	jQuery('#audioplayerdiv .audioplayerswfdiv').flash(
		{
			src: swffile,
			width: swf_width,
			height: swf_height,
			allowScriptAccess: 'sameDomain',
			allowFullScreen: false,
			wmode: 'transparent',
			quality: 'high',
			swliveconnect: true,
			flashvars: swfparam
		},{version: '9.0'});
}

function print_video_s_flash(swffile, place, swfparam, swf_width, swf_height)
{
	/* wmode='transparent' not available this flash (see:special characters bug) */
	var print_arr = new Array();
	print_arr.push('<div id="audioplayerdiv">');
	print_arr.push('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" id="subtitlerflash" width="' + swf_width + '" height="' + swf_height + '" align="middle">');
	print_arr.push('<param name="FlashVars" value="' + swfparam + '">');
	print_arr.push('<param name="allowScriptAccess" value="always">');
	print_arr.push('<param name="wmode" value="transparent">');
	print_arr.push('<param name="allowFullScreen" value="false">');
	print_arr.push('<param name="swliveconnect" value="true">');
	print_arr.push('<param name="movie" value="' + swffile + '">');
	print_arr.push('<param name="quality" value="high">');
	print_arr.push('<embed src="' + swffile + '" FlashVars="' + swfparam + '" quality="high" width="' + swf_width + '" height="' + swf_height + '" name="subtitlerflash" align="middle" wmode="transparent" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">');
	print_arr.push('</object>');
	print_arr.push('</div>');
	$(place).update(print_arr.join("\n"));
}

Event.observe(document.body, "mousemove", positiontip,false);

myVIPvideo={
	Version: '0.2',
	advurl_start: '',
	advurl_end: '',
	advertatplay: false,
	appear:function(){
	},
	play:function(flv){
		if(this.advurl_start!='' && this.advertatplay) this.adv_click(987);
	},
	adv_appear:function(target)
	{
		if(!$('count_advvideo'))
		{
			var s=document.createElement('IFRAME');
			s.src="count_advvideo.html";
			s.style["position"]="absolute";
			s.style["left"]="-10000px";
			s.id="count_advvideo";
			document.body.insertBefore(s, document.body.firstChild);
		}
	},
	adv_click: function(target)
	{
		if(target==0)window.open(this.advurl_start,'_blank');
		else if(target==987) window.location.href=this.advurl_start;
		else window.open(this.advurl_end,'_blank');
	},
	setVolume:function(value)
	{
		Myvip.setCookie('FlvPlayerVolume', value, 365);
	},
	getVolume:function()
	{
		var r=Myvip.getCookie('FlvPlayerVolume');
		if(r==null)r=0.75;
		return r;
	},
	
	overbannerappear:function(v)
	{
		;
	},

	overbannerclose:function(v)
	{
// 		Myvip.setCookie('videooverlay', 1, 1, null, null, null, 1);
	},

	overbannerclick:function(v)
	{
		Myvip.setCookie('videooverlay', 1, 1);
	},
	
	get_flvplayer:function (videoid,videourl,picurl,videodesc,autowidth,mode,preurl,posturl)
	{
		var r=0.5625;
		var width="480";
		var height="390";
		videodesc=escape(videodesc);
		if(autowidth!="default")
		{
			if(autowidth==0)
			{
				width="100%";
				height="100%";
			}
			else
			{
				width=autowidth;
				height=Math.round(width*r)+30;
			}
		}
		var advvideostr='';

		if(preurl!='') advvideostr=advvideostr+'&prelink='+preurl;
		if(posturl!='') advvideostr=advvideostr+'&postlink='+posturl;

		var ret = '<object id="videoobject" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+width+'" height="'+height+'">';
		ret += '<param name="movie" value="http://static.myvip.com/embed6.swf">';
		ret += '<param name="quality" value="high">';
		ret += '<param name="allowFullScreen" value="true">';
		ret += '<param name="allowScriptAccess" value="always">';
		ret += '<param name="FlashVars" value="videoid='+videoid+'&videourl='+videourl+'&picurl='+picurl+'&videodesc='+videodesc+'&mode='+mode+'&needxml=0'+advvideostr+'">';
		ret += '<embed name="videoobject" src="http://static.myvip.com/embed6.swf" FlashVars="videoid='+videoid+'&videourl='+videourl+'&picurl='+picurl+'&videodesc='+videodesc+'&mode='+mode+'&needxml=0'+advvideostr+'" quality="high" allowFullScreen=true type="application/x-shockwave-flash" allowScriptAccess="always" width="'+width+'" height="'+height+'">';
		ret += '</object>';
		return(ret);
	},
	print_flvplayer:function (videoid,videourl,picurl,videodesc,autowidth,mode,preurl,posturl)
	{
		document.write(this.get_flvplayer(videoid,videourl,picurl,videodesc,autowidth,mode,preurl,posturl));
	}
}

function getclubs(userid,type,page)
{
	var myAjax=new Ajax.Request(
		"profile.php?act="+type+"&p="+page+"&uid="+userid,
		{
			method: "post",
			onSuccess: function(req)
			{
				$(type).innerHTML=req.responseText;
			}
		}
	);
}

function resizepopup()
{
	Myvippopup.showbox();
}

function do_contact(type,uid) {
	uid*=1;
	var titles={
		'add'		: 'Ismerősnek jelölés',
		'sub'		: 'Jelölés visszavonása',
		'accept'	: 'Jelölés elfogadása',
		'deny'		: 'Jelölés visszautasítása',
		'del'		: 'Kapcsolat törlése'
	};
	if(titles[type] !== undefined && uid>0) {
//		popupWindow.open({box:{'title':titles[type]},height:275,width:450,ajax:{'url':'/contact.php',data:'isajax=1&act='+type+'&uid='+uid}});
		popupWindow.open({box:{'title':titles[type]},width:385,ajax:{'url':'/contact.php',data:'isajax=1&act='+type+'&uid='+uid}});
	}
}

function send_contact() {
	jQuery.ajax({
		url: 'contact.php',
		type: 'POST',
		data: 'isajax=1&'+jQuery('#contact_form').serialize(),
		complete: function(xhr,status) {
			var i = 0;
			var uid = jQuery('#contact_uid').val();
			var extra = new Array();

			jQuery('.usercard'+uid+' .extra').each(function(x,item) { //elméletileg erre nincs szükség
				extra[i] = jQuery(item).html();
				i++;
			});

			var arr = xhr.responseText.split('#*delimiter*#',3);
			jQuery('.usercard'+uid).each(function(x,item) {
				jQuery(item).html(arr[1]);
			});
			jQuery('.userlink_'+uid).each(function(x,item) {
				jQuery(item).attr("rel", jQuery(item).attr("rel").replace(/status:'\d'/,"status:'"+arr[2]+"'"));
			});

			i = 0;
			jQuery('.usercard'+uid+' .extra').each(function(x,item) { //elméletileg erre nincs szükség
				jQuery(item).html(extra[i]);
				i++;
			});

			window.alerts.message(arr[0]);
			popupWindow.close();
		}
	});
//	var myAjax = new Ajax.Request(
//		'contact.php?isajax=1&'+$('contact_form').serialize(),
//		{
//			method: 'post',
//			evalScripts: true,
//			onComplete: function(req)
//			{
//				var i=0;
//				var extra=new Array();
//				var extraarr=$$('.usercard'+$F('contact_uid')+' .extra').each(
//					function(item)
//					{
//						extra[i]=item.innerHTML;
//						i++;
//					});
//				var arr=req.responseText.split('#*delimiter*#',3);
//				$$('.usercard'+$F('contact_uid')).each(
//					function(item)
//					{
//						item.update(arr[1]);
//					}
//				);
//
//				$$('.userlink_'+$F('contact_uid')).each(
//					function(item)
//					{
//						var s=item.getAttribute("rel");
//						//eval(s);
//						s=s.replace(/status:'\d'/,"status:'"+arr[2]+"'");
//						item.writeAttribute("rel",s);
//					}
//				);
//
//				i=0;
//				extraarr=$$('.usercard'+$F('contact_uid')+' .extra').each(function(item){item.update(extra[i]);i++;});
//				alert(arr[0]);
//				Myvippopup.close();
//			}
//		}
//		);
}

function colortd(item,type)
{
	$A(item.parentNode.parentNode.getElementsByTagName("td")).each(function(elem){elem.removeClassName("sel")});
	if(type)$A(item.parentNode.getElementsByTagName("td")).each(function(elem){elem.addClassName("sel")});
}

function confirmrevokeevent(clubid,eventid)
{
	if (confirm("Biztos, hogy szeretnéd visszavonni a csatlakozási kérelmed ebbe a Klubba?")) window.location.href="clubevent.php?act=revokeevent&clubid="+clubid+"&eventid="+eventid;
}

function choose_paytype(packid,interval,cgistr)
{
	Myvippopup.open('creditman.php?act=choosebuy&packid='+packid+'&interval='+interval+cgistr,"Válassz fizetési módot!",500,350);
}
function send_paytype(packid,interval,cgistr,type)
{
	//console.log(packid,interval,cgistr,type);
	Myvippopup.open('creditman.php?isajax=1&act=dobuy&packid='+packid+'&interval='+interval+'&type='+type+cgistr,"Válassz fizetési módot!",500,350);
}
MyvipBrowser={
	init: function()
	{
		this.nVer = navigator.appVersion;
		this.nAgt = navigator.userAgent;
		this.browserName  = navigator.appName;
		this.fullVersion  = ''+parseFloat(navigator.appVersion);
		this.majorVersion = parseInt(navigator.appVersion,10);
		var nameOffset,verOffset,ix;

		// In MSIE, the true version is after "MSIE" in userAgent
		if ((verOffset=this.nAgt.indexOf("MSIE"))!=-1) {
		 this.browserName = "IE";
		 this.fullVersion = this.nAgt.substring(verOffset+5);
		 if (document.documentMode) this.fullVersion = "8"+this.nAgt.substring(verOffset+6);	//	detect IE8 in IE7 mode
		}
		// In Opera, the true version is after "Opera"
		else if ((verOffset=this.nAgt.indexOf("Opera"))!=-1) {
		 this.browserName = "Opera";
		 this.fullVersion = this.nAgt.substring(verOffset+6);
		}
		// In Chrome, the true version is after "Chrome"
		else if ((verOffset=this.nAgt.indexOf("Chrome"))!=-1) {
		 this.browserName = "Chrome";
		 this.fullVersion = this.nAgt.substring(verOffset+7);
		}
		// In Safari, the true version is after "Safari"
		else if ((verOffset=this.nAgt.indexOf("Safari"))!=-1) {
		 this.browserName = "Safari";
		 this.fullVersion = this.nAgt.substring(verOffset+7);
		}
		// In Firefox, the true version is after "Firefox"
		else if ((verOffset=this.nAgt.indexOf("Firefox"))!=-1) {
		 this.browserName = "Firefox";
		 this.fullVersion = this.nAgt.substring(verOffset+8);
		}
		// In most other browsers, "name/version" is at the end of userAgent
		else if ( (nameOffset=this.nAgt.lastIndexOf(' ')+1) < (verOffset=this.nAgt.lastIndexOf('/')) )
		{
		 this.browserName = this.nAgt.substring(nameOffset,verOffset);
		 this.fullVersion = this.nAgt.substring(verOffset+1);
		 if (this.browserName.toLowerCase()==this.browserName.toUpperCase()) {
		  this.browserName = navigator.appName;
		 }
		}
		// trim the fullVersion string at semicolon/space if present
		if ((ix=this.fullVersion.indexOf(";"))!=-1) this.fullVersion=this.fullVersion.substring(0,ix);
		if ((ix=this.fullVersion.indexOf(" "))!=-1) this.fullVersion=this.fullVersion.substring(0,ix);

		this.majorVersion = parseInt(''+this.fullVersion,10);
		if (isNaN(this.majorVersion)) {
		 this.fullVersion  = ''+parseFloat(navigator.appVersion);
		 this.majorVersion = parseInt(navigator.appVersion,10);
		}
	},
	getbrowserName: function()
	{
		return this.browserName;
	},
	getfullVersion: function()
	{
		return this.fullVersion;
	},
	getmajorVersion: function()
	{
		return this.majorVersion;
	},
	getappVersion: function()
	{
		return this.nVer;
	},
	getuserAgent: function()
	{
		return this.nAgt;
	},
	writeAll: function()
	{
		document.write('Browser name  = '+this.getbrowserName()+'<br>');
		document.write('Full version  = '+this.getfullVersion()+'<br>');
		document.write('Major version = '+this.getmajorVersion()+'<br>');
		document.write('navigator.appVersion = '+this.getappVersion()+'<br>');
		document.write('navigator.userAgent = '+this.getuserAgent()+'<br>');
	}
}
MyvipBrowser.init(); 

function captcha_regen(formid)
{
	var sid=$("captchaform"+formid).sid.value;
	$("captchaalert"+formid).style.display="none";
	$("captchashow"+formid).style.display="";
	$("captchaimg"+formid).src="http://captcha.myvip."+logged_tld+"/captcha.php?sid="+sid+"&rnd="+Math.random();
	$("captchaform"+formid).code.value="";
	$("captchaform"+formid).code.focus();
}

function captcha_submit(formid)
{
	var myform=$("captchaform"+formid);
	var params=Form.serialize(myform);
	var myAjax=new Ajax.Request(
		myform.action,
		{
			method: "post",
			parameters: params,
			onComplete: function(req)
			{
				if (req.responseText=="ERR") captcha_regen(formid);
				else $("captchadiv"+formid).innerHTML=req.responseText;
			}
		}
	);
}
function change_member_status(clubid,userid,new_status)
{
	if (confirm("Valóban módosítani akarod a klubtag státuszát?"))
	{
		jQ.ajax(
		{
			url: "clubmember.php?act=changestatus&clubid="+clubid+"&userid="+userid+"&newstatus="+new_status,
			type: "post",
			dataType: "json",
			error: function(req)
			{
				alert("A klub-státusz módosítás nem történt meg.");
			},
			success: function(req)
			{
				if (req.error=="") jQ("#usercard_extra_clubmembers_status_"+userid).html(req.status);
				else alert(req.error);
			}
		});
	}
}
function sethiddenmode(mode)
{
	new Ajax.Request(
		"sethidden.php?mode="+mode,
		{
			onSuccess: function()
			{
				//alert(mode);
				if(mode)
				{
					try{$('hiddendiv').addClassName("hiddendiv");} catch(e){}
					$('hiddenchanger').update("<a class='spritepic eyeclosed active' title='normál módra váltás' href='javascript:;' onclick='sethiddenmode(0); return false;'></a>");
					alert("Mostantól rejtett módban használod a myVIP-t.");
				}
				else
				{
					try{$('hiddendiv').removeClassName("hiddendiv");} catch(e){}
					$('hiddenchanger').update("<a class='spritepic eyeopened'  title='rejtett módra váltás' href='javascript:;' onclick='sethiddenmode(1); return false;'></a>");
				}
			},
			onFailure: function()
			{
				//alert("A rejtett módot, csak az Internet Explorer 8-at használó felhasználóink használhatják!");
				Myvippopup.open('/loadfile.php?f=hiddenmode_download.htm','Internet Explorer 8 letöltése',700,420);
				$('hiddenchanger').update("<a class='spritepic eyeopened'  title='rejtett módra váltás' href='javascript:;' onclick='sethiddenmode(1); return false;'></a>");
			}
		}
	);
} 

function beforeAjax(containerId)
{
	var setHeight=parseInt($(containerId).style['height']);//Ez csak akkor ad erteket, ha valami be van allitva
	//var setHeight=parseInt($(containerId).getStyle("height"));//Ez akkor is ad erteket, ha nincs beallitva
	var className="";
	var backHeight="";
	var restH=false;

	if(isNaN(setHeight)){
		restH=true;
		var innerHeight=parseInt($(containerId).getHeight());
		var paddingTopSize=parseInt($(containerId).getStyle("padding-top"));
		var paddingBottomSize=parseInt($(containerId).getStyle("padding-bottom"));
		var borderTopSize=parseInt($(containerId).getStyle("border-top-width"));
		if(isNaN(borderTopSize)) borderTopSize=0;
		var borderBottomSize=parseInt($(containerId).getStyle("border-bottom-width"));
		if(isNaN(borderBottomSize)) borderBottomSize=0;

		var height=innerHeight-paddingTopSize-paddingBottomSize-borderTopSize-borderBottomSize;
		$(containerId).style['height']=height+"px";

		if(innerHeight>70) className="ajax_loading_big";
		else className="ajax_loading_small";
		backHeight="auto";
	}else{
		if(setHeight>70) className="ajax_loading_big";
		else className="ajax_loading_small";
	}

	var retArray = {
		uploadClassName:className,
		needRestoreHeight:restH,
		restoreHeight:backHeight
	};

	return retArray;
}

function simpleAjaxUpdate(containerId, url, params)
{
	var beforeAjaxRet = beforeAjax(containerId);

	$(containerId).innerHTML="";
	$(containerId).addClassName(beforeAjaxRet.uploadClassName);
	//if(params.length>0) params=params+"&isajax=1";
	//else params="isajax=1";

	var myAjax=new Ajax.Updater(
		containerId,
		url,
		{
			method: 'post',
			parameters: params,
			evalScripts: true,
			onComplete: function(req)
			{
				$(containerId).removeClassName(beforeAjaxRet.uploadClassName);
				if(beforeAjaxRet.needRestoreHeight) $(containerId).style['height']=beforeAjaxRet.restoreHeight;
				runjQueryPlugins('#'+containerId);
			}
		}
	);
}

var tabboxContent = new Array();
function change_tabboxtab(newtabid,tabboxid,url,params)
{
	//Fulek inaktivalasa
	var tabElements = $$('#tabbox_'+tabboxid+' .tab');
	tabElements.each(function(el){
		el.removeClassName('active');
	});

	//Adott ful aktivalasa
	$('tabtitle_'+tabboxid+'_'+newtabid).addClassName('active');

	if(url != undefined && params != undefined)
	{	//Befoglalo div tartalmat ajax-al ujra kell tolteni.
		var containerId='tabcontent_'+tabboxid+'_'+newtabid;
		$(containerId).cleanWhitespace();
		if($(containerId).innerHTML == '')
			simpleAjaxUpdate(containerId, url, params);
	}

	//Content div-ek inaktivalasa
	var tabcElements = $$('#tabbox_'+tabboxid+' .tabc');
	tabcElements.each(function(el){
		el.style.display='none';
	});

	//Adott div aktivalasa
	$('tabcontent_'+tabboxid+'_'+newtabid).style.display='block';
}

function myVIP_setBanner468Height(pHeight)
{
	$('banner_468').style['height']=pHeight<100?"90px":"180px";
}

// Removes leading whitespaces
function LTrim(value)
{
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
}

// Removes ending whitespaces
function RTrim(value)
{
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
}

// Removes leading and ending whitespaces
function trim(value)
{
	return LTrim(RTrim(value));
}
function clog(str){if(false && (typeof(window.console)!='undefined'))console.log(str);}
function click_h24item(){
	img=new Image();
	img.src="http://ad.adverticum.net/b/cl,1,28847,398192,490770/click.prm";
}

function advert_browse_browsepage(page)
{
	window.location.href="advert.php?act=browse&page="+page;
	return false;
}

function club_home_gotopage(type,page)
{
	jQ.ajax(
	{
		url: "clubhome.php?act=get"+type+"clubs&page="+page,
		success: function(req)
		{
			jQ("#"+type+"clubs").html(req);
		}
	});
}
function profile_gotopage(type,page,uid)
{
	jQ.ajax(
	{
		url: "profile.php?act=get"+type+"clubs&page="+page+"&uid="+uid,
		success: function(req)
		{
			jQ("#"+type+"clubs").html(req);
		}
	});
}

function cbdependentclick(obj,val,truearr,falsearr)
{
	if (obj.checked==val)
	{
		for (var i=0;i<truearr.length;i++)
		{
			if (jQ("#"+truearr[i]).attr("checked")==false)
			{
				jQ("#"+truearr[i]).trigger("click");
			}
		}
		for (var i=0;i<falsearr.length;i++)
		{
			if (jQ("#"+falsearr[i]).attr("checked")==true)
			{
				jQ("#"+falsearr[i]).trigger("click");
			}
		}
	}
}

function do_clubcontact(type,clubid)
{
	var url='';
	var title='';
	switch (type)
	{
		case 'invite': {url='act=invite&userid='+clubid;title='Klubmeghívó küldése';}break;
		case 'join': {url='act=join&clubid='+clubid;title='Csatlakozás a klubhoz';}break;
		case 'accept': {url='act=join&agree=yes&clubid='+clubid;title='Klubmeghívás elfogadása';}break;
		case 'deny': {url='act=join&agree=no&clubid='+clubid;title='Klubmeghívás elutasítása';}break;
	}

	popupWindow.open({box:{'title':title},width:500,content:'',ajax:{'url':'/clubmember.php',data:"isajax=1&"+url}});
}

function club_settings_open(clubid)
{
	popupWindow.open({box:{'title':"Klubbeállítások"},width:920,height:625,content:'',ajax:{'url':'/clubsettings.php',data:"initwin=1&clubid="+clubid}});
}

function club_settings_submit()
{
	jQ.ajax(
	{
		url: jQ("#club_settings_form").attr("action"),
		data: jQ("#club_settings_form").serialize(),
		type: "post",
		success: function(req)
		{
			jQ("#club_settings_window").html(req);
		},
		error: function(req)
		{
			alert("Hiba történt a beállítások mentése közben!");
		}
	});
}

function club_order_new_open()
{
	popupWindow.open({box:{'title':"Új klub nyitása"},width:500,content:'',ajax:{'url':'/cluborder.php',data:"act=new"}});
}

function club_order_new_submit()
{
	jQ.ajax(
	{
		url: jQ("#club_order_form").attr("action"),
		data: jQ("#club_order_form").serialize(),
		type: "post",
		dataType: "json",
		success: function(req)
		{
			if (req.error!="") alert(req.error);
			else
			{
				alert(req.success);
				window.location.href="clubprofile.php?clubid="+req.clubid;
			}

			jQ("#club_settings_window").html(req);
		},
		error: function(req)
		{
			alert("MISSING_KEYWORD");
		}
	});
}

function club_order_extend_open(clubid,error)
{
	popupWindow.open({box:{'title':"Klublejárat meghosszabbítása"},width:600,content:'',ajax:{'url':'/cluborder.php',data:"act=extend&clubid="+clubid+"&showerror="+error}});
}

function club_leave(clubid)
{
	if (confirm("Biztos vagy benne, hogy törlöd magad a klubból?"))
	{
		window.location.href="/clubmember.php?act=doleave&clubid="+clubid;
	}
}

function club_kickuser(clubid,userid)
{
	popupWindow.open({box:{"title":"Klubtag eltávolítása"},width:500,content:"",ajax:{"url":"/clubmember.php",data:"isajax=1&act=kick&clubid="+clubid+"&userid="+userid}});
}

function club_delinvitation(clubid,userid)
{
	if (confirm("Biztosan visszavonod a klubmeghívót?"))
	{
		jQ.ajax(
		{
			url: "/clubmember.php?isajax=1&act=dodelinvitation&userid="+userid+"&clubid="+clubid,
			type: "post",
			dataType: "json",
			success: function(req)
			{
				alert(req.alert);
			}
		});
	}
}

function send_clubcontact()
{
	jQ.ajax(
	{
		url: "/clubmember.php?isajax=1&"+jQ("#clubcontactform").serialize(),
		type: "post",
		dataType: "json",
		success: function(req)
		{
			alert(req.alert);
			popupWindow.close();

			if (window.location.pathname=="/clubprofile.php") window.location.reload();
			else jQ(".list-row-clubcard-"+req.clubid).replaceWith(req.card);
		},
		error: function(req)
		{
			popupWindow.close();
		}
	});
}

function simpleJsonProcess(url,params,options)
{
	var ajaxLoaderGif=false;

	if ((typeof(options)!='undefined') && (typeof(options.ajaxLoaderGif)!='undefined')) ajaxLoaderGif=options.ajaxLoaderGif;
	if (ajaxLoaderGif)
	{
		var sn=ALG.newAjaxRequest();
		options.algsn=sn;
	}

	jQ.ajax(
	{
		url: url,
		data: params,
		type: "post",
		dataType: "json",
		error: function()
		{
			alert("Hiba az adat továbbítás során.");
		},
		success: function(req)
		{
			window.json_ret=new JsonRet(req,options);
			json_ret.process();
		},
		complete: function()
		{
			if (ajaxLoaderGif) ALG.doneAjaxRequest(sn);
			if (typeof(options.onCompleteFunc)=="function") options.onCompleteFunc();
		}
	});
}

function getFlashMovieObject(movieName)
{
  if (window.document[movieName])
  {
	  return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
	if (document.embeds && document.embeds[movieName])
	  return document.embeds[movieName];
  }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
	return document.getElementById(movieName);
  }
}

function comment_add()
{
	if (jQ("#comment_form textarea").val().trim()=="") alert("Nem írtál be szöveget!");
	else
	{
		jQ.ajax(
		{
			url: url_addcomment,
			data: {comment:jQ("#comment_form textarea").val()},
			type: "post",
			dataType: "json",
			success: function(req)
			{
				if (req.status=="OK")
				{
					comment_update(req);
//					alert("A kommentár hozzáadása megtörtént.");
				}
				else alert("Hiba a kommentár mentése közben!");
			},
			complete: function(req)
			{
				jQ("#comment_form").attr("disabled",false);
			}
		});
	}

	return false;
}

function comment_get()
{
	jQ.ajax(
	{
		url: url_getcommentpage,
		type: "post",
		dataType: "json",
		success: function(ret)
		{
			if (ret.status) comment_update(ret);
			else alert(ret.msgtext);
		}
	});
}

function comment_del(linkobj,msgid)
{
	if (confirm("Valóban törölni akarod a kommentet?"))
	{
		jQ(linkobj).css("visibility","hidden");

		jQ.ajax(
		{
			url: replaceUrlParam(url_delcomment,msgid),
			type: "post",
			dataType: "json",
			success: function(req)
			{
				if (req.status=="OK")
				{
					comment_update(req);
					alert("A kommentár törlése megtörtént.");
				}
				else
				{
					jQ(linkobj).css("visibility","visible");
					alert(req.msgtext);
				}
			},
			error: function()
			{
				jQ(linkobj).css("visibility","visible");
			}
		});
	}
}

function comment_update(req)
{
	jQ("#comment_container").html(req.content);
	jQ("#comment_count").html(req.commentcount);
}

function replaceUrlParam()
{
	if (arguments[0]!="undefined") var url=arguments[0];
	if (arguments[1]!="undefined") var param0=arguments[1];
	if (arguments[2]!="undefined") var param1=arguments[2];
	if (arguments[3]!="undefined") var param2=arguments[3];
	if (arguments[4]!="undefined") var param3=arguments[4];
	if (arguments[5]!="undefined") var param4=arguments[5];
	if (arguments[6]!="undefined") var param5=arguments[6];

	if (url!="undefined")
	{
		if (param0!="undefined") url = url.replace("(#param0#)",param0);
		else url = url.replace("(#param0#)","notparam");

		if (param1!="undefined") url = url.replace("(#param1#)",param1);
		else url = url.replace("(#param1#)","notparam");

		if (param2!="undefined") url = url.replace("(#param2#)",param2);
		else url = url.replace("(#param2#)","notparam");

		if (param3!="undefined") url = url.replace("(#param3#)",param3);
		else url = url.replace("(#param3#)","notparam");

		if (param4!="undefined") url = url.replace("(#param4#)",param4);
		else url = url.replace("(#param4#)","notparam");

		if (param5!="undefined") url = url.replace("(#param5#)",param5);
		else url = url.replace("(#param5#)","notparam");

		return url;
	}
	else
		return null;
}

function clubvote_change_is_end_date(val)
{
	if (val=="y") jQ("#voteend_box").show();
	else jQ("#voteend_box").hide();
}

function clubvote_answer_add()
{
	for(key in answerTextName)
	{
		if(key.substring(0,6) == 'ansdiv')
		{
			var textObj = $("vote_answer_"+answerTextName[key]);
			if(textObj)
			{
				alert(textObj.value);
				textObj.innerHTML = textObj.value;
			}
		}
	}

	if(AnswersCount < MaxAnswers)
	{
		var NextAnswerNum = LastAnswerNum + 1;
		answerTextName['ansdiv_'+NextAnswerNum] = NextAnswerNum;

		jQ.ajax(
		{
			url: "clubvote.php?act=add&clubid="+clubid+"&num="+ NextAnswerNum,
			type: 'post',
			error: function(req)
			{
				alert("Új válaszlehetőség hozzáadása nem történt meg.");
			},
			success: function(req)
			{
				if (req!="")
				{
					jQ("#vote_answers").append(req);
					LastAnswerNum=NextAnswerNum;
					AnswersCount++;
				}
				else
				{
					alert("Új válaszlehetőség hozzáadása nem történt meg.");
				}
			}
		}
		);
	}
	else
	{
		var msg = "Maximum %d válaszlehetőség adható meg! ";
		alert(msg.replace("%d",MaxAnswers));
	}
}

function clubvote_answer_del(ansNum)
{
	if (confirm("Valóban törölni szeretnéd a válaszlehetőséget?"))
	{
		var divId = 'ansdiv_'+ansNum;
		if(divId){
			var El = $(divId);
			if(El) El.parentNode.removeChild(El);
			AnswersCount--;
			delete answerTextName['ansdiv_'+ansNum];
		}
	}
}

function club_vote(clubid,voteid){
	var objName="vote_"+voteid;
	var radioObj=document.getElementsByName(objName);
	if(radioObj){
		answerid=0;
		for(var i=0; i<radioObj.length; i++){
			var obj=document.getElementsByName(objName).item(i);
			if(obj.checked){answerid=obj.value;break;}
		}

		if(answerid>0){
			var url="clubvote.php";
			var params="act=vote&clubid="+clubid+"&voteid="+voteid+"&answerid="+answerid;
			simpleJsonProcess(url,params,{typeError:'alert',typeContent:'update'});
		}
		else alert("Válassz a lehetőségek közül!");
	}
}

function club_vote_startpage(clubid,voteid){
	var objName="vote_"+voteid;
	var radioObj=document.getElementsByName(objName);
	if(radioObj){
		answerid=0;
		for(var i=0; i<radioObj.length; i++){
			var obj=document.getElementsByName(objName).item(i);
			if(obj.checked){answerid=obj.value;break;}
		}

		if(answerid>0){
			var url="clubvote.php";
			var params="act=votestartpage&clubid="+clubid+"&voteid="+voteid+"&answerid="+answerid;
			simpleJsonProcess(url,params,{typeError:'alert',typeContent:'update'});
		}
		else alert("Válassz a lehetőségek közül!");
	}
}

function club_event_setopinion(clubid,eventid,agree)
{
	jQ.ajax(
	{
		url: "clubevent.php?act=setopinion&clubid="+clubid+"&eventid="+eventid+"&agree="+agree,
		type: "post",
		dataType: "json",
		success: function(req)
		{
			if (req.error!="") alert(req.error);
			else jQ("#event"+eventid).html(req.content);
		}
	});
}

function club_event_setopinion(clubid,eventid,agree)
{
	club_event_process(clubid,eventid,"act=setopinion&agree="+agree);
}

function club_event_approve(clubid,eventid)
{
	club_event_process(clubid,eventid,"act=approve");
}

function club_event_force(clubid,eventid)
{
	club_event_process(clubid,eventid,"act=force");
}

function club_event_stop(clubid,eventid)
{
	club_event_process(clubid,eventid,"act=stop");
}

function club_event_process(clubid,eventid,url)
{
	jQ.ajax(
	{
		url: "clubevent.php?"+url+"&clubid="+clubid+"&eventid="+eventid,
		type: "post",
		dataType: "json",
		success: function(req)
		{
			if (req.error!="") alert(req.error);
			else jQ("#event"+eventid).html(req.content);
		}
	});
}

function club_billboard_loadreply(clubid,msgid)
{
	club_billboard_process(clubid,msgid,"getreply","reply","down");
}

function club_billboard_loadreplies(clubid,msgid)
{
	club_billboard_process(clubid,msgid,"getreplies","replies","up");
}

function club_billboard_moderate(clubid,msgid)
{
	club_billboard_process(clubid,msgid,"moderate","comment",null);
}

function club_billboard_process(clubid,msgid,act,div,slide)
{
	jQ.ajax(
	{
		url: "clubbillboard.php?act="+act+"&clubid="+clubid+"&msgid="+msgid,
		type: "post",
		dataType: "json",
		success: function(req)
		{
			if (req.error!="") alert(req.error);
			else
			{
				jQ("#"+div+msgid).html(req.content);

				switch (slide)
				{
					case "down":jQ("#"+div+msgid).slideDown();break;
					case "up":jQ("#"+div+msgid).slideDown();break;
				}
			}
		}
	});
}

function club_billboard_reply(clubid,msgid)
{
	popupWindow.open({box:{"title":"Új faliújság üzenet"},width:450,ajax:{"url":"/clubbillboard.php",data:"act=new&clubid="+clubid+"&msgid="+msgid}});
}

function club_billboard_reply_submit()
{
	jQ("#club_billboard_form").attr("disabled",true);

	jQ.ajax(
	{
		url: "clubbillboard.php?act=donew&clubid="+clubid,
		type: "post",
		data: jQ("#club_billboard_form").serialize(),
		dataType: "json",
		success: function(req)
		{
			if (req.error!="")
			{
				alert(req.error);
				popupWindow.close();
			}
			else window.location.href="clubbillboard.php?clubid="+clubid;
		},
		error: function()
		{
			popupWindow.close();
		}
	});

	return false;
}

jQuery(document).ready(function(){
	jQuery('.tipsy').tipsy();
	jQuery('.tipsy-e').tipsy({gravity: 'e'});
	jQuery('.tipsy-w').tipsy({gravity: 'w'});
	jQuery('.tipsy-s').tipsy({gravity: 's'});
	jQuery('.tipsy-n').tipsy({gravity: 'n'});
});

(function($){
	window.BannerHandler={};
	window.BannerHandler.extend=$.extend;
	var B=window.BannerHandler;
	B.extend({
		hideAll: function(){
			var $banners=$('.flash-hideable');
			$.each($banners, function(i,e){
				B.hide(e);
			});
			$.each($('.flash-moveable'), function(i,e){
				$(e).css('paddingTop',200);
			});
		},
		showAll: function(){
			$.each($('.flash-hideable'), function(i,e){
				B.show(e);
			});
			$.each($('.flash-moveable'), function(i,e){
				$(e).css('paddingTop',0);
			});
		},
		hide: function(e){
			var $e=$(e);
			if(!$e.attr('data-hidden')){
				$e.after(
					$('<div></div>').css({
							width: $e.outerWidth(true),
							height: $e.outerHeight(false)
					})
					.addClass('flash-hideable-replace')
				)
				.attr({
					'data-orig-position':$e.css('position'),
					'data-orig-left':$e.css('left'),
					'data-orig-top':$e.css('top'),
					'data-hidden':'1'
				});
				$e.css({
					position: 'absolute',
					left: '-10000px',
					top: '-10000px'
				});
			}
		},
		show: function(e){
			var $e=$(e);
			$e.next('.flash-hideable-replace').remove();
			$e.css({
				position: $e.attr('data-orig-position')||'relative',
				left: $e.attr('data-orig-left')||'0',
				top: $e.attr('data-orig-top')||'0'
			});
			$e.removeAttr('data-hidden');
		}
	});

})(jQuery);

function isModernBrowser(){
	return !(jQuery.browser.msie && parseInt(jQuery.browser.version)<8);
}

jQuery.ajaxSetup({
	nomedian: 0
});
jQuery(document).ajaxComplete(function(event,XMLHttpRequest,ajaxOptions){
	if (!ajaxOptions.nomedian) reload_median();
});

var openBrowserPopup=function(){
	popupWindow.open({
		box:{'title':'Frissítsd a böngésződ!','symbol':'warning'},
		ajax: {
			url: "/loadfile.php",
			data: 'f=global_browser_deprecated.html'
		}
	});
}
jQuery(document).ready(function(){
	(function($){
		if(!isModernBrowser()) {
			var browsercookie=Myvip.getCookie('deprecated_browser_informed');
			if(!browsercookie){
				Myvip.setCookie('deprecated_browser_informed',1,365);
				openBrowserPopup();
			} else if(parseInt(browsercookie)==1){
				$(".site-wrapper-inner").before(
					$("<div></div>")
					.addClass("bg-error")
					.addClass("rounded-normal")
					.addClass("browser-warning")
					.css({
						'cursor': 'pointer',
						'width': '972px',
						'margin': '0 auto'
					})
					.html("Felhívjuk a figyelmed, hogy a böngésződ elavult! Emiatt lehetséges, hogy a myVIP nem nyújtja ugyanazt a felhasználói élményt, mint másoknak. Kattints a részletekért!")
					.click(openBrowserPopup)
				);
			}
		}
	})(jQuery);
});

function waitForObject(object, callback, until) {
	var counter = 0,
		until = until || 50;
	function check(object, callback) {
		counter++;
		if(typeof object == 'undefined' && counter < until) setTimeout('check(object, callback)', 100);
		else callback(counter < until);
	}
	typeof callback == 'function' && check(object, callback);
}

var ado_counter = {};
/**
 * ADOcean stuff
 */
function checkBannerAndOcean(banner) {
	var start_size = banner == '-main' ? 8 : 4;
	ado_counter[banner] = typeof ado_counter[banner] == 'undefined' ? 1 : ado_counter[banner]+1;
	if(jQuery('.banner'+banner).find('*').size() > start_size) {
		jQuery('.banner'+banner).show();
		jQuery('.banner'+banner).find(':hidden:not(script)').show();
		return true;
	}
	if(ado_counter[banner] < 50) {
		setTimeout("checkBannerAndOcean('"+banner+"');", 500);
	} else {
//		jQuery('.banner'+banner).hide();
	}
	return false;
}

