var path = 'http://'+((document.location.host.length > 0) ? document.location.host : 'www.hotdog.hu');
//var url = 'http://www.hotdog.hu';

$(document).ready(function(){
	//ie6 os árnyékok
	if (jQuery.browser.msie==true && jQuery.browser.version<7)
		$(".arny").each(function(obj){
			$(this).height($(this).parent().height());
		});
	//képrotáló
	HD.keprotalo.init();
	$("body").append('<iframe height="0" width="0" frameborder="0" src="'+hotdogconf.root_url+'chat/checkonline.hot" id="checkonline_frame" name="checkonline_frame"></iframe>');
});

function getElementPosition(e) {//page coordinates
	var pos=new Object();
	pos.x = pos.y = 0;
	if (e.style.position=='absolute' && e.style.posWidth>=0) {
		pos.width = parseInt(e.style.posWidth);
		pos.height = parseInt(e.style.posHeight);
	}
	else {
		pos.width = parseInt(e.offsetWidth);
		pos.height = parseInt(e.offsetHeight);
	}

	while (e) {
		if (e.style.position=='absolute' && e.style.posLeft>=0) {
			pos.x += parseInt(e.style.posLeft);
			pos.y += parseInt(e.style.posTop);
		}
		else {
			pos.x += parseInt(e.offsetLeft);
			pos.y += parseInt(e.offsetTop);
		}
		e = e.offsetParent;
	} 
	return pos;
}

var bubishow=false;

$("#bubi_img").load(function(){
	if (bubishow==true) {
		$("#bubi").show();
		
		if (jQuery.browser.msie == true) {
			if (jQuery.browser.version < 7) {
				$("#bubi>.arnyek>.arny").height($("#bubi>.arnyek").height());
			}
		}
	}
});

function showUserBubble(obj, img){
	if (img) {
		var pos = getElementPosition(obj);
		var l=pos.x < ((document.body.clientWidth / 2));
		$('#bubi').css("left", (pos.x + (l?pos.width + 18:-167)) + "px");
		$('#bubi').css("top", pos.y - 15 + "px");

		if (l) {
			$("#bubi>.arnyek>.mutato_jobb").hide();
			$("#bubi>.arnyek>.mutato").show();
		}
		else {
			$("#bubi>.arnyek>.mutato_jobb").show();
			$("#bubi>.arnyek>.mutato").hide();
		}
		bubishow=true;
		$("#bubi_img").attr({
			src: img
		})
	}
}

function hideuserBubble(){
	bubishow=false;
	$("#bubi").hide();
}

function showTextBubble(obj, text){
	if (text) {
		var pos = getElementPosition(obj);
		var l=pos.x < ((document.body.clientWidth / 2));
		$(".bubi_2").html(text);
		$('#bubi_2').css("top", pos.y + "px");
		$('#bubi_2').css("left", (pos.x + (l?pos.width + 18:-197)) + "px");
		
		if (l) {
			$("#bubi_2>.arnyek>.mutato_jobb").hide();
			$("#bubi_2>.arnyek>.mutato").show();
		}
		else {
			$("#bubi_2>.arnyek>.mutato_jobb").show();
			$("#bubi_2>.arnyek>.mutato").hide();
			
		}
		$("#bubi_2").show();
		
		if (jQuery.browser.msie == true) {
			if (jQuery.browser.version < 7) {
				$("#bubi_2>.arnyek>.arny").height($("#bubi_2>.arnyek").height());
			}
		}
	}
}

function hideTextBubble(){
	$("#bubi_2").hide();
}

var bubishow3=false;

$(".bubi_3 #bubi_3_img img").load(function(){
	if (bubishow3==true) {
		$("#bubi_3").show();
		if (jQuery.browser.msie == true) {
			if (jQuery.browser.version < 7) {
				$("#bubi_3>.arnyek>.arny").height($("#bubi_3>.arnyek").height());
			}
		}
	}
});

