
/// ARC 
/// ARC 
/// ARC 

var _arc_debug=function(str){return};
var _arc_debug_flag = false;
var windowInterface;
var _arc_startMode;

if(typeof(arc)=="undefined"){

        var arc = {

                  enabled:false,

                  enableRichApps:function(){
                        this.enabled = true;
                        _arc_debug(" enabled = true");
                  },
                  disableRichApps:function(){
                        this.enabled = false;
                        _arc_debug(" enabled = false");
                  }       

        };


        arc.Util={
                  isIE:function(){
                    return navigator.appName.indexOf("Microsoft")>=0;
                  },
                  needsEagerRepaint:function(){
                    return (navigator.userAgent.indexOf("Firefox")>=0)&&(navigator.userAgent.indexOf("Macintosh")>=0);
                  },
                  getBody:function(){
                    return document.getElementsByTagName("body").item(0);
                  },
                  resolveElement:function(_1){
                    return (typeof _1=="string")?document.getElementById(_1):_1;
                  },
                  getSwfById:function(id){
                    return this.isIE() ? window[id]: document[id];
                  },
                  getAbsoluteLeft:function(_3){
                    var o=arc.Util.resolveElement(_3);
                    var _5=0;
                    if(o.offsetParent){
                      var _5=o.offsetLeft;
                      while(o.offsetParent!=null){
                        var _6=o.offsetParent;
                        _5+=_6.offsetLeft;
                        o=_6;
                      }
                    }else{
                        if(o.x){
                           _5+=o.x;
                        }
                    }
                    return _5;
                },
                getAbsoluteTop:function(_7){
                        var o=arc.Util.resolveElement(_7);
                        var _9=0;
                        if(o.offsetParent){
                                _9=o.offsetTop;
                                while(o.offsetParent!=null){
                                        var _a=o.offsetParent;
                                        _9+=_a.offsetTop;
                                        o=_a;
                                }
                        }else{
                                if(o.y){
                                        _9+=o.y;
                                }
                        }
                        return _9;
                },
                setCookie:function(name,value,expires,options) {
                          if (options===undefined) { options = {}; }
                          if ( expires ) {
                              var expires_date = new Date();
                              expires_date.setTime(expires_date.getTime() + (expires*1000));
                          }
                          document.cookie = name+'='+escape( value ) +
                              ( ( expires ) ? ';expires='+expires_date.toGMTString() : '')+
                              ( ( options.path ) ? ';path=' + options.path : ';path=/' ) +
                              ( ( options.domain ) ? ';domain=' + options.domain : '')+
                              ( ( options.secure ) ? ';secure' : '');
                },
                getCookie:function(_d){
                    var _e=_d+"=";
                    var _f=null;
                    if(document.cookie.indexOf(_e)==0){
                      _f=_e.length;
                    }else{
                      var ix=document.cookie.indexOf("; "+_e);
                      if(ix>0){
                        _f=ix+2+_e.length;
                      }
                    }
                    if(_f==null){
                      return null;
                    }
                    var end=document.cookie.indexOf(";",_f);
                    if(end<0){
                        end=document.cookie.length;
                    }
                    return unescape(document.cookie.substring(_f,end));
                },
			    eraseCookie: function(name)
			    {
			        // set the expires date to the past so cookie will be deleted
			        var date = new Date();
					date.setTime(date.getTime()-1);
					var GMTdate = date.toGMTString();
			        document.cookie = name + "=; expires= " + GMTdate + "; path=/";
			    },
                debugMode:function(){
                    return document.location.href.indexOf("?debug=true")>=0;
                },
                getUrlParameter: function( name )
                {
                    name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
                    var regexS = "[\\?&]"+name+"=([^&#]*)";
                    var regex = new RegExp( regexS );
                    var results = regex.exec( window.location.href );
                    return ( results == null ) ? "" : results[1];
                },
                getMaxZindex:function() {
                    // Hard code this to avoid expensive code to walk the entire DOM tree
                    return 9999;
                },
                page:function()
                {
                        if ( this.browser == null ) 
                        {
                                var _arc_browser = function()
                                {
                                    this.isPPC = function() { return ( navigator.userAgent.indexOf("PPC")>-1); }
                                    this.isMac =  function() { return (navigator.platform.indexOf("Mac")==0) ; }
                                        this.isWin =  function() { return (navigator.platform.indexOf("Win")==0) ; }

                                        this.isIE = function() { return ( navigator.appName.indexOf("Microsoft")==0); }
                                        this.isFirefox = function() { return ( navigator.userAgent.indexOf("Firefox")>-1); }
                                        this.isOpera = function() { return ( navigator.userAgent.indexOf("Opera")==0); }
                                        this.isSafari = function()
                                        { 
                                              if ( this.isMac() ) return ( navigator.userAgent.indexOf("Safari")>-1); 
                                              return ( navigator.userAgent.indexOf("AppleWebKit" ) >-1);
                                        }

                                        this.is = function(_arg)
                                        {
                                                if ( typeof (_arg) != 'object' && typeof (_arg) != 'string' ) return false;
                                                if ( typeof (_arg) == 'object' ) 
                                                {
                                                        condition = true;
                                                        for ( i=0;i<_arg.length;i++)
                                                        {
                                                          if ( condition ) 
                                                            if ( eval( 'this.is'+_arg[i]+'() == false ' ) == true ) condition = false;
                                                        }
                                                        return condition;
                                                }
                                                else
                                                {
                                                    return ( eval (  'this.is'+_array+'()'  )   );
                                                }

                                        }
                                        this.isNot = function(_arg)
                                        {
                                                return ( ! this.is(_arg) );
                                        }
                                }
                                this.browser = new _arc_browser();
                        }
                        
                        this.height   = function () { return arc.Util.documentHeight() ;}
                        this.width    = function () { return arc.Util.documentWidth()  ;}

                        this.offsetY = function () { return windowInterface.getScrollY() ;}
                        this.offsetX = function () { return windowInterface.getScrollX() ;}


                        this.visibleHeight = function () { return windowInterface.getHeight() ;}
                        this.visibleWidth  = function () { return windowInterface.getWidth()  ;}

                },
                documentHeight : function() {
                        var body = arc.Util.getBody();
                        var innerHeight =
                                ((typeof(self.innerHeight)!="undefined")&&!isNaN(self.innerHeight))?self.innerHeight:0;
                        if (!document.compatMode || document.compatMode=="CSS1Compat") {
                                var topMargin = 0;
                                var bottomMargin =0;
                                return Math.max(
                                        body.offsetHeight + topMargin + bottomMargin,
                                        document.documentElement.clientHeight,
                                        document.documentElement.scrollHeight,  
                                        ( !(typeof(self.innerHeight)!="undefined") || isNaN(self.innerHeight) ) ? 0:self.innerHeight) ;
                        }
                        return Math.max(
                                body.scrollHeight, 
                                body.clientHeight,
                                ( !(typeof(self.innerHeight)!="undefined") || isNaN(self.innerHeight)) ? 0:self.innerHeight );
                },
                documentWidth : function() {
                        var body = arc.Util.getBody();
                        var innerWidth =
                                ((typeof(self.innerWidth)!="undefined")&&!isNaN(self.innerWidth))?self.innerWidth:0;
                        if (!document.compatMode || document.compatMode=="CSS1Compat") {
                                var topMargin = 0; 
                                var bottomMargin = 0;
                                return Math.max(
                                        body.offsetWidth + topMargin + bottomMargin,
                                        document.documentElement.clientWidth,
                                        document.documentElement.scrollWidth,  
                                        ( !(typeof(self.innerWidth)!="undefined") || isNaN(self.innerWidth) ) ? 0:self.innerWidth) ;
                        }
                        return Math.max(
                                body.scrollWidth, 
                                body.clientWidth,
                                ( !(typeof(self.innerWidth)!="undefined") || isNaN(self.innerWidth)) ? 0:self.innerWidth );
                },
                getBrowserProfile:function(obj) {
                        if ( typeof( _arc_debug_flag ) == "undefined" ||  !_arc_debug_flag ) return "disabled";
                        var str = "****************************\n";
                        str +=  navigator.userAgent + "\n";

                        str +=  "\tpage visible height="+obj.visibleHeight()+"\n";
                        str +=  "\tpage visible width="+obj.visibleWidth()+"\n";

                        str +=  "\tpage offset Y="+obj.offsetY()+"\n";
                        str +=  "\tpage offset X="+obj.offsetX()+"\n";

                        str +=  "\tpage total height="+obj.height()+"\n";
                        str +=  "\tpage total width="+obj.width()+"\n";

                        str +=  "\n\tisMac="+obj.browser.isMac()+"\n";
                        str +=  "\tisFF="+obj.browser.isFirefox()+"\n";

                        return str+"\n****************************\n";

                },
                debugMode:function(){
                        return document.location.href.indexOf("?debug=true")>=0;
                },
                alert:function(str) {
                        if (document.getElementById("_arc_debug_area") && typeof(_arc_debug_flag) != "undefined" && _arc_debug_flag ) {
                               document.getElementById("_arc_debug_area").value = str +"\n"+ document.getElementById("_arc_debug_area").value ;
                         } else { 
                               if ( _arc_debug_flag )  alert(str);
                        }
                }

        };
               
               
   // STAGE & SNIFF
   // STAGE & SNIFF
   // STAGE & SNIFF
               
        arc.stage = { 
            
            flashVersionRequired:"9",
            showFlash:false,
            shownSize:100,
            flashBackground:"#cc6600",
            sniffCookie:"arcDownloadRate",
            downloadRateRequired:45,
            state:"",
            preloadList:{},
            assignmentCookie:"arcAssignment",
            assignmentCookieStr:null,
            assignmentThreshold:1.0,
            assignmentExpires:999,
            
            initialize:function(){
                this.createAssignmentValue();
                var assignedRich = this.judgeAssignmentValue(arc.stage.assignmentCookieStr);
                if (assignedRich==false) return;
                
                // check for bad code in countrystatedropdown.js
                if (Object.prototype.getValues!=null || Object.prototype.getKeys!=null) return;
                
                var _12=arc.Util.getCookie(this.sniffCookie);
                _arc_debug(" sniff cookie =  " + this.sniffCookie + ":" + _12 );
                this.stageDiv=this.createStageDiv();
                if(_12==null)  this.startSniff();
                else  this.judgeDownloadRate(_12);
            },
            createAssignmentValue:function(){
                // check URL and assignmentCookie to see if we need to set assignment value
                var assignVal = null;
		        var assignParam = arc.Util.getUrlParameter('arcAssign');
		        if (assignParam!=null && assignParam.length>0) {
		            arc.Util.eraseCookie(this.assignmentCookie);
		            arc.Util.setCookie(this.assignmentCookie,assignParam,this.assignmentExpires);
		            assignVal = assignParam;
		        }
		        else {
                    var cookieVal = arc.Util.getCookie(this.assignmentCookie);
                    if (cookieVal!=null && cookieVal.length>0) {
                        assignVal = cookieVal;
                    }
		        }

                if (assignVal==null){
                    var rand = Math.random();
                    assignVal = rand+"";
                    arc.Util.setCookie(this.assignmentCookie,assignVal,this.assignmentExpires);
                }
                this.assignmentCookieStr = assignVal;
                _arc_debug(" assignment cookie =  " + this.assignmentCookie + ":" + this.assignmentCookieStr );
            },
            createStageDiv:function(){
                var _13=this.showFlash;
                var _14=_13?this.shownSize:1;
                var _15=_13?this.shownSize:1;
                var _16=document.createElement("div");
                _16.style.position="absolute";
                _16.style.zIndex=arc.Util.getMaxZindex();
                _16.style.left=(_13)?this.shownSize+"px":"-"+this.shownSize+"px";
                _16.style.top=(_13)?this.shownSize+"px":"-"+this.shownSize+"px";
                _16.style.width=_14+"px";
                _16.style.height=_15+"px";
                //_16.style.visibility=(arc.Util.isIE()||_13)?"visible":"hidden";
                //_16.style.display=(_13)?"block":"none";
                _16.style.padding="0px 0px 0px 0px";
                _16.style.backgroundColor="white";
                arc.Util.getBody().appendChild(_16);
                return _16;
            },
            startSniff:function(){
                
                _arc_debug(" ***  stage.startSniff" );
                var _17=this.createSwf();
                _17.addVariable("measure","true");
                _17.addVariable("targetUrl", STATIC_ARC_URL+"allurentLogo.jpg");
                _17.addVariable("sufficientBytes",30000);
                _17.addVariable("timeout",5000);
                _arc_debug(this.stageDiv);
                
                //_17.getSWFHTML(this.stageDiv);
                //_arc_debug( _17.write(this.stageDiv) + " = result of swf.write() using this.stageDiv="+this.stageDiv );
                _arc_debug( "_17  get swfHTml=" + _17.getSWFHTML() );
                if(!_17.write(this.stageDiv)){
                    this.showFailure("arcInitFailed","noflash");
                }else{
                    setTimeout("arc.stage.sniffTimeout(3);",3000);
                }
            },
            judgeDownloadRate:function(_18){
                _arc_debug(" judgeDownloadRate " + _18);
                if ( arc.Util.getCookie("arcLoadComplete")) return;
                var value = parseFloat(_18);
                if(value!=Math.NaN && value>=this.downloadRateRequired){
                    this.startPreload();
                }else{
                    this.showFailure("arcInitFailed","downloadRate="+_18);
                }
            },
            judgeAssignmentValue:function(valueStr){
                _arc_debug("judgeAssignmentValue " + valueStr);
                var res = false;
                var value = parseFloat(valueStr);
                if(value!=Math.NaN && value<this.assignmentThreshold){
                    res = true;
                }else{
                    this.showFailure("arcInitFailed","assignmentValue="+valueStr);
                }
                return res;
            },
            handleEvent:function(_19){
                _arc_debug("  ***  stage handleEvent _19 = "+_19.type);
                switch(_19.type){
                case "arcSniffFailed":
                    this.showFailure("arcInitFailed",_19.reason);
                    break;
                    
                case "arcSniffComplete":
                    _arc_debug(" this.state "+ this.state);
                    if(this.state==""){
                        arc.Util.setCookie(arc.stage.sniffCookie,_19.kps );
                        this.judgeDownloadRate(_19.kps);
                    }
                    break;
                    
                case "arcPreloadComplete":
                    if(this.state=="loading"){
                        setTimeout("arc.stage.preloadNext();",100);
                    }
                    break;
                }        
            },
            startPreload:function(){
                _arc_debug(" startPreload ");
                for(var _1a in arc.clientMgr.clients){
                    if(arc.clientMgr.clients[_1a].preload){
                        var _1b=arc.clientMgr.clients[_1a].swfUrl;
                        this.preloadList[_1b]="";
                    }
                }
                this.state="loading";
                arc.dispatchEvent({type:"arcLoadStarted"});
                setTimeout("arc.stage.preloadTimeout(3);",10000);
                setTimeout("arc.stage.preloadNext();",100);
            },
            preloadNext:function(){
                _arc_debug(" preloadNext ");
                var _1c=null;
                var _tempUrl = null;
                for(_tempUrl in this.preloadList){
                    delete this.preloadList[_tempUrl];
                    break;
                }

                if (_1c == null) {
                    // alert("load completed");
                    this.state="complete";
                    arc.dispatchEvent({type:"arcLoadComplete"});
                } else {
                    // alert("loading " + _1c);
                      new Ajax.Request(_1c , { 
                         method:'get' ,
                        onSuccess: function(transport){
                            arc.stage.preloadNext();
                        },
                        onFailure: function(){ 
                            arc.stage.showFailure("arcLoadFailed","Preload failed."); 
                        }
                    } );
                }
            },
            createSwf:function(){
                _arc_debug( " stage createSwf ... " );
                var _1e=navigator.userAgent.toLowerCase();
                var _1f=_1e.indexOf("mozilla")>=0&&_1e.indexOf("linux")>=0&&_1e.indexOf("gecko")>=0;
                _arc_debug( ' _1f _1e.indexOf("mozilla")>=0&&_1e.indexOf("linux")>=0&&_1e.indexOf("gecko")>=0; = ' + _1f );
                var _20=10;
                var _21=10;
                if(this.showFlash){
                    _20=this.shownSize;
                    _21=this.shownSize;
                }else{
                    if(_1f){
                        _20=1;
                        _21=1;
                    }
                }
                var _22=new SWFObject( STATIC_ARC_SNIFF,"sniff20",_20,_21,this.flashVersionRequired,this.flashBackground);
                _22.addVariable("versionChecked",true);
                _22.addVariable("allowScriptAccess","always");
                _arc_debug("\n\nswfObject " + _22.getSWFHTML() );
                return _22;
            },
            sniffTimeout:function(count){
                _arc_debug( " arc.stage.sniffTimeout " );
                if ( this.state == "complete" ) return;
                count--;
                _arc_debug( "  -- Trys remaining " + count + " \n this.state = " + this.state );
                if(this.state == ""  && ( count < 1 )){
                    _arc_debug(" in failed waiting for sniff");
                    this.showFailure("arcInitFailed","Sniff failed to run nor dispatch event");
                } else {
                    if ( this.state != "failed"  && count > 0) 
                        setTimeout("arc.stage.sniffTimeout("+ (count )+");",3000);
                }
            },         
            preloadTimeout:function(count){
                _arc_debug( " arc.stage.preloadTimeout " );
                
                count--;
                if(this.state=="loading" && ( count < 1 ) ){
                    this.showFailure("arcLoadFailed","Preload timed out.");
                } else {
                    if ( this.state != "failed"  && count > 0) 
                        setTimeout("arc.stage.preloadTimeout("+ (count )+");",10000);
                }
            },
            
            
            showFailure:function(_23,_24){
                _arc_debug(" showFailure this.state = " + this.state );
                if ( this.state == "" ) 
                { // if there is no reason for failure, it may be Mac Safari which can't sniff well
                    return;
                }
                if(this.state!="failed"){
                    arc.dispatchEvent({type:_23,reason:_24});
                    this.state="failed";
                }
                
            }
            
        };

        // CLIENT MANAGER
        // CLIENT MANAGER
        // CLIENT MANAGER

        arc.clientMgr={
                clients:{},
                windowCount:0,
                clientVisible:false,
                getClientDesc:function(_39){
                        return this.clients[_39];
                },
                addClientDesc:function(_3a){
                    _arc_debug(" ADD Client " ); //+ _3a.clientId );
                        this.clients[_3a.clientId]=_3a;
                },
                handleEvent:function(_3b){
                        _arc_debug("_3b="+_3b.type);
                        switch(_3b.type){
                           case "arcClientStarted":
                           this.clients[_3b.sourceClientId].handleStart();
                           break;
                           case "arcCloseClient":
                           setTimeout("arc.clientMgr.closeClient(\""+_3b.sourceClientId+"\");",250);// START 

                           break;
                        }
                        var _3c=false;        
                        for(var _3d in this.clients){ 
                            var _3e=this.clients[_3d];
                            _arc_debug("cycle thru "+ _3e.clientId + " launchEvents  type  is not null ? "+(_3e.launchEvents[_3b.type]!=null));
                            if(_3e.launchEvents[_3b.type]!=null){
                                  this.activateClient(_3e,_3b);
                                  _3c=true;
                            }   
                        }     
                        if(!_3c&&_3b.topic!=null){
                             for(var _3d in this.clients){
                                 if(_3d!=_3b.sourceClientId){
                                     _arc_debug(" handleEvents "+_3b.type);
                           
                                    this.clients[_3d].handleEvent(_3b);
                                 }
                             }
                        }
                },
                activateClient:function(_3f,_40){
                        _arc_debug("activateClient _3f "+ _3f + ", _40 "+ _40.type );
                        
                        _arc_debug(" is visible ? "+ _3f.visible );
                        if(!_3f.visible){
                                _3f.pendingEvent=_40;
                                _3f.showSwf();                                
                                _3f.visible=true;
                                this.clientVisible=true;
                        }
                        if(_3f.started){
                                _3f.handleEvent(_40);
                        }
                },
                closeClient:function(_41){
                        _arc_debug(" closeClient _41 "+ _41 );
                        var _42=this.clients[_41];
                        _arc_debug(" closeClient _42 "+ _42 );
                        if(_42!=null&&_42.handleClose()){
                                _42.visible=false;
                        }
                        this.clientVisible=false;
                        for(i=0;i<this.clients.length;i++)
                        {
                                if ( this.clients[i].visible ) this.clientVisible=true;                               
                        }
                }
        };

       // EVENT MANAGER
       // EVENT MANAGER
       // EVENT MANAGER


        arc.eventMgr={

            eventListeners:{seed:1},
            addEventListener:function(_44,_45){
                if(this.eventListeners[_44]==null){
                    _arc_debug( " Adding Event Manager - Event Listiner " + _44 );
                    this.eventListeners[_44]=new Array();
                }
                this.eventListeners[_44].push(_45);
            },
            dispatchEvent:function(_46){
                _arc_debug(" eventMgr dispacthing _46="+_46.type);
                var _47=this.eventListeners[_46.type];
                _arc_debug(" eventMgr _47="+_47);
                if(_47!=null){
                    for(var i=0;i<_47.length;++i){
                        _47[i](_46);
                    }
                }
            }
            
        };
 
        arc.setFlashVersionRequired=function(_49){
                        arc.stage.flashVersionRequired=_49;
        };
        arc.setDownloadRateRequired=function(_4a){
                        _arc_debug(" setDownloadRateRequired ");
                        arc.stage.downloadRateRequired=_4a;
        };
        arc.addEventListener=function(_4b,_4c){
            _arc_debug(" Adding Arc Eventlistener " + _4b.clientId + " "+ typeof ( _4c )  ) ;
            arc.eventMgr.addEventListener(_4b,_4c);
        };
        arc.dispatchEvent=function(_4d){

                 
                 // Mac Safari ExternalInteface bug
                 // http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?catid=585&threadid=1169978&enterthread=y
                 _arc_debug(" arc dispatchEvent _4d " + _4d.type);

                 switch(arc.stage.state){
                                case "complete":
                                  arc.clientMgr.handleEvent(_4d);
                                  break;
                                  case "failed":
                                  break;
                                  default:
                                  arc.stage.handleEvent(_4d);
                }

                arc.eventMgr.dispatchEvent(_4d);
        };

        arc.initialize=function(){
                _arc_debug( " arc intitialize " );
                arc.stage.initialize();
        };

} // end if arc == null
 

    // PROD FX
    // PROD FX
    // PROD FX


