var active_menu_item;

// TOP MENU related params
var top_menu_items_params =  {	'about' : {'id' : 'about',
											'title' : 'About Sky Country',
											'color_bg' : 'white',
											'color_title' : 'red',
											'container_div_id' : 'container_about'},
								'products' : {'id' : 'products',
											'title' : 'SC Products',
											'color_bg' : 'white',
											'color_title' : 'red',
											'container_div_id' : 'container_products'},
								'contact' : {'id' : 'contact',
											'title' : 'Contact Sky Country',
											'color_bg' : 'white',
											'color_title' : 'red',
											'container_div_id' : 'container_contact'},
								'links' : {'id' : 'links',
											'title' : 'Links',
											'color_bg' : 'white',
											'color_title' : 'red',
											'container_div_id' : 'container_links'}
							};


// LEFT MENU
var left_menu =  {
						'products' :		
								{'gliders' : {'id' : 'leftmenuitem_gliders',
											'title' : 'Gliders',
											'color' : '#365573',
											'color_bg' : '#78BDFF',
											'bg_image' : 'images/gliders_bg.jpg',
											'container_div_id' : 'container_gliders'},
								'harnesses' : {'id' : 'leftmenuitem_harnesses',
											'title' : 'Harnesses and reserves',
											'color_bg' : '#FECECD',
											'color' : '#FE6B68',
											'img_over' : 'images/menu_left_harnesses_over.jpg',
											'container_div_id' : 'container_harnesses'},
								'kites' : {'id' : 'leftmenuitem_kites',
											'title' : 'Kites',
											'color' : '#A0FD7C',
											'color_bg' : '#538441',
											'container_div_id' : 'container_kites'},
								'parachutes' : {'id' : 'leftmenuitem_parachutes',
											'color_bg' : '#FF8661',
											'color' : 'orange',
											'title' : 'Parachutes',
											'container_div_id' : 'container_parachutes'}											
								}
					};

// CORNER ITEMS
var corner_content_items_params = {
									  'gliders' :		
									  {
											'muscat' : 
											{
													'id' : 'muscat',
													'title' : 'MuSCat',
													'color_bg' : '#78bdff',
													'container_div_id' : 'container_muscat',
													'cornericons_div_id' : 'cornercontainer_gliders'
											},
											'discovery2' : 
											{
													'id' : 'discovery2',
													'title' : 'Discovery2',
													'color_bg' : '#78bdff',
													'container_div_id' : 'container_discovery2',
													'cornericons_div_id' : 'cornercontainer_gliders'
											},
											'scorpion2' : 
											{
													'id' : 'scorpion2',
													'title' : 'SCorpion2',
													'color_bg' : '#78bdff',
													'container_div_id' : 'container_scorpion2',
													'cornericons_div_id' : 'cornercontainer_gliders'
											},
											'mystic' : 
											{
													'id' : 'mystic',
													'title' : 'mystic',
													'color_bg' : '#78bdff',
													'container_div_id' : 'container_mystic',
													'cornericons_div_id' : 'cornercontainer_gliders'
											},
											'bidiscovery' : 
											{
													'id' : 'bidiscovery',
													'title' : 'Bi-diSCovery',
													'color_bg' : '#78bdff',
													'container_div_id' : 'container_bidiscovery',
													'cornericons_div_id' : 'cornercontainer_gliders'
											}
										},
									  'kites' :		
									  {
											'alasca' : 
											{
													'id' : 'alasca',
													'color_bg' : '#A0FD7C',
													'container_div_id' : 'container_alasca',
													'cornericons_div_id' : 'cornercontainer_kites'
											},
											'reflex' : 
											{
													'id' : 'reflex',
													'color_bg' : '#A0FD7C',
													'container_div_id' : 'container_reflex',
													'cornericons_div_id' : 'cornercontainer_kites'
											},
											'wave' : 
											{
													'id' : 'wave',
													'color_bg' : '#A0FD7C',
													'container_div_id' : 'container_wave',
													'cornericons_div_id' : 'cornercontainer_kites'
											},
											'buggy' : 
											{
													'id' : 'buggy',
													'color_bg' : '#A0FD7C',
													'container_div_id' : 'container_buggy',
													'cornericons_div_id' : 'cornercontainer_kites'
											}
										}
      							   };


