
function cfg_global(  ) {
	
	this.img_dir			= '/kernel/img/';
	this.plg_dir			= 'plg/';
	this.flv_dir			= 'lib/FlvPlayer/';
	this.img_ext_dir		= './img/';
	this.file_ext_dir		= './file/';
	this.img_load			= this.img_dir+'loading.gif';
	
	this.scr_width			= 1024;
	this.scr_height			= 768;
	this.scr_scroll_y_pos	= 0;
	this.scr_scroll_x		= 1024;
	this.scr_scroll_y		= 768;
	this.scr_total_x		= 1024;
	this.scr_total_y		= 768;
	
	this.curt_show_speed	= 300;
	this.curt_hide_speed	= 400;
	
	this.popup_show_speed	= 200;
	this.popup_hide_speed	= 200;
	
	this.popup_width		= 400;
	this.popup_border_color	= '0066CC';
	this.popup_body_color	= 'EEEEEE';
	this.popup_top_color	= 'EEEEEE';
	
	this.motion_speed		= 300;
	
	this.path_pref			= 'index.php';
}

cgg = new cfg_global(  );

function do_alert(  ) {
	
	alert( 5 );
}

function round( val, num ) {
	
	if ( !num ) {
		
		result	= parseInt( val );
	}
	else {
		
		result	= parseInt( val*Math.pow( 10, num ) )/Math.pow( 10, num );
	}
	
	return result;
}

function swap_img( img_id ) {
	
	link_id 	= img_id + '_link';
	hover_id	= img_id + '_hover';
	
	document.getElementById( link_id ).style.visibility		= 'hidden';
	document.getElementById( hover_id ).style.visibility	= 'visible';
}


function back_img( img_id ) {
	
	link_id 	= img_id + '_link';
	hover_id	= img_id + '_hover';
	
	document.getElementById( link_id ).style.visibility		= 'visible';
	document.getElementById( hover_id ).style.visibility	= 'hidden';
}

function get_body( bid, string, loader ) {
	
	if ( 'pop_up' == bid && document.getElementById( bid ) ) {
		
		document.getElementById( bid ).innerHTML	= "<center><img src='"+cgg.img_load+"' style='border:0px; margin-top:50px;'></center>";
	}
	if ( loader && document.getElementById( bid ) ) {
		
		document.getElementById( bid ).innerHTML	= "<center><img src='"+cgg.img_load+"' style='border:0px;'></center>";
	}
	
	if ( document.getElementById( bid ) || 'empty' == bid ) {
		
		JsHttpRequest.query( '/ajax.php', {
				
				'ajax_string': string
			},
			function( result ) {
				
				if ( result && result['res'] ) {
					
					if ( result['res']['body'] ) {
						
						if ( 'empty' != bid ) {
							
							document.getElementById( bid ).innerHTML	= result['res']['body'];
						}
					}
		       		
					if ( result['res']['info'] ) {
		        		
						do_act( result['res']['info'] );
					}
				}
			},
			true
	    );
    }
}

function get_scr_size(  ) {
	
	if ( self.innerHeight ) {	// all except Explorer
		
		cgg.scr_width	= self.innerWidth;
		cgg.scr_height	= self.innerHeight;
	}
	else if ( document.documentElement && document.documentElement.clientHeight ) { // Explorer 6 Strict Mode
		
		cgg.scr_width	= document.documentElement.clientWidth;
		cgg.scr_height	= document.documentElement.clientHeight;
	}
	else if ( document.body ) { // other Explorers
		
		cgg.scr_width	= document.body.clientWidth;
		cgg.scr_height	= document.body.clientHeight;
	}
	
	
	if ( self.pageYOffset ) {
		
		cgg.scr_scroll_pos_y = self.pageYOffset;
	}
	else if ( document.documentElement && document.documentElement.scrollTop ) {
		
		cgg.scr_scroll_pos_y = document.documentElement.scrollTop;
	}
	else if ( document.body ) {
		
		cgg.scr_scroll_pos_y = document.body.scrollTop; 
	}
	
	
	if ( window.innerHeight && window.scrollMaxY ) {
		
		cgg.scr_scroll_x	= document.body.scrollWidth;
		cgg.scr_scroll_y	= window.innerHeight + window.scrollMaxY;
	}
	else if ( document.body.scrollHeight > document.body.offsetHeight ) { // all but Explorer Mac
		
		cgg.scr_scroll_x	= document.body.scrollWidth;
		cgg.scr_scroll_y	= document.body.scrollHeight;
	}
	else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		
		cgg.scr_scroll_x	= document.body.offsetWidth;
		cgg.scr_scroll_y	= document.body.offsetHeight;
	}
	
	cgg.scr_total_x	= cgg.scr_width  > cgg.scr_scroll_x ? cgg.scr_width  : cgg.scr_scroll_x;
	cgg.scr_total_y	= cgg.scr_height > cgg.scr_scroll_y ? cgg.scr_height : cgg.scr_scroll_y;
}

