/*
	Copyright (c) 2004-2008, The Dojo Foundation
	All Rights Reserved.

	Licensed under the Academic Free License version 2.1 or above OR the
	modified BSD license. For more information on Dojo licensing, see:

		http://dojotoolkit.org/book/dojo-book-0-9/introduction/licensing
*/


if(dojo.version.flag!=="mackr"){
dojo.registerModulePath("site","/js/v1/site");
}
dojo.require("generic.img");
dojo.require("site.cart");
dojo.require("generic._base");
var cartStatus={};
var global={cartHandler:new site.cart(),playerversion:null};
if(navigator.userAgent.indexOf("Macintosh")!=-1){
global.playerversion="10.0.0";
}
dojo.addOnLoad(function(){
heightHandler.init();
cartStatus.init();
dojo.query("img.rollover").forEach(function(_1){
var _2=new generic.rollover(_1,null);
});
initLiveChatPopup("gnav_popup_live_chat");
initLiveChatPopup("popup_live_chat");
initLiveChatPopup("popup_live_chat_2");
});
cartStatus={doCartRefresh:false,init:function(){
this.countNode=dojo.byId("global_cart_count");
this.cartHandler=global.cartHandler;
this.updateCount();
var _3=dojo.byId("shopping_bag_items");
if(_3){
dojo.removeClass(_3,"hidden");
}else{
return;
}
var _4=this;
dojo.subscribe("/page/cart/alterCart",this,function(_5){
_4.onAlterCart(_5);
});
},onAlterCart:function(_6){
this.updateCount();
if(_6.action==="add"&&_6.cartType==="checkout"){
this.doCartRefresh=true;
if(dojo.global.mymacNav){
dojo.global.mymacNav.handlePanelRefresh({event:"alter_cart"});
}
}
},updateCount:function(){
if(this.countNode){
var _7=this.cartHandler.getItemCount();
this.countNode.innerHTML=_7;
}
}};
heightHandler={pagetype:null,min:620,winh:0,bodyh:0,bodyhOriginal:0,bodyhWithoutPanel:0,offset:18,isCMS:false,spacer:null,excludeOnResize:["color_play"],excludeOnload:["color_play","locator"],isLoading:false,isResizing:false,timer:null,isIE6:false,hasCMSLayers:false,init:function(){
this.hasCMSLayers=(dojo.query(".cms_layer","main_content_td").length>0);
if(this.hasCMSLayers&&page_data.panel_nav["default"].id!=="locator"){
this.cmsCleanup();
}
var _8=dojo.byId("globalnav_container");
if(!_8){
return;
}
var _9=dojo.byId("column_spacer");
if(dojo.isIE==6){
this.isIE6=true;
var _a=dojo.byId("color_nav_td");
_9=(_a?_a:_9);
}
this.spacer=_9;
this.setPageType();
this.winh=this.getWindowHeight();
if(this.pagetype!=="home"){
this.bodyhOriginal=this.getBodyHeight();
this.bodyh=this.bodyhOriginal;
}
this.onLoad();
dojo.subscribe("/panelnav/event/show",this,function(_b){
var _c=(_b.type==="accordion"?true:false);
if(!_c){
try{
_c=dijit.byId(_b.subId).hasLoaded;
}
catch(err){
}
}
if(_c){
this.onPanel("show",_b);
}
});
dojo.subscribe("/globalnav/event/getcontent/onload",this,function(_d){
try{
_d.id=dijit.byId(_d.parentId).panelId;
}
catch(err){
}
if(_d.id){
this.onPanel("show",_d);
}
});
dojo.subscribe("/panelnav/event/hide",this,function(_e){
this.onPanel("hide",_e);
});
if(dojo.indexOf(this.excludeOnResize,this.pagetype)==-1){
dojo.connect(window,"onresize",this,"onResize");
}
this.isLoading=false;
},cmsCleanup:function(){
var _f=[];
dojo.forEach(dojo.query(".cms_layer","main_content_td"),function($_){
pushNew(_f,$_.parentNode);
});
dojo.forEach(_f,function($_){
if(!dojo.hasClass($_,"noCMSCleanup")){
parseCMSLayers($_);
}
});
function parseCMSLayers(_12){
var _13=false;
if(dojo.hasClass(_12,"hidden")){
_13=true;
_12.origLeft=_12.style.left;
_12.style.left="-5000px";
dojo.removeClass(_12,"hidden");
}
var _14=dojo.query(".cms_layer",_12);
var _15=_14.sort(function(a,b){
return parseInt(a.style.top)-parseInt(b.style.top);
});
var _18=[];
var _19=[];
_18[0]=[];
var _1a=0;
var _1b=0;
for(var i=0;i<_15.length;i++){
_15[i].style.height="auto";
_15[i].cmsTop=parseInt(_15[i].style.top);
_15[i].actualHeight=parseInt(_15[i].clientHeight);
_15[i].impliedTopMargin=(i==0)?_15[i].cmsTop:_15[i].cmsTop-_15[i-1].cmsTop-_15[i-1].actualHeight;
_1b=(i==0)?_15[i].style.top:_15[i-1].style.top;
if(_15[i].style.top==_1b){
}else{
_18[_1a]=_18[_1a].sort(function(a,b){
return parseInt(a.style.left)-parseInt(b.style.left);
});
_1a++;
_18[_1a]=[];
}
_18[_1a].push(_15[i]);
}
_18[_1a]=_18[_1a].sort(function(a,b){
return parseInt(a.style.left)-parseInt(b.style.left);
});
var o={};
var css="";
var _23=(_12.id=="main_content_td")?476:0;
for(var i=0;i<_18.length;i++){
for(var j=0;j<_18[i].length;j++){
o=_18[i][j];
css="position:relative;";
css+="width:"+o.style.width+";";
css+="height:"+o.actualHeight+"px;";
css+="margin-left:"+(parseInt(o.style.left)-_23)+"px;";
css+="margin-top:"+o.impliedTopMargin+"px;";
o.style.cssText=css;
_12.appendChild(o);
}
}
if(_13){
dojo.addClass(_12,"hidden");
_12.style.left=_12.origLeft;
}
};
function pushNew(arr,o){
var n=true;
for(var i=0;i<arr.length;i++){
if(arr[i]==o){
n=false;
break;
}
}
if(n){
arr.push(o);
}
};
try{
var _29=(dojo.isSafari)?dojo.byId("color_nav_standalone"):dojo.byId("color_nav");
_29.style.height=(dojo.byId("main_table").scrollHeight+dojo.byId("footernav").clientHeight+50)+"px";
}
catch(e){
}
},onLoad:function(){
if(dojo.indexOf(this.excludeOnload,this.pagetype)>-1){
if(!this.isIE6){
return;
}else{
if(!dojo.byId("color_nav_container")){
return;
}
}
}
this.isLoading=true;
var h=(this.winh>this.min)?this.winh:this.min;
var _2b=this.spacer;
if(this.pagetype==="home"){
h=(this.winh-this.offset);
this.spacer=_2b=dojo.byId("main_content");
_2b.style.height=h+"px";
}else{
if(!this.hasCMSLayers&&(h>=this.bodyh)){
_2b.style.height=h+"px";
}
if(this.isIE6){
var _2c=(dojo.isSafari)?dojo.byId("color_nav_standalone"):dojo.byId("color_nav");
if(_2c){
var _2d=(2800>this.bodyh)?2800:this.bodyh;
if(dojo.isIE){
_2c.style.height=this.bodyh+"px";
}else{
if(dojo.isSafari){
_2c.style.height=_2d+"px";
}else{
setTimeout(function(){
_2c.style.height=_2d+"px";
},2000);
}
}
}
_2b.style.height=this.bodyh+"px";
}else{
if(this.pagetype==="flash_browser"){
_2b.style.height=h+"px";
}
}
}
this.bodyhOriginal=this.bodyh=this.bodyhWithoutPanel=h;
},setPageType:function(){
var pd=dojo.global.page_data;
if(this.pagetype){
type=this.pagetype;
}else{
try{
this.pagetype=pd.panel_nav["default"].id;
}
catch(err){
}
}
this.isCMS=(pd?pd.cms_generated:null);
},onPanel:function(_2f,_30){
if(this.isResizing){
return;
}
var _31=_30.type;
var _32=_30.parentId;
if(_32==="globalnav_container"&&_31==="accordion"){
return;
}
var _33=this.spacer;
var id=_30.id;
if(_31==="panel"){
this.activePanelId=id;
}
var _35=this.activePanelId;
var _36=dojo.byId(_35);
if(!_36){
return;
}
this.isResizing=true;
var _37=this;
var _38=function(){
if(_2f==="hide"&&_31==="panel"){
var h=_37.bodyhWithoutPanel;
if(h<_37.winh){
h=_37.winh;
}
_33.style.height=h+"px";
_37.bodyh=h;
}else{
if(_2f==="show"){
var _3a=_36.offsetHeight;
if(_3a>_37.winh&&_3a>_37.bodyh){
_33.style.height=_3a+"px";
_37.bodyh=_3a;
}
}
}
_37.isResizing=false;
};
setTimeout(_38,600);
},onResize:function(){
if((this.isResizing||this.isLoading)&&!this.isIE6){
return;
}
var _3b=this.getWindowHeight();
var _3c=this.bodyh;
var _3d=this.pagetype;
if(_3b>_3c){
this.doResize(_3d,_3b);
}else{
if(_3d==="home"){
if((_3b<this.min)&&(this.min>_3c)){
this.doResize(_3d,this.min);
}
}else{
if(this.isIE6){
_3c=this.getBodyHeight();
if(_3c!=this.bodyh){
this.doResize(_3d,_3c);
this.bodyh=_3c;
}
}
}
}
this.winh=_3b;
},doResize:function(_3e,_3f){
var _40=this.timer;
var _41=this.spacer;
var _42=this.offset;
var h=_3f;
var _44=this;
var _45=function(){
if(_3e==="home"){
h=(_3f-_42);
}
_41.style.height=h+"px";
_44.bodyh=_44.bodyhWithoutPanel=h;
};
if(dojo.isIE){
if(_40){
clearTimeout(_40);
}
_40=setTimeout(_45,300);
}else{
_45();
}
},getBodyHeight:function(){
var h=dojo.body().scrollHeight;
return h;
},getWindowHeight:function(){
var h;
if(typeof window.innerHeight!=="undefined"){
h=window.innerHeight;
}else{
h=document.documentElement.clientHeight;
}
return h;
},getCMSHeight:function(){
var h=0;
var _49=dojo.query(".cms_layer","#main_content_td");
if(_49.length==0){
return 800;
}
var _4a=_49[_49.length-1];
_4a.style.height="auto";
var _4b=parseInt(_4a.clientHeight);
var _4c=parseInt(_4a.style.top);
h=(_4b+_4c+40);
return h;
}};
function clearField(_4d,_4e){
_4e=_4e?_4e:"";
_4d.value=_4e;
if(_4d.createTextRange){
var rng=_4d.createTextRange();
rng.move("character",0);
rng.select();
}else{
if(_4d.selectionStart){
_4d.focus();
_4d.setSelectionRange(0,0);
}
}
};
var livechatPopArgs={url:"/includes/live_chat_popup.tmpl",resizable:"no",scrollbars:"no",width:483,height:409};
function initLiveChatPopup(_50){
var lc=new generic.popup({activator:_50,url:livechatPopArgs.url,resizable:livechatPopArgs.resizable,scrollbars:livechatPopArgs.scrollbars,width:livechatPopArgs.width,height:livechatPopArgs.height});
};
function openLiveChatPopup(){
var lc=window.open(livechatPopArgs.url,"live_chat","resizable=0, scrollbars=0, width="+livechatPopArgs.width+", height="+livechatPopArgs.height);
cmCreateConversionEventTag("Live Chat","1","ASK AN ARTIST","10");
};
function openFullWindow(url,_54,w,h){
var w=window.open(url,_54,"menubar=1, toolbar=1, resizable=1, scrollbars=1, width="+w+", height="+h);
};
var newsPopup={open:function(id){
var pop=dojo.byId("pop_news-"+id);
if(pop){
dojo.style(pop,"top","0");
}
},close:function(id){
var pop=dojo.byId("pop_news-"+id);
if(pop){
dojo.style(pop,"top","-5000px");
}
}};