//flying parameters

var params_description = {
							'gliders':
							{
								0: 'Zoom factor', 1: 'Flat surface area,sq.m.', 2: 'Flat wingspan, m', 3: 'Flat aspect ratio', 4: 'Projected surface area, sq.m.', 5: 'Projected wingspan, m', 6: 'Projected aspect ratio', 7: 'Root chord,m', 8: 'Tip chord,m', 9: 'No of cells', 10: 'V min, km/h', 11: 'V max, km/h', 12: 'V y min,m/s', 13: 'Take-off weight, kg'
							},
							'kites':
							{
								0: 'Wing Area (sq.m)', 1: 'Aspect Ratio', 2: 'No of cells', 3: 'Wind Range, km/h (min.opt.max)', 4: 'Recommended retail price (30m lines, handles/bar<br> and a backpack are included), Ca$'
							}
						  };

var params_caption = 	{
						 'gliders':

							 {
								'muscat' : {0: 'Muscat 23', 1: 'Muscat 25', 2: 'Muscat 27', 3: 'Muscat 29', 4: 'Muscat 31'},
								'muscat2' : {0: 'Muscat 23', 1: 'Muscat 25', 2: 'Muscat 27', 3: 'Muscat 29', 4: 'Muscat 31'},
								'discovery2' : {0: 'D2-22', 1: 'D2-24', 2: 'D2-25', 3: 'D2-27', 4: 'D2-28', 5: 'D2-30', 6: 'D2-31', 7: 'D2-33'},
							  	'discovery3' : {0: 'D3-23', 1: 'D3-25', 2: 'D3-27', 3: 'D3-29', 4: 'D2-31', 5: 'D2-33'},
							  	'scorpion2' : {0: 'Scorpion-2 22', 1: 'Scorpion-2 24', 2: 'Scorpion-2 25', 3: 'Scorpion-2 26', 4: 'Scorpion-2 27'},
							  	'mystic' : {0: 'Mystic-24', 1: 'Mystic-25', 2: 'Mystic-26.5'},
							  	'bidiscovery' : {0: 'Bi-DiSCovery-42'}
							  },
						  'kites':	  
							{
								'alasca' : {0: 'alasca 7', 1: 'alasca 10', 2: 'alasca 12'},
							  	'reflex' : {0: 'Reflex 2',  1: 'Reflex 3', 2: 'Reflex 4', 
											3: 'Reflex 5', 4: 'Reflex 6', 5: 'Reflex 7', 
											6: 'Reflex 8', 7: 'Reflex 10'},
							  	'wave' : {0: 'Wave 10', 1: 'Wave 12', 2: 'Wave 15'}
							}  
						};

