function openpopup( url, w, h, wn )
{
	l = (screen.width/2)  - (w/2);
	t = (screen.height/2) - (h/2);

	win1 = window.open( url, wn, 'left='+l+', top='+t+', width='+w+', height='+h+', status=no, toolbar=no, menubar=no, resizable=yes, scrollbars=yes' );
}

function openpopup2( url, w, h, wn )
{
	l = (screen.width/2)  - (w/2);
	t = (screen.height/2) - (h/2);

	win1 = window.open( url, wn, 'left='+l+', top='+t+', width='+w+', height='+h+', status=no, toolbar=no, menubar=no, resizable=yes, scrollbars=no' );
}

function redirectself( url )
{
	self.location = url;
}

function redirectblank( url, wn )
{
	w = screen.width;
	h = screen.height;

	win1 = window.open( url, wn, 'width='+w+', height='+h+'status=yes, toolbar=yes, location=yes, menubar=yes, resizable=yes, scrollbars=yes' );
}

function js_select_all(id)
{
	w_el = document.getElementById(id);
	for( i = 0; i < w_el.length; i++ )
	{
		w_el[i].selected = 1;
	}
}

function js_deselect_all(id)
{
	w_el = document.getElementById(id);
	for( i = 0; i < w_el.length; i++ )
	{
		w_el[i].selected = 0;
	}
}

function js_select_switch( f )
{
	checked = true;
	for (i = 0; i < f.length; i++)
	{
		if( f.elements[i].checked == 0 )
		{
			checked = false;
		}
	}

	if( checked == false )
	{
		for (i = 0; i < f.length; i++)
		{
			f.elements[i].checked = 1;
		}
	}

	if( checked == true )
	{
		for (i = 0; i < f.length; i++)
		{
			f.elements[i].checked = 0;
		}
	}
}

// TEXT CHECK FUNCTIONS
function CheckEmailField( text )
{
	return (text.search( /^\w+([\.\-]*\w+)*@\w+([\.\-]*\w+)*(\.\w{2,4})+$/ ) == -1) ? true : false;
}

function CheckNameField( text )
{
	return (text.search( "^[a-zA-Z_ 0-9\-]*$" ) == -1) ? true : false;
}

function CheckNumberField( text )
{
	return (text.search( "^[0-9]+$" ) == -1) ? true : false;
}

function MyFindEmail( text )
{
	return (text.search( /\w+([\.-]*\w+)*@\w+([\.-]*\w+)*(\.\w{2,4})+/ ) == -1) ? false : true;
}

function MyFindUrl( text )
{
	return (text.search( /((https?:\/\/)|(www\.))\w+([\.-]?\w+)*(\.\w{2,4})+/i ) == -1) ? false : true;
}

// MULTI_LANG FUNCTIONS
function ChangeLang()
{
	var lang_str = document.getElementById( 'lang' ).value;
	redirectself( '/' + lang_str + '/?reload=1' );
	return false;
}

// CHAT INVITE FUNCTIONS
function OpenInviteTicket( used_lang, my_name_p, layer, layer_id, layer_name, chat_type_layer )
{
	_open_url_user = document.getElementById( layer_name ).innerHTML;
	_open_url_id = document.getElementById( layer_id ).innerHTML;
	my_name = document.getElementById( my_name_p ).innerHTML;

	chat_type = document.getElementById( chat_type_layer ).innerHTML;
	if( chat_type == 'm' )
	{
		chat_type_prg = 'messengerAccept';
	}
	else if( chat_type == 'c' )
	{
		chat_type_prg = 'communicatorAccept';
	}
	else
	{
		chat_type_prg = 'messengerAccept';
	}

	document.getElementById( layer ).style.top = -100;
	//document.getElementById('chat_updater_iframe').src = '/chat_decline.php?id=' + _open_url_id;
    openFChatWindow( my_name, _open_url_user, '/' + used_lang + '/premium/' + chat_type_prg + '/' + _open_url_id, 'user_name=' + my_name + '&id=' + _open_url_id, chat_type );
}

