﻿
var outColor="#363A40"
var overColor="#980000"
var sizeH=0;
var menuTopPosition = 100;
var menuItem = new Array();
var glan;
var lan=1;

var c=0;
var t;



function timedCount()
{
if (c == 1) {
     c= 0;  
    Display('banner2');Hide('banner1');
} else {
    Display('banner1');Hide('banner2');
    c=1;
}

t=setTimeout("timedCount()",10000);
}




function Display(id) {
    try {
    var oObject=document.getElementById(id);
    oObject.style.display="block";
    } catch(err) {
    }
}

function Hide(id) {
    try {
    var oObject=document.getElementById(id);
    oObject.style.display="none";
    } catch(err) {
    }
}

function MouseOver(Id) {
    obj = document.getElementById(Id);
	obj.style.backgroundColor=overColor;
} 

function genericMouseOut(Id) {
    obj = document.getElementById(Id);
	obj.style.backgroundColor=outColor;
} 

function LoadImg(oId,sImg) {
  var oObject=document.getElementById(oId);
  oObject.src=sImg;
}

function LoadTopBanner(lan) {
  var oObject=document.getElementById('bannerTop');
  oObject.style.backgroundImage="url('images/bannerTop" + lan + ".gif')";
}


function LoadBGImg(oId,sImg) {
  var oObject=document.getElementById(oId);
  oObject.style.backgroundImage="url('" + sImg +"')";
}

function DisplaySubmenu(menutype,Id) {
  
    array=getArray(menutype);
    array[getIndex(array,Id)].on=true;
    for (x in array) {
        if (array[x].parentId==Id) {
           Display(array[x].Id)
        }
    }
}

function HideSubmenu(menutype,Id) {
    if (Id!="") {
            array=getArray(menutype);
            array[getIndex(array,Id)].on=false;}
        for (x in array) {
            if (Id=="") {
                if (array[x].parentId!="") {Hide(array[x].Id)}
            } else {
            if (array[x].parentId==Id) {
               Hide(array[x].Id)
            }
        }
    }
}

function LoadBGImgFromLeft(bgpicture) {
  oObject=getMenuPageElement('banner')
  oObject.style.backgroundImage="url('images/menu/" + bgpicture + "')";

}


function getMenuPageElement(objName) {
   var obj;
   
   
   if (navigator.appName.indexOf("Microsoft") != -1) {
    obj=parent.menupage.window[objName]
 }
 else {
  obj=parent.menupage.document[objName]
 }
 
   return(obj);
}

function MouseOut(menutype,Id) {
    array=getArray(menutype);
    
    var index=getIndex(array,Id);
    if ((array[index].keepon) == false) {
        genericMouseOut (Id)
    }
}

function getIndex(array,Id) {
    for (x in array) {
        if (array[x].Id==Id) {
            return array[x].index;
        }
    }
}

function AddMenuItem(menuItem,addSpace,lan)
{

	
	objMenuItem = document.getElementById(menuItem.Id);
	objMenuItem.innerHTML = "";
	space="";
	if (addSpace==1) {
	    space="&nbsp" + "&nbsp" 
	}
	
	if (addSpace==2) {
	    space="&nbsp" + "&nbsp" +"&nbsp" + "&nbsp" 
	} 
	

   
	if (menuItem.parentId=="") {
        if (lan=='EN') {
	        objMenuItem.innerHTML = "<div class='separator2px'></div><div class='txtMenuEN'>" + menuItem.Text +  space+ "</div>";
	    } else {

	        objMenuItem.innerHTML ="<div class='separator2px'></div><div class='txtMenuES'>" + menuItem.TextES +  space+ "</div>";
	    }
	    objMenuItem.style.display="block";
	} 
	else {
	    objMenuItem.style.display="none";
	    
	    if (menuItem.last==1) {
        if (lan=='EN') {
	        objMenuItem.innerHTML = "<div class='separator2px'></div><div class='txtMenuEN'>" + menuItem.Text +  space+ " </div>";
	    } else {

	        objMenuItem.innerHTML ="<div class='separator2px'></div><div class='txtMenuES'>" + menuItem.TextES +  space+ " </div>";
	    }
	    } else {
	    
        if (lan=='EN') {
	        objMenuItem.innerHTML = "<div class='separator2px'></div><div class='txtMenuEN'>" + menuItem.Text +  space+ "<div class='separatorWhite'></div></div>";
	    } else {

	        objMenuItem.innerHTML ="<div class='separator2px'></div><div class='txtMenuES'>" + menuItem.TextES +  space+ "<div class='separatorWhite'></div></div>";
	    }	    
	    }
	}

}