function str_replace( search, replace, subject ) {
	
	return subject.split( search ).join( replace );
}

function check_scr(  ) {
	
	str		= 'prj=' + cgn.prj + '/lng=' + cgn.lng + '/plg=service/ctrl=CService/act=set_scr/scr_w=' + cgg.scr_width + '/scr_h=' + cgg.scr_height;
	
	get_body( 'empty', str );
}

function act_resize(  ) {
	
	get_scr_size(  );
	
	check_scr(  );
}

function hide_div( el_id ) {
	
	if ( document.getElementById( el_id ) ) {
		
		document.getElementById( el_id ).style.display	= 'none';
	}
}

function keep_session( prj ) {
	
	str		= 'prj=' + prj + '/plg=service/ctrl=CService/act=empty/lng=ru';
	
	get_body( 'empty', str, 0 );
	
	setTimeout( "keep_session(  );", 300000 );
}

function set_cb_stat( status ) {
	
	$( ".cb_lst" ).attr( "checked", status );
}

function show_popup( title, font_color ) {
	
	if ( document.getElementById( 'body_main' ) ) {
		
		if( cgg.scr_height > parseInt( document.getElementById( 'body_main' ).scrollHeight ) ) {
			
			curt_height	= cgg.scr_height;
		}
		else {
			
			curt_height	= parseInt( document.getElementById( 'body_main' ).scrollHeight );
		}
	}
	else {
		
		curt_height	= cgg.scr_height;
	}
	
	curt_height	= 850;
	
	var pop_up_top	= gen_popup_top( title, font_color );
	
	if ( document.getElementById( 'pop_up_top' ) ) {
		
		document.getElementById( 'pop_up_top' ).innerHTML = pop_up_top;
	}
	$( "#curtain" ).hide(  );
    $( "#popup_box" ).hide(  );
    
    if ( document.getElementById( 'curtain' ) ) {
    	
		document.getElementById( 'curtain' ).style.display		= 'none';
		document.getElementById( 'curtain' ).style.height		= curt_height;
		document.getElementById( 'curtain' ).style.width		= '100%';
    }
    
	document.getElementById( 'popup_box' ).style.display	= 'block';
	
    $( "#curtain" ).animate( {opacity : "show"}, cgg.curt_show_speed-1 );
    $( "#popup_box" ).animate( {opacity : "show"}, cgg.popup_show_speed-1 );
}

function init_popup( el_width, el_height, pos_left, pos_top, bg_body_color, bg_top_color, border_color ) {
	
	if ( 'max' == el_width ) {
		
		el_width	= cgg.scr_width - 60;
		pos_left	= 30;
		pos_top		= 30;
	}
	
	if ( 'max' == el_height ) {
		
		el_height	= cgg.scr_height - 60;
		pos_left	= 30;
		pos_top		= 30;
	}
	
	if ( 'half' == el_width ) {
		
		el_width	= cgg.scr_width/2;
	}
	
	if ( 'half' == el_height ) {
		
		el_height	= cgg.scr_height/2;
	}
	
	if ( 'center' == pos_left &&  'max' != el_width ) {
		
		pos_left	= ( cgg.scr_width - el_width )/2;
	}
	if ( 'center' == pos_top &&  'max' != el_height ) {
		
		pos_top		= ( cgg.scr_height - el_height )/2;
	}
	
			
	cgg.popup_width			= el_width;
	cgg.popup_border_color	= border_color;
	cgg.popup_body_color	= bg_body_color;
	cgg.popUpbg_top_color	= bg_top_color;
	
	if ( document.getElementById( 'popup_box' ) ) {
		
		document.getElementById( 'popup_box' ).style.left				= pos_left;
		document.getElementById( 'popup_box' ).style.top				= pos_top;
		document.getElementById( 'popup_box' ).style.width				= el_width;
		document.getElementById( 'popup_box' ).style.height				= el_height;
		document.getElementById( 'popup_box' ).style.backgroundColor	= bg_body_color;
		document.getElementById( 'popup_box' ).style.borderTop			= '1px solid #'+border_color;
		document.getElementById( 'popup_box' ).style.borderBottom		= '1px solid #'+border_color;
	}
	
	if ( document.getElementById( 'pop_up' ) ) {
		
		document.getElementById( 'pop_up' ).style.width							= el_width;
		document.getElementById( 'pop_up' ).style.height						= el_height-60;
		document.getElementById( 'pop_up' ).style.backgroundColor				= bg_body_color;
		document.getElementById( 'pop_up' ).style.borderBottom					= '1px solid #'+border_color;
	}
	
	if ( document.getElementById( 'pop_up_bottom' ) ) {
		
		document.getElementById( 'pop_up_bottom' ).style.borderBottom			= '1px solid #'+border_color;
		document.getElementById( 'pop_up_bottom' ).style.backgroundColor		= bg_body_color;
	}
}


