var colors = new Array();
colors[0] = '#6B8A98';// default color
colors[1] = '#3c8c1e';//marci
colors[2] = '#a1b4b8';//femei
colors[3] = '#6b8a98';//mamici
colors[4] = '#9d8ba6';//copii
colors[9] = '#ae6688';//adolescenti
colors[5] = '#6b797c';//barbati
colors[6] = '#513468';//marimi mari
colors[11] = '#e8a1c3';//lenjerie
colors[8] = '#9c937c';//incaltaminte
colors[10] = '#8dbcde';//sport
colors[12] = '#abbc58';//lenjerii de pat
colors[13] = '#7c6a62';//accesorii casa
colors[14] = '#D90000';//lichidari de stoc

var curent_hover_elem = 0;
var curent_dep_id = 0;
var visible = false;
var need_to_hide = false;
var need_to_change = true;
var hide1_login = false;
var focus_text = false;
var focus_pass = false;

function focus_this(what, really){
	if (really){
		if (what == 1){
			focus_text = true;
		} else {
			focus_pass = true;
		}
	} else {
		if (what == 1){
			focus_text = false;
		} else {
			focus_pass = false;
		}
	}
}

function select_togle_pagina(pos){
	if (pos.parentNode.getAttribute('id')=='nrpag1'){
		if (document.getElementById('meniu_paginare1').style.display == 'block'){
			document.getElementById('meniu_paginare1').style.display = 'none';
		} else {
			document.getElementById('meniu_paginare1').style.display = 'block';
			document.getElementById('meniu_paginare1').style.border = '1px solid '+colors[selectat];
		}
	} else {
		if (document.getElementById('meniu_paginare2').style.display == 'block'){
			document.getElementById('meniu_paginare2').style.display = 'none';
		} else {
			document.getElementById('meniu_paginare2').style.display = 'block';
			document.getElementById('meniu_paginare2').style.border = '1px solid '+colors[selectat];
		}
	}
}


function meniu_pagini_hover(elem, position, attribute, def_color){
	var atribut = 'background-color';
	if (attribute != undefined){
		atribut = attribute;
	}
	var def_c = '#FFFFFF';
	if (def_color != undefined){
		def_c = def_color;
	}
	var old_style = elem.getAttribute('style');
	var color = colors[selectat];
	if (elem.getAttribute('departament_id')){
		color = colors[elem.getAttribute('departament_id')];
	}
	if (position == 1){
		elem.style.cssText = old_style + '; ' + atribut + ':' + color;
	} else {
		elem.style.cssText = old_style + '; ' + atribut + ':' + def_c;
	}
}

function show_login(){
	hide1_login = false;
	show_hide_login(1);
}

function hide_login(){
	var hide = true;
	if (focus_text){
		hide = false;
	}
	if (focus_pass) {
		hide = false;
	}
	if (hide){
	hide1_login = true;
	setTimeout('show_hide_login(2)', 100);
	}
}

function show_hide_login(act){
	if (act == 1){
		document.getElementById('submenu_nou_user').style.display='block';
		document.getElementById('submenu_nou_user_transparent_layer').style.display='block';
		document.getElementById('login_label').style.background = 'url(/views/images/menu_nou/drop-up.png)';

	} else {
		if (hide1_login){
			document.getElementById('submenu_nou_user').style.display = 'none';
			document.getElementById('submenu_nou_user_transparent_layer').style.display='none';
			document.getElementById('login_label').style.background = 'url(/views/images/menu_nou/cont_bg.png)';
            document.getElementById('login_label').style.backgroundRepeat = 'no-repeat';
		}
	}
}

function dont_hide_this(){
	need_to_change = false;
	hover_this_menu(curent_hover_elem, curent_dep_id);
}

function hide_it(){
	unhover_this_menu(curent_hover_elem);
}

function unhover_all(elem){
	var element = document.getElementById('main_menu_nou');
	var elements  = element.getElementsByTagName('li');
	var i = 0;
	var elem;
	for (i = 0; i < elements.length; i++){
		if (elements[i] != elem){
			if (elements[i].getAttribute('dep_id') != selectat){
				elem = elements[i];
				elem.style.backgroundColor = '#ffffff';
				elem.getElementsByTagName('a')[0].style.color = '#556e73';
			}
		}
	}
}