if(typeof prodFx=="undefined"){

        function _arcQuickShop(x,y,imgUri,imgOver){

            this.x=x;
            this.y=y;
            this.overProduct=false;
            this.buttonImg=document.createElement("img");
            this.buttonImg.parent=this;
            this.buttonImg.imgUri=imgUri;
            this.buttonImg.imgOver=imgOver;
            this.buttonImg.setAttribute("src",imgUri);
            this.buttonImg.style.position = 'absolute';
            this.buttonImg.style.cursor='pointer';
            this.buttonImg.style.zIndex = arc.Util.getMaxZindex() ;
            this.buttonImg.over=false;
            this.buttonImg.onmouseover = function()
            {
                this.over=true;
                this.setAttribute("src",this.imgOver);
            }
            this.buttonImg.onmouseout = function()
            {
                this.over=false;
                this.setAttribute("src", this.imgUri);
            }
            this.buttonImg.onclick = function()
            {
                prodFx.click();
            }
        }

    if (  typeof ( STATIC_PICK_BUTTON_UP ) != "undefined"   && typeof ( STATIC_PICK_BUTTON_DOWN ) != "undefined"  )
        var prodFx = new _arcQuickShop(12,80, STATIC_PICK_BUTTON_UP , STATIC_PICK_BUTTON_DOWN );

        _arcQuickShop.prototype.showButton = function(event,_offsetX,_offsetY,uri){

            if (! arc.enabled || arc.clientMgr.clientVisible ) return;
            _arc_debug(' showButton page info:\n' + arc.Util.getBrowserProfile( new arc.Util.page() ) ); 
            this.productUri = uri;
            _arc_debug(" prodFx showButton " + uri);
            this.overProduct=true;
            if (!event) var event = window.event;
            var tg = (window.event) ? event.srcElement : event.target;
            this.buttonImg.style.left = (parseInt(arc.Util.getAbsoluteLeft(tg)) + (_offsetX!=null?_offsetX:this.x) )+"px";
            this.buttonImg.style.top  = (parseInt(arc.Util.getAbsoluteTop(tg))  + (_offsetY!=null?_offsetY:this.y) )+"px";
            this.buttonImg.style.visibility='visible';
            this.buttonImg.style.display='block';
            document.body.appendChild(this.buttonImg);
        }
        _arcQuickShop.prototype.hideButton = function(){
            if (! arc.enabled ) return;
            this.overProduct=false;
            setTimeout("prodFx.timeoutButton();", 100);
        }
        _arcQuickShop.prototype.timeoutButton = function()
        {
           if (!this.buttonImg.over && !this.overProduct)
           { 
              this.destroy();
           }
        }
        _arcQuickShop.prototype.destroy = function()
        {
              this.productUri = null;
              this.buttonImg.style.visibility='hidden';
              this.buttonImg.style.display='none';          
        }
        _arcQuickShop.prototype.click = function()
        {

              _arc_debug ( "launch " + this.productUri );              
              var editNewOrderItemEvent = 
                 {
                        type: "editNewOrderItem",
                        topic: "order",
                        className: "com.allurent.arc.events.OrderEvent",
                        data: { productUri: this.productUri, context: "external" }
                 };
              this.destroy();

              _arc_debug ( "launch " + editNewOrderItemEvent.toString() );   
              arc.dispatchEvent(editNewOrderItemEvent);
        }
}


   // CLIENT DESC
   // CLIENT DESC
   // CLIENT DESC