function hide_popup(  ) {
	
    $( "#curtain" ).animate( {opacity : "hide"}, cgg.curt_hide_speed-1 );
    $( "#popup_box" ).animate( {opacity : "hide"}, cgg.popup_hide_speed-1 );
    setTimeout( "clear_popup(  );", cgg.popup_hide_speed-1 );
}

function curtain_on( el_z ) {
	
	if ( document.getElementById( 'curtain_ini' ) ) {
		
		document.getElementById( 'curtain_ini' ).style.height	= cgg.scr_total_y + 'px';
		document.getElementById( 'curtain_ini' ).style.zIndex	= el_z;
	}
}

function curtain_off(  ) {
	
	if ( document.getElementById( 'curtain_ini' ) ) {
		
		document.getElementById( 'curtain_ini' ).style.height	= '0px';
	}
}

function clear_popup(  ) {
	
	if ( document.getElementById( 'pop_up' ) ) {
		
		document.getElementById( 'pop_up' ).innerHTML = '';
	}
	
	if ( document.getElementById( 'pop_up_top' ) ) {
		
		document.getElementById( 'pop_up_top' ).innerHTML = '';
	}
}

function gen_popup_top( title, font_color ) {
	
	if( undefined == title ) {
		
		title = '';
	}
	if( undefined == font_color ) {
		
		font_color = '000000';
	}
	s_width = cgg.popup_width-50;
	
	str = '';
	str+=	'<table width="'+cgg.popup_width+'" border="0" cellspacing="0" cellpadding="0">';
	str+=		'<tr style="height:40px;">';
	str+=			'<td width="50" style=" background-color:#'+cgg.popup_top_color+'; border-bottom:1px solid #'+cgg.popup_border_color+';">&nbsp;</td>';
	str+=			'<td width="'+s_width+'" valign="middle" class="text_pink" style="font-size:22px; text-align:center; color:#'+font_color+'; border-bottom:1px solid #'+cgg.popup_border_color+'; background-color:#'+cgg.popup_top_color+';" id="pop_up_title">&nbsp;'+title+'&nbsp;</td>';
	str+=			'<td width="50" style=" background-color:#'+cgg.popup_top_color+'; border-bottom:1px solid #'+cgg.popup_border_color+';" align="center" valign="middle"><img src="'+cgg.img_dir+'close.png" border="0" onclick="hide_popup(  );" style="cursor:pointer;"></td>';
	str+=		'</tr>';
	str+=	'</table>';
	str+=	'<br />';
	
	return str;
}

function close_box( elid ) {
	
	if ( document.getElementById( elid ) ) {
		
		document.getElementById( elid ).innerHTML		= '';
		document.getElementById( elid ).style.display	= 'none';
	}
}

function show_box( elid ) {
	
	if ( document.getElementById( elid ) ) {
		
		document.getElementById( elid ).style.display	= 'block';
	}
}

function hide_box( elid ) {
	
	if ( document.getElementById( elid ) ) {
		
		document.getElementById( elid ).style.display	= 'none';
	}
}

