var g_images = new Array();

var g_popup_messages = new Array();	// a list of popup messages
var g_timeout = 800;				// the time before popups appear (in milliseconds)
var g_help_id = -1;					// whether the help is already visible
var g_error_id = -1;				// whether the error is already visible

var g_animating = false;
 
/*
 * Onload Default
 * ==============
 *
 * The default onload function
 */
 
function onload_default()
{ 
	onload_input( "toolbar_search", "Поиск по сайту..." );
	onload_hover();
	onload_menus();
	onload_buttons();
	onload_profile();
	onload_numbers();
	onload_popup_messages();
}


function preload_images()
{
	if (document.images)
	{
		for( var i = 0; i < preload_images.arguments.length; i++ )
		{
			var img = new Image();
			img.src = preload_images.arguments[i];
			window.g_images.push( img );
		}
	}
}


/*
 * Onload Hover
 * ============
 *
 * Finds all tags of class name hover (either a tags or input tags) and then update the onmouseover code
 * so that the image's hover image is preloaded and ready to roll (see what I did there? :P)
 *
 * Note: all hover images must have the same filename but with the _over prefix before the filename extension,
 * i.e. 'my_image.jpg' => 'my_image_over.jpg'
 */
function onload_hover()
{
	// get all the relevant tags
	var a_tags = document.getElementsByTagName( 'A' );
	var input_tags = document.getElementsByTagName( 'INPUT' );
	
	// merge them all into one big lovely array
	var objs = array_merge( a_tags, input_tags );
	
	// loop through the objects looking for those objects of class name 'hover'
	for( var i = 0; i < objs.length; i++ )
	{
		var obj = objs[ i ];
		if( obj.className == "hover" )
		{
			// figure out whether the obj is of type a or input (since they need to be handeled a little
			// bit differently to one another)
			target_obj = obj;
			
			if( obj.tagName == "A" )
			{
				// we have an a tag, we need to get the child image tag and make that the target object
				target_obj = obj.childNodes[ 0 ];
			}
			
			// get the src filename and get the end of the file (postfix), i.e. .jpg
			var file1 = target_obj.src;
			var postfix = file1.split( '.' );
			postfix = postfix[ postfix.length - 1 ];
			postfix = "." + postfix;
			
			// now we can create the onmousover file by replacing the postfix with _over plus the original postfix
			var file2 = file1.replace( postfix, "_over" + postfix );
			preload_images( new Array( file2 ) );
			
			
			
			if( target_obj.addEventListener )
			{
				target_obj.addEventListener( "mouseover", function ( a, b ) { return function(){ update_image( a, b ); } }( target_obj, file2 ), false ); 
				target_obj.addEventListener( "mouseout", function ( a, b ) { return function(){ update_image( a, b ); } }( target_obj, file1 ), false );
			}
			else
			{
				target_obj.attachEvent( "onmouseover", function ( a, b ) { return function(){ update_image( a, b ); } }( target_obj, file2 ) ); 
				target_obj.attachEvent( "onmouseout", function ( a, b ) { return function(){ update_image( a, b ); } }( target_obj, file1 ) );
			}
		}
	}
}


/*
 * Update Image
 * ============
 *
 * Updates an objects src with the specified image. Can pass either an object or the id of an object (string) and
 * the fucntion will do the conversion if necessary.
 */
function update_image( obj, image )
{
	if( typeof( obj ) != "object" )
	{
		obj = document.getElementById( obj );
	}
	obj.src = image;
}

function update_div( obj, class_name )
{
	if( typeof( obj ) != "object" )
	{
		obj = document.getElementById( obj );
	}
	obj.className = class_name;
}

