function historyHandler () {    
    // this is the public method that will be called to add an entry
    this.addHistory = function(data) {
        unFocus.History.Keeper.addHistory(data);
    };
    this.writeTitle = function(title) {
        document.title = unescape(title);
    }
    // the method that will take updates from the History Keeper
    this.onHistoryChange = function(data) {
        if (data != null){
            pushDeeplink (data);
        }
        //xiti calls
    };
    // add the event listener
    // A private method would not be properly scoped, and could not update state.
    unFocus.History.Keeper.addEventListener('historyChange', this.onHistoryChange);
    this.getCurrentState = function() {
        //always was here alert(state);
    };

    //setCookie method for internal Flash pages
    /*
    this.setCookie = function(lang){
        document.cookie = "lang="+lang+"; expires="+expireOffset+"; path=/;";
        goLocation(lang);
    }
    */

    this.setCookie = function(deeplink, lang){
        document.cookie = "lang="+lang+"; expires="+expireOffset+"; path=/;";
        goLangDeeplink(deeplink);
    }   

    // These page tracking functions must live inside the HistoryHandler object
    // in order to prevent a Flash/JS display bug in IE6
    this.pageTrack = function(xiti_section, xiti_page, spotlight_section, spotlight_page) {
        pageTrack(xiti_section, xiti_page, spotlight_section, spotlight_page);
    };
    
    this.xitiDownloadClick = function(section, url, popup) {
        xitiDownloadClick(section, url, popup, "2");
    };
    
    this.xitiExitClick = function(section, url, popup) {
        xitiExitClick(section, url, popup, "2");
    };
    
    this.xitiFlashEvent = function(section, name) {
        xitiFlashEvent(section, name);
    };
    
    this.xitiFlashMediaEvent = function(section, medianame, control, seconds) {
        xitiFlashMediaEvent(section, medianame, control, seconds);
    };

    this.xitiNavClick = function(section, trackString, targetUrl) {
        xitiNavClick(section, trackString, "2", null, targetUrl);
    };

};
document.historyHandler = new historyHandler ();
function getSWF (movieName) {
if(fla!='flash=no'){
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
    }
    else {
        return document[movieName]
    }
}
}
function pushDeeplink (id) {
if(fla!='flash=no'){
    if(fo.installedVer.major>=8){
          getSWF("loader").pushDeeplink(id);
    }
}
}
/*
function setUpResize(obj){
    this.obj = obj;
    this.pushResize = function(height,width){)};
    return this.obj;
}
flashMovie = new setUpResize(getSWF("loader"));
function pushResize () {
if(fla!='flash=no'){
    if(fo.installedVer.major>=8){
          //flashMovie.pushResize(height,width,alert(height+":"+ width));
    }
}
}
*/

var ext = ".jsp";
var deeplink = "";
var params = "";
var firstDeepLink = "";
var urlUpdate = "";
var hash = url.substring(url.indexOf('#')+1,url.length);
if(hash.indexOf('http')<0){
    hashIndex = hash.indexOf('|');
    if(hashIndex>0){
        params = "?"+hash.substring(hashIndex+1,hash.length);
        hash = hash.substring(0,hashIndex);
    }
    firstDeepLink = hash;
    urlUpdateTemp = hash.split('/');
    urlUpdateTempLength = urlUpdateTemp.length;
    for(var i=3;i<urlUpdateTempLength;i++){
        urlUpdate+="/"+urlUpdateTemp[i];
    }
    urlUpdate = urlUpdate.substring(1,urlUpdate.length);
    if (params!=''){
        window.location.href = base+urlUpdate+ext+params;
    }else{
        window.location.href = base+urlUpdate+ext;
    }
}else{
    params = url.substring(url.indexOf('?')+1,url.length);
    baseTempLength = baseTemp.length;
    deeplink="/"+lang+"/xml/";
    for(var i=4;i<baseTempLength;i++){
        deeplink+=baseTemp[i]+"/";
    }
    firstDeepLink = deeplink.substring(0,deeplink.lastIndexOf('.'));
}
//kill Flash in PPC
var agt = navigator.userAgent;
if(agt.indexOf('Mac')>0){//if mac
    if(agt.indexOf('Intel')<0){//if ppc
        fla='flash=no';
    }
    else if (agt.indexOf('Version/3') > 0){//if intel && safari 3
        //fla = 'flash=no';
        fla = 'flash=yes';
    }
    else{
        fla = 'flash=yes';
    }
}
///en/media/swf/index.swf will now be pulled by proxy.swf and located on Akamai
if(fla!='flash=no'){
    var BinaryPath = {
        _initialized:false,
        init:function(){
            this.Map = {    
                "http://www.rolex.com":"http://binary.rolex.com",
                "http://rolex.com":"http://binary.rolex.com"
            }
            this.MapH = $H(this.Map);
            this._initialized = true;
        },
        getBase:function(url){
            if (!this.initialized){
                this.init();
            }
            var binaryPath = "";
            var urlParts = url.toLowerCase().split('/');
            if (urlParts.length > 2){
                binaryPath = this.MapH["http://"+urlParts[2]];
            }
            if (binaryPath == undefined || binaryPath == null || binaryPath == ""){
                return base;
            }
            return binaryPath + "/" + lang + "/";
        }
    }
    
    var binaryBase = BinaryPath.getBase(window.location.href);
    ///en/media/swf/proxy.swf
    ///en/media/swf/proxy.swf
    var fo = new SWFObject("/" + lang + "/media/swf/proxy.swf", "loader", "100%", "100%", "8", "#000000", true);
    fo.addVariable("firstDeeplink", firstDeepLink);
    fo.addVariable("params", params);    fo.addParam("allowScriptAccess", "always");
    fo.addParam("wmode", "opaque");
    fo.addVariable("lang", lang);
    fo.addParam("scale", "noscale");
    fo.addParam("fullscreen", "true");
    fo.addParam("base", binaryBase);
    fo.addVariable("baseTitle", baseTitle);
    fo.addVariable("breadcrumbHomeText", breadcrumbHomeText);
    fo.setAttribute('xiRedirectUrl', url);
    
    //fo.addVariable("countDown", countDown);
    if(fo.installedVer.major>=8){
        var flashWritten = true; //required for omniture & xiti
        $('flashcontent').style.height="100%";
        $('flashcontent').style.width="100%";
        fo.write("flashcontent");
        $('content').style.display='none';
        $('nav-tocs').style.display='none';
        $('nav').style.display='none';
        $('breadcrumb').style.display='none';
        $('breadcrumb-links').style.display='none';
        //$('utility-links').style.display='none';
        $('footer').style.display='none';
        $('frame').style.background='transparent';
    }else{
        $('flashcontent').style.display='none';
        flash = false;
		window.location = "/en/index.jsp";
    }        
}else{
    $('flashcontent').style.display='none';
    flash = false;
	window.location = "/en/index.jsp";
}