function empty_el( elid ) {
	
	if ( document.getElementById( elid ) ) {
		
		document.getElementById( elid ).innerHTML	= '';
		document.getElementById( elid ).value		= '';
	}
}

function body_row_over( this_el ) {
	
	this_el.className	= 'row_over';
}

function body_row_out( this_el, cl ) {
	
	this_el.className	= cl;
}

function swap_cls( elid, cls ) {
	
	if ( document.getElementById( elid ) ) {
		
		document.getElementById( elid ).className	= cls;
	}
}

function swap_filter( status ) {
	
	display_status	= document.getElementById( 'filter_box_int' ).style.display;
	
	if ( !display_status ) {
		
		width_status	= document.getElementById( 'filter_box_int' ).clientHeight;
		
		if ( 0 == width_status ) {	swap_status	= 'show';	}	else	{	swap_status	= 'hide';	}
	}
	else {
		
		if ( 'block' == display_status ) {	swap_status	= 'hide';	}	else	{	swap_status	= 'show';	}
	}
	
	if ( status )	{	swap_status	= status;	}
	
	setTimeout( "act_swap_filter( '" + swap_status + "' )", 100 );
}

function act_swap_filter( status ) {
	
	$( "#filter_box_int" ).animate( {opacity : swap_status}, cgg.curt_show_speed-1 );
}

function filter_change( base_link, id ) {
	
	document.location.href	= base_link + '/' + id;
}

//////////////// slide functions

function cfg_slide(  ) {
	
	this.val_min	= 0;
	this.val_max	= 0;
	this.val_cur	= 0;
	
	this.on			= 1;
	
	this.step_rate	= 1000;
	this.step_shift	= 1000;
	
	this.step_int	= 1000;
	this.step_first	= 1000;
}

csl	= new cfg_slide(  );

function slide_start( min, max, s_rate, s_shift, s_int, s_first ) {
	
	csl.val_min		= min;
	csl.val_max		= max;
	
	csl.step_rate	= s_rate;
	csl.step_int	= s_int;
	csl.step_first	= s_first;
	
	csl.step_shift	= s_shift;
	
	setTimeout( 'slide_show(  );', csl.step_first );
}

function slide_show(  ) {
	
	if ( csl.on ) {
		
		elid	= 'img_slide_' + csl.val_cur;
		
		$( "#" + elid ).animate( {opacity:'hide'}, csl.step_rate );
		
		if ( csl.val_cur < csl.val_max ) {
			
			csl.val_cur++;
		}
		else {
			
			csl.val_cur	= csl.val_min;
		}
		
		setTimeout( 'show_next_slide(  );', csl.step_shift );
	}
	
	setTimeout( 'slide_show(  );', csl.step_int );
}

function slide_play( play_id, stop_id ) {
	
	if ( document.getElementById( play_id ) )	{	document.getElementById( play_id ).style.display	= 'none';	}
	if ( document.getElementById( stop_id ) )	{	document.getElementById( stop_id ).style.display	= 'block';	}
	
	csl.on	= 1;
}

function slide_stop( play_id, stop_id ) {
	
	if ( document.getElementById( play_id ) )	{	document.getElementById( play_id ).style.display	= 'block';	}
	if ( document.getElementById( stop_id ) )	{	document.getElementById( stop_id ).style.display	= 'none';	}
	
	csl.on	= 0;
}

function slide_next(  ) {
	
	elid	= 'img_slide_' + csl.val_cur;
	
	$( "#" + elid ).animate( {opacity:'hide'}, csl.step_rate );
	
	if ( csl.val_cur < csl.val_max ) {
		
		csl.val_cur++;
	}
	else {
		
		csl.val_cur	= csl.val_min;
	}
	
	setTimeout( 'show_next_slide(  );', csl.step_shift );
}

function slide_prev(  ) {
	
	elid	= 'img_slide_' + csl.val_cur;
	
	$( "#" + elid ).animate( {opacity:'hide'}, csl.step_rate );
	
	if ( csl.val_cur > csl.val_min ) {
		
		csl.val_cur--;
	}
	else {
		
		csl.val_cur	= csl.val_max;
	}
	
	setTimeout( 'show_next_slide(  );', csl.step_shift );
}

function show_next_slide(  ) {
	
	elid	= 'img_slide_' + csl.val_cur;
	
	$( "#" + elid ).animate( {opacity:'show'}, csl.step_rate );
}