function CloseInviteTicket( layer, url_id, url_name, chat_type_layer )
{
	document.getElementById( layer ).style.top = -100;
	_open_url_user = document.getElementById( url_name ).innerHTML;
	_open_url_id = document.getElementById( url_id ).innerHTML;
	document.getElementById('chat_updater_iframe').src = '/chat_decline.php?a=decline&id=' + _open_url_id + '&name=' + _open_url_user;
}

function _openFChatWindow(url, name, width, height, noresize)
{
    name = name.replace(/[^\w\d]/, "_");
    name = name.replace(/undefined/, "_");

	var left = Math.round((screen.width - width) / 2);
	var top = Math.round((screen.height - height) / 2);
	var styleStr = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no";
	styleStr += ",resizable=" + (noresize ? "no" : "yes");
	styleStr += ",width=" + width	+ ",height=" + height;
	styleStr += ",left=" + left + ",top=" + top;
	styleStr += ",screenX=" + left + ",screenY=" + top;

	window.open(url, name, styleStr);
}

function openFChatWindow( receiver, sender, url, updater_url, chat_type )
{
	if( chat_type == 'm' )
	{
		var name = "messenger_" + receiver + "_" + sender;
		document.getElementById('chat_updater_iframe').src = '/chat_updater.php?' + updater_url;
		_openFChatWindow(url, name, 400, 310);
	}
	else if( chat_type == 'c' )
	{
		var name = "communicator_" + receiver + "_" + sender;
		document.getElementById('chat_updater_iframe').src = '/chat_updater.php?' + updater_url;
		_openFChatWindow(url, name, 597, 251, true);
	}
	else
	{
		var name = "messenger_" + receiver + "_" + sender;
		document.getElementById('chat_updater_iframe').src = '/chat_updater.php?' + updater_url;
		_openFChatWindow(url, name, 400, 310);
	}
}

function inviteFChatWindow( url, chat_type )
{
	sender = document.getElementById('my_community_name').innerHTML;
	var uid = document.getElementById('invited_uid').value;
	var receiver = document.getElementById('invited_uname').value;
	if( uid && receiver )
	{
		openFChatWindow( receiver, sender, url + '/' + uid, 'user_name=' + sender, chat_type );
	}
}

function inviteFChatWindowDirect( url, uid, receiver, chat_type )
{
	sender = document.getElementById('my_community_name').innerHTML;
	if( uid && receiver )
	{
		openFChatWindow( receiver, sender, url + '/' + uid, 'user_name=' + sender, chat_type );
	}
}

function _openVideoChatWindow( url )
{
	sender = document.getElementById('my_community_name').innerHTML;
	var name = "videochat_" + sender;
	_openFChatWindow(url, name, 740, 480);
}

// HIDE/SHOW FUNCTIONS
function ShowComments( id )
{
	document.getElementById('view_comments').style.display = 'none';
	document.getElementById('hide_comments').style.display = 'none';
	document.getElementById('loading_comments').style.display = '';

	x_ReturnAllComments( id, setCommentsText );
}

function ShowComments2( id )
{
	document.getElementById('view_comments').style.display = 'none';
	document.getElementById('hide_comments').style.display = 'none';
	document.getElementById('loading_comments').style.display = '';

	x_ReturnAllComments2( id, setCommentsText );
}

function setCommentsText( text )
{
	document.getElementById('all_comments_text').innerHTML = text;
	document.getElementById('all_comments_text').style.display = '';

	document.getElementById('view_comments').style.display = 'none';
	document.getElementById('loading_comments').style.display = 'none';
	document.getElementById('hide_comments').style.display = '';
}

function HideComments()
{
	document.getElementById('all_comments_text').style.display = 'none';
	document.getElementById('all_comments_text').innerHTML = '';

	document.getElementById('view_comments').style.display = '';
	document.getElementById('loading_comments').style.display = 'none';
	document.getElementById('hide_comments').style.display = 'none';
}

