function showFlashMessage( type, message)
{	
	var flashMessageHtml = '<div class="flashmsg"><table><tr><td align="center" valign="top" width="40"><img class="transparent" src="images/acpopup/icon_' + type + '.png" alt="" align="absmiddle" class="flashmsg-icon" /></td><td><div class="' + type + '" style="padding-top: 4px;">' + message + '</div></td></tr></table>';
	flashMessageHtml += '<div class="button"><input type="button" value="OK" class="button" style="padding: 0 10px;" onClick="hideAcPopup();" /></div></div>';
	showAcPopup({content: flashMessageHtml});
}

function validate_email(email)
{
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(email)) 
	{
		return true;
	}
	return false;
}

function selectSelectedEl( el, selected )
{
	var select_el = document.getElementById( el );
	if ( select_el != null )
	{
		for ( i = 0; i < select_el.options.length; i ++ )
		{
			if ( select_el.options[i].value == selected )
				select_el.options[i].selected = true;
		}
	}
}

function showPreloader( div_id )
{
	var width = parseInt($("#" + div_id ).width() );
	var height = parseInt($("#" + div_id ).height() );
	var vertical = (height / 2 ) - 16;
	var loading = '<div style="padding: '+ vertical +'px 0 0 0; width: ' + width + 'px; height: ' + (height - vertical) + 'px; text-align: center;"><img src="/admin/images/ajax-loading.gif" alt="" title="" /></div>';
	$("#" + div_id ).html( loading );
}

function imgPopupOver( obj )
{
	if ( obj.hasClass('selectedImg') )
		return;
	
	obj.addClass('img-popup-on');
	obj.removeClass('img-popup');	
}

function imgPopupOut( obj )
{
	if ( obj.hasClass('selectedImg') )
		return;
		
	obj.addClass('img-popup');
	obj.removeClass('img-popup-on');	
}

function imgPopupClick( num )
{
	$('img.img-popup-on').removeClass('selectedImg').removeClass('img-popup-on').addClass('img-popup');
	$('#img_link_' + num).addClass('selectedImg').addClass('img-popup-on');
	$('img#img-popup-center').attr();
	$('img.big-img').hide();
	$('img#img_' + num).show();
	$('img#img_link_' + num).removeClass('img-popup').addClass('img-popup-on').addClass('selectedImg');
	selected_img = num;
}

function selectPrev()
{
	if ( selected_img == 1 )
	{
		selected_img = cnt_images+1;
	}
	
	$('img.img-popup-on').removeClass('selectedImg').removeClass('img-popup-on').addClass('img-popup');
	imgPopupClick( selected_img-1 );
}

function selectNext()
{
	if ( selected_img == cnt_images )
	{
		selected_img = 0;
	}
	
	$('img.img-popup-on').removeClass('selectedImg').removeClass('img-popup-on').addClass('img-popup');
	imgPopupClick( selected_img+1 );
}