var _imga = new Array();
var _imgt = 0;
var _iebg = false;
var _ordr = null;
var _ordx = false;
var _unit = 1;
var _h3ok = false;
var _parc = new Array();
var _reqs = null;
var _stop = false;

preload = function(a){
	if(a && typeof a=='string'){
	_imga[_imgt] = new Image();
	_imga[_imgt].src = a.toString();
	_imgt++;
	}
}

function up(num, hmany){
	if(hmany){
	return Math.floor(num)+'.'+(parseInt((num-Math.floor(num)+'').substring(2,2+hmany))+1);
	} else{
	return Math.floor(num+1);
	}
}

function format(str, chr){
	var o = '';
	var s = str.toString();
	for(var i=s.length; i>=0; i--){
	if(i<s.length && (s.length-1-i)%3==0) o = chr+o;
	o = s.charAt(i)+o;
	}
	return o;
}

function ieBug(){
	if($.browser.msie && _iebg==false){
	$('.nextride:first, .parcelsearch:first, .notepad:first').css('position', 'relative').css('top', function(){
		return parseInt($(this).css('top'))-2+'px';
	});
		_iebg = true;
	}
}

function addUnit(sy, sz, ma, my){
	if(sy&&sz&&ma&&my) $('.csomag:first a:last').prev().prev().prev().prev().prev().before('<div id="ord'+_unit.toString()+'"><input type="text" class="pdetail" name="csomag_sulya'+_unit.toString()+'" maxlength="2" value="'+sy.toString()+'" /><span class="iedebug">(kg) × </span><input type="text" class="pdetail" name="csomag_szelessege'+_unit.toString()+'" maxlength="3" value="'+sz.toString()+'" /><span class="iedebug">(cm) × </span><input type="text" class="pdetail" name="csomag_magassaga'+_unit.toString()+'" maxlength="3" value="'+ma.toString()+'" /><span class="iedebug">(cm) × </span><input type="text" class="pdetail" name="csomag_melysege'+_unit.toString()+'" maxlength="3" value="'+my.toString()+'" /><span class="iedebug">(cm)</span><br /><span>A csomag tartalma</span><br /><input type="text" name="csomag_tartalma'+_unit.toString()+'" /><br /><span>A csomag értéke <b>(kérjük jelölje a pénznemet is)</b></span><br /><input type="text" name="csomag_erteke'+_unit.toString()+'" /><br /><br /><a href="javascript:deleteUnit()">TÖRLÖM EZT A TÉTELT</a></div>');
	else $('.csomag:first a:last').prev().prev().prev().prev().prev().before('<div id="ord'+_unit.toString()+'"><input type="text" class="pdetail" name="csomag_sulya'+_unit.toString()+'" maxlength="2" /><span class="iedebug">(kg) × </span><input type="text" class="pdetail" name="csomag_szelessege'+_unit.toString()+'" maxlength="3" /><span class="iedebug">(cm) × </span><input type="text" class="pdetail" name="csomag_magassaga'+_unit.toString()+'" maxlength="3" /><span class="iedebug">(cm) × </span><input type="text" class="pdetail" name="csomag_melysege'+_unit.toString()+'" maxlength="3" /><span class="iedebug">(cm)</span><br /><span>A csomag tartalma</span><br /><input type="text" name="csomag_tartalma'+_unit.toString()+'" /><br /><span>A csomag értéke <b>(kérjük jelölje a pénznemet is)</b></span><br /><input type="text" name="csomag_erteke'+_unit.toString()+'" /><br /><br /><a href="javascript:void(0)">TÖRLÖM EZT A TÉTELT</a></div>');
	$('#ord'+_unit.toString()+' > a:last').click(deleteUnit);
	_unit++;
	if(_unit>1 && _h3ok==false) $('.csomag:first h3:first').attr('innerHTML', function(){
		_h3ok = true;
		return $(this).attr('innerHTML') + 'ok';
	});
	$('.csomag:first .pdetail').keypress(function(e){
		var c = (e.which)? e.which : window.event.keyCode;
		if(c<=13){
		return true;
		} else{
		var k = String.fromCharCode(c);
		var r = /[0-9]/
		return r.test(k);
		}
	});
	$('.csomag:first div').css('-moz-border-radius', '5px');
	$('.csomag:first div').css('-webkit-border-radius', '5px');
	$('.csomag:first div a').css('color','#454545');
}

function deleteUnit(){
	if(_unit>1){
	var temp = parseInt((($(this).parent().attr('id')).toString()).substr(3));
	$(this).parent().remove();
	for(var i=temp; i<(_unit-1); i++){
		$('#ord'+(i+1).toString()).attr('id', function(){
		return 'ord'+i;
		});
	}
	_unit--;
	if(_unit==1){
		$('.csomag:first h3:first').attr('innerHTML', 'A csomag');
		_h3ok = false;
	}
	}
}

function postit(){
	$('.notepad:first').animate({top:'-405px',opacity:0},400,'swing');
	$('.notepad:first').animate({left:'0px',top:'-15px'},1,'',function(){$(document).focus();$('.notepad a:last').remove();}).animate({top:'20px',opacity:1},800,'swing');
}

function fadeBluebox(whatobj){
	if($.browser.msie && $.browser.version<=6.5){$('select').css('visibility', 'hidden');}
	if($.browser.msie){
		$('.bluebox:first').css('visibility', 'visible').animate({ opacity:0.85 }, 1, function(){
		$(whatobj).css('visibility', 'visible');
		window.scrollTo(null, 0);
		});
	} else{
		$('.bluebox:first').css('visibility', 'visible').animate({ opacity:0.85 }, 600, 'swing', function(){$(whatobj).css({'opacity':0,'visibility':'visible'}).animate({opacity:1}, 400, 'swing');});
		$.scrollTo(0, 600);
	}
}

var login = {
	name: '',
	pass: '',
	hitname: false,
	hitpass: false
}

var lang = {
	title_weight: 'Súly(kg)',
	title_wide: 'Szélesség(cm)',
	title_height: 'Magasság(cm)',
	title_deep: 'Mélység(cm)',
	title_new: 'Újabb tétel',
	title_del: 'Tétel törlése',
	title_afa: 'Ez megközelítőleg bruttó',
	msg_error: new Array('KEVÉS ADAT A SZÁMOLÁSHOZ!', 'Szükséges adatok a kalkulációhoz:', '- pontos súly és/vagy', '- dimenzionális paraméterek'),
	unable_function: 'Ez a funkció jelenleg nem elérhető!',
	span_yourprice: 'Az Ön szállítási díja',
	span_tax: 'ÁFA',
	a_details: 'Részletes szállítási feltételeinkért kattintson ide'
}