function showTextBubbleWithImg(obj, text, img){
	if (text) {
		var pos = getElementPosition(obj);
		
		var l=pos.x < ((document.body.clientWidth / 2));
		$('#bubi_3').css("left", (pos.x + (l?pos.width + 18:-167)) + "px");
		$('#bubi_3').css("top", pos.y - 15 + "px");
		
		if (l) {
			$("#bubi_3>.arnyek>.mutato_jobb").hide();
			$("#bubi_3>.arnyek>.mutato").show();
		}
		else {
			$("#bubi_3>.arnyek>.mutato_jobb").show();
			$("#bubi_3>.arnyek>.mutato").hide();
			
		}
		
		bubishow3=true;
		$(".bubi_3 #bubi_3_img img").attr('src', img);
		$(".bubi_3 #bubi_3_text").html(text);
		$('#bubi_3').show();
				
	}
}

function hideTextBubbleWithImg(){
	bubishow3=false;
	$("#bubi_3").hide();
}

function showHint(obj, text) {
	if (text) {
		hideHint();
		
		var obj =  ($(obj).children('img')[0]) ? $(obj).children('img')[0] : obj;
		var pos = getElementPosition(obj);
		
		if (pos.y>30) {
			if (pos.x<(document.body.clientWidth/2)) {
				var d = $('#hintDiv1');
				var txtTD = $('#hintDivText1');
				txtTD.html(text)
				d.css('left', pos.x + pos.width - 5 +'px');
				d.css('top', pos.y - 18 +'px');
			}
			else {
				var d = $('#hintDiv2');
				var txtTD = $('#hintDivText2');
				txtTD.html(text)
				d.css('left', pos.x + 5 - d.width() +'px');
				d.css('top', pos.y - 18 +'px');
			}
		}
		else {
			if (pos.x<(document.body.clientWidth/2)) {
				var d = $('#hintDiv4');
				var txtTD = $('#hintDivText4');
				txtTD.html(text)
				d.css('left', pos.x + pos.width - 5 +'px');
				d.css('top', pos.y + pos.height +'px');
			}
			else {
				var d = $('#hintDiv3');
				var txtTD = $('#hintDivText3');
				txtTD.html(text)
				d.css('left', pos.x - d.width() + 5 +'px');
				d.css('top', pos.y + pos.height +'px');
			}
		}
		d.show();
	}
}

function hideHint(){
	for(var i=1;i<=4;i++)
		if ($('#hintDiv'+ i))
			$('#hintDiv'+ i).hide();
}

function show_message(mit){
	$.blockUI(mit); 
	var width=$('.blockMsg').width();
	var height=$('.blockMsg').height();
	var wheight=$(window).height();
	$('.blockMsg').css("left",parseInt(500-(width/2))+"px");
	$('.blockMsg').css("top",parseInt((wheight/2)-(height/2))+"px");
        window.scrollBy(0,1);
}

function hide_message()
{
	$.unblockUI();
}

function show_login()
{
	smartDownload(hotdogconf.darksite_url +'login.hot',function(html){show_message(html);});
}

function show_reg()
{
	show_message($('#reg_div').html());
}

function checkPressedEnter(MyEvent) {
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (MyEvent) keycode = MyEvent.which;
	else return false;
	if (keycode == 13) smart_login(1);
	return false;
}

function isPressedEnter(MyEvent) 
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (MyEvent) keycode = MyEvent.which;
	else return false;
	if (keycode == 13) {
		return true;
	} else {
		return false;
	}
}

function smart_login(id){
	var login = $("#remember_login_" + id);
	var pass = $("#remember_password_" + id);
	
	$("#login_remember_" + id).attr({
		value: (login.attr("checked") == true) ? login.attr("value") : 0
	});
	$("#password_remember_" + id).attr({
		value: (pass.attr("checked") == true) ? pass.attr("value") : 0
	});
	
	$.blockUI.defaults.overlayCSS =  {backgroundColor: '#aeaeae', opacity: '0.8'};
	if (id==2) $("#belepes_form_2").block();
	else $("#belepes_form").block();
	$.blockUI.defaults.overlayCSS =  {backgroundColor: '#000000', opacity: '0.8'};
	
	$.post(hotdogconf.root_url + "hotdog.hot", $("#login_" + id).serialize(), function(data){
		var ret = eval('('+ data +')');

		if (ret.success == true) {
			eval(ret.toEval);
		}
		else {
			if (id==2)
			{
				$("#belepes_form_2").unblock();
				$("#belepes_form_2").css('display', 'none');
				$("#belepes_message_text_2").html(ret.text);
				$("#belepes_message_2").css('display', 'block');
			}
			else
			{
				$("#belepes_form").unblock();
				$("#belepes_form").css('display', 'none');
				$("#belepes_message_text").html(ret.text);
				$("#belepes_message").css('display', 'block');
			}
			
		}
	});
}