//////////////////////////////////// admin menu scripts

function cfg_menu(  ) {
	
	this.menu_active	= new Array(  );
	this.over			= 0;
	this.mid			= 0;
}

cgm = new cfg_menu(  );

function menu_admin_over( mid ) {
	
	did	= 'drop_' + mid;
	
	if( document.getElementById( did ) ) {
		
		cgm.menu_active[ did ] = 1;
		
		document.getElementById( did ).style.display    = 'block';
	}
}

function menu_admin_out( mid ) {
	
	did	= 'drop_' + mid;
	
	if( document.getElementById( did ) ) {
		
		cgm.menu_active[ did ] = 0;
		
		setTimeout( "menu_drop_hide( '" + mid + "' );", 250 );
	}
}

function menu_drop_hide( mid ) {
	
	did	= 'drop_' + mid;
	
	if( 0 == cgm.menu_active[ did ] ) {
		
		if( document.getElementById( did ) ) {
			
			document.getElementById( did ).style.display    = 'none';
		}
	}
}


//////////////////////////////////// end of admin menu script




//////////////////////////////////// default do_act scripts

function do_act_default( info ) {
	
	if ( 'login' == info['type'] )			{	do_act_login( info );			}
 	
 	if ( 'user_login' == info['type'] )		{	do_act_user_login( info );		}
 	
 	if ( 'pwd_restore' == info['type'] )	{	do_act_pwd_restore( info );		}
 	
 	if ( 'pass_request' == info['type'] )	{	do_act_pass_requset( info );	}
 	
 	if ( 'mail_send' == info['type'] )		{	do_act_mail_send( info );		}
	
	if ( 'unic_check' == info['type'] ) 	{	do_act_unic_check( info );		}
}

function do_act_login( info ) {
    
    if ( 'page' == info['source'] )	{  	source	= info['source'];    }	else	{	source	= 'panel';	}
    
	if ( 'OK' == info['act'] ) {
		
		if ( document.getElementById( source + '_warn_login_wrong' ) ) {
			
			document.getElementById( source + '_warn_login_wrong' ).style.display    = 'none';
		}
		
		document.location.href = info['link'];
	}
	if ( 'NO' == info['act'] ) {
		
		if ( document.getElementById( source + '_warn_login_wrong' ) ) {
			
			document.getElementById( source + '_warn_login_wrong' ).style.display    = 'block';
		}
	}
}

function do_act_pwd_restore( info ) {
	
	if ( 'page' == info['source'] )	{  	source	= info['source'];    }	else	{	source	= 'panel';	}
	
	if ( document.getElementById( source + '_restore_pwd_login' ) ) {
		
		document.getElementById( source + '_restore_pwd_login' ).style.display    = 'none';
	}
    
	if ( 'OK' == info['act'] ) {
		
		if ( document.getElementById( source + '_restore_pwd_ok' ) ) {
			
			document.getElementById( source + '_restore_pwd_ok' ).style.display		= 'block';
		}
		
		if ( document.getElementById( source + '_restore_pwd_wrong' ) ) {
			
			document.getElementById( source + '_restore_pwd_wrong' ).style.display	= 'none';
		}
	}
	
	if ( 'NO' == info['act'] ) {
		
		if ( document.getElementById( source + '_restore_pwd_wrong' ) ) {
			
			document.getElementById( source + '_restore_pwd_wrong' ).style.display	= 'block';
		}
		
		if ( document.getElementById( source + '_restore_pwd_ok' ) ) {
			
			document.getElementById( source + '_restore_pwd_ok' ).style.display		= 'none';
		}
	}
}

function do_act_user_login( info ) {
    
    if ( 'page' == info['source'] )	{  	source	= info['source'];    }	else	{	source	= 'panel';	}
    
	if ( 'OK' == info['act'] ) {
		
		if ( document.getElementById( source + '_user_login_wrong' ) ) {
			
			document.getElementById( source + '_user_login_wrong' ).style.display    = 'none';
		}
		
		document.location.href = info['link'];
	}
	if ( 'NO' == info['act'] ) {
		
		if ( document.getElementById( source + '_user_login_wrong' ) ) {
			
			document.getElementById( source + '_user_login_wrong' ).style.display    = 'block';
		}
	}
}