var params_data = 	{
					'gliders':
						{
							'muscat'	 :
							{
									0 :
									{
										0: '0.923', 1: '23', 2: '10.82', 3: '5.1', 4: '19.43', 5: '8.26', 6: '3.511', 7: '2.653', 8: '0.533', 9: '41', 10: '20', 11: '48', 12: '1.2', 13: '60-75'										
									},
									1 :
									{
										0: '0.962', 1: '25', 2: '11.33', 3: '5.1', 4: '21.11', 5: '8.6', 6: '3.511', 7: '2.765', 8: '0.556', 9: '41', 10: '20', 11: '48', 12: '1.2', 13: '70-90'									
									},
									2 :
									{
										0: '1', 1: '27', 2: '11.73', 3: '5.1', 4: '22.81', 5: '8.95', 6: '3.511', 7: '2.875', 8: '0.578', 9: '41', 10: '20', 11: '48', 12: '1.2', 13: '80-100'
									},
									3 :
									{
										0: '1.036', 1: '29', 2: '12.15', 3: '5.1', 4: '24.48', 5: '9.27', 6: '3.511', 7: '2.978', 8: '0.598', 9: '41', 10: '20', 11: '48', 12: '1.2', 13: '90-115'										
									},
									4 :
									{
										0: '1.071', 1: '31', 2: '12.56', 3: '5.1', 4: '26.16', 5: '9.58', 6: '3.511', 7: '3.079', 8: '0.619', 9: '41', 10: '20', 11: '48', 12: '1.2', 13: '100-125'										
									}
							},
							'muscat2'	 :
							{
									0 :
									{
										0: '0.923', 1: '23', 2: '10.82', 3: '5.1', 4: '19.43', 5: '8.26', 6: '3.511', 7: '2.653', 8: '0.533', 9: '41', 10: '22', 11: '48', 12: '1.2', 13: '60-75'										
									},
									1 :
									{
										0: '0.962', 1: '25', 2: '11.33', 3: '5.1', 4: '21.11', 5: '8.6', 6: '3.511', 7: '2.765', 8: '0.556', 9: '41', 10: '22', 11: '48', 12: '1.2', 13: '70-90'									
									},
									2 :
									{
										0: '1', 1: '27', 2: '11.73', 3: '5.1', 4: '22.81', 5: '8.95', 6: '3.511', 7: '2.875', 8: '0.578', 9: '41', 10: '22', 11: '48', 12: '1.2', 13: '80-100'
									},
									3 :
									{
										0: '1.036', 1: '29', 2: '12.15', 3: '5.1', 4: '24.48', 5: '9.27', 6: '3.511', 7: '2.978', 8: '0.598', 9: '41', 10: '22', 11: '48', 12: '1.2', 13: '90-115'										
									},
									4 :
									{
										0: '1.071', 1: '31', 2: '12.56', 3: '5.1', 4: '26.16', 5: '9.58', 6: '3.511', 7: '3.079', 8: '0.619', 9: '41', 10: '22', 11: '48', 12: '1.2', 13: '100-125'										
									}
							},
							'discovery2' :
							{

									0 :
									{
										0: '0.912', 1: '22.5', 2: '10.8', 3: '5.2', 4: '19.59', 5: '8.7', 6: '3.87', 7: '2.6', 8: '0.543', 9: '23*2+6', 10: '23', 11: '50', 12: '1.1', 13: '60-75'										
									},
									1 :
									{
										0: '0.943', 1: '24', 2: '11.17', 3: '5.2', 4: '20.95', 5: '9', 6: '3.87', 7: '2.691', 8: '0.562', 9: '23*2+6', 10: '23', 11: '50', 12: '1.1', 13: '65-80'										
									},
									2 :
									{
										0: '0.972', 1: '25.5', 2: '11.52', 3: '5.2', 4: '22.25', 5: '9.27', 6: '3.87', 7: '2.773', 8: '0.579', 9: '23*2+6', 10: '23', 11: '50', 12: '1.1', 13: '70-90'										
									},
									3 :
									{
										0: '1', 1: '27', 2: '11.85', 3: '5.2', 4: '20.56', 5: '9.54', 6: '3.87', 7: '2.854', 8: '0.596', 9: '23*2+6', 10: '23', 11: '50', 12: '1.1', 13: '80-100'
									},
									4 :
									{
										0: '1.027', 1: '28.5', 2: '12.17', 3: '5.2', 4: '24.85', 5: '9.8', 6: '3.87', 7: '2.931', 8: '0.612', 9: '23*2+6', 10: '23', 11: '50', 12: '1.1', 13: '90-110'
									},
									5 :
									{
										0: '1.054', 1: '30', 2: '12.49', 3: '5.2', 4: '26.17', 5: '10.06', 6: '3.87', 7: '3.008', 8: '0.628', 9: '23*2+6', 10: '23', 11: '50', 12: '1.1', 13: '100-120'
									},
									6 :
									{
										0: '1.08', 1: '31.5', 2: '12.78', 3: '5.2', 4: '27.48', 5: '10.3', 6: '3.87', 7: '3.082', 8: '0.643', 9: '23*2+6', 10: '23', 11: '50', 12: '1.1', 13: '110-130'
									},
									7 :
									{
										0: '1.06', 1: '33', 2: '13.11', 3: '5.2', 4: '28.82', 5: '10.55', 6: '3.87', 7: '3.156', 8: '0.659', 9: '23*2+6', 10: '23', 11: '50', 12: '1.1', 13: '120-145'
									}	
							},
							'discovery3' :
							{

									0 :
									{
										0: '0.923', 1: '22.95', 2: '11.04', 3: '5.31', 4: '19.84', 5: '8.73', 6: '3.84', 7: '2.62', 8: '0.46', 9: '53', 10: '24', 11: '52', 12: '1.1', 13: '60-80'					
									},
									1 :
									{
										0: '0.962', 1: '24.93', 2: '11.5', 3: '5.31', 4: '21.55', 5: '9.1', 6: '3.84', 7: '2.735', 8: '0.48', 9: '53', 10: '24', 11: '52', 12: '1.1', 13: '70-90'									
									},
									2 :
									{
										0: '1', 1: '26.94', 2: '11.96', 3: '5.31', 4: '23.79', 5: '9.46', 6: '3.84', 7: '2.843', 8: '0.5', 9: '53', 10: '24', 11: '52', 12: '1.1', 13: '80-100'												
									},
									3 :
									{
										0: '1.036', 1: '28.91', 2: '12.39', 3: '5.31', 4: '25.0', 5: '9.8', 6: '3.84', 7: '2.945', 8: '0.52', 9: '53', 10: '24', 11: '52', 12: '1.1', 13: '90-115'
									},
									4 :
									{
										0: '1.72', 1: '30.95', 2: '12.82', 3: '5.31', 4: '26.76', 5: '10.14', 6: '3.84', 7: '3.04', 8: '0.54', 9: '53', 10: '24', 11: '52', 12: '1.1', 13: '105-130'
									},
									5 :
									{
										0: '1.105', 1: '32.89', 2: '13.21', 3: '5.31', 4: '28.44', 5: '10.45', 6: '3.84', 7: '3.14', 8: '0.55', 9: '53', 10: '24', 11: '52', 12: '1.1', 13: '120-145'
									}
							},
							'scorpion2' :
							{

									0 :
									{
										0: '0.921', 1: '22.5', 2: '11.33', 3: '5.81', 4: '19.64', 5: '9.18', 6: '4.295', 7: '2.45', 8: '0.43', 9: '59', 10: '22', 11: '55+', 12: '0.9', 13: '60-75'										
									},
									1 :
									{
										0: '0.946', 1: '24', 2: '11.8', 3: '5.809', 4: '20.98', 5: '9.49', 6: '4.295', 7: '2.54', 8: '0.44', 9: '59', 10: '22', 11: '55+', 12: '0.9', 13: '70-85'										
									},
									2 :
									{
										0: '0.975', 1: '25.5', 2: '12.1', 3: '5.809', 4: '22.28', 5: '9.78', 6: '4.295', 7: '2.62', 8: '0.45', 9: '59', 10: '22', 11: '55+', 12: '0.9', 13: '80-100'
									},
									3 :
									{
										0: '1', 1: '26.5', 2: '12.31', 3: '5.809', 4: '23.16', 5: '9.97', 6: '4.295', 7: '2.67', 8: '0.46', 9: '59', 10: '22', 11: '55+', 12: '0.9', 13: '90-115'
									},
									4 :
									{
										0: '1.013', 1: '27.5', 2: '12.53', 3: '5.809', 4: '24.05', 5: '10.16', 6: '4.295', 7: '2.72', 8: '0.47', 9: '59', 10: '22', 11: '55+', 12: '0.9', 13: '100-130'
									}
							},
							'mystic' :
							{

									0 :
									{
										0: '1', 1: '24', 2: '12.37', 3: '6.37', 4: '21', 5: '10.12', 6: '4.88', 7: '2.415', 8: '0.426', 9: '71', 10: '24', 11: '60', 12: '0.9', 13: '80-100'										
									},
									1 :
									{
										0: '1.025', 1: '25.2', 2: '12.68', 3: '6.37', 4: '22.06', 5: '10.37', 6: '4.88', 7: '2.475', 8: '0.437', 9: '71', 10: '24', 11: '60', 12: '0.9', 13: '90-115'
									},
									2 :
									{
										0: '1.05', 1: '26.5', 2: '12.99', 3: '6.37', 4: '23.15', 5: '10.63', 6: '4.88', 7: '2.536', 8: '0.447', 9: '71', 10: '24', 11: '60', 12: '0.9', 13: '105-130'
									}
							},	
							'bidiscovery' :
							{
									0 :
									{
										0: '1.225', 1: '42', 2: '14.7', 3: '5.12', 4: '36.8', 5: '11.72', 6: '3.73', 7: '3.713', 8: '0.49', 9: '47', 10: '25', 11: '42', 12: '1.3', 13: '150-220'										
									}
							},
							
						},
					
					'kites':
					{				
							'alasca' :
							{

									0 :
									{
										0: '7.5', 1: '4.1', 2: '24', 3: '25 36 54', 4: '1000'
									},
									1 :
									{
										0: '10', 1: '4.1', 2: '24', 3: '18 29 43', 4: '1100'
									},
									2 :
									{
										0: '12.5', 1: '4.1', 2: '24', 3: '14 22 36', 4: '1200'
									}
							},
							'reflex' :
							{

									0 :
									{
										0: '2', 1: '5.1', 2: '34', 3: 'go nuts', 4: '410'
									},
									1 :
									{
										0: '3', 1: '5.1', 2: '34', 3: '29 43 57', 4: '480'
									},
									2 :
									{
										0: '4', 1: '5.1', 2: '34', 3: '22 36 50', 4: '515'
									},
									3 :
									{
										0: '5', 1: '5.1', 2: '34', 3: '18 29 43', 4: '560'
									},
									4 :
									{
										0: '6', 1: '5.1', 2: '34', 3: '16 25 39', 4: '625'
									},
									5 :
									{
										0: '7.2', 1: '5.1', 2: '34', 3: '14 22 36', 4: '720'
									},
									6 :
									{
										0: '8.5', 1: '5.1', 2: '34', 3: '10 18 32', 4: '775'
									},
									7 :
									{
										0: '10', 1: '5.1', 2: '34', 3: '7 14 29', 4: '800'
									}
							},
							'wave' :
							{

									0 :
									{
										0: '10', 1: '4.4', 2: '27', 3: '29 36 50', 4: '915'
									},
									1 :
									{
										0: '12.5', 1: '4.4', 2: '27', 3: '21 29 43', 4: '1000'
									},
									2 :
									{
										0: '15', 1: '4.4', 2: '27', 3: '14 21 36', 4: '1100'
									}
							}
						}
					};