function back_login(id){
	if (id==2)
	{
		$("#belepes_message_2").css('display', 'none');
		$("#belepes_message_text_2").html('');
		$("#belepes_form_2").css('display', 'block');
	}
	else
	{
		$("#belepes_message").css('display', 'none');
		$("#belepes_message_text").html('');
		$("#belepes_form").css('display', 'block');
	}
}

function smartDownload(url, handler, params, _method){
	var method = _method || 'GET'; 
	var u = url.split('?');
	url = u.shift();var p = u.join('?');
	if(params == null) params = p;
	else{
		var params_array = new Array();
		for(key in params)
		{ 
			params_array.push(key+'='+encodeURIComponent(params[key])); 
		} 
		params = params_array.join('&'); 
	}
	
	$.ajax({
		type:method,
		url:url,
		data:params,
		encoding:'iso-8859-2',
		success:function(response){
			handler(response);
		}
	});
}

function showDarkSite(what, whereof, func){
	if (what.indexOf('http://')==-1) what = path + '/darksites/' + what;
	
	smartDownload(what,
			function(html){
				if (html) {
					//show_message($('#'+ whereof).html(html));
					show_message(html);
				}
				else 
					if (func) 
						eval(func);
				}
			);
}

function sendRemember()
{	
	var login_rem=$('#login_rem').attr("value");
	var email_rem=$('#email_rem').attr("value");
	
	if (login_rem) smartDownload(hotdogconf.root_url+'_boxes/send_password.hot?login='+login_rem, function(html){alert(html);});
	if (email_rem) smartDownload(hotdogconf.root_url+'_boxes/send_password.hot?email='+email_rem, function(html){alert(html);});

	hide_message();
}

function sendNewPwRequest()
{	
	var login_rem=$('#login_rem').attr("value");
	var email_rem=$('#email_rem').attr("value");

	if (login_rem) smartDownload(hotdogconf.root_url+'_boxes/send_password_auth.hot?login='+login_rem, function(html){alert(html);});
	if (email_rem) smartDownload(hotdogconf.root_url+'_boxes/send_password_auth.hot?email='+email_rem, function(html){alert(html);});

	hide_message();
}

function smartSubmit(form, callback, params){
	if (callback) {
		var options = {
    		success: function(responseText) {
				callback(responseText);
    		}
		};
	}
	if (typeof(form) == 'string')
		form = $('#'+ form);
	
	if (typeof(form) == 'object')
		form.ajaxSubmit(options);
}

function changeAcceptButton(){
	if (document.getElementById('feltetel').checked){
		document.getElementById('cancelButton').style.display='none';
		document.getElementById('acceptButton').style.display='block';
	}else {
		document.getElementById('acceptButton').style.display='none';
		document.getElementById('cancelButton').style.display='block';
	}
}

function myAttachEvent(obj, event, handler) {
	if (obj.attachEvent) obj.attachEvent("on"+event,handler);	//ie
	else if (obj.addEventListener) obj.addEventListener(event, handler, false); //gecko
	else alert("FATAL: Can't add event listener. Your browser must support 'attachEvent' or 'addEventListener' DOM function!"); 
}

function myDetachEvent(obj, event, handler) {
	if (obj.detachEvent) obj.detachEvent("on"+event,handler);	//ie
	else if (obj.removeEventListener) obj.removeEventListener(event, handler, false); //gecko
	else alert("FATAL: Can't add event listener. Your browser must support 'detachEvent' or 'removeEventListener' DOM function!"); 
}

function getScrollY(w) {
	if (!w) w=window;
	return w.scrollY || w.document.documentElement.scrollTop || w.document.body.scrollTop;
}

function getScrollX(w) {
	if (!w) w=window;
	return w.scrollX || w.document.documentElement.scrollLeft || w.document.body.scrollLeft;
}