function onload_input( id, str )
{
	var obj = document.getElementById( id );
	
	if( obj )
	{
	
		if( obj.addEventListener )
		{
			obj.addEventListener( "focus", function ( a, b ) { return function(){ if( a.value == b ) obj.value = ''; } }( obj, str ), false ); 
			obj.addEventListener( "blur", function ( a, b ) { return function(){ if( a.value == '' ) a.value = b; } }( obj, str ), false );
		}
		else
		{
			obj.attachEvent( "onfocus", function ( a, b ) { return function(){ if( a.value == b ) obj.value = ''; } }( obj, str ) ); 
			obj.attachEvent( "onblur", function ( a, b ) { return function(){ if( a.value == '' ) a.value = b; } }( obj, str ) );
		}
	}
}

function onload_buttons()
{
	var buttons = new Array( 'toolbar_button_default', 'toolbar_button_arrow' );
	var buttons_selected = new Array( 'toolbar_button_default_selected', 'toolbar_button_arrow_selected' );
	
	buttons = array_merge( buttons, buttons_selected );
	
	preload_images( 'images/toolbar_button_default_over.png',
				    'images/toolbar_button_arrow_over.png',
					'images/toolbar_button_over.gif',
					'images/toolbar_button_selected.gif'
					);
	
	var objs = array_merge( document.getElementsByTagName( 'div' ), document.getElementsByTagName( 'li' ) );
	
	var length = objs.length;
	for( var i = 0; i < length; i++ )
	{
		obj = objs[ i ];
		if( in_array( obj.className, buttons ) )
		{
			var class_out = obj.className;
			var class_over = obj.className + "_over";
			
			if( !in_array( class_out, buttons_selected ) )
			{
				if( obj.addEventListener )
				{
					obj.addEventListener( "mouseover", function ( a, b ) { return function(){ update_div( a, b ); } }( obj, class_over ), false ); 
					obj.addEventListener( "mouseout", function ( a, b ) { return function(){ update_div( a, b ); } }( obj, class_out ), false );
				}
				else
				{
					obj.attachEvent( "onmouseover", function ( a, b ) { return function(){ update_div( a, b ); } }( obj, class_over ) ); 
					obj.attachEvent( "onmouseout", function ( a, b ) { return function(){ update_div( a, b ); } }( obj, class_out ) );
				}
			}
			
			// now figure out whether the div contains an a href

			var children = obj.getElementsByTagName( 'a' );
			if( children.length > 0 )
			{
				var a = children[ 0 ];
				var url = a.href;
				
				if( obj.addEventListener )
				{
					obj.addEventListener( "click", function ( a ) { return function() { window.location = a; } }( url ), false );
				}
				else
				{
					obj.attachEvent( "onclick", function ( a ) { return function() { window.location = a; } }( url ) );
				}
			}
		}
	}
}

function onload_menus()
{
	var menus = new Array( 'menu_top', 'menu_middle', 'menu_bottom' );
	var menus_selected = new Array( 'menu_top_selected', 'menu_middle_selected', 'menu_bottom_selected' );
	
	menus = array_merge( menus, menus_selected );
	
	preload_images(  'images/menu_top_over.png',
				     'images/menu_middle_over.png',
					 'images/menu_bottom_over.png',
					 'images/sub_menu_top_over.png',
					 'images/sub_menu_middle_over.png',
					 'images/sub_menu_bottom_over.png'
					);
	
	var objs = array_merge( document.getElementsByTagName( 'div' ), document.getElementsByTagName( 'li' ) );
	
	var length = objs.length;
	for( var i = 0; i < length; i++ )
	{
		obj = objs[ i ];
		if( in_array( obj.className, menus ) )
		{
			var class_out = obj.className;
			var class_over = obj.className + "_over";
			
			var a = obj.getElementsByTagName( 'a' )[ 0 ];
			var url = a.href;
			
			if( obj.addEventListener )
			{
				if( !in_array( class_out, menus_selected ) )
				{
					obj.addEventListener( "mouseover", function ( a, b ) { return function(){ update_div( a, b ); } }( obj, class_over ), false ); 
					obj.addEventListener( "mouseout", function ( a, b ) { return function(){ update_div( a, b ); } }( obj, class_out ), false );
				}
				if( !a.onclick )
				{
					obj.addEventListener( "click", function ( a ) { return function() { window.location = a; } }( url ), false );
				}
			}
			else
			{
				if( !in_array( class_out, menus_selected ) )
				{
					obj.attachEvent( "onmouseover", function ( a, b ) { return function(){ update_div( a, b ); } }( obj, class_over ) ); 
					obj.attachEvent( "onmouseout", function ( a, b ) { return function(){ update_div( a, b ); } }( obj, class_out ) );
				}
				if( !a.onclick )
				{
					obj.attachEvent( "onclick", function ( a ) { return function() { window.location = a; } }( url ) );
				}
			}
		}
	}
}

