// Iniciação do modelo
var model = new Object();
model.init = function() {



    model.CallUrlGet = function(url, Handler) {



        
        
        url += "?Key=45DF6E7C"
        $.get(url, function(data, textStatus, xmlhttprequest) {
            if (data != "erro")
                Handler(data);
        });
    }

    model.CallUrlGetParams = function(url, params, Handler) {

        
        url += "?Key=45DF6E7C&" + params;
        $.get(url, function(data, textStatus, xmlhttprequest) {
            if (data != "erro")
                Handler(data);
        });
    }

    model.trackPageView = function(urlToTrack) {
        _gaq.push(['_trackPageview', urlToTrack]);
    }

    model.page = new Page();


}






  //// Manutenção de estado da pagina
  function Page() {

      //Mapper URL ->  Função a ser chamada

      this.MenuRightIsLoaded = true;   
      this.SubMenuIsLoaded = false;
      this.ContentMainIsLoaded = false;
      this.MenuLeftIsLoaded = true;
      this.ContentLeftIsLoaded = false;


      this.GetLanguage = function() {
          completeUrl = window.location.pathname;
          completeUrl = completeUrl.split("/");

          if (completeUrl[1]==null || completeUrl[1]=='')
            completeUrl[1]='pt';
          
          return completeUrl[1];
          //alert(window.location.pathname);
      }  
      
      this.GetRelativeUrlWithoutLang = function() {

          var aux = window.location.hash;
          aux = aux.replace(".aspx", "");
          aux = aux.replace("#/", "/");
          aux = aux.substr(3);
          
          return aux;

      }
      
       
      this.GetRelativeUrl = function() {

          var aux = window.location.hash;
          aux = aux.replace(".aspx", "");
          aux = aux.replace("#/", "/");
          return aux;

      }


      this.isHomepage = function() {

          
          if (this.GetRelativeUrlWithoutLang() == "") {
              return true;
          }
          return false;
      }


      this.GetFunc = function() {
          return DictURlFUNC[this.GetRelativeUrlWithoutLang()];
      }

     // recebe url em pt	
     this.IssameURLInDiferentLanguages = function(urlPt, url)
     {
	        if(urlPt=="/produtos/vinhos")
	        {
		        if(url=="/produtos/vinhos" || url=="/products/wines" || url=="/productos/vinhos" || url=="/produits/vins")
		            return true;
		        if (url == "/produtos/escolha-jose-avillez" || url == "/products/escolha-jose-avillez" || url == "/productos/escolha-jose-avillez" || url == "/produits/escolha-jose-avillez")
		            return true;
            }

             if (urlPt == "/produtos/escolha-jose-avillez") 
             {
              
                if (url == "/produtos/escolha-jose-avillez" || url == "/products/escolha-jose-avillez" || url == "/productos/escolha-jose-avillez" || url == "/produits/escolha-jose-avillez")
                    return true;
             }
	
    	return false;
     }	

    
      var DictURlFUNC = new Object();


      DictURlFUNC["/homepage"] = 'GoToHomepage()';
      DictURlFUNC[""] = 'GoToHomepage()';


      DictURlFUNC["/novidades"] = 'LoadContenForLeftMenu()';


      DictURlFUNC["/o-que-se-diz-sobre"] = 'LoadContenForLeftMenu()';
      DictURlFUNC["/what-is-said-about"] = 'LoadContenForLeftMenu()';	
      DictURlFUNC["/a-propos-de"] = 'LoadContenForLeftMenu()';	
      DictURlFUNC["/que-se-dice"] = 'LoadContenForLeftMenu()';	
				
      DictURlFUNC["/imprensa"] = 'LoadContenForLeftMenu()';
      DictURlFUNC["/press"] = 'LoadContenForLeftMenu()';
      DictURlFUNC["/prensa"] = 'LoadContenForLeftMenu()';
      DictURlFUNC["/presse"] = 'LoadContenForLeftMenu()';

      DictURlFUNC["/trabalhe-connosco"] = 'LoadContenForLeftMenu()';
      DictURlFUNC["/work-with-us"] = 'LoadContenForLeftMenu()';
      DictURlFUNC["/travaillez-avec-nous"] = 'LoadContenForLeftMenu()';
      DictURlFUNC["/trabaje-con-nosotros"] = 'LoadContenForLeftMenu()';



     DictURlFUNC["/contacte-nos"] = 'LoadContenForLeftMenu()';
     DictURlFUNC["/contact-us"] = 'LoadContenForLeftMenu()';
	 DictURlFUNC["/contactez-nous"] = 'LoadContenForLeftMenu()';
	 DictURlFUNC["/contactenos"] = 'LoadContenForLeftMenu()';



      DictURlFUNC["/jose-avillez"] = 'LoadContenForRightMenu()';
      DictURlFUNC["/jose-avillez"] = 'LoadContenForRightMenu()';
      DictURlFUNC["/jose-avillez"] = 'LoadContenForRightMenu()';
      DictURlFUNC["/jose-avillez"] = 'LoadContenForRightMenu()';



      DictURlFUNC["/belcanto"] = 'LoadContenForRightMenu()';
   /*   DictURlFUNC["/jose-avillez"] = 'LoadContenForRightMenu()';
      DictURlFUNC["/jose-avillez"] = 'LoadContenForRightMenu()';
      DictURlFUNC["/jose-avillez"] = 'LoadContenForRightMenu()';*/


      DictURlFUNC["/jose-avillez/biografia"] = 'LoadContenForRightMenu()';
      DictURlFUNC["/jose-avillez/biography"] = 'LoadContenForRightMenu()';
      DictURlFUNC["/jose-avillez/biographie"] = 'LoadContenForRightMenu()';
      DictURlFUNC["/jose-avillez/biografia"] = 'LoadContenForRightMenu()';

      DictURlFUNC["/jose-avillez/percurso"] = 'LoadContenForRightMenu()';
    

      DictURlFUNC["/jose-avillez/reconhecimentos-e-participacoes"] = 'LoadContenForRightMenu()';
      DictURlFUNC["/jose-avillez/acknowledges-and-participations"] = 'LoadContenForRightMenu()';
      DictURlFUNC["/jose-avillez/prix-et-participations"] = 'LoadContenForRightMenu()';
      DictURlFUNC["/jose-avillez/reconocimientos-y-participaciones"] = 'LoadContenForRightMenu()';

        DictURlFUNC["/jose-avillez/inspiracoes"] = 'LoadContenForRightMenu()';
	DictURlFUNC["/jose-avillez/inspirations"] = 'LoadContenForRightMenu()';
	DictURlFUNC["/jose-avillez/inspiración"] = 'LoadContenForRightMenu()';
	DictURlFUNC["/jose-avillez/inspiración"] = 'LoadContenForRightMenu()';




        DictURlFUNC["/jose-avillez/parceiros"] = 'LoadContenForRightMenu()';
	DictURlFUNC["/jose-avillez/partners"] = 'LoadContenForRightMenu()';
	DictURlFUNC["/jose-avillez/partenaires"] = 'LoadContenForRightMenu()';
	DictURlFUNC["/jose-avillez/colaboradores"] = 'LoadContenForRightMenu()';

      DictURlFUNC["/tavares"] = 'LoadContenForRightMenu()';
      DictURlFUNC["/ja"] = 'LoadContenForRightMenu()';
      DictURlFUNC["/cantinho-do-avillez"] = 'LoadContenForRightMenu()';


      DictURlFUNC["/jose-avillez-catering"] = 'LoadContenForRightMenu()';	


      DictURlFUNC["/jose-avillez-consultoria"] = 'LoadContenForRightMenu()';
      DictURlFUNC["/jose-avillez-consulting"] = 'LoadContenForRightMenu()';
      DictURlFUNC["/jose-avillez-consulting"] = 'LoadContenForRightMenu()';
      DictURlFUNC["/jose-avillez-consultoria"] = 'LoadContenForRightMenu()';


        DictURlFUNC["/livros"] = 'LoadContenForRightMenu()';
	DictURlFUNC["/books"] = 'LoadContenForRightMenu()';
	DictURlFUNC["/livres"] = 'LoadContenForRightMenu()';
	DictURlFUNC["/libros"] = 'LoadContenForRightMenu()';
	

      //DictURlFUNC["/produtos"] = 'LoadContenForRightMenu()';

      DictURlFUNC["/produtos/vinhos"] = 'LoadContenForRightMenu()';
      DictURlFUNC["/products/wines"] = 'LoadContenForRightMenu()';
      DictURlFUNC["/productos/vinhos"] = 'LoadContenForRightMenu()';
      DictURlFUNC["/produits/vins"] = 'LoadContenForRightMenu()';


      DictURlFUNC["/produtos/escolha-jose-avillez"] = 'LoadContenForRightMenu()';
      DictURlFUNC["/products/wines"] = 'LoadContenForRightMenu()';
      DictURlFUNC["/productos/vinhos"] = 'LoadContenForRightMenu()';
      DictURlFUNC["/produits/vins"] = 'LoadContenForRightMenu()';




//      DictURlFUNC["/jose-avillez"] = 'LoadAvillez()';
//      DictURlFUNC["/jose-avillez/biografia"] = 'LoadBiografia()';
//      DictURlFUNC["/jose-avillez/percurso"] = 'LoadPercurso()';
//      DictURlFUNC["/jose-avillez/reconhecimento"] = 'LoadPercurso()';
//      DictURlFUNC["/jose-avillez/inspiracoes"] = 'LoadInspiracoes()';
//      DictURlFUNC["/jose-avillez/parceiros"] = 'LoadParceiros()';
//      
//      DictURlFUNC["/tavares"] = 'LoadTavares()';
//      DictURlFUNC["/ja"] = 'LoadTavares()';
//      DictURlFUNC["/jose-avillez-catering"] = 'LoadTavares()';
//      DictURlFUNC["/jose-avillez-consultoria"] = 'LoadTavares()';
//      DictURlFUNC["/livros"] = 'LoadTavares()';
//      DictURlFUNC["/produtos"] = 'LoadTavares()';
      
    }