function getInnerWidth(w) {
	if (!w) w=window;
	return w.innerWidth || w.document.documentElement.clientWidth || w.document.body.clientWidth;
}

function getInnerHeight(w) {
	if (!w) w=window;
	return w.innerHeight || w.document.documentElement.clientHeight || w.document.body.clientHeight;
}

function cancelEvent(event) {
	if (!event) event=window.event;
	if (event.preventDefault) event.preventDefault();
	else event.returnValue=false;
}

function cancelBubble(event) {
	if (!event) event=window.event;
	event.cancelBubble=true;
}

function DoEnter(type, id, MyEvent) {
	if (!MyEvent) MyEvent=window.event;
	var keycode=MyEvent.keyCode;
	if (keycode == 13) {
		if (type == 1) {//form submit
		    var obj = document.getElementById(id);
		    
		    if (obj != null)
	      		obj.submit();
		}
		if (type == 2) {//fuggveny futtatas
			eval(id);
		}
		if (MyEvent.preventDefault) MyEvent.preventDefault();
		else MyEvent.returnValue = false;
	} else {
		return false;
	}
}

/* Relation 2*/
function showRelationDiv(callObj, userId, login, xCorrection, yCorrection) {
	smartDownload(hotdogconf.root_url +'common/relation/relation_layer2.hot?noreferer=1&userId='+userId+'&login='+login,
		function(response){
			if (response) {
				var pos = getElementPosition(callObj);
				var div = $('#relationDiv');
				div.html(response);
				var d = $('#relationContainerDiv');
				if (xCorrection == null && yCorrection == null){
					var left = (pos.x + pos.width - Math.floor(d.width()/2));
					if (left + d.width() >= 1000)
						left = (1000- d.width());
					else if(left < 0)
						left = (pos.x + pos.width);
					
					var top = (pos.y - (d.height() + 10));
					if (top < 0)
						top = pos.y;
					
					d.css('left', left +"px");
					d.css('top', top +"px");
				}
				else {
					d.css('left', (pos.x + pos.width + xCorrection)+"px");
					d.css('top', (pos.y + yCorrection)+"px");
				}
				d.show();
			}
		});
}

function doRelation(type) {
	var myform = document.forms['relationForm'];
	myform.relation_type.value = type;
	myform.submit();
}

function doRelation2(type) {
	var myform = document.forms['relationForm2'];
	myform.relation_type.value = type;
	myform.submit();
}
/* Relation 2 vége*/ 

function norating()
{
	showDarkSite('norating.hot', 'alert_div');
}


//common.js-böl
function getOuterHTML(node) {
	if (node.outerHTML) return node.outerHTML;
	var span=node.ownerDocument.createElement('span');
	span.appendChild(node.cloneNode(true));
	return span.innerHTML;
}

function getPageX(event) {
	if (!event) event=window.event;
	return event.pageX || (event.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft));
}

function getPageY(event) {
	if (!event) event=window.event;
	return event.pageY || (event.clientY + (document.documentElement.scrollTop || document.body.scrollTop));
}

var movieName = "onlinekliens";