function onload_profile()
{
	var objs = document.getElementsByTagName( 'div' );
	
	preload_images(  'images/profile_bottom_view_basket.png',
				   	 'images/profile_bottom_checkout.png' );
	
	
	var length = objs.length;
	for( var i = 0; i < length; i++ )
	{
		var obj = objs[ i ];
		
		var class_over = null;
		if( obj.className == "profile_view_basket" )
		{
			class_over = "profile_bottom_view_basket";	
		}
		else if( obj.className == "profile_checkout" )
		{
			class_over = "profile_bottom_checkout";	
		}
		
		if( class_over )
		{
			var class_out = "profile_bottom";
			var url = null;
			if( class_over == "profile_checkout" )
			{
				url = obj.href;	
			}
			
			var parent = obj.parentNode;
			
			if( parent.addEventListener )
			{
				obj.addEventListener( "mouseover", function ( a, b ) { return function(){ update_div( a, b ); } }( parent, class_over ), false ); 
				obj.addEventListener( "mouseout", function ( a, b ) { return function(){ update_div( a, b ); } }( parent, class_out ), false );
				if( url )
				{
					obj.addEventListener( "click", function ( a ) { return function() { window.location = a; } }( url ), false );	
				}
			}
			else
			{
				obj.attachEvent( "onmouseover", function ( a, b ) { return function(){ update_div( a, b ); } }( parent, class_over ) ); 
				obj.attachEvent( "onmouseout", function ( a, b ) { return function(){ update_div( a, b ); } }( parent, class_out ) );
				
				if( url )
				{
					obj.attachEvent( "onclick", function ( a ) { return function() { window.location = a; } }( url ) );
				}
			}
		}
	}
}

function array_merge()
{
	var result = new Array();
	
	for( var i = 0; i < arguments.length; i++ )
	{
		var arr = arguments[ i ];
		for( var j = 0; j < arr.length; j++ )
		{
			result.push( arr[ j ] );	
		}
	}
	
	return result;
}

function in_array( needle, haystack )
{
    var result = false;
	var length = haystack.length;
    for( var i = 0; i < length && !result; i++ ) 
	{
        if( haystack[ i ] == needle )
		{
			result = true;
		}
    }
    return result;
}

function load_player( id, url )
{
	flowplayer(	"player", 
			 	 "images/flowplayer-3.1.5.swf", 
				{ 
					clip: { autoPlay: true, scaling: 'fit' }, 							
					canvas:  { backgroundColor: '#000000', backgroundGradient: 'none' },
					plugins: {
						controls: {
							  durationColor: '#a9b7bc',
							  tooltipTextColor: '#ffffff',
							  tooltipColor: '#34bffe',
							  sliderGradient: 'none',
							  progressGradient: 'medium',
							  volumeSliderColor: '#333333',
							  buttonOverColor: '#399fc0',
							  timeColor: '#ffffff',
							  volumeSliderGradient: 'none',
							  buttonColor: '#333333',
							  timeBgColor: '#333333',
							  bufferGradient: 'none',
							  backgroundColor: '#000000',
							  borderRadius: '0px',
							  backgroundGradient: [0.6,0.3,0,0,0],
							  progressColor: '#34bffe',
							  bufferColor: '#333333',
							  sliderColor: '#4093a5',
							  height: 24,
							  opacity: 1.0
						}
					}
 				} );	
}