function hover_this_menu(elem, dep_id){
	unhover_all(elem);
	need_to_hide = false;
		elem.style.backgroundColor = colors[dep_id];
		elem.getElementsByTagName('a')[0].style.color = '#FFFFFF';
	if (dep_id != curent_dep_id){
		curent_hover_elem = elem;
		visible= true;
		curent_dep_id = dep_id;
		if ((dep_id != 1)&&(dep_id != 14)){
			show_submenu(dep_id, 'submenu_menu_nou');
		} else {
			document.getElementById('submenu_menu_nou').style.display = 'none';
		}
	} else {
		if (need_to_change){
			elem.style.backgroundColor = colors[dep_id];
			need_to_change = true;
			curent_hover_elem = elem;
			visible= true;
			elem.getElementsByTagName('a')[0].style.color = '#FFFFFF';
			curent_dep_id = dep_id;
			if ((dep_id != 1)&&(dep_id != 14)){
				show_submenu(dep_id, 'submenu_menu_nou');
			}
		}
	}
}

function unhover_this_menu(elem){
	need_to_hide = true;
	setTimeout('unhover1_this_menu()', 150);
}

function unhover1_this_menu(){
	if (need_to_hide){
		if (selectat != curent_dep_id){
			curent_hover_elem.style.backgroundColor = '#FFFFFF';
			curent_hover_elem.getElementsByTagName('a')[0].style.color = '#556E73';
		}
		document.getElementById('submenu_menu_nou').style.display = 'none';
		visible = false;
	} 
}

	var inaltimi = new Array();
	var aranjare = new Array();

