// IE specifikus HTML[lang=xy] helyett
if ( is.ie ) document.documentElement.className = document.documentElement.getAttribute('lang');

/**
 * oldalak inicializációja
*/
loadEventBinding( window, function() {
	switch ( document.body.id ) {
		case 'view_a_car' : 
			var els = document.getElementById('pg-panels-head').getElementsByTagName('h2'), i, elA, sHref;
			for ( i = 0; i < els.length; i++ ) {
				els[i].onclick = function() {
					if ( alternateStyle.activeSkin == null || alternateStyle.activeSkin.id == 'skin-microsite' ) {
						var els = this.parentNode.getElementsByTagName('h2'), j, k;
						for ( j = 0; j < els.length; j++ ) {
							els[j].className = ( els[j] == this ) ? 'active' : '';
							elA = els[j].getElementsByTagName('a')[0];
							sHref = elA.getAttribute('href');
							if ( sHref.charAt(0) != '#' ) {
								sHref = sHref.substring( sHref.lastIndexOf('#') )
							}
							sHref = sHref.substring( 1 );
							document.getElementById( sHref ).style.display = ( els[j] == this ) ? 'block' : 'none';
						};
					};
					return false;
				};
			};
			/* stílusváltó konfigurálás */
			alternateStyle.setOption('swapFlash', false);
			alternateStyle.setOption('swapJs', false);
			alternateStyle.setOption('swapCss', true);
			alternateStyle.setOption('useChecker', false);
			alternateStyle.setOption('useCookie', false);
			alternateStyle.addAlternate( { css : 'skin-microsite' } );
			alternateStyle.initStyle();
			
			$('.parking-button').click( function( event ) {
				var thisElement = $(this);
				Parking.addEventHandler( event, thisElement );
				return false;
			} );

			break;
		case 'send_info' : 
			proform.initForm('frm_main');
			proform.addGroup( { id : 'group-email', 
								checkElements : [ 'email_from', 'email_to' ],
								checkFunction : function ( oT ) {
									var aReturn = [];
									aReturn.push( proform.condition.required( oT.email_from.value == '', [oT.email_from] ) );
									aReturn.push( proform.condition.required( oT.email_to.value == '', [oT.email_to] ) );
									aReturn.push( proform.condition.warning( oT.email_from.value != '' && !proform.condition.checkFormat( 'email', oT.email_from.value ), [oT.email_from], ['A megadott e-mail formátuma nem megfelelő!'] ) );
									aReturn.push( proform.condition.warning( oT.email_to.value != ''   && !proform.condition.checkFormat( 'email', oT.email_to.value   ), [oT.email_to],   ['A megadott e-mail formátuma nem megfelelő!'] ) );
									return proform.condition.totalize(aReturn);
								}
							  } );
			proform.setConfig( 'submitError', 'A levél elküdéséhez a megkülönböztetett színnel megjelölt mezők helyes kitöltése szükséges.' );
			proform.init();
			break;
		case 'public_bid_search' :
		case 'public_bid_opening' :
			if ( document.getElementById( 'frm_main' ) ) {
				proform.initForm('frm_main');
				proform.addGroup( { id : 'group-filter', 
									checkElements : [ 'mark', 'price_from', 'price_to', 'km_from', 'km_to', 'year_from', 'year_to', 'type', 'ccm_from', 'ccm_to', 'make', 'fuel', 'number_of_doors',
									                  'car_state', 'sales_address', 'car_state', 'categories', 'deadlines' ],
									checkFunction : function ( oT ) {
										var sFormFillerCommand = 'bid-search';
										var sSearchParameters = getSearchParameters(sFormFillerCommand);
										document.getElementById('form_filler').src = 'form_filler.php?form_filler_command=' + sFormFillerCommand + '&' + sSearchParameters;
										return true;
									}
								  } );
				proform.init();
				bPageInited = true;
				break;
			}	
		case 'filter' :
			if ( document.getElementById( 'frm_main' ) ) {
				var filterParams = [ 'mark', 'price_from', 'price_to', 'km_from', 'km_to', 'year_from', 'year_to', 'type', 'ccm_from', 'ccm_to', 'make', 'fuel', 'number_of_doors'];
				if (hasClass(document.getElementsByTagName("body")[0], "SZGK")) {
				    filterParams.push('is_fleet' );
				}
				proform.initForm('frm_main');
				proform.addGroup( { id : 'group-filter', 
									checkElements : filterParams,
									checkFunction : function ( oT ) {
										var sFormFillerCommand = 're-search';
										var sSearchParameters = getSearchParameters(sFormFillerCommand);
										document.getElementById('form_filler').src = 'form_filler.php?form_filler_command=' + sFormFillerCommand + '&' + sSearchParameters;
										return true;
									}
								  } );
				proform.init();
				bPageInited = true;
				break;
			}
		case 'make_an_offer' :
			if ( document.getElementById( 'frm_main' ) ) {
				proform.initForm('frm_main');
				proform.addGroup( { id : 'group-email', 
									checkElements : [ 'email_from', 'offer', 'note', 'user_name', 'make_an_offer_phone_prefix', 'make_an_offer_phone' ],
									checkFunction : function ( oT ) {
										var aReturn = [];
										aReturn.push( proform.condition.required( oT.email_from.value == '', [oT.email_from] ) );
										aReturn.push( proform.condition.warning ( oT.email_from.value != '' && !proform.condition.checkFormat( 'email', oT.email_from.value ), [oT.email_from], ['A megadott e-mail formátuma nem megfelelő!'] ) );
										aReturn.push( proform.condition.required( oT.offer.value == '', [oT.offer] ) );
										aReturn.push( proform.condition.warning ( oT.offer.value != '' && !/^\d*$/.test( oT.offer.value ), [oT.offer], ['A mezőben lévő adat formátuma nem megfelelő!'] ) );
										aReturn.push( proform.condition.required( oT.user_name.value == '', [oT.user_name] ) );
										aReturn.push( proform.condition.warning ( oT.make_an_offer_phone_prefix.value != '' && !/^\d*$/.test( oT.make_an_offer_phone_prefix.value ), [oT.make_an_offer_phone_prefix], ['A mezőben lévő adat formátuma nem megfelelő!'] ) );
										aReturn.push( proform.condition.required( oT.make_an_offer_phone_prefix.value == '', [oT.make_an_offer_phone_prefix] ) );
										aReturn.push( proform.condition.warning ( oT.make_an_offer_phone.value != '' && !/^\d*$/.test( oT.make_an_offer_phone.value ), [oT.make_an_offer_phone], ['A mezőben lévő adat formátuma nem megfelelő!'] ) );
										aReturn.push( proform.condition.required( oT.make_an_offer_phone.value == '', [oT.make_an_offer_phone] ) );
										return proform.condition.totalize(aReturn);
									}
								  } );
				proform.config.autoFocus = false;
				proform.config.errorFocus = false;
				proform.init();
				bPageInited = true;
				break;
			}
		case 'public_otletlada' :
			if ( document.getElementById( 'form-otletlada' ) ) {
				proform.initForm('form-otletlada');
				proform.addGroup( { id : 'group-otletlada', 
									checkElements : [ 'message' ],
									checkFunction : function ( oT ) {
										var aReturn = [];
										aReturn.push( proform.condition.required( oT.message.value == '', [oT.message] ) );
										return proform.condition.totalize(aReturn);
									}
								  } );
				proform.config.autoFocus = false;
				proform.config.errorFocus = false;
				proform.init();
				break;
			}
		case 'financing-calculator' :
			if ( document.getElementById( 'form-financing-calculator' ) ) {
				$('#form-financing-calculator').submit( function() {
					proform.config.alertOnError = false;
					if ( proform.isSendable() ) {
						$('#result p').hide();
						$.post( 'finanszirozasikalkulator.php?format=json', $('#form-financing-calculator').serialize(), function( data ) {
							eval( 'var dataJSON = ' + data );
							if ( 'object' == typeof dataJSON ) {
								if ( !dataJSON.communicationError ) {
									$('#osszeg').html( dataJSON.osszeg );
									$('#thm').html( dataJSON.thm );
									$('#result .proform-help').show();
								}
								else if ( 'undefined' != typeof dataJSON.errorMsg && '' != dataJSON.errorMsg ) {
									$('#result #error-message').html( dataJSON.errorMsg );
									$('#result #error-message').show();
								}
								else {
									$('#result #error').show();
								}
							}
							else {
								$('#result #error').show();
							}
						} );
					}
					proform.config.alertOnError = true;
					return false;
				} );
				$('#ajax-loading').ajaxSend( function() {
					$('#submit_button').css( 'visibility', 'hidden' );
					$(this).show();
				} );
				$('#ajax-loading').ajaxStop( function() {
					$('#submit_button').css( 'visibility', 'visible' );
					$(this).hide();
				} );

				proform.initForm('form-financing-calculator');
				proform.addGroup( { id : 'group-financing-calculator', 
									checkElements : [ 'gyartmany', 'tipus', 'evjarat_ev', 'evjarat_ho', 'vetelar', 'kezdo_befizetes', 'futamido', 'penznem', 'barlista_nem', 'barlista_passziv', 'barlista_aktiv' ],
									checkFunction : function ( oT ) {
										var aReturn = [];
//										aReturn.push( proform.condition.required( 0 == oT.gyartmany.selectedIndex, [oT.gyartmany] ) );
										aReturn.push( proform.condition.required( 0 == oT.tipus.selectedIndex, [oT.tipus] ) );
										aReturn.push( proform.condition.required( 0 == oT.evjarat_ev.selectedIndex, [oT.evjarat_ev] ) );
										aReturn.push( proform.condition.required( 0 == oT.evjarat_ho.selectedIndex, [oT.evjarat_ho] ) );
										aReturn.push( proform.condition.required( oT.vetelar.value == '', [oT.vetelar] ) );
										aReturn.push( proform.condition.warning ( oT.vetelar.value != '' && !/^\d*$/.test( oT.vetelar.value ), [oT.vetelar], ['A vételár formátuma nem megfelelő!'] ) );
										aReturn.push( proform.condition.required( 0 == oT.kezdo_befizetes.selectedIndex, [oT.kezdo_befizetes] ) );
										aReturn.push( proform.condition.required( 0 == oT.futamido.selectedIndex, [oT.futamido] ) );
										aReturn.push( proform.condition.required( 0 == oT.penznem.selectedIndex, [oT.penznem] ) );
										aReturn.push( proform.condition.required( !oT.barlista_nem.checked && !oT.barlista_passziv.checked && !oT.barlista_aktiv.checked, [oT.barlista_nem, oT.barlista_passziv, oT.barlista_aktiv] ) );

										return proform.condition.totalize(aReturn);
									}
								  } );
				proform.config.autoFocus = false;
				proform.config.errorFocus = false;
				proform.init();
				break;
			}
		case 'password_lost' :
			if ( document.getElementById( 'password_lost_form' ) ) {
				proform.initForm('password_lost_form');
				proform.addGroup( { id : 'password_lost_group', 
									checkElements : [ 'email_or_username', 'captcha' ],
									checkFunction : function ( oT ) {
										var aReturn = [];
										aReturn.push( proform.condition.required( '' == oT.email_or_username.value, [oT.email_or_username] ) );
										aReturn.push( proform.condition.required( '' == oT.captcha.value, [oT.captcha] ) );

										return proform.condition.totalize(aReturn);
									}
								  } );
				proform.config.autoFocus = false;
				proform.config.errorFocus = false;
				proform.init();
			}
			break;
		case 'new_password' :
			if ( document.getElementById( 'password_new_form' ) ) {
				proform.initForm('password_new_form');
				proform.addGroup( { id : 'password_new_group', 
									checkElements : [ 'password_new', 'password_new_confirm' ],
									checkFunction : function ( oT ) {
										var aReturn = [];
										aReturn.push( proform.condition.required( '' == oT.password_new.value, [oT.password_new] ) );
										aReturn.push( proform.condition.required( '' == oT.password_new_confirm.value, [oT.password_new_confirm] ) );
										aReturn.push( proform.condition.warning( oT.password_new.value != '' && oT.password_new.value.length < 6 , [oT.password_new], ['A jelszónak minimum 6 karaktert tartalmaznia kell.'] ) );
										aReturn.push( proform.condition.warning( oT.password_new_confirm.value != '' && oT.password_new_confirm.value.length < 6 , [oT.password_new_confirm], ['A jelszónak minimum 6 karaktert tartalmaznia kell.'] ) );
										if ( oT.password_new.value.length >= 6 && oT.password_new_confirm.value.length >= 6 ) {
											aReturn.push( proform.condition.warning(  oT.password_new.value != oT.password_new_confirm.value, [oT.password_new, oT.password_new_confirm], ['A megadott két jelszó nem egyezik meg', 'A megadott két jelszó nem egyezik meg'] ) );
										};

										return proform.condition.totalize(aReturn);
									}
								  } );
				proform.config.autoFocus = false;
				proform.config.errorFocus = false;
				proform.init();
			}
			break;
		case 'public-change-password' :
			if ( document.getElementById( 'form-change-password' ) ) {
				proform.initForm('form-change-password');
				proform.addGroup( { id : 'group-change-password', 
									checkElements : [ 'password_0', 'password_1', 'password_2' ],
									checkFunction : function ( oT ) {
										var aReturn = [];
										aReturn.push( proform.condition.required( '' == oT.password_0.value, [oT.password_0] ) );
										aReturn.push( proform.condition.required( '' == oT.password_1.value, [oT.password_1] ) );
										aReturn.push( proform.condition.required( '' == oT.password_2.value, [oT.password_2] ) );
										aReturn.push( proform.condition.warning( oT.password_1.value != '' && oT.password_1.value.length < 6 , [oT.password_1], ['A jelszónak minimum 6 karaktert tartalmaznia kell.'] ) );
										aReturn.push( proform.condition.warning( oT.password_2.value != '' && oT.password_2.value.length < 6 , [oT.password_2], ['A jelszónak minimum 6 karaktert tartalmaznia kell.'] ) );
										if ( oT.password_1.value.length >= 6 && oT.password_2.value.length >= 6 ) {
											aReturn.push( proform.condition.warning(  oT.password_1.value != oT.password_2.value, [oT.password_1, oT.password_2], ['A megadott két jelszó nem egyezik meg', 'A megadott két jelszó nem egyezik meg'] ) );
										};

										return proform.condition.totalize(aReturn);
									}
								  } );
				proform.config.autoFocus = false;
				proform.config.errorFocus = false;
				proform.init();
			}
			break;
		case 'public_fleet_subscribe' :
			if ( document.getElementById( 'fleet_subscribe_form' ) ) {
				proform.initForm('fleet_subscribe_form');
				proform.addGroup( { id : 'fleet_subscribe_group', 
									checkElements : [ 'name', 'email' ],
									checkFunction : function ( oT ) {
										var aReturn = [];
										aReturn.push( proform.condition.required( '' == oT.name.value, [oT.name] ) );
										aReturn.push( proform.condition.required( '' == oT.email.value, [oT.email] ) );
										aReturn.push( proform.condition.warning ( oT.email.value != '' && !proform.condition.checkFormat( 'email', oT.email.value ), [oT.email], ['A megadott e-mail formátuma nem megfelelő!'] ) );

										return proform.condition.totalize(aReturn);
									}
								  } );
				proform.config.autoFocus = false;
				proform.config.errorFocus = false;
				proform.init();
			}
			break;
		case 'public_bid_search' :
			$('.parking-button').click( function( event ) {
				var thisElement = $(this);
				Parking.addEventHandler( event, thisElement );
				return false;
			} );
			break;
		case 'public_fleet_list' :
			$('.fleet_checkbox').click( function(){
				if ( $(this).is(':checked') ) {
					$(this).parent().parent().parent().addClass('selected');
				}
				else {
					$(this).parent().parent().parent().removeClass('selected');
				}
			} );
			if ( document.getElementById( 'public_fleet_list_form' ) ) {
				proform.initForm('public_fleet_list_form');
				proform.addGroup( { id : 'public_fleet_list_group', 
					checkElements : [ 'offer_price' ],
					checkFunction : function ( oT ) {
						var aReturn = [];
						aReturn.push( proform.condition.required( '' == oT.offer_price.value, [oT.offer_price] ) );
						aReturn.push( proform.condition.warning ( oT.offer_price.value != '' && !/^[\d]*$/.test( oT.offer_price.value ), [oT.offer_price], ['Az Ajánlati ár mező csak egész szám lehet!'] ) );

						return proform.condition.totalize(aReturn);
					}
				  } );
				proform.config.autoFocus = false;
				proform.config.errorFocus = false;
				proform.init();
			}
			break;
	};

	if ( 'function' == typeof $ ) {
		// parkoló függvényei
		$(document).ready( function() {
			// licit oldalon, részletes oldalon megjelenő parkolóba tevő linkek kezelése
			if ( $('body').hasClass('parking') ) {
				$('.parking-button').click( function( event ) {
					var thisElement = $(this);
					Parking.addEventHandler( event, thisElement );
					return false;
				} );
			}
		} );
		
		Parking = {
			// eseménykötés
			addEventHandler: function( event, thisElement ) {
				if ( $('body').hasClass('parking_list') ) {
					Parking.deleteGroup( thisElement.attr('rel'), thisElement );
				}
				else {
					if ( thisElement.hasClass('parking-enabled') ) {
						Parking.sendTo( thisElement.attr('rel'), thisElement );
					}
					else {
						Parking.remove( thisElement.attr('rel'), thisElement );
					}
				}
			},
			// parkolóba helyezés (licit és részletes oldalon)
			sendTo: function( sGroupId, thisElement ) {
				$.get( 'parking.php?operation=add&bid_group_id=' + sGroupId, {}, function( response ) {
					eval( 'var responseJSON = ' + response );
					if ( responseJSON.success ) {
						thisElement.find('span').html('parkolóból eltávolít');
						thisElement.attr('title', 'parkolóból eltávolít');
						thisElement.removeClass('parking-enabled');
						thisElement.addClass('parking-desabled');
					}
				} );
				return false;
			},
			// parkolóból kivétel (licit és részletes oldalon)
			remove: function( sGroupId, thisElement ) {
				$.get( 'parking.php?operation=remove&bid_group_id=' + sGroupId, {}, function( response ) {
					eval( 'var responseJSON = ' + response );
					if ( responseJSON.success ) {
						thisElement.find('span').html('parkolóba helyez');
						thisElement.attr('title', 'parkolóba helyez');
						thisElement.removeClass('parking-desabled');
						thisElement.addClass('parking-enabled');
					}
				} );
				return false;
			},
			// parkolóból kivétel (parkoló oldalán)
			deleteGroup: function( sGroupId, thisElement ) {
				$.get( 'parking.php?operation=remove&bid_group_id=' + sGroupId, {}, function( response ) {
					eval( 'var responseJSON = ' + response );
					if ( responseJSON.success ) {
						thisElement.parents('table:eq(0)').fadeOut('fast', function() {
							thisElement.parents('table:eq(0)').remove();
							});
					}
				} );
				return false;
			}
		}
	}
} );