var req = new Object();

var priv = {
	fueladdition: function(){
		if(req.def_fuel<270){
			return 1.0;
		} else{
			return 1+((Math.floor((req.def_fuel-270)/10)+1)*0.01);
		}
	},
	weightFrom00: 1.8,
	weightFrom10: 0.98,
	weightFrom25: 0.95,
	weightFrom50: 0.92,
	system : 'eur'
}

var calculator = {
	c: 0,
	v: true,
	d: new Object(),
	p: 0,
	a: false,
	x: false,
	f: 0,
	
	newline: function(){
		if(_stop==false){
		calculator.c++;
		var trow = document.createElement('tr');
			trow.id = 'unit'+calculator.c.toString();
		var tcol1 = document.createElement('td');
			tcol1.className = 'first';
		var tcol2 = document.createElement('td');
		var tcol3 = document.createElement('td');
		var tcol4 = document.createElement('td');
		var tcol5 = document.createElement('td');
		var tinput1 = document.createElement('input');
			tinput1.type = 'text';
			tinput1.className = 'weight';
			tinput1.id = 'cweight'+calculator.c.toString();
			tinput1.name = 'cweight'+calculator.c.toString();
			tinput1.value = '';
			tinput1.setAttribute('maxLength', 2);
			tinput1.title = lang.title_weight;
			
		var tinput2 = document.createElement('input');
			tinput2.type = 'text';
			tinput2.id = 'cwide'+calculator.c.toString();
			tinput2.name = 'cwide'+calculator.c.toString();
			tinput2.value = '';
			tinput2.setAttribute('maxLength', 3);
			tinput2.title = lang.title_wide;
			
		var tinput3 = document.createElement('input');
			tinput3.type = 'text';
			tinput3.id = 'cheight'+calculator.c.toString();
			tinput3.name = 'cheight'+calculator.c.toString();
			tinput3.value = '';
			tinput3.setAttribute('maxLength', 3);
			tinput3.title = lang.title_height;
			
		var tinput4 = document.createElement('input');
			tinput4.type = 'text';
			tinput4.id = 'cdeep'+calculator.c.toString();
			tinput4.name = 'cdeep'+calculator.c.toString();
			tinput4.value = '';
			tinput4.setAttribute('maxLength', 3);
			tinput4.title = lang.title_deep;
			
		var timg5 = new Image();
			timg5.src = 'img/calc_plus.jpg';
			timg5.title = lang.title_new;
		
		$('.calc table tbody').append(trow);
		$('.calc table tbody tr:last').append(tcol1);
		$('.calc table tbody tr:last td:last').append(tinput1);
		$('.calc table tbody tr:last').append(tcol2);
		$('.calc table tbody tr:last td:last').append(tinput2);
		$('.calc table tbody tr:last').append(tcol3);
		$('.calc table tbody tr:last td:last').append(tinput3);
		$('.calc table tbody tr:last').append(tcol4);
		$('.calc table tbody tr:last td:last').append(tinput4);
		$('.calc table tbody tr:last').append(tcol5);
		$('.calc table tbody tr:last td:last').append(timg5);
		$('.calc table tbody tr:last input:first').focus();
		$('.achievment:first').css('top', function(){
		return parseInt($(this).css('top'))+(($.browser.mozilla)?21:(($.browser.msie)?24:25))+'px';
		});
		
		$(this).attr('src', 'img/calc_minus.jpg');
		$(this).attr('title', lang.title_del);
		$(this).unbind('click', calculator.newline);
		$(this).click(function(){
			if(_stop==false){
			var temp = parseInt($(this).parent().parent().attr('id').substr(4));
			$(this).parent().parent().remove();
			for(var i=temp; i<calculator.c; i++){
				$('#unit'+(i+1).toString()).attr('id', function(){
				return 'unit'+i;
				});
				
				$('#unit'+i.toString()+' input:eq(0)').attr('id', 'cweight'+i);
				$('#unit'+i.toString()+' input:eq(1)').attr('id', 'cwide'+i);
				$('#unit'+i.toString()+' input:eq(2)').attr('id', 'cheight'+i);
				$('#unit'+i.toString()+' input:eq(3)').attr('id', 'cdeep'+i);
				
				$('#unit'+i.toString()+' input:eq(0)').attr('name', 'cweight'+i);
				$('#unit'+i.toString()+' input:eq(1)').attr('name', 'cwide'+i);
				$('#unit'+i.toString()+' input:eq(2)').attr('name', 'cheight'+i);
				$('#unit'+i.toString()+' input:eq(3)').attr('name', 'cdeep'+i);
			}
			calculator.c--;
			$('.achievment:first').css('top', function(){
			return parseInt($(this).css('top'))-(($.browser.mozilla)?21:(($.browser.msie)?24:25))+'px';
			});
			}
		});
		
		calculator.initialize();
		}
	},
	
	initialize: function(){
		$('.holder .calc table tr:last td input').keypress(function(e){
			var c = (e.which)? e.which : window.event.keyCode;
			if(c<=13){
			return true;
			} else{
			var k = String.fromCharCode(c);
			var r = /[0-9]/
			return r.test(k);
			}
		});
		$('.holder .calc table tr:last td input').blur(function(){
			if($(this).val()!='' && $(this).val().indexOf('cm')==-1 && $(this).val().indexOf('kg')==-1 && $.browser.safari!=true){
			if($(this).attr('className') != 'weight'){
				$(this).attr('value', $(this).attr('value') + ' cm');
			} else{
				$(this).attr('value', $(this).attr('value') + ' kg');
			}
			if(parseInt($(this).val())==0) $(this).attr('value', '');
			}
		});
		$('.calc table tr:last td:last img').bind('click', calculator.newline);
		$('.calc table tr td input').focus(function(){
			if($(this).val()!='') $(this).attr('value', parseInt($(this).attr('value')));
			$(this).select();
		});
	},
	
	validate: function(){
		var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
		$('.calc:first table:first input').each(function(){
		if($(this).val()=='' && calculator.v==true){
		 calculator.v = false;
		 calculator.d = $(this);
		}
		});
		if($('.agreethis:first input[type="checkbox"]:first').attr('checked')==true && calculator.v==true){
			if($('#email').val()==''){
			calculator.v = false;
			calculator.d = $('#email');
			} else{
			var testing = filter.test($('#email').val());
			if(!testing){
			calculator.v = false;
			calculator.d = $('#email');
			}
			}
		}
		if(calculator.v == false){
			$(calculator.d).select();
			calculator.v = true;
			calculator.d = new Object();
		} else{
			// HA MINDEN MEZŐ KIVOLT TÖLTVE AKKOR SZÁMÍTÁS
			
			calculator.p = 0;
			
			$('.calc:first table:first tbody:first tr').each(function(){
				var _id = $(this).attr('id').toString().substring(4);
				var _weight = up((parseInt($('#cwide'+_id).val())*parseInt($('#cheight'+_id).val())*parseInt($('#cdeep'+_id).val()))/6000, 1);
					_weight = (parseFloat(_weight)>parseInt($('#cweight'+_id).val()))? parseFloat(_weight) : parseInt($('#cweight'+_id).val());
				var _zone = up(((parseInt($('#to').val())+2)*parseInt($('#from').val()))*8/100+0.98, 2);
				
				if(_weight<10){ _weight = 10*priv.weightFrom00; } else
				if(_weight<25){ _weight = 20*priv.weightFrom10; } else
				if(_weight<50){ _weight = 45*priv.weightFrom25; } else
				if(_weight>=10){ _weight = _weight*priv.weightFrom50; }
				
				calculator.p += parseFloat(up(_weight * _zone * req.def_price * priv.fueladdition(), 1));
			});
			
			// HA KÉRI A SZÁMÍTÁS EREDMÉNYEIT AKKOR => AJAX
			
			if($.trim($('#email').val())!='' && $('.agreethis:first input[type="checkbox"]:first').attr('checked')==true){
			var query = 'all='+(calculator.c+1)+'&prize='+encodeURI(((priv.system=='eur')?'€':((priv.system=='gbp')?'₤':'HUF'))+' '+((priv.system=='eur')?up(calculator.p,1):((priv.system=='gbp')?up(calculator.p*req.money_gbp,1):(((calculator.p*req.money_huf).toString().length>3)?format(up(calculator.p*req.money_huf),' '):up(calculator.p*req.money_huf)))))+'&'+$('form:eq(1)').serialize().replace(/\+cm/g, '').replace(/\+kg/g, '');
			
			$('.calc:first input, .calc:first select').each(function(){
			$(this).attr('disabled', 'disabled');
			_stop = true;
			});
			
			$.ajax({
			type: 'POST',
			url: 'lib/ajax/calculator.php',
			data: query,
			cache: false,
			success: function(data){
				if(data=='done'){
				$('.agreethis:first input[type="checkbox"]:first').attr('checked', null);
				} else{
				alert('A SZERVER TÚLTERHELT VAGY NEM ELÉRHETŐ!\n\nA kalkuláció eredménye nem lett elküldve a megadott email címre.\nKérjük próbálja meg később');
				}
			}
			});
			} else{
				$('.calc:first input, .calc:first select').each(function(){
				$(this).attr('disabled', 'disabled');
				_stop = true;
			});
			}
			calculator.calculate();
		}
	},
	
	calculate: function(){
		if(calculator.x==false){
		
		var cdiv = document.createElement('div');
			cdiv.className = 'achievment';
		var csp1 = document.createElement('span');
			csp1.innerHTML = lang.span_yourprice;
		var chrl = document.createElement('hr');
		var cbr1 = document.createElement('br');
		var cbr2 = document.createElement('br');
		var csp2 = document.createElement('span');
			csp2.className = 'pr';
		var csp3 = document.createElement('span');
			csp3.id = 'conc';
			csp3.innerHTML = ((priv.system=='eur')?'€':((priv.system=='gbp')?'₤':'HUF'))+' '+((priv.system=='eur')?up(calculator.p,1):((priv.system=='gbp')?up(calculator.p*req.money_gbp,1):(((calculator.p*req.money_huf).toString().length>3)?format(up(calculator.p*req.money_huf),' '):up(calculator.p*req.money_huf))));
		var csup = document.createElement('sup');
			csup.innerHTML = ' + ' + lang.span_tax;
		var can1 = document.createElement('a');
			can1.href = 'javascript:void(0)';
			can1.innerHTML = lang.a_details;
		var can2 = document.createElement('a');
			can2.className = 'orderbutton';
			can2.href = 'javascript:void(0)';
		var clos = document.createElement('a');
			clos.className = 'close';
			clos.onclick = function(){
				$('.button:first').html('Számítás').unbind('click').click(calculator.validate);
				$('.calc:first input, .calc:first select').each(function(){
				$(this).attr('disabled', null);
				_stop = false;
				});
				$('.achievment:first').animate({ opacity:0, top:'355px' }, 600, 'swing', function(){
				$(this).remove();
				});

				calculator.a = false;
				calculator.x = false;
			};
			
		$('body:first .holder:first').append(cdiv);
		$('.achievment:first').append(csp1);
		$('.achievment:first').append(chrl);
		$('.achievment:first').append(csp2);
		$('.achievment:first').append(cbr1);
		$('.achievment:first').append(can1);
		$('.achievment:first').append(cbr2);
		$('.achievment:first').append(can2);
		$('.achievment:first span:last').append(csp3);
		$('.achievment:first span:last').append(csup);
		$('.achievment:first').append(clos);
		if($.browser.safari){
		$('.achievment:first a:first').css('top', '24px');
		}
		
		calculator.x = true;
		}
		
		if(calculator.a==false){
			$('.button:first').html('Új számítás').unbind('click').click(function(){
				$('.button:first').html('Számítás');
				$('.button:first').click(calculator.validate);
				$('.achievment:first').animate({ opacity:0, top:'355px' }, 600, 'swing', function(){$(this).remove();});
				$('.calc:first input, .calc:first select').each(function(){
				$(this).attr('disabled', null);
				_stop = false;
				});
				calculator.a = false;
				calculator.x = false;
			});
			$('.achievment:first').css('top', '355px');
			$('.achievment:first').css('visibility', 'visible');
			if($.browser.msie || $.browser.safari) $('.achievment:first').animate({ top: 355+$('.calc:first').height()+40 + 'px' }, 600, 'swing', function(){
			}); else $('.achievment:first').animate({ opacity:0 }, 1).animate({ top: 355+$('.calc:first').height()+40 + 'px', opacity: 1 }, 600, 'swing', function(){
			});
			calculator.a = true;
		} else{
			document.getElementById('conc').innerHTML = ((priv.system=='eur')?'€':((priv.system=='gbp')?'₤':'HUF'))+' '+((priv.system=='eur')?up(calculator.p,1):((priv.system=='gbp')?up(calculator.p*req.money_gbp,1):(((calculator.p*req.money_huf).toString().length>3)?format(up(calculator.p*req.money_huf),' '):up(calculator.p*req.money_huf)))) + '<sup> + ' + lang.span_tax + '</sup>';
		}
		
		$('.achievment:first sup:first').mouseover(function(){
			$(this).css('color', 'yellow');
			$(this).css('cursor', 'help');
			$(this).attr('title', function(){
				return ((priv.system=='eur')?lang.title_afa+' €':((priv.system=='gbp')?lang.title_afa+' ₤':lang.title_afa+' HUF'))+' '+((priv.system=='eur')?up(up(calculator.p,1)*req.def_afa):((priv.system=='gbp')?up(up(calculator.p*req.money_gbp,1)*req.def_afa):(((calculator.p*req.money_huf).toString().length>3)?format(up(up(calculator.p*req.money_huf)*req.def_afa),' '):up(up(calculator.p*req.money_huf)*req.def_afa))));
			});
		});
		$('.achievment:first sup:first').mouseout(function(){
			$(this).css('color', '#efefef');
			$(this).css('cursor', 'defult');
			$(this).attr('title', '');
		});
		$('.achievment:first .orderbutton:first').click(calculator.order).prev().prev().click(function(){
		if($.browser.msie && $.browser.version<=6.5) $('select').css('visibility', 'hidden');
		if($.browser.msie){
			$('.bluebox:first').css('visibility', 'visible').animate({ opacity:0.95 }, 1, function(){
			$('.agreements:first').css('visibility', 'visible');
			});
		} else{
			$('.bluebox:first').css('visibility', 'visible').animate({ opacity:0.95 }, 400, 'swing');
			$('.agreements:first').css('opacity', 0).css('visibility', 'visible').animate({ opacity:0.95 }, 1000, 'swing');
		}
		ieBug();
		});
	},
	
	order: function(){
		_parc = new Array();
		$('.csomag:first > div[id!="ord0"]').each(function(){ $(this).remove(); });
		$('.calc:first > form:first > table:first > tbody:first input').each(function(){ _parc.push(parseInt($(this).val())); });
		for(var i=0; i<(_parc.length/4); i++){
		if(i==0){
			$('.csomag:first > div:first > input:eq(0)').val(_parc[0]);
			$('.csomag:first > div:first > input:eq(1)').val(_parc[1]);
			$('.csomag:first > div:first > input:eq(2)').val(_parc[2]);
			$('.csomag:first > div:first > input:eq(3)').val(_parc[3]);
		} else{
			addUnit(_parc[(4*i)], _parc[(4*i)+1], _parc[(4*i)+2], _parc[(4*i)+3]);
		}
		}
		if($.browser.msie && $.browser.version<=6.5) $('select').css('visibility', 'hidden');
		if($.browser.msie){
			$('.bluebox:first').css('visibility', 'visible').animate({ opacity:0.95 }, 1, function(){
			$('.order:first').css('visibility', 'visible');
			$('.megrendelo:first input:first').select();
			});
		} else{
			$('.bluebox:first').css('visibility', 'visible').animate({ opacity:0.95 }, 400, 'swing');
			$('.order:first').css('opacity', 0).css('visibility', 'visible').animate({ opacity:0.95 }, 1000, 'swing');
		}
		ieBug();
		$('.megrendelo:first input:first').select();
	}
}