// FUNCTIONS


function topmenu_change(menu_item)
{
	for (i = 0; i < menu_item.parentNode.childNodes.length; i++)
	{
		kid = menu_item.parentNode.childNodes[i];
		if (kid.tagName == "TD" && kid == active_menu_item)
		{
			kid.bgColor = '';
		}
	}
	active_menu_item = menu_item;
	menu_item.bgColor = 'white';
	
}

function leftmenu_change(leftmenu_item, key_event)
{
	var section_name = leftmenu_item.parentNode.parentNode.parentNode.id.replace('leftmenu_table_', '');
	var section = left_menu[section_name];
	var leftmenu_item_id = leftmenu_item.id.replace('leftmenuitem_', '');
	
	if (key_event == 'onclick')
	{
		//new_classname = 'active';
		new_bg_key = '_active';
		
		for (index in section)
		{
			var obj = get(section[index].id);
			if (obj != leftmenu_item)		//release the previous active menu
			{
				//if (classname(obj, 'check', 'active'))
				if (obj.style.backgroundImage.indexOf('active'))
				{
					//classname(obj, 'swap', 'active', 'off');
					section_off = obj.id.replace('leftmenuitem_', '');
					obj.style.backgroundImage = "url(images/menu_left_" + section_off + ".gif)";
				}
			}
		}

		replace_content(left_menu[section_name][leftmenu_item_id]);

	}
	
	if (key_event == 'over')
	{
		//new_classname = 'over';
		new_bg_key = '_over';
	}
	if (key_event == 'out')
	{
		var content_table_section = 'content_table_' + leftmenu_item_id;

		if (get(content_table_section).parentNode.id != 'content_wrapper')
		{
			//new_classname = 'off';
			new_bg_key = '';
		}
		else 
		{
			//new_classname = 'active';			
			new_bg_key = '_active';
		}
	}
	//leftmenu_item.className = new_classname;	

	leftmenu_item.style.backgroundImage = "url(images/menu_left_" + leftmenu_item_id + new_bg_key + ".gif)";

}