/**
 * Nyomtatási előnézet
 */
function switchPrinterFriendly( el ) {                      
	var elLink, elLinkPrewiev;
	if ( !el.bState ) {
		el.bState = 'normal';
	};
	if ( el.bState == 'normal' ) {
		// a print CSS-t átnevezzük
		elLink = document.getElementById('skin-print');
		elLink.id = 'skin-print-real';
		// lemásoljuk a print CSS-t, és átalaktjuk screen médiára
		elLinkPrewiev = elLink.cloneNode(true);
		elLinkPrewiev.id = 'skin-print';
		document.getElementsByTagName('head')[0].appendChild( elLinkPrewiev );
		elLinkPrewiev.media = 'screen';
		elLinkPrewiev.rel = 'alternate stylesheet';
		if ( is.gecko ) {
			elLinkPrewiev.sheet.media.appendMedium('screen');
		};
		// váltunk az újonan létrehozott CSS-re
		alternateStyle.addAlternate( { css : 'skin-microsite' } );
		alternateStyle.addAlternate( { css : 'skin-print' } );
		alternateStyle.setActive('skin-print');
		// gomb átalakítása
		el.value = 'vissza a normál verzióhoz'
		el.bState = 'print';
		// nyomtatás link
/*		elPrint = document.createElement('a');
		elPrint.appendChild( document.createTextNode( 'Nyomtatás' ) );
		elPrint.href = '#';
		elPrint.onclick = function() { window.print() };
		elPrint.id = 'etc-printer-friendly-print';
		document.body.insertBefore( elPrint, document.body.firstChild );*/
		document.getElementById('car_data').removeAttribute('style');
		document.getElementById('expert_opinion').removeAttribute('style');
		document.getElementById('dealer_data').removeAttribute('style');
		try {
			window.print();
		}
		catch( e ) {
		}
		return setTimeout( function() { alert(el.bState); return true; }, 2000 );
	}
	else if ( el.bState == 'print' ) {
		// váltunk a nomál css-re
		alternateStyle.setActive('skin-microsite');
		// a preview CSS-t töröljük
		elLinkPrewiev = document.getElementById('skin-print');
		elLinkPrewiev.parentNode.removeChild( elLinkPrewiev );
		// helyreállítjuk a normál print CSS-t
		elLink = document.getElementById('skin-print-real');
		elLink.id = 'skin-print';
		// töröljük a nyomtató gombot
		//document.body.removeChild( document.getElementById('etc-printer-friendly-print' ) );
		// gomb visszaállítása	
		el.value = 'nyomtat'
		el.bState = 'normal';
		document.getElementById('pg-panels-head').getElementsByTagName('h2')[0].className = 'active';
		document.getElementById('pg-panels-head').getElementsByTagName('h2')[1].className = '';
		document.getElementById('pg-panels-head').getElementsByTagName('h2')[2].className = '';
		return true;
	};
};
 