function crc32(str) {// computes crc value
	var i, j, k;
	var bit;
	var datalen;
	var len;
	var actchar;
	var flag;
	var counter;
	var c;
	var crc = new Array (8+1);
	var mask = new Array (8);
	var hexnum = new Array ("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F");
	
	var data;
	var order;
	var polynom = new Array (8);
	var init = new Array (8);
	var xor = new Array (8);
	
	var result = "";

	// convert crc order
	order=32;//parseInt(document.crcform.order.value, 10);
	if (isNaN(order) == true || order<1 || order>64) {
		result = "CRC order must be between 1 and 64";
		return;
	}

	// convert crc polynom
	polynom = convertentry ('4C11DB7', order);
	if (polynom[0]<0) {
		result = "Invalid CRC polynom";
		return;
	}

	// convert crc init value
	init = convertentry ('FFFFFFFF', order);
	if (init[0]<0) {
		result = "Invalid initial value";
		return;
	}

	// convert crc xor value
	xor = convertentry ('FFFFFFFF', order);
	if (xor[0]<0) {
		result = "Invalid XOR value";
		return;
	}

	// generate bit mask
	counter = order;
	for (i=7; i>=0; i--) {
		if (counter>=8) mask[i] = 255;
		else mask[i]=(1<<counter)-1;
		counter-=8;
		if (counter<0) counter=0;
	}
	
	crc = init;

	var nondirect = false;//document.crcform.crcinittype[0].checked;
	if (nondirect) {// nondirect -> direct
		crc[8] = 0;
		
		for (i=0; i<order; i++) {
			bit = crc[7-((order-1)>>3)] & (1<<((order-1)&7));
			for (k=0; k<8; k++) {
				crc[k] = ((crc [k] << 1) | (crc [k+1] >> 7)) & mask [k];
				if (bit) crc[k]^= polynom[k];
			}
		}
	}

	//data = unescape(document.crcform.data.value);
	data = str;//document.crcform.data.value;
	datalen = data.length;
	len=0;// number of data bytes
	
	crc[8]=0;

	// main loop, algorithm is fast bit by bit type
	for (i=0; i<datalen; i++) {
		c = data.charCodeAt(i);
		if (data.charAt(i)=='%') {// unescape byte by byte (%00 allowed)
			if (i>datalen-3) {
				result = "Invalid data sequence";
				return;
			}
			ch = parseInt(data.charAt(++i), 16);
			if (isNaN(ch) == true) {
				result = "Invalid data sequence";
				return;
			}
			c = parseInt(data.charAt(++i), 16);
			if (isNaN(c) == true) {
				result = "Invalid data sequence";
				return;
			}
			c = (c&15) | ((ch&15)<<4);
		}

		// perform revin
		/*if (document.crcform.reflect[0].checked)*/ c = reflectByte(c);

		// rotate one data byte including crcmask
		for (j=0; j<8; j++) {
			bit=0;
			if (crc[7-((order-1)>>3)] & (1<<((order-1)&7))) bit=1;
			if (c&0x80) bit^=1;
			c<<=1;
			for (k=0; k<8; k++)	{	// rotate all (max.8) crc bytes
				crc[k] = ((crc [k] << 1) | (crc [k+1] >> 7)) & mask [k];
				if (bit) crc[k]^= polynom[k];
			}
		}
		len++;
	}

	// perform revout
	/*if (document.crcform.reflect[1].checked)*/ crc = reflect(crc, order, 0);

	// perform xor value
	for (i=0; i<8; i++) crc [i] ^= xor [i];

	// write result

	flag=0;
	for (i=0; i<8; i++)	{
		actchar = crc[i]>>4;
		if (flag || actchar) {
			result+= hexnum[actchar];
			flag=1;
		}
		
		actchar = crc[i] & 15;
		if (flag || actchar || i==7) {
			result+= hexnum[actchar];
			flag=1;
		}
	}
	
	return result;
}

function reflectByte(inbyte) {
	// reflect one byte
	var outbyte=0;
	var i=0x01;
	var j;
	
	for (j=0x80; j; j>>=1) {
		if (inbyte & i) outbyte|=j;
		i<<=1;
	}
	return (outbyte);
}

function reflect(crc, bitnum, startLSB) {
	// reflect 'bitnum' bits starting at lowest bit = startLSB
	var i, j, k, iw, jw, bit;
	
	for (k=0; k+startLSB<bitnum-1-k; k++) {
		iw=7-((k+startLSB)>>3);
		jw=1<<((k+startLSB)&7);
		i=7-((bitnum-1-k)>>3);
		j=1<<((bitnum-1-k)&7);
		
		bit = crc[iw] & jw;
		if (crc[i] & j) crc[iw] |= jw;
		else crc[iw] &= (0xff-jw);
		if (bit) crc[i] |= j;
		else crc[i] &= (0xff-j);
	}
	
	return(crc);
}