function onload_popup_messages()
{
	// firstly get all of the A tags
	var objs = document.getElementsByTagName( 'a' );
	for( var i = 0; i < objs.length; i++ )
	{
		var obj = objs[ i ];
		// check to see whether the class is set to hover
		
		switch( obj.className )
		{
			case 'popup_help': { onload_popup_help( obj ); } break;
			case 'popup_error': { onload_popup_error( obj ); } break;
			default: break;
		}
	}
}

function onload_popup_help( obj )
{
	var id = obj.id;
	obj.getElementsByTagName( 'img' )[ 0 ].title = "";
	
	if( obj.addEventListener )
	{
		obj.addEventListener( "click", function ( a, b ) { return function(){ show_help( a, b ); } }( obj, id ), false );
		obj.addEventListener( "click", function( e ) { e.preventDefault(); }, false ); 
		obj.addEventListener( "mouseover", function ( a, b ) { return function(){ show_help_delay( a, b ); } }( obj, id ), false ); 
		obj.addEventListener( "mouseout", function ( a ) { return function(){ hide_help( a ); } }( obj ), false );
	}
	else
	{
		obj.attachEvent( "onclick", function ( a, b ) { return function(){ show_help( a, b ); } }( obj, id ) );
		obj.attachEvent( "onclick", function( e ) { e.returnValue = false; } );  
		obj.attachEvent( "onmouseover", function ( a, b ) { return function(){ show_help_delay( a, b ); } }( obj, id ) ); 
		obj.attachEvent( "onmouseout", function ( a ) { return function(){ hide_help( a ); } }( obj ) );
	}	
}

function onload_popup_error( obj )
{
	var id = obj.id;
	obj.getElementsByTagName( 'img' )[ 0 ].title = "";
	
	if( obj.addEventListener )
	{
		obj.addEventListener( "click", function ( a, b ) { return function(){ show_error( a, b ); } }( obj, id ), false ); 
		obj.addEventListener( "click", function( e ) { e.preventDefault(); }, false ); 
		obj.addEventListener( "mouseover", function ( a, b ) { return function(){ show_error_delay( a, b ); } }( obj, id ), false ); 
		obj.addEventListener( "mouseout", function ( a ) { return function(){ hide_error( a ); } }( obj ), false );
	}
	else
	{
		obj.attachEvent( "onclick", function ( a, b ) { return function(){ show_error( a, b ); } }( obj, id ) );
		obj.attachEvent( "onclick", function( e ) { e.returnValue = false; } );   
		obj.attachEvent( "onmouseover", function ( a, b ) { return function(){ show_error_delay( a, b ); } }( obj, id ) ); 
		obj.attachEvent( "onmouseout", function ( a ) { return function(){ hide_error( a ); } }( obj ) );
	}	
}

function show_help_delay( obj, id )
{
	obj.style.cursor = 'help';
	if( !document.getElementById( 'popup_help' ) )
	{
		g_help_id = id;
		window.setTimeout( function ( a, b ) { return function(){ create_help( a, b ); } }( obj, id ), g_timeout );
	}
}

function show_help( obj, id )
{
	obj.style.cursor = 'help';
	if( !document.getElementById( 'popup_help' ) )
	{
		g_help_id = id;
		create_help( obj, id );
	}
}

function create_help( obj, id )
{
	if( g_help_id == id )
	{	
		g_help_id = -1;
		if( typeof( g_popup_messages[ id ] ) !== "undefined" )
		{
			var message = g_popup_messages[ id ];
			var class_name = "popup_help";
			create_popup_message( obj, class_name, message );
		}
	}
}