function do_act_pass_requset( info ) {
 	
	if ( 'OK' == info['act'] ) {
		
		if ( document.getElementById( 'warn_login_wrong' ) ) {
			
			document.getElementById( 'warn_login_wrong' ).style.display		= 'none';
		}
		if ( document.getElementById( 'warn_get_pwd' ) ) {
			
			document.getElementById( 'warn_get_pwd' ).style.display			= 'none';
		}
		if ( document.getElementById( 'warn_pwd_sent' ) ) {
			
			document.getElementById( 'warn_pwd_sent' ).style.display 		= 'block';
		}
	}
	if ( 'NO' == info['act'] ) {
		
		if ( document.getElementById( 'warn_pwd_sent' ) ) {
			
			document.getElementById( 'warn_pwd_sent' ).style.display		= 'none';
		}
		if ( document.getElementById( 'warn_get_pwd' ) ) {
			
			document.getElementById( 'warn_get_pwd' ).style.display			= 'none';
		}
		if ( document.getElementById( 'warn_login_wrong' ) ) {
			
			document.getElementById( 'warn_login_wrong' ).style.display		= 'block';
		}
	}
}

function do_act_mail_send( info ) {
	
	if ( 1 == info['act'] ) {
		
		if ( document.getElementById( 'contact_response_ok' ) ) {
			
			document.getElementById( 'contact_response_ok' ).style.display		= 'block';
		}
		if ( document.getElementById( 'contact_response_wrong' ) ) {
			
			document.getElementById( 'contact_response_wrong' ).style.display	= 'none';
		}
	}
	else {
		
		if ( document.getElementById( 'contact_response_ok' ) ) {
			
			document.getElementById( 'contact_response_ok' ).style.display		= 'none';
		}
		if ( document.getElementById( 'contact_response_wrong' ) ) {
			
			document.getElementById( 'contact_response_wrong' ).style.display	= 'block';
		}
	}
}

function do_act_unic_check( info ) {
	
	if( 1 == info['act'] ) {
		
		mgr	= 	'';
		mgr+=	'bid=unic_item / bar_box=' + info['elbox'] + ' / bar_type=unic_info / bar_title=' + info['title'] + ' / bar_movable=yes / bar_max=yes / bar_resizable=no / ';
		mgr+=	'bar_but_close=yes / bar_but_min=yes / bar_cls_but_close=unic_info_close / bar_cls_but_min=unic_info_min / bar_cls_but_max=unic_info_max / ';
		mgr+=	'bar_cls_box=unic_info_ajx_box / bar_cls_header=unic_info_header / bar_cls_title=unic_info_title / bar_cls_body=unic_info_ajx_body / bar_cls_cont=unic_info_ajx_cont / bar_cls_footer=unic_info_footer / ';
		
		if ( !document.getElementById( 'item_show' ) ) {
			
			barCart	= new bar_mgr( mgr );
			barCart.create_bar(  );
		}
		
		if ( document.getElementById( info['elid'] ) )	{	document.getElementById( info['elid'] ).value	= '';	}
		
		if ( document.getElementById( 'unic_item_cont' ) )	{	document.getElementById( 'unic_item_cont' ).innerHTML	= info['body'];	}
		
	}
}

//////////////////////////////////// tip scripts

function tip_show( this_el ) {
	
	if ( !this_el.id ) {
		
		this_el.id	= 'tmp_tip_id';
	}
	
	id	= this_el.id;
	
	$( "#" + id + " div" ).show(  );
}

function tip_hide( this_el ) {
	
	id	= this_el.id;
	
	$( "#" + id + " div" ).hide(  );
	
	if ( 'tmp_tip_id' == id ) {
		
		this_el.id	= '';
	}
}

///////////////////////////////////// scripts for validation


function form_validate( fid ) {
	
	var status	= 1;
	var str		= '';
	var res		= 1;
	
	for ( var i=0; i < document.forms[ fid ].elements.length; i++ ) {
		
		if( document.forms[ fid ].elements[i].className ) {
		
			res = field_check( document.forms[ fid ].elements[i] );
		}
		if ( 0 == res ) {
			
			status = 0;
		}
	}
	
	return status;
}