if(typeof arc.ClientDesc=="undefined"){

        arc.ClientDesc=function(_25,_26,_27,_28){
          this.clientId=_25;
          this.swfUrl=_26;
          this.displayParams=_27;
          this.launchEvents={};
          for(i in _28){
                //_arc_debug("new client "+_28[i]);
                this.launchEvents[_28[i]]=true;
          }
          this.started=false;
          this.preload=false;
          this.flashvars=null;
          this.page = new arc.Util.page();
          this.applicationName=null;
          this.visible=false;
          arc.clientMgr.addClientDesc(this);
          _arc_debug('new clientDesc.page info:\n' + arc.Util.getBrowserProfile(this.page) ); 
        }

        arc.ClientDesc.prototype={
                isEmbedded:function(){
                        return this.displayParams.parentElement!=null;
                },
                getParentElement:function(){
                        if(this.displayParams.parentElement!=null){
                                return arc.Util.resolveElement(this.displayParams.parentElement);
                        }
                        return null;
                },
                getSwfUrl:function(){
                        if(this.swfUrl!=null){
                                if ( arc.Util.debugMode() )
                                        this.swfUrl=this.swfUrl.substring(0,this.swfUrl.length-4)+"-debug"+".swf";      
                                return this.swfUrl;
                        }
                        return null;
                },
                getBgColor:function(){
                        var _30="#ffffff";
                        if(this.displayParams.flashBackgroundColor!=null){
                                _30=this.displayParams.flashBackgroundColor;
                        }
                        return _30;
                },
                getSwfLeft:function(){
                    return  (this.displayParams.left) ? this.displayParams.left  : (this.page.width()/2 - this.displayParams.width/2);
                },
                getSwfRight:function(){
                    return  (this.displayParams.left) ? this.displayParams.left+this.displayParams.width   : (this.page.width()/2 + this.displayParams.width/2);
                },
                getBgWindowStyleName:function(){

                    return ( typeof ( this.displayParams.bgWindowStyleName) != "undefined" ) ? this.displayParams.bgWindowStyleName : false; 
                },
                getWidthWithScrollBar:function(){
                    if ( this.page.width() != this.page.visibleWidth() )
                    {
                        return this.page.visibleWidth();
                    } else {     
                        return this.page.width();
                    }
                },
                showWindow:function(){ 
                    _arc_debug(' ***  showWindow:function() ');
                    if ( this.isEmbedded() )
                         {
                             if (this.page.browser.isNot(["Mac","Firefox"]))
                             {
                                 _arc_debug(" showWindow for non macff ");
                                 if ( this.bgDiv == null )
                                 {
                                     var _66=document.createElement("div");
                                     _66.style.position="absolute";
                                     _66.style.top="0px";         
                                     _66.style.left="0px";    
                                     _66.style.height="1px";    
                                     _66.style.width="1px";    
                                     _66.style.zIndex=4999;
                                     if ( this.getBgWindowStyleName () ) 
                                         _66.className = this.getBgWindowStyleName();
                                     this.bgDiv = _66;       
                                     arc.Util.getBody().appendChild(_66);
                                 }
                                 this.bgDiv.style.visibility="visible";
                                 this.bgDiv.style.display="block";
                                 this.bgDiv.style.width = this.getWidthWithScrollBar()+"px";
                                 this.bgDiv.style.height = this.page.height()+"px";
                                 
                             } else { 
                                 if ( this.bgDiv == null ) {
                                     this.bgDiv = new Array();
                                     var top    = this.page.offsetY()+this.getPaddingFromTop();
                                     var right  = this.getSwfRight();
                                     var bottom =  (this.page.offsetY()+this.getPaddingFromTop())+this.displayParams.height;
                                     var left   = this.getSwfLeft();
  
                                     var geomotries = new Array();
                                     geomotries[0] = new Array (  0 ,  top , this.getWidthWithScrollBar() , 0 ) ;
                                     geomotries[1] = new Array (  top ,  bottom-top ,  this.getWidthWithScrollBar()-right, right   ) ;
                                     geomotries[2] = new Array (  top ,  bottom-top ,  left , 0  ) ;
                                     geomotries[3] = new Array (  bottom ,  this.page.height() - bottom ,  this.getWidthWithScrollBar()  , 0  ) ;

                                     for ( var _ids = 0 ; _ids < geomotries.length ; _ids++ ) 
                                     {
                                         _arc_debug(" ff div create " + _ids );
                                          var _66=document.createElement("div");
                                         _66.style.position="absolute";
                                         _66.style.top=geomotries[_ids][0]+"px";
                                         _66.style.height=geomotries[_ids][1]+"px";
                                         _66.style.width=geomotries[_ids][2]+"px";
                                         _66.style.left=geomotries[_ids][3]+"px";
                                         _66.style.zIndex= 4990 + _ids;
                                         if ( this.getBgWindowStyleName () ) 
                                             _66.className = this.getBgWindowStyleName();
                                         arc.Util.getBody().appendChild(_66);
                                         // save for later removal
                                         this.bgDiv.push(_66);
                                     }
                                 } 
                             }
                             return;
                         }
            },
            
            
            hideWindow:function(){ 
                _arc_debug(' hideWindow'); 
                if ( this.isEmbedded()  )
                {
                    if( this.page.browser.isNot(["Mac","Firefox"]) ) 
                    {
                        
                        _arc_debug(' hideWindow most browser'); 
                        this.bgDiv.style.visibility="hidden";
                        this.bgDiv.style.display="none";
                    } else {
                        _arc_debug(' hideWindow macFF'); 
 
                        if ( this.bgDiv &&  this.bgDiv.length > 0 ) {
                            for ( i = 0 ; i< this.bgDiv.length;i++) 
                            {
                                arc.Util.getBody().removeChild( this.bgDiv[i]);
                            }
                        }
                        this.bgDiv = null;
                    }
                }
                return;
            },
            getWidth:function(){
                return ( this.displayParams.width ) ?  this.displayParams.width : 0;
                    },
            getPaddingFromTop:function(){
                initD = ( typeof(this.displayParams.paddingFromTop) != "undefined" ) ? this.displayParams.paddingFromTop : 0;
                if ( this.page.visibleHeight() < this.getHeight() || initD == 0 ) return 0;
                if ( this.page.visibleHeight() < (this.getHeight()+initD) ) {
                    var diff =  ( this.getHeight()+initD ) - this.page.visibleHeight() ;
                    initD = ( diff > 0 ) ? initD - Math.round(diff) : 0  ;
                }
                _arc_debug( " getPaddingFromTop = " + initD );
                return initD;
            },
            getHeight:function(){
                return ( this.displayParams.height ) ?  this.displayParams.height : 0;
            },
            showSwf:function(){

                _arc_debug(' *** client desc showSwf'); 
                if ( this.isEmbedded())  {

//                    if (this.bgDiv == null)
//                   {
                        _arc_debug(' showSWF calls showWindow '); 
                        this.showWindow();
//                    }
                    if ( this.displayParams.modal != false ){
                        if ( this.displayParams.modal!=false) {
                            this.getParentElement().style.width=this.displayParams.width?this.displayParams.width+"px":"100%";
                            this.getParentElement().style.height=this.displayParams.height?this.displayParams.height+"px":"100%";
                        }
                        if (this.swf == null ) {
                            this.getParentElement().style.display="none";
                            var _2d=new SWFObject(
                                this.getSwfUrl(),
                                this.clientId,
                                this.displayParams.width?this.displayParams.width:"100%",
                                this.displayParams.height?this.displayParams.height:"100%",
                                arc.stage.flashVersionRequired,
                                this.getBgColor());
                            _2d.addVariable("clientId",this.clientId);
                            _2d.addVariable("applicationName",this.applicationName!=null?this.applicationName:this.pendingEvent.type);
                            _2d.addVariable("allowScriptAccess","always");
                            _2d.addVariable("repaintEagerly",arc.Util.needsEagerRepaint());
                            if(this.flashvars!=null){
                                for(var _2e in this.flashvars){
                                  if (Object.prototype[_2e] === undefined)
                                  {
                                    _2d.addVariable(_2e,this.flashvars[_2e]);
                                  }
                                }
                            }
                            _2d.write(this.getParentElement());
                            this.swf=arc.Util.getSwfById(this.clientId);
                        }  
                        
                        if (this.displayParams.anchorElement )
		        {					    
                            this.swfDiv.style.left = ( ( this.displayParams.anchorElementXoffset ) ? this.displayParams.anchorElementXoffset : 0 ) + arc.Util.getAbsoluteLeft(this.displayParams.anchorElement) + "px";
                            this.swfDiv.style.top = ( ( this.displayParams.anchorElementYoffset ) ? this.displayParams.anchorElementYoffset : 0 ) + arc.Util.getAbsoluteTop(this.displayParams.anchorElement) + "px";
		        }
                        if( this.isEmbedded() ){
                            this.swfDiv = this.getParentElement();
                            this.swfDiv.style.zIndex = 5000;//arc.Util.getMaxZindex();  
                        }
                        if ( this.displayParams.modal == true){
                            this.swfDiv.style.position="absolute";
                            _arc_debug( "page width="+ this.page.width() +" - client width="+this.getWidth()  );
                            this.swfDiv.style.left= this.getSwfLeft()+"px" ;
                            this.swfDiv.style.top = (this.page.offsetY()+this.getPaddingFromTop()) +"px";
                        }
                        this.getParentElement().style.display="inline";
                        this.getParentElement().style.visibility= "visible";
                        this.visible=true;
                    }

                }
                else 
                {
                    _arc_debug( " in showSwf ( not embedded ) " );
                    // if (this.bgWindow == null)
                    // {
                    _arc_debug(" bgWin is null ");
                    /*******************/
                    if (this.swfDiv == null)
                    {
                        // First time - create.
                        
                        this.swfDiv = document.createElement("div");
                        this.swfDiv.setAttribute("id", "arcStage0");
                        this.swfDiv.style.position = "absolute";
                        arc.Util.getBody().appendChild(this.swfDiv);
                    }    
		    //if (this.displayParams.anchorElement == "richInLineCart")
		    if (this.displayParams.anchorElement == "bagTextLink")
		    {					    
                        this.swfDiv.style.left = arc.Util.getAbsoluteLeft("bagTextLink") + this.displayParams.xoffset + "px";
                        this.swfDiv.style.top = arc.Util.getAbsoluteTop("bagTextLink") + this.displayParams.yoffset + "px";					
		    }
		    else if (this.displayParams.anchorElement != null)
                    {
		        var potentialTop = arc.Util.getAbsoluteTop(this.displayParams.anchorElement) + this.displayParams.yoffset;
                        var actualTop = Math.max(arc.Util.getScrollY(), Math.min(potentialTop, arc.Util.getInnerHeight()+arc.Util.getScrollY()-this.getHeight()));					    
                        this.swfDiv.style.left = this.displayParams.xoffset + "px";
                        this.swfDiv.style.top = actualTop + "px";
                    }
                    else
                    {
                        this.swfDiv.style.left = "165px";
                        this.swfDiv.style.top = "161px";
                    }
                    
                    this.swfDiv.style.width = this.getWidth() + "px";
                    this.swfDiv.style.height = this.getHeight() + "px";
                    this.swfDiv.style.visibility = "visible";
                    this.swfDiv.style.padding = "0px 0px 0px 0px";
                    this.swfDiv.style.color = this.getBgColor();
                    this.swfDiv.style.zIndex = 1000;
                    this.swfDiv.style.overflow = "hidden";
                    


                    if (this.swf == null)
                    {
                        var swfObj = new SWFObject(this.getSwfUrl(),
                            this.clientId,
                            "100%", "100%",
                            arc.stage.flashVersionRequired,
                            this.getBgColor());
                        
                        // Add Allurent-defined flashvars:
                        swfObj.addVariable("clientId", this.clientId);
                        swfObj.addVariable("applicationName", this.applicationName != null ? this.applicationName : this.pendingEvent.type);
                        swfObj.addVariable("allowScriptAccess", "always");
                        
                        // Logic to force eager screen repainting on a platform that requires it
                        swfObj.addVariable("repaintEagerly", arc.Util.needsEagerRepaint());
                        
                        // Add application-defined flashvars:
                        if (this.flashvars != null)
                        {
                            for (var varName in this.flashvars)
                            {
                                if (Object.prototype[varName] === undefined)
                                {
                                    swfObj.addVariable(varName, this.flashvars[varName]);
                                }
                            }
                        }
                        
                        swfObj.write(this.isEmbedded() ? this.getParentElement()
                                     : this.swfDiv);
                        this.swf = arc.Util.getSwfById(this.clientId);
                        

                        /*******************/

                    }
              
                }
            },
            handleClose:function(){ 
                _arc_debug(" handleClose " + this.swfDiv );
                if(this.swfDiv!=null){
                    if ( this.displayParams.modal!=false) this.hideWindow();
                    this.swfDiv.style.top= "-" + (this.getHeight()+100)+"px";
                    if ( this.page.browser.isOpera() ) this.swfDiv.style.visibility= "hidden";
                    this.visible=false; 
                }
                return false;
            },
            handleStart:function(){
                _arc_debug(" STARTED " + this.started + " pending event = " + this.pendingEvent );
                if(!this.started){
                    this.started=true;
                    if(this.pendingEvent!=null){
                        _arc_debug(" Pending Event " + this.pendingEvent );
                        this.handleEvent(this.pendingEvent);
                    }
                }
                
                
            },
            handleEvent:function(_35){
                _arc_debug(" HANDLE EVENT _35="+_35.type + " started = " + this.started );

                if (this.started && this.swf ) 
                {
                    switch(this.swf.arcHandleEvent(_35)){
                    case true:
                        break;
                    case false:
                        break;
                    default:
                        //alert("ERROR: event not handled");
                    }
                }
            }
        }
}


        // START 
        // START 
        // START 