/**
 * új ablak megnyitása
 */
function newWindow( sURL, sWindowName, nWidth, nHeight, sScroll, sResize ) {
	win = null;
	nLeftPosition = ( screen.width ) ? ( screen.width - nWidth ) / 2 : 0;
	nTopPosition = ( screen.height ) ? ( screen.height - nHeight) / 2 : 0;
	sSettings = 'height=' + nHeight + ',width=' + nWidth + ',top=' + nTopPosition + ',left=' + nLeftPosition + ',scrollbars=' + sScroll + ',resizable=' + sResize
	win = window.open( sURL, sWindowName, sSettings );
};

var imageChange = {
	set : function() {
		var els = document.getElementById('pg-panel').getElementsByTagName('img'), i, el;
		imageChange.state = imageChange.state == 1 ? 0 : 1;
		for ( i = 0; i < els.length; i++ ) {
			//if ( /image_/.test( els[i].src ) ) {
				//els[i].src = els[i].src.replace( /image_small|image_big/, imageChange.state == 0 ? 'image_small' : 'image_big' );
			if ( /car_/.test( els[i].src ) ) {
				// ezek lettek az új URL-ek
				// http://w3.local.marsnet.hu/~teecee/lombard.microsite/file/cars/car_th_110.jpg
				// http://w3.local.marsnet.hu/~teecee/lombard.microsite/file/cars/car_110.jpg
				els[i].src = els[i].src.replace( /car_th_|car_/, imageChange.state == 0 ? 'car_th_' : 'car_' );
				els[i].className = imageChange.state == 0 ? '' : 'big';
				els[i].width = imageChange.state == 0 ? 64 : 266;
				els[i].height = imageChange.state == 0 ? 48 : 199;
 			};
			// sor eltűntetése
/*			if ( imageChange.state == 1 ) {
				els[i].parentNode.parentNode.parentNode.cells[0].colSpan = 2;
				imageChange.temp.push( els[i].parentNode.parentNode.parentNode.cells[1].cloneNode(true) );
				els[i].parentNode.parentNode.parentNode.removeChild( els[i].parentNode.parentNode.parentNode.cells[1] );
			}
			else {
				els[i].parentNode.parentNode.parentNode.cells[0].colSpan = 1;
				els[i].parentNode.parentNode.parentNode.insertBefore( imageChange.temp[i], els[i].parentNode.parentNode.parentNode.cells[1] )
			};*/
		};

		this.sendState();

		/* public_windowheight.js szükséges hozzá */
		setFooter();
	},
	// Ez elküldi a kép aktuális állapotát, az xml_http_request_server.php meg elmenti session-ba :)
	sendState : function() {
		var oRequest;
		oRequest = new XMLHttpRequest();
		oRequest.open( 'GET', 'xml_http_request_server_other.php?command=setImageSize&size=' + this.state, true );
		oRequest.send( null );
	},
	temp : [],
	state : 0 // 0 = small; 1 = big
};