function show_submenu(departament_id, div_id){
	if ((departament_id != '1')&&(departament_id != '14')){
		document.getElementById(div_id).style.display = 'block';
	} else {
		document.getElementById(div_id).style.display = 'none';
	}
	if (!adresa_siteului){
		var adresa_siteului = 'http://www.laredoute.ro';
	}
	document.getElementById(div_id).style.backgroundColor = colors[departament_id];
	var elem = document.getElementById(div_id);
	var text = '';
	text += '<div class="menu_white_panel">';
	text += '<img src="'+adresa_siteului+'/views/images/menu_nou/'+departament_id+'.jpg" style="_width:170px;" />';
	var i = 0;
	var j =0;
	var nr = 0;
    var nrcol = 0;
    cat_parinte = 0;
    var catnr = 0;
    var col = 1;
    text += '<table cellpadding="0" cellspacing="0"><tr>';
    //pun in coloane textul care trebuie pus pentru categorii
    txt_col1 = '';
    txt_col2 = '';
    txt_col3 = '';
    for (i =0; i < categorii_id.length; i++){
        if (categorii_departament[i]==departament_id && categorii_parent[i] == 0 && catnr < 9 ){
            nr = 0;
            if(col == 1){
                txt_col1 += '<div class="categorie" style="display:block;" id="categoria_'+categorii_id[i]+'"> <a href="'+ categorii_link[i] +'" class="link_categorie" style="color:'+colors[departament_id]+';width:170px;">'+categorii_name[i]+'</a>';
                for (j = 0; j < categorii_id.length; j++){
					if (nr < 4){
						if (categorii_parent[j] == categorii_id[i]){
							nr++;
							txt_col1 += '<a href="'+ categorii_link[j] +'" class="link_subcategorie" style="display:block;clear:both;width:150px;">'+categorii_name[j]+'</a>';
						}
					}
				}
				if (nr == 4){
					txt_col1 += '<a href="'+ categorii_link[i] +'" class="categorie" style="display:block;clear:both;font-weight:normal;color:'+colors[departament_id]+';padding-left:50px;">Toate categoriile...</a>';
				}
                txt_col1 += '</div>';
                col++;
            }
            else if(col == 2){
                txt_col2 += '<div class="categorie" style="display:block;float:left;" id="categoria_'+categorii_id[i]+'"> <a href="'+ categorii_link[i] +'" class="link_categorie" style="color:'+colors[departament_id]+';width:170px;">'+categorii_name[i]+'</a>';
                for (j = 0; j < categorii_id.length; j++){
					if (nr < 4){
						if (categorii_parent[j] == categorii_id[i]){
							nr++;
							txt_col2 += '<a href="'+ categorii_link[j] +'" class="link_subcategorie" style="display:block;clear:both;width:150px;">'+categorii_name[j]+'</a>';
						}
					}
				}
				if (nr == 4){
					txt_col2 += '<a href="'+ categorii_link[i] +'" class="categorie" style="display:block;clear:both;font-weight:normal;color:'+colors[departament_id]+';padding-left:50px;">Toate categoriile...</a>';
				}
                txt_col2 += '</div>';
                col++;
            }
            else if(col == 3){
                txt_col3 += '<div class="categorie" style="display:block;float:left;" id="categoria_'+categorii_id[i]+'"> <a href="'+ categorii_link[i] +'" class="link_categorie" style="color:'+colors[departament_id]+';width:170px;">'+categorii_name[i]+'</a>';
                for (j = 0; j < categorii_id.length; j++){
					if (nr < 4){
						if (categorii_parent[j] == categorii_id[i]){
							nr++;
							txt_col3 += '<a href="'+ categorii_link[j] +'" class="link_subcategorie" style="display:block;clear:both;width:150px;">'+categorii_name[j]+'</a>';
						}
					}
				}
				if (nr == 4){
					txt_col3 += '<a href="'+ categorii_link[i] +'"  style="display:block;clear:both;font-weight:normal;color:'+colors[departament_id]+';padding-left:50px;">Toate categoriile...</a>';
				}
                txt_col3 += '</div>';
                col = 1;
            }
            catnr++;
        }
    }
    text += '<td valign="top">'+txt_col1+'</td>'+'<td  valign="top">'+txt_col2+'</td>'+'<td  valign="top">'+txt_col3+'</td>';
//    td = true;
//	for (i =0; i < categorii_id.length; i++){
//
//		if (categorii_departament[i]==departament_id){
//			if (categorii_parent[i] == 0){
//			  if(td == true){
//				        text += '<td valign="top" style="width:180px;">';
//                        td    = false;
//				    }
//				nr = 0;
//				text += '<div class="categorie" style="display:block;float:left;clear:right;" id="categoria_'+categorii_id[i]+'"> <a href="'+ categorii_link[i] +'" class="link_categorie" style="color:'+colors[departament_id]+'">'+categorii_name[i]+'</a>';
//                nrcol += 1;
//				for (j = 0; j < categorii_id.length; j++){
//					if (nr < 4){
//						if (categorii_parent[j] == categorii_id[i]){
//							nr++;
//							text += '<a href="'+ categorii_link[j] +'" class="link_subcategorie">'+categorii_name[j]+'</a>';
//                            nrcol++;
//						}
//					}
//				}
//				if (nr == 4){
//					text += '<a href="'+ categorii_link[i] +'" class="link_subcategorie">...</a>';
//                    nrcol++;
//				}
//				text += '</div>';
//                if(nrcol >= 14){
//                    text += '</td>';
//                    nrcol = 0;
//                    td = true;
//                }
//			}
//		}
//	} //190 55
	text += '</tr></table></div>';
	text += "<div class='menu_right_panel'><!--[if !IE]> -->"
	text += '<object type="application/x-shockwave-flash" wmode="transparent"';
	text += 'data="/views/flash/menu_nou/flash1.swf" width="255" height="245">';
	text += '<!-- <![endif]--><!--[if IE]><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="255" height="245"> <param name="movie" value="/views/flash/menu_nou/flash1.swf" /> <!--><!--dgx-->  <param name="loop" value="true" />  <param name="menu" value="false" /> <param name="wmode" value="transparent">  <p>This is <b>alternative</b> content.</p></object><!-- <![endif]-->';
	text += '</div>';


	inaltimi.length = 0;
	elem.innerHTML = text;
//	for (i =0; i < categorii_id.length; i++){
//		if (categorii_departament[i]==departament_id){
//			if (categorii_parent[i] == 0){
//				inaltimi[inaltimi.length] = document.getElementById('categoria_'+categorii_id[i]).offsetHeight;
//			}
//		}
//	}
	
}