var disableArc20;

arc.start = function(app,debug){

    if ( disableArc20 ) {
        return ;   
    }

        if ( debug ) {
            /* debugConsole false will show many many alert dialogs.*/
            _arc_debug_flag = true;
            var _page = new arc.Util.page();
            // debugger not IE friendly 
            if(_page.browser.isNot(["Win","IE"])) 
            {
                window._arc_debug = function(str){ arc.Util.alert(str); }

                var _arc_debug_textarea = document.createElement("textarea");
                 _arc_debug_textarea.rows=13;                
                 _arc_debug_textarea.id="_arc_debug_area";
                 
                 _arc_debug_textarea.cols=60;
                 _arc_debug_textarea.style.position="absolute";
                 _arc_debug_textarea.style.top="0px";
                 _arc_debug_textarea.style.width="320px";
                 _arc_debug_textarea.style.height="700px";
                 _arc_debug_textarea.style.left="810px";               
                arc.Util.getBody().appendChild(_arc_debug_textarea);
            }
        }
         _arc_startMode = app;

}


   // WINDOW STATE 
   // WINDOW STATE 
   // WINDOW STATE 

/*

NOTE: the first call to the - getWindowState - function should
not happen until after the browser has passed the opening BODY
tag (else the corresponding element will not be available in
the DOM).

var clientWidth = windowInterface.getWidth();
var clientHeight = windowInterface.getHeight();
var verticalScroll = windowInterface.getScrollY();
var horizontalScroll = windowInterface.getScrollX();

*/
function _arc_getWindowState(){
        _arc_debug(" _arc_getWindowState ");
        var global = this;
        var lastSt,lastSl,lastIW,lastIH,bodyRank = null,docElRank = null;
        var twoTestCount = 0;

        var readScroll = {scrollLeft:NaN,scrollTop:NaN};
        var readSizeC = {clientWidth:NaN,clientHeight:NaN};
        var readSizeI = {innerWidth:NaN,innerHeight:NaN};


        var readScrollX = 'scrollLeft';
        var readScrollY = 'scrollTop';

        var theInterface = {
                getScrollX:getScrlXMain,
                getScrollY:getScrlYMain,
                getWidth:function(){return initWidthHeight('getWidth');},
                getHeight:function(){return initWidthHeight('getHeight');}
        };


        function getScrlXTest(){hasChangedScroll();return getScrlXMain();}
        function getScrlYTest(){hasChangedScroll();return lastSl;}

        function getScrlXMain(){return readScroll[readScrollX];}
        function getScrlYMain(){return readScroll[readScrollY];}

        function getWidthI(){return readSizeI.innerWidth;}
        function getHeightI(){return readSizeI.innerHeight;}


        function getWidthC(){return readSizeC.clientWidth;}
        function getHeightC(){return readSizeC.clientHeight;}

        function getHeightSmart(){
                return (hasChangedSize()?theInterface.getHeight:getHeightC)();
        }
        function getWidthSmart(){
                return (hasChangedSize()?theInterface.getWidth:getWidthC) ();
        }

        function setInnerWH(){
                theInterface.getWidth = getWidthI;
                theInterface.getHeight = getHeightI;
        }

        function setMinimumScroll(){
                theInterface.getScrollX = getScrlXMain;
                theInterface.getScrollY = getScrlYMain;
        }

        function hasChangedSize(){
                if(
                        (lastIH != (lastIH = getHeightI()))||
                        (lastIW != (lastIW = getWidthI()))
                ){
                        threeObjectTest();
                        return true;
                }
                return false;
        }
        function hasChangedScroll(){
                if(
                        (lastSl != (lastSl = getScrlYMain()))||
                        (lastSt != (lastSt = getScrlXMain()))
                ){
                        threeObjectTest();
                }
        }

        function rankObj_inner(testObj, rankObj){
                /* Variables that will hold vertical and horizontal differences
                   between client and inner values:-
                */
                var dv,dh;

                if(
                        ((dv = (global.innerHeight - testObj.clientHeight)) >= 0)&&
                        ((dh = (global.innerWidth - testObj.clientWidth)) >= 0)&&
                        (!(getScrlXMain()&&!dv))&&
                        (!(getScrlYMain()&&!dh))&&

                        (
                        !(
                        (
                        dh&&(rankObj.hDiff||(rankObj.hDiff = dh))&&
                        (dh != rankObj.hDiff)
                        )||(
                        dv&&(rankObj.vDiff||(rankObj.vDiff = dv))&&
                        (dv != rankObj.vDiff)
                        )
                        )
                        )
                ){
                        if(dh == dv){
                                rankObj.rank = Number(Boolean(dh));

                        }else if((dh&&!dv)||(dv&&!dh)){

                                rankObj.rank = (dh+dv);
                        }else{
                                rankObj.rank = NaN;
                        }
                }else{
                        rankObj.rank = NaN;
                }
                return rankObj;
        }

        function propsAreNumbers(testObj){
                for(var c = arguments.length;--c;){
                        if(typeof testObj[arguments[c]] != 'number'){
                                return false;
                        }
                }
                return true;
        }

        function rankObj(testObj, rankObj){
                if(
                        testObj&&
                        propsAreNumbers(testObj, 'clientWidth','clientHeight')
                )
                {
                        rankObj_inner(testObj, rankObj)
                }
                return rankObj;
        }

        function initWidthHeight(callOn){
                lastIW = getWidthI();
                lastIH = getHeightI();
                lastSt = getScrlYMain();
                lastSl = getScrlXMain();

                bodyRank = {vDiff:0,hDiff:0,rank:NaN};
                docElRank = {vDiff:0,hDiff:0,rank:NaN};

                theInterface.getWidth = getWidthSmart;
                theInterface.getHeight = getHeightSmart;

                theInterface.getScrollX = getScrlXTest;
                theInterface.getScrollY = getScrlYTest;

                threeObjectTest();

                rankObj = rankObj_inner;

                return theInterface[callOn]();
        }

        function threeObjectTest(){

                var bodyNaN = isNaN(rankObj(document.body, bodyRank).rank);
                var docElNaN =
                        isNaN(rankObj(document.documentElement, docElRank).rank);

                if(bodyNaN||docElNaN){

                        if(bodyNaN&&docElNaN){
                                setMinimumScroll();
                                setInnerWH();

                        }else{
                                readSizeC = ((docElNaN)?document.body:
                                document.documentElement);
                                bodyRank = ((docElNaN)?bodyRank:docElRank);
                                docElRank = null;

                                threeObjectTest = twoObjectTest;
                        }

                }else{
                        readSizeC = ((bodyRank.rank < docElRank.rank)?
                        document.body:
                        document.documentElement);
                }
        }

        function twoObjectTest(){

                if(isNaN(rankObj(readSizeC, bodyRank).rank)){
                        bodyRank = null;
                        setMinimumScroll();
                        setInnerWH();

                }else if(
                        (bodyRank.vDiff)&&(bodyRank.hDiff)&&
                        (++twoTestCount > 2)
                ){
                                bodyRank = null;
                                theInterface.getWidth = getWidthC;
                                theInterface.getHeight = getHeightC;
                                setMinimumScroll();
                }
        }

        // called once at singleton creation
        if(!propsAreNumbers(global, 'innerHeight', 'innerWidth')){
                readSizeC = compatModeTest(readSizeC);
                theInterface.getWidth = getWidthC;
                theInterface.getHeight = getHeightC;
        }else{

                readSizeI = global;
        }

        if(propsAreNumbers(global, 'pageYOffset', 'pageXOffset')){
                readScroll = global;
                readScrollY = 'pageYOffset';
                readScrollX = 'pageXOffset';

        }else{
                readScroll = compatModeTest(readScroll);
        }

        return (_arc_getWindowState = function(){return theInterface;})();
        }


        function compatModeTest(obj){
                if(     (document.compatMode)&&
                        (document.compatMode.indexOf('CSS') != -1)&&
                        (document.documentElement)
                ){
                        return (compatModeTest = function(){
                                return document.documentElement;
                        })((obj = null));
                }else if(document.body){
                        return (compatModeTest = function(){
                        return document.body;
                })((obj = null));
                }else{
                return obj;
        }
}