function convertentry (input, order) {
	// convert from ascii to hexadecimal value (stored as byte sequence)
	
	var len;
	var actchar;
	var polynom = new Array (0,0,0,0,0,0,0,0);
	var brk = new Array (-1,0,0,0,0,0,0,0);
	
	// convert crc value into byte sequence
	len = input.length;
	for (i=0; i < len; i++)	{
		actchar = parseInt(input.charAt(i), 16);
		if (isNaN(actchar) == true) return (brk);
		actchar&=15;
		
		for (j=0; j<7; j++) polynom[j] = ((polynom [j] << 4) | (polynom [j+1] >> 4)) & 255;
		polynom[7] = ((polynom[7] <<4) | actchar) & 255;
	}
	
	// compute and check crc order
	count = 64;
	for (i=0; i<8; i++)	{
		for (j=0x80; j; j>>=1) {
			if (polynom[i] & j) break;
			count--;
		}
		if (polynom[i] & j) break;
	}
	if (count > order) return (brk);
	return(polynom);
}

function show_login_div(type)
{
	sl.fader.show();
	document.getElementById('login_div').style.top=(getScrollY()+50);
	document.getElementById('login_div').style.display='block';
	document.getElementById('login_div_username').focus();
	document.getElementById('login_type').value=type;
}

function select_by_value(obj,value)
{
	for (i=0;i<obj.length;i++)
	{
		if (obj.options[i].value==value)
		{
			obj.selectedIndex=i;
			return true;
		}
	}
}

function showHideDropdownSearch()
{
	if($('#kereses_dropdown').css('display') == 'none') $('#kereses_dropdown').css('display', 'block');
	else $('#kereses_dropdown').css('display', 'none');
}
function dropdownSearchSelect(id)
{
	$('#kereses_dropdown').css('display', 'none');
	$('#search-select').val(id);
	$("#[id*=dropdown_res_]").css('color', '#323232');
	if(($('#fejlec_kereso_mezo').css('color') == '#323232') || ($('#fejlec_kereso_mezo').css('color') == 'rgb(50, 50, 50)')) {}
	else 
	{
		$('#fejlec_kereso_mezo').val($('#dropdown_res_' + id).html() + ' közt');
	}
	$('#dropdown_res_' + id).css('color', '#ff1182');
}

if (!HD) var HD = {};

HD.keprotalo = {
	timer: null,													//időzítő
	interval: 4000,													//dia váltás közötti idő
	switchPics: true,												//váltsuk-e a diákat
	actPic: 0,														//aktuális dia azonosítója
	allPic: 0,														//összes dia száma
	animateCaption: true,											//animáljuk-e a szöveget
	useEffect: true,												//használjunk-e effectet a diák váltásakor
	switchEffects: false,											//váltogassuk-e az effecteket
	effectFunctions: ["fade", "boxBumm", "lines", "fade", "fade"],	//ezekből váltogatjuk az effecteket, ha kell
	defaultEffect: "fade",											//ha nem váltogatjuk, akkor ez az alap effect, amit használunk

	init: function(){
		this.allPic = parseInt($("div.keprotalo div.keprotaloItem").size());
		if (this.useEffect) {
			$("div.keprotalo div.keprotaloItem").css({opacity: 0});
			$("div.keprotalo div.keprotaloItem:visible").css({opacity: 1});
		}
		HD.keprotalo.step();
	},

	step: function(){
		if (this.switchPics == true) {
			$("#keprotalo_pause").hide();
			this.effects.switchPics(this.actPic, (this.actPic == this.allPic)?1:this.actPic+1);
			this.actPic++;
			if (this.actPic > this.allPic) this.actPic = 1;
			this.timer = setTimeout('HD.keprotalo.step()', HD.keprotalo.interval);
		}
	},

	jump: function(pic){
		clearTimeout(this.timer);
		this.timer = null;
		$("#keprotalo_pause").hide();
		if (this.actPic != pic){
			this.effects.switchPics(this.actPic, pic);
			this.actPic = pic;
			if (this.actPic > this.allPic) this.actPic = 1;
			this.timer = setTimeout('HD.keprotalo.step()', HD.keprotalo.interval);
		}
	},

	start: function(){
		if (this.switchPics == true && this.timer == null)
			this.timer = setTimeout("HD.keprotalo.step()", 1);
	},

	stop: function(){
		clearTimeout(this.timer);
		this.timer = null;
		$("#keprotalo_pause").show();
	},

	effects: {
		switchPics: function(actId, nextId){//alapból mindegyik hidden
			var actPic = $("#keprotalo_"+ actId);
			var nextPic = $("#keprotalo_"+ nextId);
			var p = HD.keprotalo;
			//numbers
			$("#keprotalo_number_"+ actId).css('background-color', '#fff');
			$("#keprotalo_number_"+ nextId).css('background-color', '#0fc0eb');
			if (p.useEffect) {
				if (p.switchEffects && p.effects[p.effectFunctions[p.actPic-1]]){
					p.effects[p.effectFunctions[p.actPic-1]](actPic, nextPic);
				}
				else {
					p.effects[p.defaultEffect](actPic, nextPic);
				}
			}
			else {
				p.effects.display(actPic, 0);
				p.effects.display(nextPic, 1);
			}
		},
		animateCaption: function(container){
			var caption = container.find(".caption");
			if (HD.keprotalo.animateCaption){
				caption.stop().css({top: 256}).show().animate({top: 180}, 250);
			}
			else
				caption.css({top: 180}).show();
		},
		display: function(item, mode){
			if (mode) {
				item.show(0, function(){
					HD.keprotalo.effects.animateCaption(item);
				});
			}
			else
				item.hide().find(".caption").hide().css({top: 256});
		},
		fade: function(toHide, toShow){
			var caption = toHide.find(".caption");
			if (HD.keprotalo.animateCaption){
				setTimeout(function(){
					toShow.stop().animate({opacity: 1}, 500, function(){
						HD.keprotalo.effects.animateCaption(toShow);
					}).show();
					toHide.stop().animate({opacity: 0}, 100).hide();
				}, 200);
				caption.stop().animate({top: 256}, 100);
			}
			else {
				caption.css({top: 256}).hide();
				toShow.stop().animate({opacity: 1}, 500, function(){
					HD.keprotalo.effects.animateCaption(toShow);
				}).show();
				toHide.stop().animate({opacity: 0}, 100).hide();
			}
		},
		boxBumm: function(toHide, toShow){
			HD.keprotalo.effects.fade(toHide, toShow);
		},
		lines: function(toHide, toShow){
			HD.keprotalo.effects.fade(toHide, toShow);
		}
	}
};