// FlashCheck
flash.getFlashCheck( 7.00, function() { 
//			window.location.replace('../browser_scripting_error.html');
}, function() {} );

// browser check
/*if ( !is.bs5 ) {
	window.location.replace('../browser_scripting_error.html');
}*/

/* kiegészítések 2008-11-21 */
/* public.js */

// IE specifikus HTML[lang=xy] helyett
if ( is.ie ) document.documentElement.className = document.documentElement.getAttribute('lang');

/* _lib.js-ből kiemelve ottani függvény teljes másolata; Opera9 csak így volt hajlandó betölteni a függvényt */
/**
 * $ getViewport.js,v 1.5 2005/01/03 13:22:09 gyuris Exp $
 * @package  lib.getViewport
 * @author   Gyuris Gellért
 * @see      browserCheck
 */
/**
 * getViewport - visszaaja a tartalomban rendelkezésre álló terület a görgetősávok NÉLKÜL.
 * XXX - át kell alakítani MINDEN böngészőre egyenként és külön a css1compat és az backcompat||quirksmode
 * @return Object  Az adatokat tartalmazó értékek számmal.
 */
function getViewport() {
	var nWidth, nHeight, nScollTop, nScollHeight;
	if ( is.compatMode == 'css1compat' ) {
		if ( is.ie7 || is.ie6 || is.geckoRv >= 1.5 || ( is.opera && is.appVer >= 7 ) ) {
			nWidth = document.documentElement.clientWidth;
			nHeight = document.documentElement.clientHeight;
			nScollTop = document.documentElement.scrollTop;
			nScollHeight = document.documentElement.scrollHeight;
		};
		if ( is.opera && is.appVer >= 7 ) {
			nHeight = window.innerHeight //document.documentElement.clientHeight;
		};
		if ( is.gecko ) {
			nWidth = ( document.body.scrollWidth >= document.body.clientWidth ) ? document.body.clientWidth : window.innerWidth;
			nHeight = ( document.body.scrollHeight >= document.body.clientHeight ) ? document.body.clientHeight : window.innerHeight;
			if ( is.geckoRv >= 1.7 ) {
				nWidth = ( document.documentElement.scrollWidth >= document.documentElement.clientWidth ) ? document.documentElement.clientWidth : window.innerWidth;
				nHeight = ( document.documentElement.scrollHeight >= document.documentElement.clientHeight ) ? document.documentElement.clientHeight : window.innerHeight;
			}
			nScollTop = window.scrollY;
			nScollHeight = document.documentElement.scrollHeight;
		};
	}
	else {
		if ( is.ie ) {
			nWidth = document.body.clientWidth;
			nHeight = document.body.clientHeight;
			nScollTop = document.body.scrollTop;
			nScollHeight = document.body.scrollHeight;
		}
		else if ( is.khtml ) {
			nWidth = window.innerWidth;
			nHeight = window.innerHeight;
		}
		else if ( is.bss ) {
			nWidth = ( document.body.scrollWidth >= document.body.clientWidth ) ? document.body.clientWidth : window.innerWidth;
			nHeight = ( document.body.scrollHeight >= document.body.clientHeight ) ? document.body.clientHeight : window.innerHeight;
			nScollTop = window.scrollY;
			nScollHeight = document.documentElement.scrollHeight;
		};
		if ( ( is.opera && is.appVer >= 7 ) || is.khtml ) {
			nScollTop = document.documentElement.scrollTop;
			nScollHeight = document.documentElement.scrollHeight;
		};
	};
	// kompatibilitás miatt
	window.strictInnerWidth   = nWidth;
	window.strictInnerHeight  = nHeight;
	window.strictScrollTop    = nScollTop;
	window.strictScrollHeight = nScollHeight;
	return { width        : nWidth,
			 height       : nHeight,
			 scrollTop    : nScollTop,
			 scrollHeight : nScollHeight };
};