function menu(index,Id,Text,TextES,menuLink,parentId,bgpicture,last) {
    this.Text=Text;
    this.Id=Id;
    this.top=1;
    this.left=1;
    this.parentId=parentId;
    this.index=index;
    this.on=false;
    this.keepon=false;
    this.TextES=TextES;
    this.menuLink=menuLink;
    this.bgpicture=bgpicture;
    this.last=last;
}

function MouseClick(menutype,Id) {
   array=getArray(menutype);
   parentId=array[getIndex(array,Id)].parentId
   bgpicture=array[getIndex(array,Id)].bgpicture
   isOn=array[getIndex(array,Id)].on 
   
    if (parentId=="") {
	     if (menutype=="top") { 
	        for (x in array) {
                array[x].on=false;
            }
           
    }
    
    if (!isOn) {
        for (x in array) {
            HideSubmenu(menutype,array[x].Id);
        }
        DisplaySubmenu(menutype,array[getIndex(array,Id)].Id)
        array[getIndex(array,Id)].on=true;
    } else {
        array[getIndex(array,Id)].on=false;}
	}
	
}


menuItem[0]=    new menu(0,"menu_0"     ,"THE CHAMBER"          ,"LA CÁMARA"                ,"QuienesSomos.aspx"       ,"","whatisthechamber.jpg",0);

menuItem[1]=    new menu(1,"menu_1"     ,"SERVICES"             ,"SERVICIOS"                 ,""                   ,"","",0);
  menuItem[2]=  new menu(2,"menu_1_0"   ,"PROMOTION"            ,"PROMOCIÓN"                 ,"promotion.aspx"     ,"menu_1","promocion.jpg",0);
  menuItem[3]=  new menu(3,"menu_1_1"   ,"INFORMATION"          ,"INFORMACIÓN"               ,"Information.aspx"   ,"menu_1","informacion.gif",0);
  menuItem[4]=  new menu(4,"menu_1_2"   ,"MANAGEMENT & CONSULTANCY"  ,"ASESORÍA Y GESTIÓN"   ,"Asesoria.aspx"    ,"menu_1","asesoria.jpg",0);
  menuItem[5]=  new menu(5,"menu_1_3"   ,"LIAISON OFFICE" ,   "OFICINA DE ENLACE"          ,"Oficina.aspx"        ,"menu_1","oficina.jpg",1);

menuItem[6]=    new menu(6,"menu_2"     ,"PUBLICATIONS"         ,"PUBLICACIONES"             ,"Publicaciones.aspx"  ,"","publicaciones.jpg",0);

menuItem[7]=   new menu(7, "menu_3"     ,"EVENTS"               ,"EVENTOS"                   ,""                    ,"","",0);
 menuItem[20]= new menu(20,"menu_3_0"   ,"PAST"                 ,"PASADOS"                   ,"EventsDB.aspx?Type=0"    ,"menu_3"  ,"eventspast.jpg",0);
 menuItem[21]= new menu(21,"menu_3_1"   ,"FUTURE"               ,"FUTUROS"                   ,"EventsDB.aspx?Type=1"  ,"menu_3"  ,"eventsfuture.jpg",0);
 menuItem[26] = new menu(26, "menu_3_2" ,"TRADE EVENTS"         ,"MISIONES COMERCIALES"      , "EventsDB.aspx?Type=3", "menu_3", "trade.jpg", 0);
 menuItem[22] = new menu(22, "menu_3_3" ,"MEMBERS’ EVENTS"      ,"DE EMPRESAS ASOCIADAS"     , "EventsDB.aspx?Type=2", "menu_3", "eventos.jpg", 1);
 


menuItem[8]=    new menu(8,"menu_4"      ,"TRAINING"             ,"FORMACIÓN"                 ,""                    ,"","",0);
  menuItem[9]=  new menu(9,"menu_4_0"    ,"YOUNG ENTREPRENEUR"   ,"JOVEN EMPRENDEDOR"         ,"Joven.aspx"          ,"menu_4","joven.jpg",0);
  menuItem[10]= new menu(10,"menu_4_1"   ,"BUSINESS SPANISH CERTIFICATE"  ,"ESPAÑOL DE NEGOCIOS"       ,"EN.aspx"     ,"menu_4","espanol.jpg",1);
 
