/* 
SAA PLUS Packs Calculator v. 1.0.1
Copyright 2007 Stock Artists Alliance. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

See the License for the specific language governing permissions and
limitations under the License.

Based on PLUS Packs Calculation Module by Rivaldo Does 
(also licensed under the Apache License, Version 2.0)
*/

var PLUSPACKSCALC={matrix:PLUSPACKSCALC.matrix,currency:PLUSPACKSCALC.currency,notice:PLUSPACKSCALC.notice,init:function(){
var i,x;
this.menuItemSelected="";
// if there's a global variable for the "add to cart" button text, use it. 
if ( typeof(strSCartPrompt) == "string") {
  document.getElementById("ppksAddToCartBtn").firstChild.nodeValue = strSCartPrompt;
}
x=document.getElementsByTagName("div");
for(i=0;i<x.length;i++){
if(x[i].className=="menuItem"){
x[i].onmouseover=this.hover.on;
x[i].onmouseout=this.hover.off;
}
}
PLUSPACKSCALC.error=PLUSPACKSCALC.validMatrix();
this.initCurrencySign();
this.resetUsage();
},validMatrix:function(){
var i,_4,_5,_6,_7;
if(typeof (this.matrix)=="undefined"){
_4="PLUS Packs error: could not locate a valid price data file. If you have one installed, it is likely corrupted.";
alert(_4);
}else{
for(i in this.matrix.base){
_5=this.matrix.base[i];
_6=_5*1;
if(isNaN(_6)){
_4+=i+" : "+_5+". ";
}
}
if(_4){
_7="The following data in the price data file is invalid or malformed: ";
_7+=_4;
_7+="Please see the documentation on how to properly enter values in your data file.";
alert(_7);
}
}
return _4;
},initCurrencySign:function(){
var _8="";
var _9=[];
_9=this.currency.sign.split(",");
for(var i in _9){
_8+=String.fromCharCode(_9[i]);
}
this.currency.sign=_8;
},hover:{on:function(){
PLUSPACKSCALC.currentTooltip=this.getAttribute("id")+"TT";
if(document.getElementById(PLUSPACKSCALC.currentTooltip)){
document.getElementById(PLUSPACKSCALC.currentTooltip).style.visibility="visible";
}
if(this!=PLUSPACKSCALC.menuItemSelected){
PLUSPACKSCALC.hoverOffColor=this.className;
if(PLUSPACKSCALC.hoverOffColor=="menuItem"){
this.className="menuItemHover";
}else{
this.className="menuItemGrayoutHover";
}
}
},off:function(){
if(this!=PLUSPACKSCALC.menuItemSelected){
this.className=PLUSPACKSCALC.hoverOffColor;
}
if(document.getElementById(PLUSPACKSCALC.currentTooltip)){
document.getElementById(PLUSPACKSCALC.currentTooltip).style.visibility="hidden";
}
}},resetUsage:function(){
this.quote={pack:"",definition:"",duration:"",coverage:"",total:""};
this.plus={pack:"",duration:"",coverage:""};
this.calc={duration:"",coverage:"",total:0};
},toggleSelection:function(_b,_c){
var i,id;
for(i in _b){
id=_b[i];
if(id==_c){
document.getElementById(id).className="menuItemSelect";
this.menuItemSelected=document.getElementById(id);
}else{
document.getElementById(id).className="menuItemGrayout";
}
}
},getDuration:function(pack){
  switch (pack) {
  case "PAWE" :
    return this.matrix.duration50;
    break;
  default:
    return this.matrix.duration;
  }
},getCoverage:function(pack){
  switch (pack) {
  case "PBIP" :
    return this.matrix.coveragePBIP;
    break; 
  case "PBIO" :
    return this.matrix.coveragePBIO;
  case "PBIA" :
    return this.matrix.coveragePBIA;
  case "PBCP" :
     return this.matrix.coveragePBCP;
  case "PBCO" :
     return this.matrix.coveragePBCO;
  case "PBCA" : 
    return this.matrix.coveragePBCA;
    break;
  case "PPIO" :
    return this.matrix.coveragePPIO;
  case "PPCO" :
    return this.matrix.coveragePPCO;
    break;
  case "PEWE" :
    return this.matrix.coverage333; 
  case "PICO" :
    return this.matrix.coverageFlat;
    break;
  default:
    return this.matrix.coverage;
  }
},menuLevel:function(){
var _f=[];
_f[3]=["ppksMenuCov","ppksMenuCovPrice","ppksMenuDur"];
_f[2]=_f[3].concat(["ppksMenuCov","ppksMenuEditrBook","ppksMenuEditrPerio"]);
_f[1]=_f[2].concat(["ppksMenuAdvert","ppksMenuEditr","ppksMenuInternal"]);
_f[0]=_f[1].concat("ppksMenuInitial");
return _f;
},menuItems:{initial:["ppksAdvert","ppksEditr","ppksInternal","ppksPers"],advert:["ppksPapa","ppksPada","ppksPamm","ppksPpop","ppksPawe"],editr:["ppksEditrBook","ppksEditrPerio","ppksPewe"],editrBook:["ppksPbip","ppksPbio","ppksPbia","ppksPbcp","ppksPbco","ppksPbca"],editrPerio:["ppksPpio","ppksPpco"],internal:["ppksPico","ppksPcom","ppksPicr"],cov:["ppksCovLocal","ppksCovRgnl","ppksCovNatl","ppksCovContl","ppksCovWorld"],covPrice:["ppksCovPriceLocal","ppksCovPriceRgnl","ppksCovPriceNatl","ppksCovPriceContl","ppksCovPriceWorld"],dur:["ppksDur6","ppksDur12","ppksDur36","ppksDur60","ppksDur120"]},definition:{PAPA:"Use in any print advertising by one end user. PLUS Pack ID: PAPA",PADA:"Use in any display media by one end user. PLUS Pack ID: PADA",PAMM:"Use in any printed marketing materials by one end user. PLUS Pack ID: PAMM",PPOP:"Use in any point of purchase media by one end user. PLUS Pack ID: PPOP",PAWE:"Use in any web and electronic media by one end user. PLUS Pack ID: PAWE",PBIP:"Use on an interior page in a single printed edition. PLUS Pack ID: PBIP",PBIO:"Use on an interior page in a single edition, all media. PLUS Pack ID: PBIO",PBIA:"Use on an interior page in all editions, all media. PLUS Pack ID: PBIA",PBCP:"Use on a cover in a single printed edition. PLUS Pack ID: PBCP",PBCO:"Use on a cover in a single edition, all media. PLUS Pack ID: PBCO",PBCA:"Use on a cover in all editions, all media. PLUS Pack ID: PBCA",PPIO:"Use on an interior page of one printed issue. PLUS Pack ID: PPIO",PPCO:"Use on a cover of one printed issue. PLUS Pack ID: PPCO",PEWE:"Use for one edition or issue in any web or electronic media. PLUS Pack ID: PEWE",PICO:"Use in any media intended for internal company purposes by one end user. PLUS Pack ID: PICO",PCOM:"Use restricted to reproduction in design prototypes for internal business review only. PLUS Pack ID: PCOM",PICR:"Use restricted to internal review for inspection or editing purposes only. PLUS Pack ID: PICR",PERS:"Use for personal display purposes only. PLUS Pack ID: PERS",ppksAdvert:"Use for commercial or promotional purposes.",ppksEditr:"Use to convey news, information or opinion.",ppksInternal:"Use for internal business purposes.",ppksEditrBook:"Use in a textbook, trade, retail, custom or reference book.",ppksEditrPerio:"Use in a magazine, newspaper or journal.",ppksCovLocal:"Use in any one state or province.",ppksCovRgnl:"Use in any three states or provinces.",ppksCovNatl:"Use in any one country.",ppksCovContl:"Use in any one continental region.",ppksCovWorld:"Use worldwide.",ppksDur6:"Use for up to six months.",ppksDur12:"Use for up to one year.",ppksDur36:"Use for up to three years.",ppksDur60:"Use for up to five years.",ppksDur120:"Use for up to ten years.",0:0},errorDataFile:function(_10){
alert("There is an error in your price data file."+"(check "+_10+")");
},showMenu:function(_11,_12){
this.showMenuHeader(_11);
document.getElementById(_11).style.left=_12;
document.getElementById(_11).style.display="block";
},collapseMenus:function(_13){
var i;
for(i=0;i<_13.length;i++){
document.getElementById(_13[i]).style.display="none";
}
},showMenuHeader:function(_15){
var i,_17;
for(i=0;i<this.menuLevel()[0].length;i++){
_17=this.menuLevel()[0][i]+"Head";
document.getElementById(_17).style.visibility="hidden";
}
_17=_15+"Head";
document.getElementById(_17).style.visibility="visible";
},durPriceIDs:{6:"ppksDur6Price",12:"ppksDur12Price",36:"ppksDur36Price",60:"ppksDur60Price",120:"ppksDur120Price"},calcDurMenu:function(){
var i,_19,_1a,_1b,_1c,_1d;
_19=["6","12","36","60","120"];
if(this.error){
for(i=0;i<_19.length;i++){
document.getElementById(this.durPriceIDs[_19[i]]).firstChild.nodeValue="Call for price";
}
}else{
_1a=this.matrix.base[this.plus.pack];
_1b=this.getCoverage(this.plus.pack)[this.calc.coverage];
_1c="";
for(i=0;i<_19.length;i++){
_1c=this.getDuration(this.plus.pack)[_19[i]];
_1d=" "+this.currency.sign+Math.round((_1a*_1c)*_1b)+this.currency.decimalSeparator+this.currency.decimalString;
document.getElementById(this.durPriceIDs[_19[i]]).firstChild.nodeValue=_1d;
}
}
},covPriceIDs:{local:"ppksCovPriceLocalAmount",regional:"ppksCovPriceRgnlAmount",national:"ppksCovPriceNatlAmount",continental:"ppksCovPriceContlAmount",world:"ppksCovPriceWorldAmount"},calcCovMenu:function(){
var i,_1f,_20,_21,_22,_23;
_1f=["local","regional","national","continental","world"];
if(this.error){
for(i=0;i<_1f.length;i++){
document.getElementById(this.covPriceIDs[_1f[i]]).firstChild.nodeValue="Call for price";
}
}else{
_20=this.matrix.base[this.plus.pack];
_21="";
_22=this.matrix.duration[this.calc.duration];
for(i=0;i<_1f.length;i++){
_21=this.getCoverage(this.plus.pack)[_1f[i]];
_23=" "+this.currency.sign+Math.round((_20*_22)*_21)+this.currency.decimalSeparator+this.currency.decimalString;
document.getElementById(this.covPriceIDs[_1f[i]]).firstChild.nodeValue=_23;
}
}
},showResult:function(){
this.calculateTotal();
this.formatData();
document.getElementById(PLUSPACKSCALC.currentTooltip).style.visibility="hidden";
document.getElementById("ppksMenus").style.display="none";
document.getElementById("ppksResult").style.display="block";
},calculateTotal:function(){
var _24,_25,_26,_27;
_24=this.matrix.base[this.plus.pack];
_25=this.getCoverage(this.plus.pack)[this.calc.coverage];
_26=this.getDuration(this.plus.pack)[this.calc.duration];
_27=Math.round((_24*_26)*_25);
this.calc.total=_27;
this.quote.total=this.currency.sign+_27+this.currency.decimalSeparator+this.currency.decimalString;
},formatData:function(){
var _28,_29;
_28=document.getElementById("ppksResultSummary");
_29="You have selected a PLUS Pack for: ";
_29+=this.quote.pack;
if(this.quote.coverage){
_29=_29+", "+this.quote.coverage;
}
if(this.quote.duration){
_29=_29+", "+this.quote.duration;
}
_28.firstChild.nodeValue=_29;
_28=document.getElementById("ppksResultDescription");
_28.firstChild.nodeValue=this.definition[this.plus.pack]+". "+this.notice;
_28=document.getElementById("ppksResultTotal");
_28.firstChild.nodeValue=this.quote.total;
},goMenuItem:function(_2a){
if(this.error){
alert("Pricing information is momentarily unavailable. Please call for pricing.");
}else{
switch(_2a){
case "ppksAdvert":
this.toggleSelection(this.menuItems.initial,_2a);
this.collapseMenus(this.menuLevel()[1]);
this.showMenu("ppksMenuAdvert","107px");
break;
case "ppksEditr":
this.toggleSelection(this.menuItems.initial,_2a);
this.collapseMenus(this.menuLevel()[1]);
this.showMenu("ppksMenuEditr","107px");
break;
case "ppksInternal":
this.toggleSelection(this.menuItems.initial,_2a);
this.collapseMenus(this.menuLevel()[1]);
this.showMenu("ppksMenuInternal","107px");
break;
case "ppksPers":
this.toggleSelection(this.menuItems.initial,_2a);
this.collapseMenus(this.menuLevel()[1]);
this.resetUsage();
this.quote.pack="Personal Use";
this.plus.pack="PERS";
this.calc.coverage="local";
this.calc.duration="6";
this.showResult();
break;
case "ppksPapa":
this.toggleSelection(this.menuItems.advert,_2a);
this.collapseMenus(this.menuLevel()[2]);
this.showMenu("ppksMenuCov","250px");
this.quote.pack="Print Advertising";
this.plus.pack="PAPA";
break;
case "ppksPada":
this.toggleSelection(this.menuItems.advert,_2a);
this.collapseMenus(this.menuLevel()[2]);
this.showMenu("ppksMenuCov","250px");
this.quote.pack="Display Advertising";
this.plus.pack="PADA";
break;
case "ppksPamm":
this.toggleSelection(this.menuItems.advert,_2a);
this.collapseMenus(this.menuLevel()[2]);
this.showMenu("ppksMenuCov","250px");
this.quote.pack="Marketing Materials";
this.plus.pack="PAMM";
break;
case "ppksPpop":
this.toggleSelection(this.menuItems.advert,_2a);
this.collapseMenus(this.menuLevel()[2]);
this.showMenu("ppksMenuCov","250px");
this.quote.pack="Point of Purchase";
this.plus.pack="PPOP";
break;
case "ppksPawe":
this.toggleSelection(this.menuItems.advert,_2a);
this.collapseMenus(this.menuLevel()[2]);
this.showMenu("ppksMenuDur","250px");
this.quote.pack="Web and Electronic Advertising";
this.quote.coverage="Worldwide Coverage";
this.calc.coverage="local";
this.plus.pack="PAWE";
this.calcDurMenu();
break;
case "ppksEditrBook":
this.toggleSelection(this.menuItems.editr,_2a);
this.collapseMenus(this.menuLevel()[2]);
this.showMenu("ppksMenuEditrBook","250px");
break;
case "ppksEditrPerio":
this.toggleSelection(this.menuItems.editr,_2a);
this.collapseMenus(this.menuLevel()[2]);
this.showMenu("ppksMenuEditrPerio","250px");
break;
case "ppksPewe":
this.toggleSelection(this.menuItems.editr,_2a);
this.collapseMenus(this.menuLevel()[2]);
this.resetUsage();
this.quote.pack="Web and Electronic Editorial";
this.quote.duration="Up to 10 years";
this.plus.duration="7DUQ";
this.plus.pack="PEWE";
this.calc.duration="6";
this.calcCovMenu();
this.showMenu("ppksMenuCovPrice","250px");
break;
case "ppksPbip":
this.toggleSelection(this.menuItems.editrBook,_2a);
this.resetUsage();
this.quote.pack="Book Interior, One Edition, Printed";
this.quote.duration="Up to 10 years";
this.plus.duration="7DUQ";
this.plus.pack="PBIP";
this.calc.duration="6";
this.calcCovMenu();
this.showMenu("ppksMenuCovPrice","467px");
break;
case "ppksPbio":
this.toggleSelection(this.menuItems.editrBook,_2a);
this.resetUsage();
this.quote.pack="Book Interior, One Edition, All Formats";
this.quote.duration="Up to 10 years";
this.plus.duration="7DUQ";
this.plus.pack="PBIO";
this.calc.duration="6";
this.calcCovMenu();
this.showMenu("ppksMenuCovPrice","467px");
break;
case "ppksPbia":
this.toggleSelection(this.menuItems.editrBook,_2a);
this.resetUsage();
this.quote.pack="Book Interior, All Editions, All Formats";
this.quote.duration="Up to 10 years";
this.plus.duration="7DUQ";
this.plus.pack="PBIA";
this.calc.duration="6";
this.calcCovMenu();
this.showMenu("ppksMenuCovPrice","467px");
break;
case "ppksPbcp":
this.toggleSelection(this.menuItems.editrBook,_2a);
this.resetUsage();
this.quote.pack="Book Cover, One Edition, Printed";
this.quote.duration="Up to 10 years";
this.plus.duration="7DUQ";
this.plus.pack="PBCP";
this.calc.duration="6";
this.calcCovMenu();
this.showMenu("ppksMenuCovPrice","467px");
break;
case "ppksPbco":
this.toggleSelection(this.menuItems.editrBook,_2a);
this.resetUsage();
this.quote.pack="Book Cover, One Edition, All Formats";
this.quote.duration="Up to 10 years";
this.plus.duration="7DUQ";
this.plus.pack="PBCO";
this.calc.duration="6";
this.calcCovMenu();
this.showMenu("ppksMenuCovPrice","467px");
break;
case "ppksPbca":
this.toggleSelection(this.menuItems.editrBook,_2a);
this.resetUsage();
this.quote.pack="Book Cover, All Editions, All Formats";
this.quote.duration="Up to 10 years";
this.plus.duration="7DUQ";
this.plus.pack="PBCA";
this.calc.duration="6";
this.calcCovMenu();
this.showMenu("ppksMenuCovPrice","467px");
break;
case "ppksPpio":
this.toggleSelection(this.menuItems.editrPerio,_2a);
this.resetUsage();
this.quote.pack="Periodical Interior, One Issue";
this.quote.duration="Up to 10 years";
this.plus.duration="7DUQ";
this.plus.pack="PPIO";
this.calc.duration="6";
this.calcCovMenu();
this.showMenu("ppksMenuCovPrice","467px");
break;
case "ppksPpco":
this.toggleSelection(this.menuItems.editrPerio,_2a);
this.resetUsage();
this.quote.pack="Periodical Cover, One Issue";
this.quote.duration="Up to 10 years";
this.plus.duration="7DUQ";
this.plus.pack="PPCO";
this.calc.duration="6";
this.calcCovMenu();
this.showMenu("ppksMenuCovPrice","467px");
break;
case "ppksPico":
this.toggleSelection(this.menuItems.internal,_2a);
this.collapseMenus(this.menuLevel()[2]);
this.showMenu("ppksMenuCov","250px");
this.quote.pack="Internal Company Use";
this.plus.pack="PICO";
break;
case "ppksPcom":
this.toggleSelection(this.menuItems.internal,_2a);
this.collapseMenus(this.menuLevel()[3]);
this.resetUsage();
this.quote.pack="Internal Comp Use";
this.quote.duration="Up to 6 months";
this.plus.duration="7DUV";
this.plus.pack="PCOM";
this.calc.coverage="local";
this.calc.duration="6";
this.calcCovMenu();
this.showResult();
break;
case "ppksPicr":
this.toggleSelection(this.menuItems.internal,_2a);
this.collapseMenus(this.menuLevel()[3]);
this.resetUsage();
this.quote.pack="Internal Review";
this.quote.duration="Up to 6 months";
this.plus.duration="7DUV";
this.plus.pack="PICR";
this.calc.coverage="local";
this.calc.duration="6";
this.calcCovMenu();
this.showResult();
break;
case "ppksCovLocal":
this.toggleSelection(this.menuItems.cov,_2a);
this.quote.coverage="Local Coverage";
this.calc.coverage="local";
this.calcDurMenu();
this.showMenu("ppksMenuDur","357px");
break;
case "ppksCovRgnl":
this.toggleSelection(this.menuItems.cov,_2a);
this.quote.coverage="Regional Coverage";
this.calc.coverage="regional";
this.calcDurMenu();
this.showMenu("ppksMenuDur","357px");
break;
case "ppksCovNatl":
this.toggleSelection(this.menuItems.cov,_2a);
this.quote.coverage="National Coverage";
this.calc.coverage="national";
this.calcDurMenu();
this.showMenu("ppksMenuDur","357px");
break;
case "ppksCovContl":
this.toggleSelection(this.menuItems.cov,_2a);
this.quote.coverage="Continental Coverage";
this.calc.coverage="continental";
this.calcDurMenu();
this.showMenu("ppksMenuDur","357px");
break;
case "ppksCovWorld":
this.toggleSelection(this.menuItems.cov,_2a);
this.quote.coverage="Worldwide Coverage";
this.calc.coverage="world";
this.calcDurMenu();
this.showMenu("ppksMenuDur","357px");
break;
case "ppksDur6":
this.toggleSelection(this.menuItems.dur,_2a);
this.quote.duration="Up to 6 months";
this.plus.duration="7DUV";
this.calc.duration="6";
this.showResult();
break;
case "ppksDur12":
this.toggleSelection(this.menuItems.dur,_2a);
this.quote.duration="Up to 1 year";
this.plus.duration="7DUW";
this.calc.duration="12";
this.showResult();
break;
case "ppksDur36":
this.toggleSelection(this.menuItems.dur,_2a);
this.quote.duration="Up to 3 years";
this.plus.duration="7DUY";
this.calc.duration="36";
this.showResult();
break;
case "ppksDur60":
this.toggleSelection(this.menuItems.dur,_2a);
this.quote.duration="Up to 5 years";
this.plus.duration="7DUZ";
this.calc.duration="60";
this.showResult();
break;
case "ppksDur120":
this.toggleSelection(this.menuItems.dur,_2a);
this.quote.duration="Up to 10 years";
this.plus.duration="7DUQ";
this.calc.duration="120";
this.showResult();
break;
case "ppksCovPriceLocal":
this.toggleSelection(this.menuItems.covPrice,_2a);
this.quote.coverage="Local Coverage";
this.calc.coverage="local";
this.showResult();
break;
case "ppksCovPriceRgnl":
this.toggleSelection(this.menuItems.covPrice,_2a);
this.quote.coverage="Regional Coverage";
this.calc.coverage="regional";
this.showResult();
break;
case "ppksCovPriceNatl":
this.toggleSelection(this.menuItems.covPrice,_2a);
this.quote.coverage="National Coverage";
this.calc.coverage="national";
this.showResult();
break;
case "ppksCovPriceContl":
this.toggleSelection(this.menuItems.covPrice,_2a);
this.quote.coverage="Continental Coverage";
this.calc.coverage="continental";
this.showResult();
break;
case "ppksCovPriceWorld":
this.toggleSelection(this.menuItems.covPrice,_2a);
this.quote.coverage="Worldwide Coverage";
this.calc.coverage="world";
this.showResult();
break;
default:
alert("Program error: unidentified menu selection ("+_2a+")");
break;
}
}
},addToCart:function(){
  if ( addToCart ) addToCart();
},reviewUsage:function(){
this.showMenuHeader("ppksMenuInitial");
document.getElementById("ppksResult").style.display="none";
document.getElementById("ppksMenus").style.display="block";
},0:0};