/* az oldalmagasság beállítása részben css-ből, ill. a public_windowheight.js segítségével történik */
var pageHeight = {
	nPlusHeight: 169 + 36, /* fölös magasság */
	init: function() {
		var elContent =	document.getElementById('pg-content'),
			elLeft = document.getElementById('level-0-left') || document.getElementById('level-1-left') || document.getElementById('level-2-left') || document.getElementById('level-3-left') || document.getElementById('pg-panel-progress'),
			elRight = document.getElementById('level-0-right') || document.getElementById('level-1-right') || document.getElementById('level-1-left') || document.getElementById('level-2-left') || document.getElementById('level-3-left') || document.getElementById('pg-panel-progress'),
			elHeaddata = document.getElementById('pg-headdata') || document.getElementById('level-1-text') || null,
			windowDim = getViewport();
		
		if ( windowDim.height > elLeft.offsetHeight + pageHeight.nPlusHeight && windowDim.height > elRight.offsetHeight + pageHeight.nPlusHeight && ( ( elHeaddata && windowDim.height > elHeaddata.offsetHeight + pageHeight.nPlusHeight + 66  ) || ( windowDim.height > elContent.offsetHeight && !elHeaddata ) ) ) {
			elContent.style.height = windowDim.height - pageHeight.nPlusHeight + 'px';
		}
		else if ( elLeft.offsetHeight > elRight.offsetHeight ) {
			if ( elLeft.offsetHeight + pageHeight.nPlusHeight > elContent.offsetHeight ) {
				elContent.style.height = elLeft.offsetHeight + 12 + 'px';
			} 
		}
		else {
			if ( elRight.offsetHeight + pageHeight.nPlusHeight > elContent.offsetHeight ) {
				elContent.style.height = elRight.offsetHeight + 12 + 'px';
			}
		}
	}
}

loadEventBinding( window, function() {
//	elWrapper = document.getElementById('pg-wrapper'), nContentHeight = elWrapper ? elWrapper.offsetHeight : 0;
/*	if ( !hasClass( document.getElementsByTagName('body')[0], 'admin' ) ) {
		pageHeight.init();
	}*/
} );

eventBinding( window, 'true', 'resize', function() {
/*	if ( !hasClass( document.getElementsByTagName('body')[0], 'admin' ) ) {
		pageHeight.init();
	}*/
}, 'true' );

