var gSEL=new Array(
new Array("streamblasterpro","3-1","StreamBlaster Pro","","3-10030-CD",0,29,25,50),
new Array("streamblasterlive","3-2","StreamBlaster Live","","3-20030-CD,3-28030-UP",10,29,25,50),
new Array("streamblasteraddon","3-5","StreamBlaster AddOn","","3-55030-CD",0,0,0,0),
new Array("abilityenterprise","2-2","Ability Enterprise","","2-20030-CD,2-28030-UP",5,29,25,50),
new Array("abilityonline","2-3","Ability Online","2-52030-CD","2-30030-CD,2-38030-UP",5,0,0,0),
new Array("abilityplus","2-4","Ability Plus","2-55030-CD,2-53030-CD,2-54030-CD,2-52030-CD,2-53030-CD,2-54030-CD","2-40030-CD,2-38030-UP",5,0,0,0),
new Array("abilityaddon","2-5","Ability AddOns","","",0,0,0,0),
new Array("phonecasteronline","4-3","PhoneCaster Online","","4-30027-CD,4-38027-UP",5,29,25,50),
new Array("webocasterenterprise","1-2","Webocaster Enterprise","","1-20026-CD",5,29,25,50),
new Array("webocasteronline","1-3","Webocaster Online","","1-30027-CD",5,29,25,50),
new Array("webocasteraddon","1-5","Webocaster AddOns","","",0,0,0,0));

var gPR=new Array(
new Array('3-10030-CD','Single desktop computer license',1,1045,749,6990),
new Array('3-18030-UP','Upgrade Program, yearly fee',1,207,149,1390),
new Array('3-10430-CD','Multilicense for 25 computers',25,10875,7920,72845),
new Array('3-18430-UP','Multilicense Upgrade Program, per year',25,2165,1590,14499),
new Array('3-15330-CD','Bulk package OEM  10 CDs',10,10430,7490,69900),
new Array('3-15430-CD','Bulk package OEM  25 CDs',25,26085,18725,174750),
new Array('3-15530-CD','Bulk package OEM  100 CDs',100,104328,74900,699000),

new Array('3-20030-CD','StreamBlaster Live, single computer',1,3260,2375,21850),
new Array('3-28030-UP','Upgrade Program, yearly fee',1,650,475,4375),
new Array('3-20230-CD','StreamBlaster Live, 2 computers',2,5710,4150,38250),

new Array('3-55030-CD','StreamBlaster eLearning Manager',1,970,715,6499),

new Array('2-20030-CD','Ability Server, 3 accounts',3,7295,5450,48850),
new Array('2-28030-UP','Upgrade Program, yearly fee',1,1740,1295,11675),
new Array('2-21000-EM','Additional license pack, 1 account',1,680,499,4550),
new Array('2-21001-EM','License pack 5 accounts',5,2975,2175,19950),

new Array('2-30030-CD','Ability Online Server, 10 accounts',10,10850,8100,72950),
new Array('2-38030-UP','Upgrade Program, yearly fee',1,1740,1295,11675),
new Array('2-31003-EM','License pack 10 accounts',10,2975,2215,19950),
new Array('2-31004-EM','License pack 25 accounts',25,5940,4425,39800),
new Array('2-31005-EM','License pack 100 accounts',100,19100,14675,128000),

new Array('2-55030-CD','Ability Encoder Manager',1,1490,1100,9975),
new Array('2-53030-CD','Ability Load Distributor',1,5375,3995,35770),
new Array('2-54030-CD','Ability Performance Analyzer',1,1490,1100,9975),
new Array('2-52030-CD','Ability Report Database',1,2175,1625,14550),
new Array('2-53030-CD','Ability Flash Slides',1,925,695,6199),


new Array('2-40030-CD','Ability Plus Server, 10 accounts',10,19375,14125,129900),
new Array('2-48030-UP','Upgrade Program, yearly fee',1,3270,2395,21899),
new Array('2-41000-EM','Additional license pack, 1 account',1,675,499,4550),
new Array('2-41001-EM','License pack 5 accounts',5,2975,2175,19950),

new Array('4-30027-CD','PhoneCaster Server, 10 accounts',10,5225,3825,35000),
new Array('4-38027-UP','Upgrade Program, yearly fee',1,1300,945,8750),
new Array('4-31003-EM','License pack 10 accounts',10,2165,1575,14500),
new Array('4-31004-EM','License pack 25 accounts',25,4325,3150,28990),

new Array('1-20026-CD','Enterprise Server, 3 accounts',3,5950,4435,39950),
new Array('1-28026-UP','Upgrade Program, yearly fee',1,870,640,5835),

new Array('1-30027-CD','Online Server, 10 accounts',10,9400,6890,63000),
new Array('1-38027-UP','Upgrade Program, yearly fee',1,870,640,5835),
new Array('1-31003-EM','License pack 10 accounts',10,2165,1575,14500),
new Array('1-31004-EM','License pack 25 accounts',25,4325,3150,28990),
new Array('1-31005-EM','License pack 100 accounts',100,9700,6995,64990),

new Array('1-52027-CD','Webocaster Reports',1,2175,1585,14550));

