function PromptMe() {
  this.promtForNew = function(url) {
    unFocus.History.addHistory(url);
  };

  this.historyListener = function(historyHash) {
    stateVar = historyHash;
    
    document.title = "Mango: " + historyHash;
    
    if(historyHash == "")
      historyHash = 'fashionshow/index.html'; // Default Page

    document.getElementById("xexternal").src = historyHash;
  };

  // subscribe to unFocus.History
  unFocus.History.addEventListener('historyChange', this.historyListener);

  // Check for an initial value (deep link).
  this.historyListener(unFocus.History.getCurrent());
};

var Mango = new function() {
  this.globalTime = 4000;
    
  this.pause = function(milisec) {
    var d = new Date();
    var begin = d.getTime();

    while ((d.getTime() - begin ) > milisec){
      // nothing... 
    }
  };
  
  
  this.visibleOption = function(value, off) {
    var on = off;
    var off = (on == 'navigation') ? "navigation_bottom" : "navigation";
    
    // Select
    $.browser.msie ? window[on].setVisibleOption(value) : document[on].setVisibleOption(value);

    // UnSelect
    $.browser.msie ? window[off].setVisibleOption(value) : document[off].setVisibleOption(value);
  };
  
  this.disableOption = function(value, nav) {
    var off = (nav == 'navigation') ? "navigation_bottom" : "navigation";
    $.browser.msie ? window[off].setVisibleOption(value) : document[off].setVisibleOption(value);
  };
  
  this.parentVisibleOption = function(value, off) {
    var on = off;
    var off = (on == 'navigation') ? "navigation_bottom" : "navigation";
  
    window.parent.document[on].setVisibleOption(value);
    window.parent.document[off].setVisibleOption(value);
  };
  
  this.getURLParameters = function(url, value){
    var regexS = "[\\?&]"+value+"=([^&#]*)";
    var regex = new RegExp(regexS);

    var results = regex.exec(url);
    return (results == null) ? "" : unescape(results[1]);
  };
  
  this.tellMeAlias = function(value){
    return (value == "") ? "" : value.split('?')[0];
  };
  
  this.iframeObserver = function() {
    //Mango.visibleOption(Mango.getURLParameters(document.getElementById('xexternal').src, "branch"), "navigation");
  };
  
  this.is_firefox = function() {
    return $.browser.mozilla ? "1" : "0";
  };
  
  this.windowHeight = function(){
    var h = $.browser.msie ? document.body.clientHeight : window.innerHeight;
    return h;
  };
  
  // this.flashContentHeight = function(){
  //   alert($('#flashcontent').css("height"));
  //   //return $('#flashcontent').css("height");
  // };
  
};


function fold(status){

  var nav = 'navigation';

  if (status == "open") {
    menu.setup(status);
    $.browser.msie ? window[nav].layerState('layerOpen') : document[nav].layerState('layerOpen');
  } else {
    $.browser.msie ? window[nav].layerState('layerClose') : document[nav].layerState('layerClose');
    menu.setup(status);
  };

};

var menu = {
 setup: function(status) {
   this.cancel();
   this.timeoutID = setTimeout(function () { $("#v594fd1615a341c77829e83ed988f137e1ba96231").css("height", (status == "open") ? "700px" : "50px"); }, (status == "open" ? 0 : 1));
 },

 cancel: function() {
   if(typeof this.timeoutID == "number") {
     clearTimeout(this.timeoutID);
     delete this.timeoutID;
   }
 }

}

function parentUnfold(){
  padre = $(window.parent.document);
  $(padre).find('#v594fd1615a341c77829e83ed988f137e1ba96231').css("height","50px");
};

// FullScreen
function fullscreen(){
  window.moveTo(0,0);
  window.resizeTo(window.screen.availWidth,window.screen.availHeight);
  // window.resizeto(screen.width,screen.height) 
  // self.resizeTo(window.screen.availWidth, window.screen.availHeight);
};

function unfullscreen(){
  self.moveTo(screen.width/5,0)
  window.resizeTo(1024, 768);
};

$(window).resize(function(){
  // var h = $.browser.msie ? document.body.clientHeight - 65 : window.innerHeight - 65;
  
  var mt = (((navigator.userAgent.indexOf("NT 5.1") != -1) || (navigator.userAgent.indexOf("NT 6") != -1)) && ($.browser.mozilla)) ? 0 : 35;
        
  var isIE = navigator.appName.indexOf("Microsoft") != -1;
  if (isIE) {
    var h = document.body.clientHeight - 65;
  } else {
    var h = window.innerHeight - 65;
  }
        
  if (mt == 0) {
    h = h + 35;
  };
    
  $('#vb925359a82e1013d3dda73d0c041aa02f7b6bae3 iframe').css("height", h);
});

// window.location=$(this).find("a").attr("href"); return false;

function jumpto(url, section, off, tracker){  
  if (document.getElementById)
    document.getElementById("xexternal").src = url;
  else if (document.all)
    document.all.xexternal.src=url;
  else {
    if (!window.win2 || win2.closed)
      win2 = window.open(url);
    else {
      win2.location = url;
      win2.focus();
    }
  }
  
  // Mango.visibleOption(section, off);
  Mango.disableOption(section, off);
  
  pageTracker._trackPageview(tracker);
  $.browser.msie ? window['navigation'].layerState('layerClose') : document['navigation'].layerState('layerClose');
};

function yaload (argument) {
  //Mango.parentVisibleOption(argument, 'navigation');
};


// Branch
function getBranch() {
  if (Mango.getURLParameters(location.href, 'branch') == "") {
    $.browser.msie ? window['navigation'].selectfirstbutton() : document['navigation'].selectfirstbutton();
  } else {
    Mango.visibleOption(Mango.getURLParameters(location.href, 'branch'), "navigation");
  };

};

function flashContentHeight(){
  $.browser.msie ? window['flashcontent'].TellMeHeight(Mango.windowHeight()) : document['flashcontent'].TellMeHeight(Mango.windowHeight());
};

function setTracker(t){
  pageTracker._trackPageview(t);
};