function field_check( elObj ) {
	
	if ( -1 != elObj.className.indexOf( 'simple_validation' ) ) {
		
		if( !elObj.value ) {
			
			mark_as_wrong( elObj );
			result	= 0;
		}
		else {
			
			mark_as_good( elObj );
			result	= 1;
		}
	}
	else if ( -1 != elObj.className.indexOf( 'mail_validation' ) ) {
		
		if( !elObj.value || ( elObj.value && !validate_email( elObj.value ) ) ) {
			
			mark_as_wrong( elObj );
			result	= 0;
		}
		else {
			
			mark_as_good( elObj );
			result	= 1;
		}
	}
	else if ( -1 != elObj.className.indexOf( 'phone_validation' ) ) {
		
		if( !elObj.value || ( elObj.value && !validate_phone( elObj.value ) ) ) {
			
			mark_as_wrong( elObj );
			result	= 0;
		}
		else {
			
			mark_as_good( elObj );
			result	= 1;
		}
	}
	else {
		
		result	= 1;
	}
	
	return result;
}

function mark_as_wrong( elObj ) {
	
	elObj.style.backgroundColor	= '#FF7D7D';
}

function mark_as_good( elObj ) {
	
	elObj.style.backgroundColor	= '#FFFFFF';
}

function validate_email( email ) {
	
	var at_sym	= email.indexOf( '@' );
	var period	= email.lastIndexOf( '.' );
	
	if ( ( ( at_sym != 0 ) && ( at_sym != -1 ) ) && ( at_sym < period ) && ( at_sym != period - 1 ) )	{	return true;	}
	
	return false;
}

function validate_phone( phone ) {
	
	num_str		= str_replace( "/", "", phone	);
	num_str		= str_replace( "(", "", num_str	);
	num_str		= str_replace( ")", "", num_str	);
	num_str		= str_replace( " ", "", num_str	);
	num_str		= str_replace( "-", "", num_str	);
	no_zero_str	= str_replace( "0", "", num_str	);
	
	if ( no_zero_str == parseInt( no_zero_str ) && ( num_str.length > 5 ) && ( num_str.length < 10 ) )	{	return true;	}
	
	return false;
}

///////////////////////////////// function for editarea //////////////////////////

function do_highlight( elid, ext ) {
	
	editAreaLoader.init({
		id : elid		// textarea id
		,syntax: ext			// syntax to be uses for highgliting
		,start_highlight: true		// to display with highlight mode on start-up
	});
}

///////////////////////////////// submit for forms with validation ////////////////

function form_submit( fid ) {
	
	if ( form_validate( fid ) ) {
		
		document.getElementById( fid ).submit(  );
	}
}

function item_over( el_obj, width ) {
	
	el_obj.style.width				= width + 10 + 'px';
	el_obj.parentNode.style.zIndex	= '100';
	
	el_obj.firstChild.style.width	= width + 'px';
	el_obj.style.height				= parseInt( el_obj.firstChild.clientHeight ) + 10 + 'px'; 
}

function item_out( el_obj, width ) {
	
	el_obj.style.width		= width + 10 + 'px';
	el_obj.parentNode.style.zIndex		= '0';
	
	el_obj.firstChild.style.width	= width + 'px';
	el_obj.style.height				= parseInt( el_obj.firstChild.clientHeight ) + 10 + 'px';
}

function filter_keyword_act( url, str ) {
	
	str = url + 'link=' + str;
	
	get_body( 'box_list', str );
}

function add_new_flex_price( prj, lng ) {
	
	elid	= Math.round( Math.random(  )*100000 );
	
	$( "#flex_price_list_box" ).append( '<div id="' + elid + '"></div>' );
	
	str		= 'prj=' + prj + '/plg=aflexprice/ctrl=CAFlexprice/act=add/lng=' + lng;
	
	get_body( elid, str, 1 );
}

function add_new_item( prj, lng, plg, ctrl, box_id ) {
	
	elid	= Math.round( Math.random(  )*100000 );
	
	$( "#" + box_id ).append( '<div id="' + elid + '"></div>' );
	
	str		= 'prj=' + prj + '/plg=' + plg + '/ctrl=' + ctrl + '/act=ajx_add_show/lng=' + lng;
	
	get_body( elid, str, 1 );
}

function show_right_filter( el_obj ) {
	
	if ( el_obj.checked ) {
		
		$( "." + el_obj.id ).show(  );
	}
	else {
		
		$( "." + el_obj.id ).hide(  );
	}
}