// PÁR KÉP ELŐRE BETÖLTÉSE

preload('img/calc_minus.jpg');
preload('img/calc_plus.jpg');
preload('img/sidebar_block_header.jpg');
preload('img/sidebar_block_footer.jpg');
preload('img/sidebar_block_header_bw.jpg');
preload('img/sidebar_block_footer_bw.jpg');
preload('img/header_logo.png');
preload('img/calc_light.png');
preload('img/sidebar_note_header.png');
preload('img/sidebar_note_footer.png');
preload('img/bluebox_bg.jpg');
preload('img/nav_tetris-act.png');
preload('img/splash_image.jpg');
preload('img/splash_image_hover.jpg');

$(document).ready(function(){

	// DATA.XML PARSING
	$.get('xml/data.xml', {}, function(xml){
		req.money_eur = $('data', xml).find('eur').text().toString();
		req.money_huf = $('data', xml).find('huf').text().toString();
		req.money_gbp = $('data', xml).find('gbp').text().toString();
		req.def_price = $('data', xml).find('price').text().toString();
		req.def_fuel = $('data', xml).find('fuel').text().toString();
		req.def_afa = $('data', xml).find('afa').text().toString();
	});
	
	// A BEJELENTKEZÉS KÉNYELMI FUNKCIÓJA
	$('#username').focus(function(){
	if(login.hitname==false){
		login.hitname=true;
		login.name=$(this).attr('value');
		if($(this).attr('value')==login.name){ $(this).attr('value', ''); } else { $(this).select(); }
	} else{
		if($(this).attr('value')==login.name){ $(this).attr('value', ''); } else { $(this).select(); }
	}
	});
	$('#username').blur(function(){
		if($(this).attr('value')=='') $(this).attr('value', login.name);
	});
	
	$('#userpass').focus(function(){
	if(login.hitpass==false){
		login.hitpass=true;
		login.pass=$(this).attr('value');
		if($(this).attr('value')==login.pass){ $(this).attr('value', ''); } else { $(this).select(); }
	} else{
		if($(this).attr('value')==login.pass){ $(this).attr('value', ''); } else { $(this).select(); }
	}
	});
	$('#userpass').blur(function(){
		if($(this).attr('value')=='') $(this).attr('value', login.pass);
	});
	
	// SIDEBAR (ÁRNYALATOK, KERET)
	$('.block').each(function(){
	if($(this).hasClass('notepad')){
		$(this).prepend('<img src="img/sidebar_note_header.png" alt="" /><img src="img/sidebar_note_footer.png" class="footer" style="bottom:-5px" alt="" />');
		
	} else{
		$(this).prepend('<img src="img/sidebar_block_header.jpg" alt="" /><img src="img/sidebar_block_footer.jpg" class="footer" alt="" />');
		$(this).css('background-color','#32789c');
	}
	});
	
	$('.log:first input[type="button"]').css('width', '80px');
	$('.log:first input[type="button"]').css('height', '21px');
	$('.log:first input[type="button"]').css('position', 'absolute');
	$('.log:first input[type="button"]').css('right', '3px');
	$('.log:first input[type="button"]').css('background-color', '#dfdfdf');
	
	// BÖNGÉSZŐ ELTÉRÉSEK
	if($.browser.safari){
		$('.holder .sidebar .block div input').css('font-size', '7pt');
		$('.log:first input[type="button"]').css('height', '19px');
	}
	if($.browser.msie){
		$('.log:first input[type="button"]').css('height', '22px');
		if($.browser.version<7){
			$('.calc').css('height', function(){$(this).height();}).css('background-image', 'none').append('<img src="img/calc_bg.png" alt="" />');
			$('.calc img:last').css({'position':'absolute', 'bottom':'0px'}).addClass('png');
		}
		$('img[src="img/sidebar_note_footer.png"]').addClass('png');
	}
	if($.browser.msie && $.browser.version<=6.5){
		$('.block').each(function(){
			$(this).children('.footer').css('top', function(){
			return $(this).parent().height()-9 + 'px';
			});
		});
		$('.agreethis').css('background-image', 'none');
		
		// PNG HIBAJAVÍTÁS
		$('img[src$="png"]').each(function(){if(!$(this).hasClass('png')){$(this).addClass('png');}});
		$('.notepad:first h4:first').css({'position':'static','margin-left':'14px'});
		ieBug();
	}
	
	// KALKULÁTOR
	$('.calc:first').prepend('<img class="light png" src="img/calc_light.png" alt="" />');
	
	$('.calc:first table:first tbody:first tr:first').attr('id', 'unit0');
	$('#cweight').attr('id', 'cweight0');
	$('#cwide').attr('id', 'cwide0');
	$('#cheight').attr('id', 'cheight0');
	$('#cdeep').attr('id', 'cdeep0');
	
	$('#cweight0').attr('name', 'cweight0');
	$('#cwide0').attr('name', 'cwide0');
	$('#cheight0').attr('name', 'cheight0');
	$('#cdeep0').attr('name', 'cdeep0');
	
	$('#cweight0').attr('title', lang.title_weight);
	$('#cwide0').attr('title', lang.title_wide);
	$('#cheight0').attr('title', lang.title_height);
	$('#cdeep0').attr('title', lang.title_deep);
	$('#cdeep0').parent().parent().children('td:last img:first').attr('title', lang.title_new);
	
	$('#from').attr('name', 'from');
	$('#to').attr('name', 'to');
	$('#moneytype').attr('name', 'moneytype');
	
	calculator.initialize();
	priv.system = $('#moneytype').val();
	
	// LABEL IMITÁCIÓ CHECKBOXRA
	$('.agreethis:first span').click(function(){
		if(_stop==false){
		if($('.agreethis:first input[type="checkbox"]:first').attr('checked')==true){
			$('.agreethis:first input[type="checkbox"]:first').attr('checked', null);
		} else{
			$('.agreethis:first input[type="checkbox"]:first').attr('checked', 'checked');
		}
		}
	});
	
	//BLUEBOXOK ELTŰNTETÉSE - AZÉRT ITT MERT KÜLÖNBEN NEM VALID
	$('.bluebox').css('opacity', 0);
	
	// BLUEBOX MAGASSÁG JAVÍTÁS
	$('.bluebox').each(function(){
		$(this).css('height', function(){
		return $(document).height()+'px';
		});
	});
	$(window).bind('resize', function(){
	$('.bluebox').each(function(){
		$(this).css('height', function(){
		return $(document).height()+'px';
		});
	});
	});
	
	// TETRIS MENÜ
	// 1(A)
	var ta1 = document.createElement('div');
		ta1.style.position = 'absolute';
		ta1.style.top = '7px';
		ta1.style.left = '6px';
		ta1.style.width = '36px';
		ta1.style.height = '38px';
		ta1.style.backgroundPosition = '300px 300px';
		ta1.style.backgroundRepeat = 'no-repeat';
		ta1.style.backgroundImage = 'url(img/nav_tetris-act.png)';
		ta1.style.cursor = 'pointer';
		ta1.id = 'ta1';
	var ta2 = document.createElement('div');
		ta2.style.position = 'absolute';
		ta2.style.top = '45px';
		ta2.style.left = '6px';
		ta2.style.width = '112px';
		ta2.style.height = '36px';
		ta2.style.backgroundPosition = '300px 300px';
		ta2.style.backgroundRepeat = 'no-repeat';
		ta2.style.backgroundImage = 'url(img/nav_tetris-act.png)';
		ta2.style.cursor = 'pointer';
		ta2.id = 'ta2';
	// 2(B)
	var tb1 = document.createElement('div');
		tb1.style.position = 'absolute';
		tb1.style.top = '7px';
		tb1.style.left = '44px';
		tb1.style.width = '74px';
		tb1.style.height = '36px';
		tb1.style.backgroundPosition = '300px 300px';
		tb1.style.backgroundRepeat = 'no-repeat';
		tb1.style.backgroundImage = 'url(img/nav_tetris-act.png)';
		tb1.style.cursor = 'pointer';
		tb1.id = 'tb1';
	// 3(C)
	var tc1 = document.createElement('div');
		tc1.style.position = 'absolute';
		tc1.style.top = '7px';
		tc1.style.left = '120px';
		tc1.style.width = '74px';
		tc1.style.height = '36px';
		tc1.style.backgroundPosition = '300px 300px';
		tc1.style.backgroundRepeat = 'no-repeat';
		tc1.style.backgroundImage = 'url(img/nav_tetris-act.png)';
		tc1.style.cursor = 'pointer';
		tc1.id = 'tc1';
	var tc2 = document.createElement('div');
		tc2.style.position = 'absolute';
		tc2.style.top = '43px';
		tc2.style.left = '120px';
		tc2.style.width = '36px';
		tc2.style.height = '38px';
		tc2.style.backgroundPosition = '300px 300px';
		tc2.style.backgroundRepeat = 'no-repeat';
		tc2.style.backgroundImage = 'url(img/nav_tetris-act.png)';
		tc2.style.cursor = 'pointer';
		tc2.id = 'tc2';
	// 4(D)
	var td1 = document.createElement('div');
		td1.style.position = 'absolute';
		td1.style.top = '83px';
		td1.style.left = '6px';
		td1.style.width = '74px';
		td1.style.height = '36px';
		td1.style.backgroundPosition = '300px 300px';
		td1.style.backgroundRepeat = 'no-repeat';
		td1.style.backgroundImage = 'url(img/nav_tetris-act.png)';
		td1.style.cursor = 'pointer';
		td1.id = 'td1';
	var td2 = document.createElement('div');
		td2.style.position = 'absolute';
		td2.style.top = '119px';
		td2.style.left = '6px';
		td2.style.width = '36px';
		td2.style.height = '38px';
		td2.style.backgroundPosition = '300px 300px';
		td2.style.backgroundRepeat = 'no-repeat';
		td2.style.backgroundImage = 'url(img/nav_tetris-act.png)';
		td2.style.cursor = 'pointer';
		td2.id = 'td2';
	// 5(E)
	var te1 = document.createElement('div');
		te1.style.position = 'absolute';
		te1.style.top = '83px';
		te1.style.left = '82px';
		te1.style.width = '36px';
		te1.style.height = '38px';
		te1.style.backgroundPosition = '300px 300px';
		te1.style.backgroundRepeat = 'no-repeat';
		te1.style.backgroundImage = 'url(img/nav_tetris-act.png)';
		te1.style.cursor = 'pointer';
		te1.id = 'te1';
	var te2 = document.createElement('div');
		te2.style.position = 'absolute';
		te2.style.top = '121px';
		te2.style.left = '44px';
		te2.style.width = '112px';
		te2.style.height = '36px';
		te2.style.backgroundPosition = '300px 300px';
		te2.style.backgroundRepeat = 'no-repeat';
		te2.style.backgroundImage = 'url(img/nav_tetris-act.png)';
		te2.style.cursor = 'pointer';
		te2.id = 'te2';
	// 6(F)
	var tf1 = document.createElement('div');
		tf1.style.position = 'absolute';
		tf1.style.top = '83px';
		tf1.style.left = '120px';
		tf1.style.width = '38px';
		tf1.style.height = '38px';
		tf1.style.backgroundPosition = '300px 300px';
		tf1.style.backgroundRepeat = 'no-repeat';
		tf1.style.backgroundImage = 'url(img/nav_tetris-act.png)';
		tf1.style.cursor = 'pointer';
		tf1.id = 'tf1';
	var tf2 = document.createElement('div');
		tf2.style.position = 'absolute';
		tf2.style.top = '45px';
		tf2.style.left = '158px';
		tf2.style.width = '36px';
		tf2.style.height = '112px';
		tf2.style.backgroundPosition = '300px 300px';
		tf2.style.backgroundRepeat = 'no-repeat';
		tf2.style.backgroundImage = 'url(img/nav_tetris-act.png)';
		tf2.style.cursor = 'pointer';
		tf2.id = 'tf2';
	
	$('.nav:first').append(ta1);
	$('.nav:first').append(ta2);
	$('.nav:first').append(tb1);
	$('.nav:first').append(tc1);
	$('.nav:first').append(tc2);
	$('.nav:first').append(td1);
	$('.nav:first').append(td2);
	$('.nav:first').append(te1);
	$('.nav:first').append(te2);
	$('.nav:first').append(tf1);
	$('.nav:first').append(tf2);
	
	// TETRIS MŰKÖDÉS
	// BLOKKOKRA BONTVA
	// 1(A)
	$('#ta1').mouseover(function(){
	$(this).css('background-position', '0px 0px');
	$('#ta2').css('background-position', '0px -38px');
	});
	$('#ta2').mouseover(function(){
	$(this).css('background-position', '0px -38px');
	$('#ta1').css('background-position', '0px 0px');
	});
	$('#ta1').mouseout(function(){
	$(this).css('background-position', '300px 300px');
	$('#ta2').css('background-position', '300px 300px');
	});
	$('#ta2').mouseout(function(){
	$(this).css('background-position', '300px 300px');
	$('#ta1').css('background-position', '300px 300px');
	});
	
	// 2(B)
	$('#tb1').mouseover(function(){
	$(this).css('background-position', '-38px 0px');
	});
	$('#tb1').mouseout(function(){
	$(this).css('background-position', '300px 300px');
	});
	
	// 3(C)
	$('#tc1').mouseover(function(){
	$(this).css('background-position', '-114px 0px');
	$('#tc2').css('background-position', '-114px -36px');
	});
	$('#tc2').mouseover(function(){
	$(this).css('background-position', '-114px -36px');
	$('#tc1').css('background-position', '-114px 0px');
	});
	$('#tc1').mouseout(function(){
	$(this).css('background-position', '300px 300px');
	$('#tc2').css('background-position', '300px 300px');
	});
	$('#tc2').mouseout(function(){
	$(this).css('background-position', '300px 300px');
	$('#tc1').css('background-position', '300px 300px');
	});
	
	// 4(D)
	$('#td1').mouseover(function(){
	$(this).css('background-position', '0px -76px');
	$('#td2').css('background-position', '0px -112px');
	});
	$('#td2').mouseover(function(){
	$(this).css('background-position', '0px -112px');
	$('#td1').css('background-position', '0px -76px');
	});
	$('#td1').mouseout(function(){
	$(this).css('background-position', '300px 300px');
	$('#td2').css('background-position', '300px 300px');
	});
	$('#td2').mouseout(function(){
	$(this).css('background-position', '300px 300px');
	$('#td1').css('background-position', '300px 300px');
	});
	
	// 5(E)
	$('#te1').mouseover(function(){
	$(this).css('background-position', '-76px -76px');
	$('#te2').css('background-position', '-38px -114px');
	});
	$('#te2').mouseover(function(){
	$(this).css('background-position', '-38px -114px');
	$('#te1').css('background-position', '-76px -76px');
	});
	$('#te1').mouseout(function(){
	$(this).css('background-position', '300px 300px');
	$('#te2').css('background-position', '300px 300px');
	});
	$('#te2').mouseout(function(){
	$(this).css('background-position', '300px 300px');
	$('#te1').css('background-position', '300px 300px');
	});
	
	// 6(F)
	$('#tf1').mouseover(function(){
	$(this).css('background-position', '-114px -76px');
	$('#tf2').css('background-position', '-152px -38px');
	});
	$('#tf2').mouseover(function(){
	$(this).css('background-position', '-152px -38px');
	$('#tf1').css('background-position', '-114px -76px');
	});
	$('#tf1').mouseout(function(){
	$(this).css('background-position', '300px 300px');
	$('#tf2').css('background-position', '300px 300px');
	});
	$('#tf2').mouseout(function(){
	$(this).css('background-position', '300px 300px');
	$('#tf1').css('background-position', '300px 300px');
	});
	
	// ESEMÉNYEK
	$('.block:first input[type="button"]:first').click(function(){
		alert(lang.unable_function);
	});
	$('.parcelsearch:first a:first').click(function(){
		$(this).blur();
		alert(lang.unable_function);
	});
	$('.agreethis:first a:first').click(calculator.validate);
	$('#moneytype').change(function(){ priv.system = $(this).val(); });
	$('.pr > sup:first').mouseover(function(){
		$(this).css('cursor', 'help');
		$(this).css('color', 'yellow');
	});
	
	// BLUEBOX INTEGRÁLÁS
	$('.nextride:first div a:first').click(function(){fadeBluebox('.timesheet');});
	$('.lawside:first a:first').click(function(){fadeBluebox('.agreements');});
	$('.lawside:first a:first').next().click(function(){fadeBluebox('.privacy');});
	$('.lawside:first a:first').next().next().click(function(){fadeBluebox('.links');});
	$('#ta1, #ta2').click(function(){fadeBluebox('.services');});
	$('#tb1').click(function(){fadeBluebox('.prizes');});
	$('#tc1, #tc2').click(function(){fadeBluebox('.order');$('.megrendelo:first input:first').select();});
	$('#td1, #td2').click(function(){fadeBluebox('.contact');});
	$('#te1, #te2').click(function(){fadeBluebox('.docs');});
	$('#tf1, #tf2').click(function(){fadeBluebox('.faq');});
	
	// MEGRENDELŐ VALIDÁLÁS
	$('.megrendelo:first a:first').click(function(){
		_ordr = null;
		_ordx = false;
		
		$('.megrendelo:first input:not(:last)').each(function(){
		if($(this).val()=='' && _ordx==false){
			_ordr = $(this);
			_ordx = true;
		}
		if($(this).attr('name')=='megrendelo_mail' && _ordx==false){
			var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
			var testing = filter.test($(this).val());
			if(!testing){
			_ordr = $(this);
			_ordx = true;
			}
		}
		});
		if(_ordr!=null){
			_ordr.select();
			_ordr = null;
			_ordx = false;
		} else{
			if(!$.browser.msie){
			$('.megrendelo:first').animate({opacity:0}, 300, 'swing', function(){
			$(this).css('display', 'none');
			}).next().css('opacity', 0).css('display', 'block').animate({opacity:1}, 300, 'swing', function(){
			$(this).children('div:first').children('input').each(function(){
			if($.trim($(this).val())==''){
				$(this).select();
				return false;
			}
			});
			});
			} else{
			$('.megrendelo:first').css('display', 'none').next().css('display', 'block').children('div:first').children('input').each(function(){
			if($.trim($(this).val())==''){
				$(this).select();
				return false;
			}
			});
			}
		}
	});
	
	// CSOMAGRENDELÉS
	// CSAK SZÁMOK A MEGFELELŐ HELYRE
	$('.csomag:first .pdetail').keypress(function(e){
		var c = (e.which)? e.which : window.event.keyCode;
		if(c<=13){
		return true;
		} else{
		var k = String.fromCharCode(c);
		var r = /[0-9]/
		return r.test(k);
		}
	});
	
	// VALIDÁLÁS
	$('.csomag:first a:last').click(function(){
		_ordr = null;
		_ordx = false;
		
		$('.csomag:first input').each(function(){
		if($(this).val()=='' && _ordx==false){
			_ordr = $(this);
			_ordx = true;
		}
		});
		if(_ordr!=null){
			_ordr.select();
			_ordr = null;
			_ordx = false;
		} else{
			if(!$.browser.msie){
			$('.csomag:first').animate({opacity:0}, 300, 'swing', function(){
			$(this).css('display', 'none');
			}).next().css('opacity', 0).css('display', 'block').animate({opacity:1}, 300, 'swing').children('label').children('input').each(function(){
			if($.trim($(this).val())==''){
				$(this).select();
				return false;
			}
			});
			} else{
			$('.csomag:first').css('display', 'none').next().css('display', 'block').children('input').each(function(){
			if($.trim($(this).val())==''){
				$(this).select();
				return false;
			}
			});
			}
		}
	});
	
	// VISSZA GOMBOK
	$('.csomag:first a:last').prev().prev().click(function(){
		if(!$.browser.msie){
		$('.csomag:first').animate({opacity:0}, 300, 'swing', function(){
		$(this).css('display', 'none');
		}).prev().css('display', 'block').animate({opacity:1}, 300, 'swing');
		} else{
		$('.csomag:first').css('display', 'none').prev().css('display', 'block');
		}
	});
	$('.cimzett:first a:last').prev().prev().click(function(){
		if(!$.browser.msie){
		$('.cimzett:first').animate({opacity:0}, 300, 'swing', function(){
		$(this).css('display', 'none');
		}).prev().css('display', 'block').animate({opacity:1}, 300, 'swing');
		} else{
		$('.cimzett:first').css('display', 'none').prev().css('display', 'block');
		}
	});
	
	// CÍMZETT VALIDÁLÁS
	
	$('.cimzett:first a:last').click(function(){
		_ordr = null;
		_ordx = false;
		
		$('.cimzett:first input:not(:last)').each(function(){
		if($(this).val()=='' && _ordx==false){
			_ordr = $(this);
			_ordx = true;
		}
		if($(this).attr('name')=='cimzett_mail' && _ordx==false){
			var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
			var testing = filter.test($(this).val());
			if(!testing){
			_ordr = $(this);
			_ordx = true;
			}
		}
		});
		if(_ordr!=null){
			_ordr.select();
			_ordr = null;
			_ordx = false;
		} else{
			var implement = 'all='+_unit+'&'+$('form:eq(2)').serialize().replace(/\+cm/g, '').replace(/\+kg/g, '');
			
			$('body').css('cursor', 'wait');
			$.ajax({
			type: 'POST',
			url: 'lib/ajax/order.php',
			data: implement,
			cache: false,
			success: function(data){
				if(data && typeof data=='string'){
				$('body').css('cursor', 'default');
				alert('KÖSZÖNJÜK MEGRENDELÉSÉT!\n\nMunkatársaink hamarosan felveszik Önnel a kapcsolatot\na megadott elérhetőségek valamelyikén!');
				$('form input[type="text"]').each(function(){
				$(this).attr('value', '');
				});
				for(var i=1; i<=calculator.c; i++){
				$('#unit'+i).remove();
				}
				calculator.c = 0;
				$('.csomag:first > div[id!="ord0"]').each(function(){ $(this).remove(); });
				$('.csomag:first > div[id="ord0"] input').each(function(){ $(this).attr('value', ''); });
				$('.achievment:first').animate({ opacity:0, top:'355px' }, 1, 'swing', function(){
				$(this).remove();
				});
				$('.calc:first input, .calc:first select').each(function(){
				$(this).attr('disabled', null);
				_stop = false;
				});
				calculator.a = false;
				calculator.x = false;
				$('#unit0 img').attr('src', 'img/calc_plus.jpg').attr('title', lang.title_new).unbind('click').click(calculator.newline);
				
				$('.bluebox:first, .order:first').css('visibility', 'hidden').css('opacity', 0);
				$('.bluebox:first .megrendelo:first').css('opacity', 1).css('display', 'block');
				$('.bluebox:first .cimzett:first').css('opacity', 0).css('display', 'none');
				} else{
				alert('A SZERVER TÚLTERHELT VAGY NEM ELÉRHETŐ!\n\nA kalkuláció eredménye nem lett elküldve a megadott email címre.\nKérjük próbálja meg később');
				}
			}
			});
		}
	});
	
	// PÁR ÁTALAKÍTÁS MAGAMNAK HOGY A KÓD SZÉP MARADJON
	
	$('.csomag:first input[name="csomag_sulya"]').attr('name', 'csomag_sulya0');
	$('.csomag:first input[name="csomag_szelessege"]').attr('name', 'csomag_szelessege0');
	$('.csomag:first input[name="csomag_magassaga"]').attr('name', 'csomag_magassaga0');
	$('.csomag:first input[name="csomag_melysege"]').attr('name', 'csomag_melysege0');
	$('.csomag:first input[name="csomag_tartalma"]').attr('name', 'csomag_tartalma0');
	$('.csomag:first input[name="csomag_erteke"]').attr('name', 'csomag_erteke0');
	$('.csomag:first a:last').prev().prev().prev().prev().prev().css('color', '#efefef').hover(function(){
		$(this).css({'background' : '#efefef', 'color' : '#4a93eb'});
	}, function(){
		$(this).css({'background' : 'none', 'color' : '#efefef'});
	});
	$('.csomag:first div:first').attr('id', 'ord0');
	$('.csomag:first div:first a:last').click(deleteUnit);
	$('.csomag:first div').css('-moz-border-radius', '5px');
	$('.csomag:first div').css('-webkit-border-radius', '5px');
	
	$('.cimzett:first input[type="radio"]').css({'background' : 'none', 'border' : 'none', 'width' : '15px'});
	if($.browser.msie){ $('.cimzett:first input[type="radio"]').css({'position' : 'relative', 'top' : '8px'}); }
	if($.browser.mozilla){ $('.cimzett:first input[type="radio"]').css({'position' : 'relative', 'top' : '2px'}); }
	
	// BLUEBOX
	
	$('.bluebox, .closer').click(function(){
	$('select').css('visibility','visible');
	$('.timesheet, .agreements, .privacy, .links, .services, .prizes, .order, .contact, .docs, .faq').css({
		'visibility' : 'hidden',
		'border-radius' : '5px',
		'-moz-border-radius' : '5px',
		'-webkit-border-radius' : '5px',
		'overflow-x' : 'hidden'
	});
	$('.bluebox').css({'opacity':0,'visibility':'hidden'});
	});
	
	$('.closer').mouseover(function(){$(this).css('background-position', '0px -27px');}).mouseout(function(){$(this).css('background-position', '0px 0px');});
	$('.splash:first').append('<img src="img/splash_image_hover.jpg" />');
	$('.splash:first img:first').css('opacity',0);
	$('.splash:first').mouseover(function(){$(this).children('img:first').animate({opacity:1},400,'swing');}).mouseout(function(){$(this).children('img:first').animate({opacity:0},400,'swing');}).children('img:first').unbind('mouseover').unbind('mouseout');
	
	// ALMENÜK KÖZÉPRE IGAZÍTÁSA
	
	$('.timesheet, .agreements, .privacy, .links, .services, .prizes, .order, .contact, .docs, .faq').css('left', function(){
		return Math.floor($(document).width()/2)-Math.floor($(this).width()/2);
	});
	$(window).bind('resize', function(){
	$('.timesheet, .agreements, .privacy, .links, .services, .prizes, .order, .contact, .docs, .faq').css('left', function(){
		return Math.floor($(document).width()/2)-Math.floor($(this).width()/2);
	});
	});
	
	// ANIMÁCIÓ ----------------
	
	$('.notepad:first > img:first').css({'position':'relative','top':'-25px'}).parent().css({'z-index':'20000','top':'-505px','left':'210px','opacity':0}).animate({opacity:1,top:'-495px'},1000,'swing');
	$('.notepad:first > div > p:last').append('<br /><a href="javascript:void(0)">Ablak bezárása</a>');
	$('.notepad p:last > a:last').click(postit);
	
	// NEWSPAPER FLASH
	$('.content p').css({'cursor':'default','background-color':'#efefef'}).mouseover(function(){$(this).css({background:'#eaeaea'});}).mouseout(function(){$(this).css({background:'#efefef'});});
	
	// NEWSLETTER
	note_opened = false;
	
	$('.notepad .newsletter:first').hide();
	$('.notepad .newsletter input[type="button"]:first').css('width','171px');
	$('.notepad a:first').click(function(){
	if(note_opened==false){
		$('.notepad a:first').css('text-decoration','underline').blur();
		$('.notepad .newsletter:first').show(200,function(){$('.notepad .newsletter:first input:first').select();});
		note_opened = true;
	} else{
		$('.notepad a:first').css('text-decoration','none').blur();
		$('.notepad .newsletter:first').hide(200);
		note_opened = false;
	}
	});
	$('.notepad .newsletter input[type="button"]:first').click(function(){
		if($.trim($('#newsletter_mail').val())==''){$('.notepad:first input:first').select();} else{
		var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
		var testing = filter.test($('#newsletter_mail').val());
		if(!testing){$('.notepad:first input:first').select();} else{

		newsletter_query = $('form:eq(0)').serialize();

		$.ajax({
		type: 'POST',
		url: 'lib/ajax/newsletter.php',
		data: newsletter_query,
		cache: false,
		success: function(data){
			if(data=='done'){
			alert('KÖSZÖNJÜK HOGY FELIRATKOZOTT HÍRLEVELÜNKRE!\n\nHamarosan értesítjük a továbbiakról a megadott email címen');
			$('.notepad .newsletter').hide(600, postit);
			$('.notepad .newsletter input').each(function(){if($(this).attr('type')!='button'){$(this).attr('value','');}});
			$('.notepad a:first').css('text-decoration','none');
			note_opened = false;
			} else if(data=='has'){
			$('.newsletter input:eq(0)').select();
			} else{
			alert('A SZERVER TÚLTERHELT VAGY NEM ELÉRHETŐ!\n\nA kalkuláció eredménye nem lett elküldve a megadott email címre.\nKérjük próbálja meg később');
			}
		}
		});
		}}
	});
	
	// SCROLLBAR UGRÁLÁS KIKÜSZÖBÖLÉSE
	$('body').css('overflow-y','scroll');
	$('body').css('overflow-x','hidden');
	
	// BLUEBOX MEGRENDELÉS CSS KAVAR GYORS JAVÍTÁSA
	$('.order a').css({'color':'#454545','background':'none'});
	$('.order > form > div > a').mouseover(function(){$(this).css('color','#656565');}).mouseout(function(){$(this).css('color','#454545');});
	$('.csomag:first a:last').prev().prev().prev().prev().prev().css('color','orange').mouseover(function(){$(this).css({'color':'#4a93eb','background':'none'});}).mouseout(function(){$(this).css('color','orange');});
	
	// PRELOAD END
	$('body:first').css('visibility', 'visible');
});