function replace_content(menu_item_array)	//something like 'gliders' or 'about'. So we can get our container_div and its innerHTML
{
	var container_div_id = menu_item_array.container_div_id;
	var new_content = document.getElementById(container_div_id);
	var content_wrapper = document.getElementById('content_wrapper');

	get('debug').innerHTML = menu_item_array.title;
	

	if (menu_item_array['cornericons_div_id'])
	{
			var cornericons = get(menu_item_array['cornericons_div_id']);
			var corneritems_innerHTML = cornericons.innerHTML;
			
	}
	else
	{
			var corneritems_innerHTML = '';		
	}

	var new_content = document.getElementById(container_div_id);
	
	
	content_wrapper.innerHTML = corneritems_innerHTML + new_content.innerHTML;
	
	document.body.bgColor = menu_item_array.color_bg;
	document.body.background = menu_item_array.bg_image;
	
}


function icon_action(this_td, key_event)
{	

	var class_new; var class_was;
	var kids = getKids(this_td, 'DIV');
	
	var icon_name = this_td.id.replace('_icon', '');	//for example 'discovery2'
	icon_name = icon_name.replace('_corner', '');	//if it is a corner icons like for gliders

	
	var papa = this_td.parentNode.parentNode.parentNode;


	this_td.style.cursor = 'pointer';

	for (i=0; i<kids.length; i++)
	{
		kid = kids[i];
		
		if(kid.className.indexOf('icon_title') != -1)		// .1. model description	// .3. model name
		{
			switch (key_event)
			{
				case  'over':
				case  'onclick':
					class_was = kid.className.replace('_over', '');
					class_new = class_was + '_over';
					//alert('class_was = ' + class_was + '  and class_new = ' + class_new);
				break;
			
				case  'out':
					class_new = kid.className.replace('_over', '');
					class_was = class_new + '_over';
				break;
			}

			classname(kid, 'swap', class_was, class_new);	
		}
		
		if(!kid.className)							// .2. icon is inside
		{
			
			/*
			try	//see if img tag is wrapped in <a>
			{
				var as = getKids(kid, 'A');
				var tag = as[0];
			}
			catch (e)
			{
				var tag = kid;		
			}
			var imgs = getKids(tag, 'IMG');
			var this_img = imgs[0];
			
			var cur_src = this_img.src;
			var folders = new Array();
			folders = cur_src.split('/');
			switch (key_event)
			{
				case  'over':
				case  'onclick':

					var new_src = 'images/' + folders[folders.length - 1].replace('icon.jpg','icon_over.jpg');
					
				break;
			
				case  'out':
					//window.parent.header.get('debug').innerHTML = 'content_table'+icon_name;
					//var content_wrapper = document.getElementById('content_wrapper');
					var new_src = 'images/' + folders[folders.length - 1].replace('_over.jpg','.jpg');
					
				break;
			}
	
			this_img.src = new_src;
			*/
			
		}	
				
	}

	if (key_event == 'onclick')		//switch to the specific model
	{
		this.location.href = icon_name + '.php';	
	}
		
	return;
		
}