/*
 * Handle successful initialization.
 */
arc.addEventListener("arcLoadComplete", function(event) {
    _arc_debug(" added event listener : " + event.type )
    arc.enableRichApps();
    arc.Util.setCookie("cartLoadFlag", "arcLoadComplete");
});


/*
 * Handle capability test failure.
 */
arc.addEventListener("arcInitFailed", function(event) {

    arc.Util.setCookie("cartLoadFlag", "arcInitFailed");
});


/*
 * Handle start of preloading.
 */
arc.addEventListener("arcLoadStarted", function(event) {
    //show loading indicator
    //showLoading();
});

/*
 * Handle preloading failure.
 */
arc.addEventListener("arcLoadFailed", function(event) {
    //hideLoading();
    //alert(event.reason);   // preload is not expected to fail
    arc.Util.setCookie("cartLoadFlag", "arcLoadFailed");
});


/**
 * Coremetrics Page View Event
 */
arc.addEventListener("cmPageView", function(event)
{
    cmCreatePageviewTag(event.data.pageId, null, event.data.categoryId);
});

/**
 * Coremetrics Product View Event
 */
arc.addEventListener("cmProductView", function(event)
{
	var categoryId = arcCheckForCorrectCategoryId(event.data.categoryId);

	cmCreateProductviewTag(event.data.productId, event.data.productName, categoryId, 
				"ALLURENT_PRODUCT: " + event.data.productName + " (" + event.data.productId + ")");

});

