function gt(ezt) {
	vissza = document.getElementById(ezt);
	return vissza;
}

function correctPNG() {
	// correctly handle PNG transparency in Win IE 5.5 & 6.
	var arVersion = navigator.appVersion.split("MSIE")
	var version = parseFloat(arVersion[1])
	if ( (version >= 5.5) && ( document.body.filters ) ) {
			for ( var i = 0; i < document.images.length; i++ ) {
				var img = document.images[i]
				var imgName = img.src.toUpperCase()
				if ( imgName.substring( imgName.length-3, imgName.length ) == "PNG" ) {
						var imgID = (img.id) ? "id='" + img.id + "' " : ""
						var imgClass = (img.className) ? "class='" + img.className + "' " : ""
						var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
						var imgStyle = "display:inline-block;" + img.style.cssText
						if (img.align == "left") imgStyle = "float:left;" + imgStyle
						if (img.align == "right") imgStyle = "float:right;" + imgStyle
						if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
						var strNewHTML = "<span " + imgID + imgClass + imgTitle
						+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
						+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
						+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
						img.outerHTML = strNewHTML
						i = i-1
				}
			}
	}
}


function expandCollapse( ezt ) {
	if ( gt(ezt).style.display == 'block' ) {
		gt(ezt).style.display='none';
	}
	else {
		gt(ezt).style.display='block';
	}
}

function stepNext( finish_txt, next_txt ) {
	var page = gt('step').value;
	gt( 'prewbutton' ).style.display = 'block';

	if ( page < 9 ) {
		if ( gt( 'general' ).value < 4 && page == '5' ) {
			gt( 'step' ).value = ( page * 1 ) + 2;
		}
		else{
			gt( 'step' ).value = ( page * 1 ) + 1;
		}
		gt( 'to_do' ).value = '';
		Post.Errorcheck( gt( 'recomform' ) );
	}
	if ( page == '7' || page == '8' ) {
		gt( 'nextbutton' ).value = finish_txt;
	}
	else{
		gt( 'nextbutton' ).value = next_txt;
	}

	gt( 'steppermenu' ).style.display = 'block'
	if ( page == '8' ) {
		gt( 'recom_endbutton' ).style.display = 'none';
		gt( 'recom_nextbutton' ).style.display = 'none';
		gt( 'recom_closebutton' ).style.display = 'block';
	}
	else {
		gt( 'recom_endbutton' ).style.display = 'block'
		gt( 'recom_nextbutton' ).style.display = 'block';
		gt( 'recom_closebutton' ).style.display = 'none';
	}
	return false;
}

function sendOuterEmails() {
	var outerMails = gt('outer_addresses').value;

}

function stepPrew( finish_txt, next_txt ) {
	var page = gt('step').value;
	if ( page == recomStepOrder[2] ) {
		gt('prewbutton').style.display = 'none';
	}
	else {
		gt('prewbutton').style.display = 'block';
	}
	// TODO: page > 1 helyett: in array && != recomStepOrder[1]
	if ( page > 1 ) {
		if ( gt('general').value < 4 && page == '7' ) {
			gt('step').value = ( page * 1 ) - 2;
		}
		else {
			gt('step').value= ( page * 1 ) - 1;
		}
		gt('to_do').value = '';
		Post.Errorcheck( gt('recomform') );
	}
	if ( page == recomStepOrder[9] ) {
		gt( 'nextbutton' ).value = finish_txt;
		gt( 'recom_endbutton' ).style.display = 'block'
		gt( 'recom_nextbutton' ).style.display = 'block';
		gt( 'recom_closebutton' ).style.display = 'none';
	}
	else {
		gt('nextbutton').value = next_txt;
	}

	gt('steppermenu').style.display='block'

	return false;
}

function stepto( page, finish_txt,next_txt ) {
	if ( page == recomStepOrder[1] ) {
		gt('prewbutton').style.display = 'none';
	}
	else {
		gt('prewbutton').style.display = 'block';
	}
	gt('to_do').value = '';

	gt('step').value = page;
	Post.Errorcheck( gt('recomform') );
	if ( page == recomStepOrder[8] ) {
		gt('nextbutton').value = finish_txt;
	}
	else {
		gt('nextbutton').value = next_txt;
	}
	return false;
}

function countchar(ezt, event) {
	var keycode;
	var maxlimit = 255;

	keycode = event.keyCode? event.keyCode : event.charCode;

		var ertek;
		var ujstr;
		ujstr='';
		ertek = ezt.value;
		hossz = ertek.length;
		gt('charcount').value = ( maxlimit - hossz );
		if ( hossz > maxlimit ) {
			ujstr = ertek.substring( 0, maxlimit );
		ezt.value = ujstr;
		}
		if ( hossz > ( maxlimit - 10 ) ) {
			gt('charcount').style.color='red';
			gt('charcount').style.fontWeight='bold';
		}
		else{
			gt('charcount').style.color='#000000';
			gt('charcount').style.fontWeight='normal';
		}

}

function refreshTimer() {
	var time_down;
	var time_up;
	var minutes;

	// leallitja a rekurziv hivasokat, ha lezarjuk az ertekelot, igy nem ketyeg ossze-vissza az ora ha tobbet nyit egymas utan
	if ( gt('timerdown') ) {
		if ( gt('closewindow') ) {
			//alert('be kene zarni az ablakot!');
		}
		if ( gt('timerup') ) {
			time_up = gt('timerup').value = ( gt('timerup').value * 1 ) + 1;
		}
		if ( gt('timerdown') ) {
			time_down = gt('timerdown').value = ( gt('timerdown').value * 1 ) - 1;
		}
		if ( time_up <= 180 ) {
			minutes = Math.floor( time_down / 60 );
			seconds = ( minutes * 60 - time_down ) * -1;
		}
		else{
			minutes = Math.floor( time_up / 60 );
			seconds = ( time_up - minutes * 60 );
		}
		if ( gt('realtime') ) {
			gt('realtime').innerHTML = minutes + ':' + seconds;
		}
		setTimeout("refreshTimer()", 1000);
	}
}

function enterkey() {
	if ( enter_pressed( event ) ) {
			gt('similarfilter').value = gt('simfil').value;
			Post.Send(gt('similarform'));
	}

}

function enter_pressed( e ){
	var keycode;
	if ( window.event ) {
		keycode = window.event.keyCode;
	}
	else if ( e ) {
		keycode = e.which;

	}
	else {
		return false;
	}
	return ( keycode == 13 );
}