function replace_content(pagename)
{
	window.location = pagename;	
}

function replace_mainimage(icon_obj, mainimage_id)
{
	//alert(icon_obj.height);
	var img_newclassname =  (icon_obj.height > icon_obj.width) ? 'side_image_vert pointer' : 'side_image_hor pointer';
	
	document.getElementById(mainimage_id).src = icon_obj.src.replace('/icons', '');
	
	document.getElementById(mainimage_id).className = img_newclassname;
}

function showBigimage(mainimage)
{
	var newimgsrc = mainimage.src.replace('/icons', '');
	var newimg = new Image;
	newimg.src = newimgsrc;
	
	var w_width = newimg.width + 30;
	var h_width = newimg.height + 30;
	
	var winref = window.open(newimgsrc,'bigpicture','width=' + w_width + ',height=' + h_width + ',resizable=yes,scrollbars=yes,toolbar=no,status=no');
	winref.resizeTo(w_width, h_width);
	//alert(newimg.width + ' and height = ' + newimg.height);
	winref.focus();
	
}

function buildGliderTable(product_name, model_name)
{
	var caption = params_caption[product_name][model_name];
	var description = params_description[product_name];
	var params = params_data[product_name][model_name];

	var html = "<table id='chart' class='chart'>";
	//var caption_color = left_menu['products'][product_name]['color_'];
	html += "<tr>";
	
	
	html += "<td>&nbsp;</td>";		//to match the headers with data
	for (i in caption)
	{
		html += "<td><b><nobr>";
		html += caption[i];
		html += "</nobr></b></td>";
	}
	html += "</tr>";
	
	var counter = 0;
	for (tr in description)
	{
		//class_name = (counter%2 > 0) ? "chart_odd" :  "chart_even";
		color = left_menu['products'][product_name]['color_bg'];
		color_bg = (counter%2 > 0) ? left_menu['products'][product_name]['color'] :  "white";
		color_text = (counter%2 > 0) ? "white" : "#636F77";
	
		counter++;
		html += "<tr style='color:" + color + "; background-color:" + color_bg + "'>";
		
		//left header
		
		html += "<td class='chart_subtitle' style='color:" + color_text + "'><nobr>";
		html += description[tr];
		html += "</nobr></td>";
	
		for (td in params)
		{
			html += "<td>";
			html += params[td][tr];
			html += "</td>";
		}
		
		html += "</tr>";
	}
	
	html += "</tr>";
	html += "</table>";
	
	document.write(html);
	//$("#chart_holder").html(html);
	//document.getElementById('chart').parentNode.style.border = "red solid thin";
	//document.getElementById('chart').parentNode.style.height = '450px';
	//alert(document.getElementById('chart').parentNode.style.height);
}


	function showMenuProductsDropdown()
	{
		var menu = get('products_dropdown');
		if (menu)
		{
			var d = menu.style.display;
			menu.style.display = (d == 'none') ? '' : 'none';
		}
		else
		{
			var menu_template = window.parent.header.document.getElementById('products_dropdown_template');
			var menu = menu_template.cloneNode(true);
			menu.id = 'products_dropdown';
			menu.style.display = '';
			document.body.appendChild(menu);
		}
	}