/**
 * Coremetrics Shop Action 5 Event sent when a product is added to bag is performed successfully
 */
arc.addEventListener("cmShopAction5", function(event)
{
	var categoryId = arcCheckForCorrectCategoryId(event.data.categoryId);

	var tempProductName = event.data.productName;
    var replaceChar = /'/g ;  // any occurence of single quotes in the string would'be matched
    if (replaceChar.test(tempProductName)) {
        tempProductName = tempProductName.replace(replaceChar,'\'') ;
    }
    
    // Stash any rich category information in a arc cart tracker cookie
    arcTrackContents(event.data.productId, categoryId, event.data.productQuantity);

	cmCreateShopAction5Tag(event.data.productId, tempProductName, 
				event.data.productQuantity, event.data.productPrice, 
				categoryId, event.data.color, event.data.size);
});

/**
 * Send a Coremetrics Display Shop 5 Event immediately after all 
 * the Shop Action 5 Event are sent for all products added to bag
 */
arc.addEventListener("cmDisplayShop5s", function(event)
{
	cmDisplayShop5s();
});

/**
 * Coremetrics Registration Event
 */
arc.addEventListener("cmRegistration", function(event)
{
	cmCreateRegistrationTag(event.data.customerID, event.data.customerEmail, event.data.customerCity,
			    event.data.customerState, event.data.customerZIP, 
			    event.data.newsletterName, event.data.subscribe);
});