function RefreshComments( id )
{
	document.getElementById('all_comments_text').style.display = 'none';
	document.getElementById('all_comments_text').innerHTML = '';

	document.getElementById('view_comments').style.display = 'none';
	document.getElementById('hide_comments').style.display = 'none';
	document.getElementById('loading_comments').style.display = '';

	x_ReturnAllComments( id, setCommentsText );
}

function RefreshComments2( id )
{
	document.getElementById('all_comments_text').style.display = 'none';
	document.getElementById('all_comments_text').innerHTML = '';

	document.getElementById('view_comments').style.display = 'none';
	document.getElementById('hide_comments').style.display = 'none';
	document.getElementById('loading_comments').style.display = '';

	x_ReturnAllComments2( id, setCommentsText );
}

function ShowSpitzblitz( id )
{
	document.getElementById(id).style.left = mousex + 10;
	document.getElementById(id).style.top = mousey + 25;
	document.getElementById(id).style.visibility = 'visible';
}

function HideSpitzblitz( id, timeout )
{
	document.getElementById(id).style.visibility = 'hidden';
}

// COMMENTS FUNCTIONS
function ReportComment( id, url, reply )
{
	try
	{
		var req = new JsHttpRequest();
		req.onreadystatechange = function()
		{
			if( req.readyState == 4 )
			{
				if( req.responseText )
				{
				}
			}
		}

		req.caching = false;
		u = url;
	 	req.loader = 'script';
	 	req.open('GET',u,true);
	 	req.send({});

	 	document.getElementById('cmt_record_'+id).innerHTML = reply;
 	}
 	catch(e)
 	{}
}

function ReportComment2(url, response_element)
{
	if ( ov_close )
	{
		ov_close();
	}
	$.post(url,'fmt=jquery',function(data) {
			var elem = document.getElementById(response_element);
			if ( elem )
			{
			    if ( data.status == 'OK' )
			    {
				    if ( data.msg )
				    {
						if ( elem.value )
						{
							// store the result in an input element
							elem.value = data.msg;
							elem.disabled = true;
						}
						else
						{
							elem.innerHTML = data.msg;
						}
					}
					else
					{
						$(elem).remove();
					}
				}
				else
				{
					alert(data.msg);
				}
			}
			else
			{
			    alert(data.msg);
			}
		},'json'
	);
}


// USERS FRIEND INVITES FUNCTIONS
function InviteApprove( id )
{
	document.getElementById('invite_res_'+id).innerHTML = document.getElementById('send_request_text').innerHTML;
    document.getElementById('invite_res_'+id).style.display = '';

    x_InvitesAct( id + ',1', _InvitesAct );
}

function InviteDecline( id )
{
    document.getElementById('invite_res_'+id).innerHTML = document.getElementById('send_request_text').innerHTML;
    document.getElementById('invite_res_'+id).style.display = '';

    x_InvitesAct( id + ',0', _InvitesAct );
}

function _InvitesAct( id )
{
	if( id > 0 )
	{
		document.getElementById('invite_res_'+id).style.display = 'none';
		document.getElementById('invite_'+id).style.display = 'none';

		var records_count = parseInt( document.getElementById('records_count').innerHTML );
        records_count--;
        document.getElementById('records_count').innerHTML = records_count;

        if( records_count == 0 )
        {
        	redirectself( empty_redirect_url );
        }
	}
	else
	{
		document.getElementById('invite_res_'+id).innerHTML = document.getElementById('request_error_text').innerHTML;
        document.getElementById('invite_res_'+id).style.display = '';
	}
}

// TOOLTIP FUNCTIONS
function ShowTooltip( id )
{
	if( mousex - 30 < 0 )
	{
		xx = 5;
	}
	else
	{
		xx = mousex - 30;
	}
	document.getElementById(id).style.left = xx;
	document.getElementById(id).style.top = mousey + 15;
	document.getElementById(id).style.visibility = 'visible';
}