function startswith(q_a,q_b){
return (q_a.substr(0,q_b.length)==q_b);
}//end function

function getFamilyrow(familyid,gSEL){
for(var ix=0;ix<gSEL.length;ix++){
if(gSEL[ix][0]==familyid){
	return ix;
}//end if
}//next
return -1;
}//end function

function html_pricing(listname,gSEL,gPR,filter){
var html="";
var iy=getFamilyrow(listname,gSEL);
if(iy==-1){
	html="No product family has been selected"
}else{
	var category=gSEL[iy][1];
	var addoncategory=category.substr(0,2)+"5";
	var headingstyle="background-color:#C0C0E0; font-weight:bold; font-family:Tahoma,Arial,Verdana; font-size:18; height:20px; padding:5 5 5 5;";
	if(listname.indexOf("addon")==-1){
	html=html+getPriceList(listname,category,gSEL[iy][2]+" Base Software",gCurrency,gCurrencysymbol,headingstyle,gSEL,gPR,filter);
	html=html+"<br><br>";
	}//end if
	html=html+getPriceList(listname,addoncategory,"Addon Modules",gCurrency,gCurrencysymbol,headingstyle,gSEL,gPR,filter);
}//end if
return html;
}//end function

function getPriceList(familyid,category,heading,currency,cursymbol,headstyle,gSEL,gPR,filter){
var iy=getFamilyrow(familyid,gSEL);
if(iy==-1){
return "No product family selected."
}else{
//	var category=gSEL[iy][1];
//	var heading=gSEL[iy][2];
	var required=gSEL[iy][3]+",";
	var defaults=gSEL[iy][4]+","+filter+",";
	var rq="";
	var ch="";
	var html="";
	html=html+"<table class='cbody' width=100% cellpadding=0 cellspacing=0 border=0>";
	html=html+"<tr style='"+headstyle+"'>";
	html=html+"<td colspan=3>"+heading+"</td>";
	html=html+"</tr>";
	for(var ix=0;ix<gPR.length;ix++){
	//if(filter==""||(filter+",").indexOf(gPR[ix][0]+",")>-1){
	if(startswith(gPR[ix][0],category)){
		html=html+"<tr>";
		ch=required.indexOf(gPR[ix][0])>-1?"checked disabled ":"";
		rq=defaults.indexOf(gPR[ix][0])>-1?"checked ":"";
		if(isAddon(gPR[ix][0])&&(ch!="")){
			pr="included";
			html=html+"<td><input type='checkbox' id='included' name='included' "+ch+rq+"  value='"+gPR[ix][0]+"' onclick='myrecalc()' onchange='myrecalc()'></td>";
		}else{
			pr=cursymbol+Math.floor(gPR[ix][3+currency]*gFactor+0.5);
			html=html+"<td><input type='checkbox' id='conf' name='conf' "+ch+rq+"  value='"+gPR[ix][0]+"' onclick='myrecalc()' onchange='myrecalc()'></td>";
		}//end if
		html=html+"<td>"+gPR[ix][1]+"</td>";
		html=html+"<td align='right'>[&nbsp;"+pr+"&nbsp;]</td>";
		html=html+"</tr>";
	}//end if
	//}//end if
	}//next
	html=html+"</table>";
	return html;
}//end if
}//end function

function html_order(listname,gSEL,gPR,filter,headingstyle,discount,price,gFactor){
var html="";
var iy=getFamilyrow(listname,gSEL);
if(iy==-1){
	html="No product family has been selected"
}else{
	var category=gSEL[iy][1];
	var shipping=gSEL[iy][6+gCurrency];
	var addoncategory=category.substr(0,2)+"5";
	html=html+"<table class='cbody' width=100% cellpadding=0 cellspacing=0 border=0>";
	if(listname.indexOf("addon")==-1){
	html=html+getOrderlist(listname,category,gSEL[iy][2]+" Base Software",gCurrency,gCurrencysymbol,headingstyle,gSEL,gPR,filter);
	html=html+"<br><br>";
	}//end if
	html=html+getOrderlist(listname,addoncategory,"Addon Modules",gCurrency,gCurrencysymbol,headingstyle,gSEL,gPR,filter);
	thesum=getSelectedsum(gCurrency,gFactor,gPR);
	html=html+getDiscountrow(headingstyle,"Total",gCurrency,gCurrencysymbol,discount,thesum,gFactor,gPR,shipping);
	html=html+"</table>";
}//end if
return html;
}//end function

