//Copyright 2003-2006 A9.com or its affiliates
var a9search=new Object;
a9search.defText="Give it a try, go ahead kick our tires.";
a9search.defText2="Go ahead, test drive the A9 Product Search.";
a9search.blur=function(elemName){
if(!elemName)
elemName="q";
var t=document.getElementById(elemName);
var inputDefText=t.defText;
if(!t.defText&&t.getAttribute("defText"))
inputDefText=t.getAttribute("defText");
if(t.value==""||t.value==a9search.defText||
(t.value==inputDefText)){
t.style.color="#aaa";
if( inputDefText )
t.value=inputDefText;
else
t.value=a9search.defText;
}
if(t.value==""||t.value==a9search.defText2){
t.style.color="#aaa";
t.value=a9search.defText2;
}
}
a9search.focus=function(elemName){
if(!elemName)
elemName="q";
var t=document.getElementById(elemName);
var inputDefText=t.defText;
if(!t.defText&&t.getAttribute("defText"))
inputDefText=t.getAttribute("defText");
a9search.noInitBlur=true;
if(t.value==a9search.defText)
t.value="";
if(t.value==a9search.defText2)
t.value="";
if(t.value==inputDefText)
t.value="";
t.style.color="black";
}
function getSearchUrl(base,val){
val=a9Trim(val);
if(val=="robots.txt"||val=="favicon.ico"||val=="siteinfo.xml"){
val='"'+val+'"';
}
if( /.*field-keywords=$/.test(base) )
return base+a9Encode(val);
else
return base.replace(/(?:q=|([?]|$))/,a9Encode(val)+"$1");
}
function checkSearchAction(formName,selectName,booksOnly){
if(!formName)
formName="sf";
if(!selectName)
selectName="searchSelect";
var form=document.getElementById(formName);
var searchSelect=document.getElementById(selectName);
if( searchSelect&&!searchSelect.checked ){
form.action=a9productSearchUrl;
}
else
form.action=a9searchUrl.replace(/http:\/\/[^\/]+\//,"http://"+document.location.host+"/");
if( booksOnly )
form.action=a9bookSearchUrl;
}
function submitProductSearch(val){
if(val==null){
val="";
}
var u=getSearchUrl(a9productSearchUrl,val);
u=fixUrl(u);
location.href=u;
return false;
}
function submitSearch(elemName,formName,selectName,booksOnly){
if(!elemName)
elemName="q";
if(!formName)
formName="sf";
var form=document.getElementById(formName);
var q=document.getElementById(elemName);
var val=q.value;
var defValue=q.defValue;
if(!q.defValue&&q.getAttribute("defValue"))
defValue=q.getAttribute("defValue");
if(!defValue )
defValue=a9search.defText;
var defText=q.defText;
if(!q.defText&&q.getAttribute("defText"))
defText=q.getAttribute("defText");
checkSearchAction(formName,selectName,booksOnly);
if(val==null){
val="";
}
else if((val==defText)||(val=="")){
val=defValue;
}
var u=getSearchUrl(form.action,val);
u=fixUrl(u);
location.href=u;
return false;
}
function fixUrl(u){return u;}
function ferr(s){
}
function a9SetAttribute(obj,attr,value){
try{
if(a9IsSafari){
obj[attr]=""+value;
}else{
obj.setAttribute(attr,value);
}
}catch (e){}
}
function a9GetAttribute(obj,attr){
try{
if(a9IsSafari){
return obj[attr];
}else{
return obj.getAttribute?obj.getAttribute(attr):null;
}
}catch (e){
return null;
}
}
function a9Encode(s){
if(typeof(encodeURIComponent)!="undefined"){
return encodeURIComponent(s);
}
return escape(s);
}
function a9Decode(s){
if(typeof(decodeURIComponent)!="undefined"){
return decodeURIComponent(s);
}
return unescape(s);
}
function a9PopupWin(url,name,options){
var win=window.open(url,name,options);
win.opener=this;
win.focus();
}
function a9GetElText(el){
var tt=a9GetAttribute(el, "textTitle");
if(tt){
if(tt==1){
if(el.title){
return el.title;
}
}else{
return tt;
}
}
if(el.innerText){
return el.innerText;
}
function getElTextInt(el){
var text="";
var children=el.childNodes;
for(var i=0;i<children.length;i++){
if(children[i].nodeType==3){
text+=children[i].nodeValue;
}else{
text+=getElTextInt(children[i]);
}
}
return text;
}
return getElTextInt(el).replace(/^\s+/,"").replace(/\s+$/,"");
}
function a9Image(name,ext){
return A9IMAGES+"/"+name+"."+(ext?ext:"gif");
}
function a9Png(name){return a9Image(name,"png");}
function getOffsetLeft(el){
var l=0;
while(el){
l+=el.offsetLeft-el.scrollLeft;
el=el.offsetParent;
}
return l;
}
function getOffsetTop(el){
var t=0;
while(el){
t+=el.offsetTop-el.scrollTop;
el=el.offsetParent;
}
return t;
}
function a9Trim(s){
return s.replace(/^\s+/,"").replace(/\s+$/,"")
}
function cloneNoId(n,iehack){
function removeIds(n){
if(n.id) n.id="";
for(var i=0;i<n.childNodes.length;i++) removeIds(n.childNodes[i]);
}
var c;
if(a9IsIE&&iehack&&n.getElementsByTagName("style").length){
c=document.createElement(n.tagName);
c.innerHTML=n.innerHTML;
c.className=n.className;
}else{
c=n.cloneNode(true);
}
removeIds(c);
return c;
}
function getStyle(el,attr){
if(window.getComputedStyle){
return window.getComputedStyle(el, "")[attr];
}
if(document.defaultView&&document.defaultView.getComputedStyle){
return document.defaultView.getComputedStyle(el, "")[attr];
}
if(el.currentStyle){
return el.currentStyle[attr];
}
return null;
}
function getPxStyle(el,attr){
var sz=getStyle(el,attr);
if(sz){
return parseInt(sz.replace("px", ""));
}
return 0;
}
var isGoodFeed=false;
var lastUrl;
function showPreview(url,page,args){
lastUrl=url;
var preview=document.getElementById("preview");
var loadingMsg="Loading...";
preview.innerHTML="<div style='height:300'>"+loadingMsg+"</div>";
var prev_url=A9NOSEARCH+"/layout/snippet.jsp?q="+a9Encode(document.getElementById("previewString").value)+"&dptp=preview&dsubmit=1&showurl=1&dfunc=updatePreview&dtile=openSearchPreview"+"&url="+a9Encode(url);
if(page>1) prev_url+="&p="+page;
if(args) prev_url+="&"+args;
if(!startXmlHttpRequest(prev_url, previewLoaded, null, null, "_t")){
a9err("loadTile bad HttpRequest");
}
}
function previewKey(evt,url){
evt=evt ? evt : event;
if(evt.keyCode==13){
showPreview(url);
}
}
function togglePreviewURL(prev_url){
var toggle=document.getElementById("toggleUrl");
var previewUrl=document.getElementById("previewUrl");
if(toggle.innerHTML=="Show Preview URL"){
var mod_prev_url=prev_url;
toggle.innerHTML="Hide Preview URL";
previewUrl.innerHTML="<a target=\"_blank\" href=\""+prev_url+"\">"+mod_prev_url.replace(/([&\/?])/g, "<wbr/>$1")+"</a>";
}else{
toggle.innerHTML="Show Preview URL";
previewUrl.innerHTML="";
}
}
function updatePreview(html){
function outputPage(n){
if(n==curPage){
return "&nbsp;"+n;
}
return "&nbsp;<a onclick='showPreview(lastUrl,"+n+(pageArgs?",\""+pageArgs+"\"":"")+")'>"+n+"</a>";
}
var preview=document.getElementById("preview");
preview.innerHTML=html+"<div id='previewPages' style='text-align:center'></div>";
var as=preview.getElementsByTagName("a");
for(var i=0;i<as.length;i++){
if(!as[i].target){
as[i].target="previewIf";
}
}
var divs=preview.getElementsByTagName("div");
var curPage=0, nPages=0, pageArgs="";
for(var i=0;i<divs.length;i++){
if(divs[i].className=="cscrollInfo"){
curPage=parseInt(a9GetAttribute(divs[i], "a9x:curPage"));
nPages=parseInt(a9GetAttribute(divs[i], "a9x:nPages"));
pageArgs=a9GetAttribute(divs[i], "a9x:args");
break;
}
}
if(curPage>0&&nPages>0){
var s="";
s+=outputPage(1);
if(nPages>1){
var start=curPage-5;
if(start<2) start=2;
var end=curPage+5;
if(end>nPages) end=nPages;
if(start>2){
s+=" ... ";
}
for(var i=start;i<=end;i++){
s+=outputPage(i);
}
if(end<nPages-1){
s+=" ... ";
}
if(end<nPages){
s+=outputPage(nPages);
}
}
document.getElementById("previewPages").innerHTML=s;
}
}
function touClick(){
var acceptTou=document.getElementById("acceptTou");
var submitFeed=document.getElementById("submitFeed");
if(isGoodFeed&&acceptTou.checked){
submitFeed.className="button-small";
submitFeed.disabled=false;
}else{
submitFeed.className="button-small-disabled";
submitFeed.disabled=true;
}
}
function checkDelColumn(){
return confirm("Clicking OK will delete this column for you and for all other A9 users.  Are you sure you wish to delete this column?");
}
function submitNonsense(url){
document.getElementById("previewString").value="itrfosalcamtaftunatcc";
showPreview(url);
}
function goodFeed(){
isGoodFeed=true;
touClick();
document.getElementById("goodFeedWarn").style.display="none";
}
function lck(){}
function previewLoaded(xml,arg,txt,status){
updatePreview(txt);
goodFeed();
}
function startXmlHttpRequest(url,func,arg,postData,ts){
try{
var xmlhttp;
if(a9IsIE){
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}else{
xmlhttp=new XMLHttpRequest();
}
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState==4){
func(xmlhttp.responseXML,arg,xmlhttp.responseText,xmlhttp.status);
}
}
if(a9IsSafari&&postData&&a9VersionMajor<312){
url+="?"+postData;
postData=null;
}
if(ts){
ts+="="+(new Date).getTime();
if(postData){
postData+="&"+ts;
}else{
url+=(url.indexOf("?")<0?"?":"&")+ts;
}
}
xmlhttp.open(postData?"POST":"GET", url, true);
if(postData){
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
}
xmlhttp.send(postData);
return true;
}catch (e){}
return false;
}
/* cookies.js
Based on Example File From "JavaScript and DHTML Cookbook"
Published by O'Reilly&Associates
Copyright 2003 Danny Goodman
*/
function cookieGetExpDate(days,hours,minutes){
var expDate=new Date();
if(typeof days=="number"&&typeof hours=="number"&&typeof hours=="number"){
expDate.setDate(expDate.getDate()+parseInt(days));
expDate.setHours(expDate.getHours()+parseInt(hours));
expDate.setMinutes(expDate.getMinutes()+parseInt(minutes));
return expDate.toGMTString();
}
}
function _getCookieVal(offset){
var endstr=document.cookie.indexOf (";", offset);
if(endstr==-1){
endstr=document.cookie.length;
}
return a9Decode(document.cookie.substring(offset,endstr));
}
function getCookie(name){
var arg=name+"=";
var alen=arg.length;
var clen=document.cookie.length;
var i=0;
while(i<clen){
var j=i+alen;
if(document.cookie.substring(i,j)==arg){
return _getCookieVal(j);
}
i=document.cookie.indexOf(" ", i)+1;
if(i==0) break;
}
return null;
}
function cookieEncode(v){
return a9Encode(v).replace(/%7B/g,"{").replace(/%7D/g,"}").
replace(/%5B/g,"[").replace(/%5D/g,"]").
replace(/%22/g, "\"").replace(/%3A/g,":");
}
function setCookie(name,value,expires,path,domain,secure){
document.cookie=name+"="+cookieEncode (value)+
((expires) ? ";expires="+expires : "")+
((path) ? ";path="+path : "")+
((domain) ? ";domain="+domain : "")+
((secure) ? ";secure" : "");
}
function deleteCookie(name,path,domain){
if(getCookie(name)){
document.cookie=name+"="+
((path) ? ";path="+path : "")+
((domain) ? ";domain="+domain : "")+
";expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}
function JSONObject(string){
if(string){
eval ("this.o="+string);
if(!this.o||typeof this.o!="object"){
this.o=new Object;
}
}else{
this.o=new Object;
}
}
JSONObject.prototype.put=function(key,value){
this.o[key]=value;
}
JSONObject.prototype.opt=function(key){
return this.o[key];
}
JSONObject.prototype.remove=function(key){
delete this.o[key];
}
JSONObject.prototype.toString=function(){
function stringify(arg){
function isUndefined(a){
return typeof a=='undefined';
}
function quote(s){
return '"'+s.replace(/(["\\])/g, '\\$1')+'"';
}
var i,o,v;
switch (typeof arg){
case 'object':
if(arg){
if(arg.constructor==Array){
o='[';
for(i=0;i<arg.length;++i){
v=stringify(arg[i]);
if(v!='function'&&!isUndefined(v)){
o+=(o!='[' ? ',' : '')+v;
}else{
o+=',';
}
}
return o+']';
}else if(typeof arg.toString!='undefined'){
o='{';
for(i in arg){
v=stringify(arg[i]);
if(v!='function'&&!isUndefined(v)){
o+=(o!='{' ? ',' : '')+
quote(i)+':'+v;
}
}
return o+'}';
}else{
return;
}
}
return 'null';
case 'unknown':
case 'undefined':
return;
case 'string':
return quote(arg);
case 'function':
return 'function';
default:
return String(arg);
}
}
return stringify(this.o);
}
function getJSONCookie(name,expDays,expHours,expMinutes,path,domain,secure){
var nm="_CK"+name;
if(!top[nm]){
top[nm]=new JSONCookie(name,expDays,expHours,expMinutes,path,domain,secure);
}
return top[nm];
}
function JSONCookie(name,expDays,expHours,expMinutes,path,domain,secure){
this.name=name;
this.expDays=expDays;
this.expHours=expHours;
this.expMinutes=expMinutes;
this.path=path;
this.domain=domain;
this.secure=secure;
this.jo=new JSONObject(getCookie(name));
}
JSONCookie.prototype.getObject=function(){
return this.jo;
}
JSONCookie.prototype.save=function(){
var s=this.jo.toString();
var exp=null;
if(this.expDays||this.expHours||this.expMinutes){
exp=cookieGetExpDate(this.expDays,this.expHours,this.expMinutes);
}
setCookie(this.name,s,exp,this.path,this.domain,this.secure);
}
var COL_COOKIE_EXPIRE_DAYS=365;
var COL_COOKIE="col";
function getColCookie(){
return getJSONCookie(COL_COOKIE, COL_COOKIE_EXPIRE_DAYS, 0, 0, "/", ".a9.com");
}