function HideTooltip( id, timeout )
{
	document.getElementById(id).style.visibility = 'hidden';
}

// REG CHECK/SUGGEST NICKNAME
function CheckNameFree()
{
	nickname = document.getElementById('n_login').value;
	if( nickname == '' || nickname.length < 4 )
	{		return false;
	}

	document.getElementById('login_suggest').style.display = 'none';
	x_CheckNickname( nickname, completeNicknameCheck );
}

function completeNicknameCheck( text )
{
	if( text != '' )
	{
		document.getElementById('login_suggest').innerHTML = text;
		document.getElementById('login_suggest').style.display = '';
	}
}

function PutNickname( name )
{
	document.getElementById('n_login').value = name;
}

// JS PROMT EXPLAIN
function ExplainAction( url, question )
{
	descr = prompt( question, "" );
	if( descr !== null )
	{
		location.href = url + '?s_reason=' + descr;
	}
}

function ConfirmExplainAction( url, question, confirm_quest, needconfirm )
{
	confirmed = needconfirm ? confirm( confirm_quest ) : true;
	if( confirmed )
	{
		descr = prompt( question, "" );
		if( descr !== null )
		{
			location.href = url + '?s_reason=' + descr;
		}
	}
}

function ExplainFormAction( url, question )
{
	descr = prompt( question, "" );
	if( descr !== null )
	{
		document.forms[0].action = url + '?s_reason=' + descr;
		document.forms[0].submit();
	}
}

function ExplainBan( url, question1, question2 )
{
	descr = prompt( question1, "" );
	days = prompt( question2, 0 );

	if( descr !== null && days !== null )
	{
		location.href = url + '?s_reason=' + descr + '&i_days=' + days;
	}
}

function ExplainFormBan( url, question1, question2 )
{
	descr = prompt( question1, "" );
	days = prompt( question2, 0 );

	if( descr !== null && days !== null )
	{
		document.forms[0].action = url + '?s_reason=' + descr + '&i_days=' + days;
		document.forms[0].submit();
	}
}

// SHOW/HIDE MESSAGES FUNCTIONS
function MarkMessage( id )
{
	x_MarkMessage( id, _MarkMessage );
}

function UnmarkMessage( id )
{
    x_UnmarkMessage( id, _UnmarkMessage );
}

function _MarkMessage( res )
{
    if( res )
	{
		document.getElementById( 'mark' + res ).style.display = 'none';
		document.getElementById( 'unmark' + res ).style.display = '';
		document.getElementById( 'mark_img' + res ).style.display = '';
		if ( document.getElementById( 'mark2_'+res ) )
		{
			document.getElementById( 'mark2_' + res ).style.display = 'none';
			document.getElementById( 'unmark2_' + res ).style.display = '';
		}
	}
}

function _UnmarkMessage( res )
{
	if( res )
	{
		document.getElementById( 'mark' + res ).style.display = '';
		document.getElementById( 'unmark' + res ).style.display = 'none';
		document.getElementById( 'mark_img' + res ).style.display = 'none';
		if (document.getElementById( 'mark2_'+res) )
		{
			document.getElementById( 'mark2_' + res ).style.display = '';
			document.getElementById( 'unmark2_' + res ).style.display = 'none';
		}
	}
}

function MsgInform( text )
{
	alert( text );
}

function ShowFullMessageText( num, msg_blocked, msg_text )
{
	if( !msg_blocked )
	{
		x_getFullMessageText( num, _ShowFullMessageText );
	}
	else
	{
		MsgInform( msg_text );
	}
}