menuItem[11]=   new menu(11,"menu_5"    ,"TRADE OPPORTUNITIES"  ,"OPORTUNIDADES"              ,""                   ,"","",0);
  menuItem[12]= new menu(12,"menu_5_0"  ,"FROM SPAIN"           ,"DESDE ESPAÑA "              ,"oportunidades.aspx?Type=1"     ,"menu_5","espana.jpg",0);
  menuItem[13]= new menu(13,"menu_5_1"  ,"FROM THE UK"          ,"DESDE REINO UNIDO"          ,"oportunidades.aspx?Type=0"        ,"menu_5","reino.jpg",0);
  menuItem[14]= new menu(14,"menu_5_2"  ,"INSERT OPPORTUNITY"   ,"INSERTAR OPORTUNIDAD"       ,"InsertarOportunidad.aspx"        ,"menu_5","inserte.jpg",1);

menuItem[15]=   new menu(15,"menu_6"    ,"CAREERS CENTRE"       ,"BOLSA DE TRABAJO"           ,""                   ,"","",0);
  menuItem[16]= new menu(16,"menu_6_0"  ,"LOOKING FOR WORK"     ,"DEMANDAS"                   ,"Demandas.aspx","menu_6","lookingforwork.jpg",0);
  menuItem[17]= new menu(17,"menu_6_1"  ,"JOB OPPORTUNITIES"    ,"OFERTAS"                    ,"Offers.aspx"         ,"menu_6","ofertas.jpg",0);
  menuItem[23]= new menu(23,"menu_6_2"  ,"SEND YOUR CV"         ,"ENVIA TU CV"                ,"SendCV.aspx"           ,"menu_6",  "sendcv.jpg",0);
  menuItem[24]= new menu(24,"menu_6_3"  ,"INSERT VACANCY"      ,"INSERTAR OFERTA"             ,"AddOffer.aspx"       ,"menu_6","insertvacancy.jpg",1);
  

menuItem[18]=   new menu(18,"menu_7"    ,"LINKS"                 ,"ENLACES"                   ,"Links.aspx"          ,"","enlaces.jpg",0);

menuItem[19]=   new menu(19,"menu_8"    ,"CONTACT"               ,"CONTACTA"                 ,"Contact.aspx"        ,"","contacta.jpg",0);




function AddMenu(lan) {

    for (x in menuItem) {
        AddMenuItem(menuItem[x],0,lan);
    }
  
    LoadTopBanner(lan)
    parent.menuleft.location="menuleft.aspx";
    parent.logos.location="logos.aspx";
 
}

function submenuClick(submenuId) {

    var index=getIndex(menuItem,submenuId);
    var parentIndex=getIndex(menuItem,menuItem[index].parentId); 
    var bgpicture=menuItem[index].bgpicture
    clearSelection();

    MouseOver (menuItem[index].parentId)
    parent.datapage.location=menuItem[index].menuLink;
    
    menuItem[index].keepon=true;
    MouseOver(menuItem[index].Id);
    menuItem[parentIndex].keepon=true;
    MouseOver(menuItem[parentIndex].Id);
    LoadBGImg('banner','images/menu/'+bgpicture ) 
  
  
}

function NoSubmenuClick(menuId) {
    
    var index=getIndex(menuItem,menuId);
     
    clearSelection();
    
    MouseOver (menuItem[index].Id)
    parent.datapage.location=menuItem[index].menuLink;
    
    menuItem[index].keepon=true;
    MouseOver( menuItem[index].Id);
    var bgpicture=menuItem[index].bgpicture
    LoadBGImg('banner','images/menu/'+bgpicture ) 
   
}

function clearSelection() {
    for (x in menuItem) {
        menuItem[x].keepon=false;
        MouseOut("top", menuItem[x].Id);
    }
}

function getArray(menutype) {
    return(menuItem);
}

function addpatron(n,imgoff,imgon,link) {
    return "<a href='" + link + "' class='patrons_links' target='_blank'><img class='patrons_logos' src='" + imgon + "' id='p" + n + "' ); /></a>"
   
   //return "<a href='" + link + "' class='patrons_links' target='_blank'><img class='patrons_logos' src='" + imgoff + "' id='p" + n + "' onmouseover=LoadImg('p" + n + "','" + imgon + "'); onmouseout=LoadImg('p"+ n + "','"+ imgoff + "'); /></a>"
}