function newWindow(a_link, window_name)
{
	var winref = window.open(a_link, window_name);
	winref.focus();
}


function get_first_array_elem(arr)
{
	for(index in arr)
	{
		return arr[index];
	}
}


function goToMain(logo_link)
{
	
	if (window.parent.header)	//if are in the frameset
	{
		window.parent.document.location.href = 'index.php';
	}
	else
	{
		logo_link.href = "index.php";
		logo_link.click();
	}			
}



// ----------------------------------------------------------------------------------
String.prototype.trim = function() { return (( ar = /^\s*([\s\S]*\S+)\s*$/.exec(this)) ? ar[1] : "" ); }  // example:  str = str.trim();

function isElem(elem)
{
    return (elem && elem.tagName) ? true : false;
}

function get(elem)
{
    if (arguments.length == 1)
    {
        return (isElem(elem)) ? elem : document.getElementById(elem);
    }
    else
    {
        for (var i = 0, args = new Array(); i < arguments.length; i++)
        {
            args.push(arguments[i]);
        }
        return superget(args);
    }
}

function classname(node, op, c1, c2)
{
    if (node = get(node))
    {
    	if (op == 'clear')
    	{
    		node.className = "";
    		return;
    	}
        if (op == 'split')
        {
            return (node.className.trim() != "") ? node.className.split(/\s+/) : new Array();
        }
        var cn = node.className;
        var index = cn.search('\\b' + c1 + '\\b');
        var exists = (index < 0) ? 0 : 1;
        var length = c1.length;
        var middle = "";

        index = (exists) ? index : cn.length;

        var pre = cn.substr(0, index).trim();
        var post = cn.substr(index + length).trim();

        switch (op)
        {
            case 'add':
                middle = c1;
            break;

            case 'swap':
                middle = (exists) ? c2 : "";
            break;

            case 'check':
            return (exists);
        }
        node.className = (pre + " " + middle + " " + post).trim();

        if (op == 'switch')
        {
            classname(node, 'add', c2);
        }
        else if (op == 'swap' && !exists)
        {
            classname(node, 'switch', c2, c1);
        }
        return node;
    }
    return null;
}

function getKids(elem, tag_name)
{	
	//var tr = this_td.parentNode;
	//var tds = tr.childNodes;
	try
	{
		var hastagname = elem.tagName;
	}
	catch(e)
	{
		return false;
	}
	var kids = elem.childNodes;
	if (!tag_name || tag_name == '' || tag_name == null || tag_name == 'all')
		return kids;
	var kids_out = new Array(); 
	for (i=0; i<kids.length; i++)
	{
		kid = kids[i];
		if(kid.tagName == tag_name)
		{
			kids_out.push(kid);	
		}		
	}
	

	return kids_out;
}