function _ShowFullMessageText( data )
{
	data[1] = data[1].replace( /\\\"/gim, "\"" );
	data[1] = data[1].replace( /\\\'/gim, "'" );

	document.getElementById( 'show_el' + data[0] ).style.display = 'none';
	document.getElementById( 'show_el2' + data[0] ).style.display = 'none';
	document.getElementById( 'text_el' + data[0] ).innerHTML = data[1];
	document.getElementById( 'text_el' + data[0] ).style.display = '';
	document.getElementById( 'hide_el' + data[0] ).style.display = '';
}

function HideFullMessageText( num )
{
	document.getElementById( 'show_el' + num ).style.display = '';
	document.getElementById( 'show_el2' + num ).style.display = '';
	document.getElementById( 'text_el' + num ).innerHTML = '';
	document.getElementById( 'text_el' + num ).style.display = 'none';
	document.getElementById( 'hide_el' + num ).style.display = 'none';
}

// FORM HANDLE FUNCTIONS
function ConfirmFormAction( f, ac, msg, needconfirm )
{
	var is_sel = 0;
	for (i = 0; i < f.length; i++)
	{
		if( f.elements[i].checked == 1 )
		{
			is_sel = 1;
		}
	}

	if( is_sel == 0 )
	{
		//alert( 'Please, select the data to work with' );
	}
	else
	{
		confirmed = needconfirm ? confirm( msg ) : true;
		if( confirmed )
		{
			f.action = ac;
			f.submit();
		}
	}
}

function ConfirmTextAction( loc, msg, needconfirm )
{
	confirmed = needconfirm ? confirm( msg ) : true;
	if( confirmed )
	{
		self.location = loc;
	}
}

function ImitateFormSubmit( ac, form_name )
{
	document.getElementById(form_name).action = ac;
	document.getElementById(form_name).submit();
}

// STORY FUNCTIONS
function ShowFullStoryText( num )
{
	x_getFullStoryText( num, _ShowFullStoryText );
}

function _ShowFullStoryText( data )
{
	//data[1] = data[1].replace( /\\\"/gim, "\"" );
	//data[1] = data[1].replace( /\\\'/gim, "'" );

	document.getElementById( 'show_el' + data[0] ).style.display = 'none';
	document.getElementById( 'text_el' + data[0] ).innerHTML = data[1];
	document.getElementById( 'text_el' + data[0] ).style.display = '';
	document.getElementById( 'hide_el' + data[0] ).style.display = '';
}

function HideFullStoryText( num )
{
	document.getElementById( 'show_el' + num ).style.display = '';
	document.getElementById( 'text_el' + num ).innerHTML = '';
	document.getElementById( 'text_el' + num ).style.display = 'none';
	document.getElementById( 'hide_el' + num ).style.display = 'none';
}

// USERS FUNCTIONS
function ShowNewPersonForm()
{
	document.getElementById('add_new_person').style.display='';
	document.getElementById('show_el').style.display='none';
	document.getElementById('hide_el').style.display='';
}

function HideNewPersonForm()
{
    document.getElementById('add_new_person').style.display='none';
    document.getElementById('show_el').style.display='';
    document.getElementById('hide_el').style.display='none';
}

function ShowDisableText( el )
{
	if( el.value == -1 )
	{
		document.getElementById('default_days').style.display = '';
	}
	else
	{
		document.getElementById('default_days').style.display = 'none';
	}
}

function ChangeCountryRegions( country_id )
{
	country_val = document.getElementById(country_id).value;
	x_getCountryRegions( country_val, _ChangeCountryRegions );
}

function _ChangeCountryRegions( regions )
{
	var box_el = document.getElementById( 'i_region' );
	var del_size = box_el.length;

	if( del_size > 0 && box_el.options[0].value == '0' )
	{
		start_del = 1;
	}
	else
	{
		start_del = 0;
	}

	for( j = 0; j < del_size - start_del; j++ )
	{
		box_el.remove(start_del);
	}

	if( regions == 0 )
	{
		document.getElementById( 'country_region' ).style.display = 'none';
	}
	else
	{
		for( i = 1; i <= regions[0]['region_id']; i++ )
		{
            box_el.options[i+start_del-1] = new Option( regions[i]['name'], regions[i]['region_id'] );
		}
		document.getElementById( 'country_region' ).style.display = '';
	}
}

// VOTING FUNCTION
function AvoteAdd( user, vsize, pr_text, er_text )
{
	var id = 0;
	f = document.getElementById('vform');
	for( i = 0; i < vsize; i++ )
	{
		if( f.elements['yvote'][i].checked == true )
		{
			id = f.elements['yvote'][i].value;
			break;
		}
	}

	if( id > 0 )
	{
		document.getElementById('vote_text').innerHTML = pr_text;
		document.getElementById('vote_but').disabled = true;

		try
		{
			var req = new JsHttpRequest();
			req.onreadystatechange = function()
			{
				if( req.readyState == 4 )
				{
					if( req.responseText.length > 100 || req.responseText == '&nbsp;' )
					{
			            // OK. write the whole voting table
			            document.getElementById('main_voting').innerHTML = req.responseText;
			            document.getElementById('vote_complete_text').style.display = '';
					}
					else
					{
						// ERROR. write only the msg
						document.getElementById('vote_text').innerHTML = req.responseText;
						document.getElementById('vote_but').disabled = false;
					}
				}
			}

			req.caching = false;
			u = site_url + '/de/vote/' + user + '/' + id;
		 	req.loader = 'script';
		 	req.open('GET',u,true);
		 	req.send({});

	 	}
	 	catch(e)
	 	{
	 		document.getElementById('vote_text').innerHTML = er_text;
			document.getElementById('vote_but').disabled = false;
	 	}
	}
	else
	{
		document.getElementById('vote_text').innerHTML = er_text;
	}
}

// CAPTCHA RELOAD FUNCTION
function CReload( id )
{
	try
	{
		var req = new JsHttpRequest();
		req.onreadystatechange = function()
		{
			if( req.readyState == 4 )
			{
				if( req.responseText )
				{
		            document.getElementById(id).src = req.responseText;
				}
			}
		}

		req.caching = false;
		u = site_url + '/captcha_reload.php?y=0.' + Math.random();
	 	req.loader = 'script';
	 	req.open('GET',u,true);
	 	req.send({});
 	}
 	catch(e)
 	{}
}

// EXPAND FUNCTIONS
function TextVisibilityExpand(id)
{
    var item  = document.getElementById(id);
    if( item.style.visibility == 'hidden' )
    {
        item.style.position   = 'relative';
        item.style.visibility = 'visible';

    }
    else
    {
        item.style.visibility = 'hidden';
        item.style.position   = 'absolute';
    }
    return false;
}

function TextDisplayExpand(id)
{
    var item  = document.getElementById(id);
    if( item.style.display == 'none' )
    {
        item.style.display = '';
    }
    else
    {
        item.style.display = 'none';
    }
    return false;
}

// LIBER-BILLER FUNCTIONS
function BillingOpen( payment_type, article_id, transaction_id )
{
	document.forms[0].PAYMENTTYPE.value = payment_type;
	//document.forms[0].ARTICLENR.value = article_id;
	document.forms[0].TANR.value = transaction_id;

	document.forms[0].submit();
}

function Preempt( url, elem )
{
	document.forms[1].i_offer.value = document.getElementById(elem).value;
	document.forms[1].action = url;
	document.forms[1].submit();
}

function textSymCounter( field_id, count_field_id, maxlimit )
{
	var field = document.getElementById( field_id );
	var countfield = document.getElementById( count_field_id );

	if( field.value.length > maxlimit )
	{
	    field.value = field.value.substring( 0, maxlimit );
	}

	if( field.value.match( /(\r\n|\n|\r)/ ) )
	{
	    field.value = field.value.replace( /(\r\n|\n|\r)+/, " " );
	}

	countfield.innerHTML = maxlimit - field.value.length;
}

function NotifyLessSymbols( field_id, place_id, minlimit )
{
	var field = document.getElementById( field_id );
	var place_to = document.getElementById( place_id );

	if( field.value.length < minlimit )
	{
		place_to.style.display = '';
	}
	else
	{
		place_to.style.display = 'none';
	}
}

function ChangeCatSelectBox( cat_id, direction_id )
{
	direction = document.getElementById(direction_id).value;
	document.getElementById(cat_id+'1').style.display = 'none';
	document.getElementById(cat_id+'2').style.display = 'none';
	document.getElementById(cat_id+direction).style.display = '';

	// move not used element out of the form
	/*var fake_form = document.getElementById( 'fake_form' );
	var used_form = document.getElementById( 'form1' );

    fake_form.appendChild( document.getElementById(cat_id+'1') );
    fake_form.appendChild( document.getElementById(cat_id+'2') );
    used_form.appendChild( document.getElementById(cat_id+direction) );*/
}

function ChangeCatSelectBox2( cat_id, direction_id )
{
	direction = document.getElementById(direction_id)[document.getElementById(direction_id).selectedIndex].value;
	document.getElementById(cat_id+'1').style.display = 'none';
	document.getElementById(cat_id+'2').style.display = 'none';
	document.getElementById(cat_id+'3').style.display = 'none';
	document.getElementById(cat_id+direction).style.display = '';
}

function ChangeCatSelectBox3( cat_id, direction_id )
{
	direction = document.getElementById(direction_id).value;
	document.getElementById(cat_id+'1').style.display = 'none';
	document.getElementById(cat_id+'2').style.display = 'none';
	document.getElementById(cat_id+'3').style.display = 'none';
	document.getElementById(cat_id+direction).style.display = '';
}

function SelectType( select_el, redirect_path )
{
	var select_val = select_el.options[select_el.selectedIndex].value;
	redirectself( site_url + redirect_path + '?sub=' + select_val );
}

function HandleKeyPress( ac, evt, formID )
{
   evt = (evt) ? evt : ( (window.event) ? event : null );
   var charCode = (evt.charCode) ? evt.charCode : ( (evt.which) ? evt.which : evt.keyCode );

   if ( charCode == 13 )
   {
        document.getElementById(formID).action = ac;
		document.getElementById(formID).submit();
   }
   else
   {
       return true;
   }
}

function RedirectRegPage( lang, in_parent_wnd )
{
    if( in_parent_wnd == 0 )
    {
    	self.location = '/' + lang + '/reg';
    }
    else
    {
    	opener.location = '/' + lang + '/reg';
    }
}

function HideMailUAlert()
{
	$("#mailu_alert_container").slideUp(1000, function () {		jQuery.getJSON('/' + js_lang + '/index/nomailwarn', {}, function(json){
		});

		/*var req = new JsHttpRequest();
		req.onreadystatechange = function()
		{
			if( req.readyState == 4 )
			{
				if( req.responseText )
				{}
			}
		}

		req.caching = false;
		u = ;
	 	req.loader = 'script';
	 	req.open('GET',u,true);
	 	req.send({});*/
	});
}

function ShowLoading()
{
	var center_w = parseInt( jQuery(document).width() / 2 );
	//center_w = 455;
	var center_h = parseInt( jQuery(document).height() / 2 ) - 16;
	jQuery("#ajax_loading1").css('left',center_w);
	jQuery("#ajax_loading1").css('top',center_h);
	jQuery("#ajax_loading1").css('display','');
}

function HideLoading()
{
    jQuery("#ajax_loading1").css('display','none');
}

function SubmitToSupporter( act, letter_id, supporter_opt_id )
{	var sup_id = document.getElementById(supporter_opt_id)[document.getElementById(supporter_opt_id).selectedIndex].value;
	var confirmed = confirm( 'Are you sure?' );
	if( confirmed )
	{		self.location = act + '?id=' + letter_id + '&i_sup=' + sup_id;	}
}