function hide_help( obj )
{
	obj.style.cursor = 'default';
	g_help_id = -1;
	if( document.getElementById( 'popup_help' ) )
	{
		var div = document.getElementById( 'popup_help' );
		div.parentNode.removeChild( div );
	}
}

function show_error_delay( obj, id )
{
	obj.style.cursor = 'help';
	if( !document.getElementById( 'popup_error' ) )
	{
		g_error_id = id;
		window.setTimeout( function ( a, b ) { return function(){ create_error( a, b ); } }( obj, id ), g_timeout );
	}
}

function show_error( obj, id )
{
	obj.style.cursor = 'help';
	if( !document.getElementById( 'popup_error' ) )
	{
		g_error_id = id;
		create_error( obj, id );
	}
}

function create_error( obj, id )
{
	if( g_error_id == id )
	{	
		g_error_id = -1;
		if( typeof( g_popup_messages[ id ] ) !== "undefined" )
		{
			var message = g_popup_messages[ id ];
			var class_name = "popup_error";
			create_popup_message( obj, class_name, message );
		}
	}
}

function hide_error( obj )
{
	obj.style.cursor = 'default';
	g_error_id = -1;
	if( document.getElementById( 'popup_error' ) )
	{
		var div = document.getElementById( 'popup_error' );
		div.parentNode.removeChild( div );
	}
}

function create_popup_message( obj, class_name, message )
{
	var padding_top = -5; 	// the amount of top padding for the popup
	var padding_left = 5;	// the amount of left padding for the popup
	var popup_width = 230;	// the width of the popup box
	var offset = 160;		// the offset from the centre when checking the position

	// i.e. show the popup to the left or right
	
	// work out the top left coordinates of the image	
	var x = get_x( obj.childNodes[ 0 ] );
	var y = get_y( obj.childNodes[ 0 ] );
	var width = obj.childNodes[ 0 ].offsetWidth;
	
	if( ( screen.width / 2 ) + offset > x )
	{
		position = 'right';
	}
	else
	{
		position = 'left';
	}
	
	// create the message box
	var div = document.createElement( 'div' );
	div.id = class_name;
	div.className =  class_name + "_" + position;
	div.innerHTML = message;
	
	div.style.top = y + padding_top + 'px';
	
	if( position == "left" )
	{
		div.style.left = ( x - popup_width - padding_left ) + 'px';
	}
	else
	{
		div.style.left = ( x + width + padding_left ) + 'px';
	}
	
	// add the message box to the page
	document.body.appendChild( div );
}

function get_x( obj )
{
	var result = 0;
	while( obj != null )
	{
		result += obj.offsetLeft;
		obj = obj.offsetParent;
	}
	
	return result;
}

function get_y( obj )
{
	var result = 0;
	while( obj != null )
	{
		result += obj.offsetTop;
		obj = obj.offsetParent;
	}
	
	return result;
}

function get_height( obj )
{
	var result = 0;
	if( obj.offsetHeight )
	{
		result = obj.offsetHeight;	
	}
	else if( obj.style.pixelHeight )
	{
		result = obj.style.pixelHeight;	
	}
	return result;
}

function get_width( obj )
{
	var result = 0;
	if( obj.offsetWidth )
	{
		result = obj.offsetWidth;	
	}
	else if( obj.style.pixelWidth )
	{
		result = obj.style.pixelWidth;	
	}
	return result;
	
}

function mouse_x( e ) 
{
	var result = null;
	
	if( e.pageX )
	{
		result = e.pageX;
	}
	else if ( e.clientX )
	{
	   result = e.clientX + ( document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft );
	}
	return result;
}

function mouse_y( e ) 
{
	var result = null;

	if( e.pageY )
	{
		result = e.pageY;
	}
	else if( e.clientY )
	{
		result = e.clientY + ( document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop );
	}
    return result;
}

function in_rect( dx, dy, x1, y1, x2, y2 )
{
	result = false;
	if( dx >= x1 && dx <= x2 && dy >= y1 && dy <= y2 )
	{
		result = true;	
	}
	return result;
}

