

//! ################################################################
//! Copyright (c) 2007 Amazon.com, Inc., and its Affiliates.
//! All rights reserved.
//! Not to be reused without permission
//! Date: 2007/01/09 
//! ################################################################
function Ajax(_1){
this.url=_1;
this.isCancellable=true;
this.failureCallback="";
this.requiresMimeOverride=navigator.userAgent.indexOf("Firefox/1.0")>-1;
this.randomID=this.randomID||0;
}
Ajax.prototype.makeRequest=function(_2,_3,_4){
this.param=_2;
this.successCallback=_3;
if(_4){
this.failureCallback=_4;
}
var _5=false;
if(window.XMLHttpRequest){
_5=new XMLHttpRequest();
if(this.requiresMimeOverride&&_5.overrideMimeType){
_5.overrideMimeType("text/xml");
}
}else{
if(window.ActiveXObject){
try{
_5=new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e){
try{
_5=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){
}
}
}
}
if(!_5){
return false;
}
var _6=this;
_5.onreadystatechange=function(){
try{
if(_5.readyState==4){
if(_5.status==200){
var _7=_5.responseText;
try{
_6.successCallback(_7);
}
catch(ex){
_6._endRequest("Error using callback ",ex);
return;
}
_6._endRequest();
}else{
_6._endRequest("Error status: "+_5.status+" : "+_5.responseText);
}
}
}
catch(ex){
_6._endRequest("Error with ajax: "+ex);
}
};
if(this.requestMethod=="GET"){
_5.open("GET",this.url+"?"+this.param+"random="+Ajax.randomID,true);
Ajax.randomID++;
}else{
_5.open("POST",this.url,true);
_5.setRequestHeader("Content-Type","application/x-www-form-urlencoded; "+"charset=UTF-8");
}
debug(this.url+"?"+this.param);
_5.send(this.param);
return true;
};
Ajax.prototype._endRequest=function(_8,_9){
if(_8){
if(this.failureCallback){
this.failureCallback();
}else{
debug("Ajax.prototype._endRequest Error: "+_8+" "+_9);
}
}
};
Ajax._requestTimedOut=function(_a){
return function(){
if(_a.isCancellable){
_a.cancel=true;
if(State.currentRequest==_a){
State.currentRequest=null;
}
}
_a._endRequest("Request timed out");
if(_a.failureCallback){
_a.failureCallback();
}
};
};
function Animations(){
}
Animations.divProcessing=new Array();
Animations.GRAIN_SIZE=15;
Animations.expandDivHeight=function(_b,_c,_d,_e,_f){
if(Animations.divProcessing[_b]==1){
return;
}
if(_c==_d){
return;
}
Animations.divProcessing[_b]=1;
var _10=document.getElementById(_b);
if(_f==null||!_f){
_10.style.height=_c+"px";
}
_10.style.display="block";
_10.style.overflow="hidden";
var _11=_e/Animations.GRAIN_SIZE;
Animations._expandDivHeight(_10,_c,_d,_11,_c,_f);
};
Animations._expandDivHeight=function(_12,_13,_14,_15,_16,_17){
var _18=parseFloat(_16)+parseFloat((_14-_13)/Animations.GRAIN_SIZE);
var _19=0;
if((_13<_14&&_18>_14)||(_13>_14&&_18<_14)){
_18=_14;
_19=1;
}
if(_18<1){
_12.style.display="none";
}else{
if(_17==null||!_17){
_12.style.height=_18+"px";
}
}
if(!_19){
setTimeout(function(){
Animations._expandDivHeight(_12,_13,_14,_15,_18);
},_15);
}else{
Animations.divProcessing[_12.id]=0;
_12.style.height="";
}
};
Animations.toggleDivHeight=function(_1a){
var div=document.getElementById(_1a);
var _1c=div.style.display;
div.style.display="block";
var _1d=div.offsetHeight;
div.style.display=_1c;
if(_1c=="block"){
Animations.expandDivHeight(_1a,_1d,0);
}else{
Animations.expandDivHeight(_1a,0,_1d);
}
};
function debug(msg){
return;
}
function EditTextarea(_1f,key,_21,_22,_23){
this.customerId=_1f;
this.key=key;
this.id=_1f+"_"+key+"_editTextarea";
this.rows=_21||10;
this.cols=_22||50;
this.defaultDisplayText=(_23)?_23:"Enter text here";
}
EditTextarea.prototype.onSubmit=function(){
var _24=document.getElementById("oldValue"+this.key);
var _25=document.getElementById("userValue"+this.key);
var _26=document.getElementById("submitButton"+this.key);
var _27=document.getElementById("changed"+this.key);
if(_24.value==_25.value||_25.value==this.defaultDisplayText){
return false;
}
function setSaved(_28){
var _29;
try{
_29=eval("("+_28+")");
}
catch(e){
debug(e);
return;
}
if(_29.isError){
_26.value="Failed: Try Again";
}else{
_24.value=_29.data;
_25.value=_29.data;
_27.value=0;
_26.disabled=true;
_26.value="Saved";
}
}
var _2a=new Ajax(BASE_PATH+"/ajax/setProfile.html");
_2a.makeRequest("key="+this.key+"&value="+_25.value,setSaved);
_24.value=_25.value;
_26.value="Saving";
return false;
};
EditTextarea.prototype.displayValue=function(_2b,_2c){
if(!_2c){
if(!_2b){
return "";
}
var _2d=document.createElement("div");
_2d.id="uneditable"+this.key;
_2d.innerHTML=_2b;
return _2d;
}
var _2e=this;
var _2f=document.createElement("form");
_2f.name=this.id;
_2f.id=this.id;
_2f.onsubmit=function(){
return _2e.onSubmit();
};
var _30=document.createElement("textarea");
_30.name="userValue"+this.key;
_30.id="userValue"+this.key;
_30.rows=this.rows;
_30.cols=this.cols;
_30.onblur=function(){
_2e.onSubmit();
};
_30.onkeyup=function(){
_2e.onKeyUp();
};
if(_2b){
_30.appendChild(document.createTextNode(_2b));
}else{
_30.appendChild(document.createTextNode(this.defaultDisplayText));
}
_2f.appendChild(_30);
var _31=document.createElement("input");
_31.type="hidden";
_31.name="oldValue"+this.key;
_31.id="oldValue"+this.key;
_31.value=_2b;
_2f.appendChild(_31);
var _32=document.createElement("input");
_32.type="hidden";
_32.name="changed"+this.key;
_32.id="changed"+this.key;
_32.value="0";
_2f.appendChild(_32);
var _33=document.createElement("input");
_33.type="submit";
_33.name="submitButton"+this.key;
_33.id="submitButton"+this.key;
_33.value="Save";
_33.disabled=true;
_2f.appendChild(_33);
return _2f;
};
EditTextarea.prototype.onKeyUp=function(){
var _34=document.getElementById("oldValue"+this.key);
var _35=document.getElementById("userValue"+this.key);
var _36=document.getElementById("submitButton"+this.key);
var _37=document.getElementById("changed"+this.key);
if(_34.value!=_35.value){
if(_37.value==1){
return;
}
_36.disabled=false;
_36.value="Save";
_37.value=1;
}else{
_36.disabled=true;
_37.value=0;
}
};
function UtilitiesDom(){
}
UtilitiesDom.getWindowWidth=function(){
var _38;
if(self.innerHeight){
_38=self.innerWidth;
}else{
if(document.documentElement&&document.documentElement.clientWidth){
_38=document.documentElement.clientWidth;
}else{
if(document.body){
_38=document.body.clientWidth;
}
}
}
return _38;
};
UtilitiesDom.getWindowHeight=function(){
var _39;
if(self.innerHeight){
_39=self.innerHeight;
}else{
if(document.documentElement&&document.documentElement.clientHeight){
_39=document.documentElement.clientHeight;
}else{
if(document.body){
_39=document.body.clientHeight;
}
}
}
return _39;
};
UtilitiesDom.clearElement=function(_3a){
if(!_3a){
return;
}
for(var i=_3a.childNodes.length-1;i>=0;i--){
_3a.removeChild(_3a.childNodes[i]);
}
};
UtilitiesDom.stripWhitespaceNodes=function(_3c){
for(var i=_3c.childNodes.length-1;i>=0;i--){
var _3e=_3c.childNodes[i];
if(_3e.nodeType==Node.ELEMENT_NODE||_3e.nodeType==Node.DOCUMENT_NODE||_3e.nodeType==Node.DOCUMENT_FRAGMENT_NODE){
UtilitiesDom.stripWhitespaceNodes(_3e);
}else{
if(_3e.nodeType==Node.COMMENT_NODE){
_3c.removeChild(_3e);
}else{
if(_3e.nodeType==Node.TEXT_NODE){
if(_3e.nodeValue==null||_3e.nodeValue.search(/^\s*$/)>=0){
_3c.removeChild(_3e);
}
}
}
}
}
};
UtilitiesDom.findYPos=function(_3f){
var y=0;
if(_3f==null){
return y;
}
if(_3f.offsetParent){
while(_3f!=null){
y+=_3f.offsetTop;
_3f=_3f.offsetParent;
}
}else{
if(_3f.y){
y+=_3f.y;
}
}
return y;
};
UtilitiesDom.findXPos=function(_41){
var x=0;
if(_41.offsetParent){
while(_41!=null){
x+=_41.offsetLeft;
_41=_41.offsetParent;
}
}else{
if(_41.x){
x+=_41.x;
}
}
return x;
};
UtilitiesDom.getStyle=function(_43,_44){
var _45;
if(window.getComputedStyle){
_45=document.defaultView.getComputedStyle(_43,null).getPropertyValue(_44);
}else{
if(_43.currentStyle){
_45=_43.currentStyle[_44];
}
}
return _45;
};
UtilitiesDom.show=function(){
for(i=0;i<arguments.length;i++){
var e=document.getElementById(arguments[i]);
if(e){
e.style.display="";
}
}
};
UtilitiesDom.hide=function(){
for(i=0;i<arguments.length;i++){
var e=document.getElementById(arguments[i]);
if(e){
e.style.display="none";
}
}
};
UtilitiesDom.clickedNode=function(_48,_49){
if(_49==null){
return false;
}
if(document.all){
var t=window.event.srcElement;
while(t.parentElement!=null){
if(t==_49){
return true;
}
t=t.parentElement;
}
return false;
}else{
if(document.getElementById&&_48){
var t=_48.target;
while(t.parentNode!=null){
if(t==_49){
return true;
}
t=t.parentNode;
}
return false;
}else{
return false;
}
}
};
UtilitiesDom.positionClickedDiv=function(_4b,_4c,_4d){
var _4e=document.getElementById(_4b);
if(!_4e){
alert("Can not find relativeId "+_4b);
return;
}
var _4f=document.getElementById(_4c);
if(!_4f){
alert("Can not find div "+_4c);
return;
}
_4f.style.display="block";
UtilitiesDom.positionDiv(_4e,_4f,_4d);
return false;
};
UtilitiesDom.positionHoverDiv=function(_50,_51,_52){
var _53=document.getElementById(_50);
if(!_53){
return;
}
var _54=document.getElementById(_51);
if(!_54){
return;
}
_54.style.display="block";
UtilitiesDom.positionDiv(_53,_54,_52);
};
UtilitiesDom.positionDiv=function(_55,_56,_57){
var el=_55;
var _59=0;
var _5a=el.offsetHeight;
while(el.offsetParent&&el.tagName.toUpperCase()!="BODY"){
_59+=el.offsetLeft;
_5a+=el.offsetTop;
el=el.offsetParent;
}
var _5b=_56.offsetWidth;
var _5c=_56.offsetHeight;
var _5d=0;
var _5e=0;
if(!_57){
_57="top-left";
}
switch(_57){
case "right":
_5d=50;
_5e=(0-Math.floor(_5c/2));
break;
case "top-right":
_5d=30;
_5e=(0-_5c);
break;
case "bottom-batch-middle":
_5e=30;
_5d=(0-Math.floor(_5b/2));
break;
case "bottom-middle":
_5d=(0-Math.floor(_5b/2));
_5e=2;
break;
case "over-middle":
_5d=(0-Math.floor(_5b/2));
_5e=(0-Math.floor(_5c/2));
break;
case "left-middle":
_5d=(0-Math.floor(_5b));
_5e=(0-Math.floor(_5c/2));
case "top-left":
default:
_5d=(0-_5b);
_5e=(0-_5c);
break;
}
_56.style.top=Math.max(10,(_5a+_5e))+"px";
_56.style.left=Math.max(10,(_59+_5d))+"px";
};
UtilitiesDom.popupTimerArray=new Object;
UtilitiesDom.leaveDiv=function(_5f,_60){
if(_60==null){
_60=400;
}
UtilitiesDom.popupTimerArray[_5f]=setTimeout(function(){
document.getElementById(_5f).style.display="none";
},_60);
};
UtilitiesDom.arriveDiv=function(_61){
if(UtilitiesDom.popupTimerArray[_61]){
clearTimeout(UtilitiesDom.popupTimerArray[_61]);
}
};
UtilitiesDom.documentOnclickStack=new Array();
UtilitiesDom.pushDocumentOnclick=function(_62){
UtilitiesDom.documentOnclickStack.push(_62);
document.onclick=_62;
};
UtilitiesDom.popDocumentOnclick=function(){
UtilitiesDom.documentOnclickStack.pop();
if(UtilitiesDom.documentOnclickStack.length>0){
document.onclick=UtilitiesDom.documentOnclickStack[UtilitiesDom.documentOnclickStack.length-1];
}else{
document.onclick="";
}
};