// Firka kampány függvényei

function firka_open(){
	$('#relationB').hide();
	$('#tippdoboz').hide();
	$('#firkacontainer').show();
	$('#firkacontainer').html('<div id="firkaflash"></div>');
	var firkadata = $('#firkadata').val().split('|');
	var save_enabled = 1;
	if(firkadata[0] == 1) save_enabled = 0;
	$('#firkaflash').flash(
	   {
		 src: hotdogconf.root_url + '_img/flash/scribble.swf',
		 width: 996,
		 height: 600,
		 wmode: 'transparent',
		 flashvars: {
				profilid: firkadata[1],
				userid: firkadata[0],
				chkcode: firkadata[2],
				save_enabled: save_enabled,
				phpurl: hotdogconf.root_url + 'profil/bitmapexporter.hot',
				scale: 'noscale',
				menu: 'false'
		 }
	   },
	   {version: 10}
   );
}
function picture_saved(){
	$('#firkacontainer').hide();
	$('#firkacontainer').html('');
	var firkadata = $('#firkadata').val().split('|');
	$.post(
		hotdogconf.root_url + 'profil/smart_firka.hot?rnd='+Math.round(Math.random()*1000),
		{
			action: 'save',
			profil_id: firkadata[1],
			user_id: firkadata[0]
		},
		function(data) {
			if (data.error) {
				showDarkSite('dark_alert_2.hot?message=session&type=' + data.error);
			} else if(data.datas){
				showDarkSite('dark_alert_2.hot?message=session&type=' + data.datas);
			}
			$('#relationB').show();
		},
		'json'
	);
}
function load_firka(firka_id, profil_id)
{
	$.post(
		hotdogconf.root_url + 'profil/smart_firka.hot?rnd='+Math.round(Math.random()*1000),
		{
			action: 'load',
			firka_id: firka_id,
			profil_id: profil_id
		},
		function(data) {
			if (data.error) {
				showDarkSite('dark_alert_2.hot?messageutf=' + data.error);
			} else if(data.datas){
				$('#relationB').hide();
				$('#tippdoboz').hide();
				$('#firkacontainer').show();
				$('#firkacontainer').html('<img src="' + data.datas + '" alt="Firka"/>');
			}
		},
		'json'
	);
}