function submit_search_form( li )
{
	if( li.id != "hidden_li" )
	{
		document.getElementById( 'toolbar_search' ).value = li.innerHTML;	
	}
	document.getElementById( 'form_toolbar_search' ).submit();
}

function update_tabs( id )
{
	// reset all tabs
	var divs = document.getElementsByTagName( 'div' );
	
	for( var i = 0; i < divs.length; i++ )
	{
		var div = divs[ i ];
		
		
		
		if( div.id == id )
		{
			div.className = "box_tab_selected";
		}
		else if( div.id == id + "_content" )
		{
			div.style.display = "block";	
		}
		else if( div.className == "box_tab_selected" )
		{
			div.className = "box_tab";	
		}
		else if( div.className == "box_tab_section" )
		{
			div.style.display = "none";				
		}
	}	
}

function max_length( obj )
{
	if( typeof( obj ) === "string" )
	{
		obj = document.getElementById( obj );	
	}
	var length = parseInt( obj.getAttribute( 'rel' ) );

	var remaining_id = obj.id + "_remaining";
	if( typeof( document.getElementById( remaining_id ) !== "undefined" ) )
	{
		var remaining_obj = document.getElementById( remaining_id );
		var current_length = length - obj.value.length;
		if( current_length < 0 ) remaining_obj.innerHTML = "<span style='color:#cc0000'><b>" + current_length + "</b></span>";
		else remaining_obj.innerHTML = "<b>" + current_length + "</b>";
	}
	return false;
}

function output_max_length( id  )
{
	document.write( '<span>(<span id="' + id + '_remaining"></span> characters remaining)</span>' );
}

function toggle_div( id )
{
	var obj = document.getElementById( id );
	
	if( !obj.style.display || obj.style.display == "block" )
	{
		obj.style.display = "none";
	}
	else
	{
		obj.style.display = "block";
	}
	
	return false;
}

function show_div( id )
{
	document.getElementById( id ).style.display = "block";	
}

function hide_div( id )
{
	document.getElementById( id ).style.display = "none";	
}

function toggle_div_slide( id )
{
	var obj = document.getElementById( id );
	
	var duration = 0.4;
	
	if( !obj.style.display || obj.style.display == "block" )
	{
		if( !g_animating )
		{
			g_animating = true;
			Effect.BlindUp( id, { duration: duration, afterFinish: function() { g_animating = false } } );
		}
	}
	else
	{
		if( !g_animating )
		{
			g_animating = true;
			Effect.BlindDown( id, { duration: duration, afterFinish: function() { g_animating = false } } );
		}
	}
	
	return false;
}

function toggle_status( visible )
{
	document.getElementById( 'status_message' ).style.display = visible ? "block" : "none";
	document.getElementById( 'status_summary' ).style.display = visible ? "none" : "block";
}

var g_toolbar_timeouts = new Array();

function show_tb_popup( obj, id )
{
	show_tb_popup_action( obj, id );
}

function show_tb_popup_action( obj, id )
{
	var x = get_x( obj );
	var y = get_y( obj ) + parseInt( obj.offsetHeight );
	
	var div = document.getElementById( id );
	div.style.top = y + 'px';
	div.style.left = x + 'px';
	div.style.display = "block";
}

function hide_tb_popup( id )
{
	g_toolbar_timeouts[ id ] = setTimeout( 'hide_tb_popup_action("' + id + '")', 50 );
}

function hide_tb_popup_action( id )
{
	document.getElementById( id ).style.display = "none";
}

function reset_tb_popup( id )
{	
	if( g_toolbar_timeouts[ id ]) clearTimeout( g_toolbar_timeouts[ id ] );	
}