function getDiscountrow(headstyle,heading,currency,cursymbol,discount,price,gFactor,gPR,shipping){
var html="";
	html=html+"<tr style='"+headstyle+"'>";
	html=html+"<td colspan=2>"+heading+"</td>";
	html=html+"</tr>";
	html=html+"<tr>";
	html=html+"<td><li>Net total</td>";
	html=html+"<td align='right'>"+cursymbol+getSelectedsum(currency,gFactor,gPR)+"</td>";
	html=html+"</tr>";
	if(discount>0){
	html=html+"<tr>";
	html=html+"<td><li>Discount "+discount+"%</td>";
	html=html+"<td style='color:#800000;' align='right'>-&nbsp;"+cursymbol+Math.floor(price*discount/100)+"</td>";
	html=html+"</tr>";
	}//end if
	html=html+"<tr>";
	html=html+"<td><li>Shipping and handling</td>";
	if(shipping>0){
	html=html+"<td align='right'>"+cursymbol+shipping+"</td>";
	}else{
	html=html+"<td align='right'>"+cursymbol+"FREE</td>";
	}//end if
	html=html+"</tr>";
	html=html+"<tr>";
	html=html+"<td><li><b>Your price</b></td>";
	html=html+"<td align='right'><b>"+cursymbol+Math.floor(shipping+price*((100-discount)/100))+"</b></td>";
	html=html+"</tr>";
return html;
}//end function

function getOrderlist(familyid,category,heading,currency,cursymbol,headstyle,gSEL,gPR,filter){
var iy=getFamilyrow(familyid,gSEL);
if(iy==-1){
return "No product family selected."
}else{
	var html="";
	var required=gSEL[iy][3]+",";
	var defaults=gSEL[iy][4]+",";
	var rq="";
	var ch="";
	var norows=true;
	html=html+"<tr style='"+headstyle+"'>";
	html=html+"<td colspan=2>"+heading+"</td>";
	html=html+"</tr>";
	for(var ix=0;ix<gPR.length;ix++){
	if(filter.indexOf(gPR[ix][0]+",")>-1){
	if(startswith(gPR[ix][0],category)){
		var norows=false;
		html=html+"<tr>";
		ch=required.indexOf(gPR[ix][0])>-1?"checked disabled ":"";
		rq=defaults.indexOf(gPR[ix][0])>-1?"checked ":"";
		if(isAddon(gPR[ix][0])&&(ch!="")){
			pr="included";
		}else{
			pr=cursymbol+Math.floor(gPR[ix][3+currency]*gFactor+0.5);
		}//end if
		html=html+"<td><li>"+gPR[ix][1]+"<input type='hidden' name='iartno' value='"+gPR[ix][0]+"'></td>";
		html=html+"<td align='right'>"+pr+"<input type='hidden' name='iprice' value='"+Math.floor(gPR[ix][3+currency]*gFactor+0.5)+"'></td>";
		html=html+"</tr>";
	}//end if
	}//end if
	}//next
	if(norows){
		return "";
	}else{
		return html;
	}//end if
}//end if
}//end function

function mySetname(listname,gSEL){
iy=getFamilyrow(listname,gSEL);
if(iy>-1){
document.getElementById("apptitle").innerText=gSEL[iy][2];
document.getElementById("apptitle2").innerText=gSEL[iy][2];
}//end if
}//end function

function setDiscount(listname,gSEL){
iy=getFamilyrow(listname,gSEL);
if(iy>-1){
return gSEL[iy][5];
}else{
return 0;
}//end if
}//end function

function getSelectedsum(currency,gFactor,gPR){
var sum=0;
var alist="";
if(document.form1.conf){
	alist=getValuelist(document.form1.conf)+",";
}else if(request_querystring("conf")>""){
	alist=request_querystring("conf")+",";
}else if(request_querystring("iartno")>""){
	alist=request_querystring("iartno")+",";
}//end if
if(alist>""){
	for(var ix=0;ix<gPR.length;ix++){
	if(alist.indexOf(gPR[ix][0]+",")>-1){
		sum=sum+Math.floor(gPR[ix][3+currency]*gFactor+0.5);
	}//end if
	}//next
}//end if
return sum;
}//end function

function getValuelist(zconf){
var aval="";
var sep="";
if(zconf){
if(zconf.length){
for(var ix=0;ix<zconf.length;ix++){
if(zconf[ix].checked){
		if(isAddon(zconf[ix].value)&&(zconf[ix].disabled)){
		}else{
		aval=aval+sep+zconf[ix].value;
		}//end if
	sep=","; 
}//end if
}//next
}else{
aval=aval+sep+zconf.value
}//end if
}//end if
return aval;
}//end function

function isAddon(aval){
return (aval.substr(1,2)=="-5");
}//end function

function inf(what){
var output = '';
for (var i in what)output += i+ ', ';
return(output);
}//end function