arc.addEventListener("helpLinkClick",function(event)
{
   // Help links from checkout, will include a URL for use as well as a KEY. Functions can use 
   // the URL in a generic single way or use the KEY to over ride basic pop up behavoir
   
   if ( event.data.key == "forgotPasswordUrl" ) {
   			
   			document.location.href=event.data.uri;
   			return;
   }
   
   if ( typeof ( CheckoutPopup ) == "function" ) {
   				CheckoutPopup( event.data.uri ) ;
   } else {
    	 arcHandleHelpLinks(event.data.uri,event.data.key);
   }
   
});



// Utility method that will be used if the function "CheckoutPopup"  can not be found
var _arc_pop_win; 
function arcHandleHelpLinks(uri,key)
{
	    if ( _arc_pop_win != null ) {
			_arc_pop_win.close();
	   	} 
       	_arc_pop_win = window.open(uri,"checkout","width=395,height=425,scrollbars=yes,status=yes,toolbar=no,menubar=no,location=no,resizable=yes");
		try {
					//_arc_pop_win.close();
		} catch (e) {
		    _arc_pop_win = null;
				alert("Pop-ups blocked.");
		}
		if ( _arc_pop_win != null ) 
		{
		   if ( typeof(_arc_pop_win.focus ) == "function" )
		   _arc_pop_win.focus();
		}
}

function arcCheckForCorrectCategoryId(dCat)
{
	var paramString = window.location.search;
	var search = /id=\w+/;
	var idParam = paramString.match(search);
	var categoryString = idParam[0].split("=");
	var categoryId = categoryString[1];

	return (categoryId != "") ? "RICH_" + categoryId : dCat ;
}

/**
 * This function collects rich category names in a cookie arcCartTracker
 * The cookie value has the format productId:categoryName:quantity|.....
 */
function arcTrackContents(productId, categoryId, quantity)
{
    var trackStr = arc.Util.getCookie("arcCartTracker");
    
    if (trackStr == null || trackStr == "" || (trackStr.indexOf(productId) < 0))
    {
        if (trackStr != null && trackStr != "")
        {
            trackStr += '|';
        }
        else
        {
            trackStr = "";
        }
        trackStr += (productId + ":" + categoryId + ":" + quantity);
        // 30 days
        arc.Util.setCookie("arcCartTracker", trackStr, 2592000);
    }
}