var g_current_image = 0;
function update_additional_images( direction, num_images )
{
	// go right
	if( direction == 1 )
	{
		slider_thumbs.slideRight();	
		if( g_current_image < num_images - 1 ) g_current_image++;
	}
	else
	{
		slider_thumbs.slideLeft();		
		if( g_current_image > 0 ) g_current_image--;
	}
	set_additional_image();
	var img = document.getElementById( 'main_image' );
	img.src = g_additional_images[ g_current_image ];
}

function set_additional_image()
{
	var objs = document.getElementsByTagName( 'p' );
	var count = 0;
	var obj = null;
	for( var i = 0; i < objs.length; i++ )
	{
		obj = objs[ i ];
		if( obj.className == "mini_thumb" || obj.className == "mini_thumb mini_thumb_selected" )
		{
			if( count == g_current_image )
			{
				obj.className = "mini_thumb mini_thumb_selected";	
			}
			else
			{
				obj.className = "mini_thumb";	
			}
			count++;	
		}
	}
}

function onload_numbers( slides, prefix )
{
	var objs = document.getElementsByTagName( 'div' );
	
	// loop through all the onmouseover a tags
	var count = 0;
	for( var i = 0; i < objs.length; i++ )
	{
		var obj = objs[ i ];
		var parent = obj.parentNode;
		
		if( parent.id == "banner_numbers_" + prefix )
		{
			if( ( obj.className == "banner_number_over" ) || ( obj.className == "banner_number" ) )
			{	
				if( obj.addEventListener )
				{
					obj.addEventListener( "mouseover", function ( a, b, c ) { return function(){ stop_banner( a, b, c ); } }( slides, parent.id, count ), false ); 
					obj.addEventListener( "mouseout", function ( a, b, c ) { return function(){ start_banner( a, b, c ); } }( slides, parent.id, count ), false );
				}
				else
				{
					obj.attachEvent( "onmouseover", function ( a, b, c ) { return function(){ stop_banner( a, b, c ); } }( slides, parent.id, count ) ); 
					obj.attachEvent( "onmouseout", function ( a, b, c ) { return function(){ start_banner( a, b, c ); } }( slides, parent.id, count ) );
				}	
				
				count++;		
			}
		}
	}
}

function update_numbers( parent_id, index )
{
	var count = 0;
	
	var objs = document.getElementsByTagName( 'div' );
	for( var i = 0; i < objs.length; i++ )
	{
		var obj = objs[ i ];
		if( obj.parentNode.id == parent_id )
		{
			if( ( obj.className == "banner_number_over" ) || ( obj.className == "banner_number" ) )
			{
				if( count == index )
				{
					obj.className = "banner_number_over";
				}
				else
				{
					obj.className = "banner_number";	
				}
				count++
			}
		}
	}
}


function stop_banner( slides, parent_id, count )
{
	update_numbers( parent_id, count )
	slides.play = false;
	slides.resetSlides( count );
}

function start_banner( slide, parent_id, count )
{
	update_numbers( parent_id, count );
	slides.play = true;
}

function is_IE6()
{
	var result = false;
	if (typeof document.body.style.maxHeight == "undefined") result = true;
	return result;
}


var timeout         = 500;
var closetimer		= 0;
var closetimer2		= 0;
var ddmenuitem      = 0;
var ddmenuitem2      = 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	if (document.getElementById(id))
	{
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';
	}
}
function mopen2(id)
{	
	// cancel close timer
	mcancelclosetime2();

	// close old layer
	if(ddmenuitem2) ddmenuitem2.style.visibility = 'hidden';

	// get new layer and show it
	if (document.getElementById(id))
	{	
	ddmenuitem2 = document.getElementById(id);
	ddmenuitem2.style.visibility = 'visible';
	}

}

// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}
function mclose2()
{
	if(ddmenuitem2) ddmenuitem2.style.visibility = 'hidden';
}


// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

function mclosetime2()
{
	closetimer2 = window.setTimeout(mclose2, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}
function mcancelclosetime2()
{
	if(closetimer2)
	{
		window.clearTimeout(closetimer2);
		closetimer2 = null;
	}
}

