/*# prices-formatting.js #*/
function format_currency(amount, pattern, ignore_decimal) {
amount = parseFloat(amount);
if (isNaN(amount)) {
amount = 0;
}
var re = /^([^\d\s]*?)(\s*)(\d+)([^\d]*)(\d+)([^\d]*).*?(\d+)(([^\d]+)(\d+))?(\s*)([^\d\s]*)$/;
var formatted = '';
var matches = pattern.match(re);
if (matches) {
/*detecting parameters*/
var currency_symbol = matches[1] ? matches[1] : matches[12];
var currency_symbol_position = matches[1] ? 'before' : 'after';
var currency_space = matches[1] ? !!(matches[2].length) : !!(matches[11].length);
var decimal_symbol = matches[9];
var digits_after_decimal = typeof matches[10] === 'undefined' ? 0 : matches[10].length;
var digit_grouping_symbol = matches[4];
var digit_grouping_type;
if (matches[3].length !== matches[5].length) {
digit_grouping_type = matches[3].length > 3 ? 3 : 1;
} else {
digit_grouping_type = 2;
}
/*formatting*/
var i, l;
formatted = String(Math.floor(amount));
if (digit_grouping_type === 1) {
var pre_formatted = formatted;
var groups_count = Math.ceil(formatted.length / 3);
formatted = '';
for (i = 1; i <= groups_count - 1; i++) {
formatted = digit_grouping_symbol + pre_formatted.substr(pre_formatted.length - 3 * i, 3) + formatted;
}
if (pre_formatted.length > (groups_count - 1) * 3) {
formatted = pre_formatted.substr(0, pre_formatted.length - (groups_count - 1) * 3) + formatted;
}
} else {
/*TODO: make here logic #2;*/
}
if (!ignore_decimal && digits_after_decimal > 0) {
var decimal = String(amount).replace(/^\d+[^\d]*/, '');
if (decimal.length > digits_after_decimal) {
decimal = String(Math.round(parseFloat(decimal) / Math.pow(10, decimal.length - digits_after_decimal)));
}
for (i = 0, l = digits_after_decimal - decimal.length; i < l; i++) {
decimal += '0';
}
formatted = formatted + decimal_symbol + decimal;
}
if (currency_symbol_position == 'before') {
formatted = currency_symbol + (currency_space ? ' ' : '') + formatted;
} else {
formatted = formatted + (currency_space ? ' ' : '') + currency_symbol;
}
}
return formatted;
}
var xml2json = function(xmlString) {
var doc;
if (document.implementation.createDocument) {
var parser = new DOMParser();
doc = parser.parseFromString(xmlString, 'text/xml');
}
else if (window.ActiveXObject) {
doc = new ActiveXObject('Microsoft.XMLDOM');
doc.async = 'false';
doc.loadXML(xmlString);
}
else {
return false;
}
function getChildren(el) {
var children = {}, i, child = el.firstChild;
while (child) {
if (child.nodeType === 1) {
if ('undefined' == typeof children[child.nodeName]) {
children[child.nodeName] = [];
}
children[child.nodeName].push(getChildren(child));
}
else if (child.nodeType === 3) {
if ('undefined' == typeof children['#text']) {
children['#text'] = [];
}
var text = child.nodeValue.replace(/(^[\s\r\n]+)|([\s\r\n]+$)/g, '');
if (text.length) {
children['#text'].push(text);
}
}
child = child.nextSibling;
}
for (i = 0; i < el.attributes.length; i++) {
// children['@' + el.attributes[i].name] = el.attributes[i].value;
children[el.attributes[i].name] = el.attributes[i].value;
}
return children;
}
var child = doc.firstChild;
//exclude <?xml
if (child.nodeType === 7) {
child = child.nextSibling;
}
var r = getChildren(child);
return r;
};
var WizardControl = function(Wizard, data) {
this.setData(data);
this.Wizard = Wizard;
};
WizardControl.prototype = {
drawSingle: function(callback, selectedValue) {
var i,
k,
parameters,
values,
name,
value,
li,
label;
parameters = this.data.param || [];
this.container = window.document.getElementById('radio');
// this.container.className = 'radio';
this.container.innerHTML = '';
for (i = 0; i < parameters.length; i++) {
values = parameters[i].value || [];
for (k = 0; k < values.length; k++) {
name = parameters[i].name;
value = k;
label = document.createElement('label');
if (k % 2) {
label.className = 'r';
}
input = document.createElement('input');
input.type = 'radio';
input.name = 'radio';
label.innerHTML = '<span class="corner-tl"></span><span class="corner-tr"></span><span class="corner-bl"></span><span class="corner-br"></span>';
label.insertBefore(document.createTextNode(values[k]['#text'][0]), label.firstChild);
label.insertBefore(input, label.firstChild);
this.container.appendChild(label);
if ('undefined' !== typeof selectedValue) {
selectedValue.forEach(function(el) {
if (el === k) {
input.checked = true;
callback(name, value);
}
});
} else if (values[k]['default'] && values[k]['default'] === 'yes') {
input.checked = true;
callback(name, value);
}
JSLib.Event.addListener(label, 'click',
function(name, value) {
return function(e, el) {
el.checked = true;
Sizzle('input',el.parentNode).forEach(function(el_input) {el_input.checked = false;});
Sizzle('input',el)[0].checked = true;
callback(name, value);
};
} (name, value));
}
}
},
drawMultiple: function(callback, selectedValue) {
var i,
k,
parameters,
values,
name,
value,
li,
label;
parameters = this.data.param || [];
this.container = window.document.getElementById('radio');
// this.container.className = 'radio';
this.container.innerHTML = '';
for (i = 0; i < parameters.length; i++) {
values = parameters[i].value || [];
for (k = 0; k < values.length; k++) {
name = parameters[i].name;
value = k;
label = document.createElement('label');
if (k % 2) {
label.className = 'r';
}
input = document.createElement('input');
input.type = 'checkbox';
input.name = 'checkbox';
label.innerHTML = '<span class="corner-tl"></span><span class="corner-tr"></span><span class="corner-bl"></span><span class="corner-br"></span>';
label.insertBefore(document.createTextNode(values[k]['#text'][0]), label.firstChild);
label.insertBefore(input, label.firstChild);
this.container.appendChild(label);
if ('undefined' !== typeof selectedValue) {
selectedValue.forEach(function(el) {
if (el === k) {
input.checked = true;
callback(name, value, input.checked);
}
});
} else if (values[k]['default'] && values[k]['default'] === 'yes') {
input.checked = true;
callback(name, value);
}
JSLib.Event.addListener(input, 'click',
function(name, value) {
return function(e, el) {
// el.checked = true;
callback(name, value, el.checked);
};
} (name, value));
}
}
},
setData: function(data) {
this.data = data;
}
};
var WizardUI = function(el) {
this.el = el;
JSLib.Event.addListener('more-info', 'click',
function(e, el) {
window.opener.document.location.href = el.href;
window.opener.focus();
e.stop();
});
JSLib.Event.addListener('download-trial', 'click',
function(e, el) {
window.opener.document.location.href = el.href;
window.opener.focus();
e.stop();
});
JSLib.Event.addListener('prev', 'mouseover',
function(e, el) {
JSLib.CSS.addClass(el, 'over');
},
this);
JSLib.Event.addListener('prev', 'mouseout',
function(e, el) {
JSLib.CSS.removeClass(el, 'over');
},
this);
JSLib.Event.addListener('next', 'mouseover',
function(e, el) {
JSLib.CSS.addClass(el, 'over');
},
this);
JSLib.Event.addListener('next', 'mouseout',
function(e, el) {
JSLib.CSS.removeClass(el, 'over');
},
this);
};
WizardUI.prototype = {
setTitle: function(title) {
var el = document.getElementById('title');
el.innerHTML = title;
if (title.length) {
JSLib.CSS.removeClass(this.el, 'notitle');
} else {
JSLib.CSS.addClass(this.el, 'notitle');
}
return el;
},
updateNavigation: function(prev, next) {
if (next) {
JSLib.CSS.addClass(this.el, 'next');
} else {
JSLib.CSS.removeClass(this.el, 'next');
}
if (prev) {
JSLib.CSS.addClass(this.el, 'prev');
} else {
JSLib.CSS.removeClass(this.el, 'prev');
}
}
};
var Wizard = function(el) {
this.el = JSLib.util.getEl(el);
this.UI = new WizardUI(this.el);
JSLib.Event.addListener(Sizzle('#single #addon-deduplication input')[0], 'change', this.recalculatePrice, this);
JSLib.Event.addListener(Sizzle('#single #addon-aur')[0], 'change', this.recalculatePrice, this);
JSLib.Event.addListener(Sizzle('#single #addon-aud')[0], 'change', this.recalculatePrice, this);
JSLib.Event.addListener(Sizzle('#single #addon-dedup')[0], 'change', this.recalculatePrice, this);
JSLib.Event.addListener(Sizzle('#single #addon-pp')[0], 'change', this.recalculatePrice, this);
JSLib.Event.addListener(Sizzle('#single #addon-deduplication input')[0], 'click', this.recalculatePrice, this);
JSLib.Event.addListener(Sizzle('#single #addon-aur input')[0], 'click', this.recalculatePrice, this);
JSLib.Event.addListener(Sizzle('#single #addon-aud input')[0], 'click', this.recalculatePrice, this);
JSLib.Event.addListener(Sizzle('#single #addon-dedup input')[0], 'click', this.recalculatePrice, this);
JSLib.Event.addListener(Sizzle('#single #addon-pp input')[0], 'click', this.recalculatePrice, this);
this.data = false;
this.structure = false;
};
Wizard.prototype = {
chain: [],
currentStep: false,
loadData: function(url_data, url_structure) {
/*JSLib.Event.addListener('prev', 'click', this.goPrev, this);*/
JSLib.Event.addListener('nextstep', 'click', this.goNext, this);
var xhr_data = new JSLib.XHR(url_data, '', 'GET',
function(r) {
var data = xml2json(r.responseText);
var steps = {};
for (var i = 0; i < data.step.length; i++) {
var id = data.step[i].id;
steps[id] = data.step[i];
steps[id].param = data.step[i].param || [];
steps[id].UI = new WizardControl(this, data.step[i]);
}
var xhr_structure = new JSLib.XHR(url_structure, '', 'GET',
function(r) {
this.structure = (function(data, parent, index) {
var r = [],
caller = arguments.callee;
data.forEach(function(el) {
r.push({
"condition": el.condition,
"id": el.id,
"selectedValue": [],
"info": (typeof steps[el.id] !== 'undefined') ? steps[el.id] : false,
"parent": parent,
"index": index
});
r[r.length - 1].steps = el.step ? caller(el.step, r[r.length - 1], index + 1) : false;
},
this);
return r;
}.createDelegate(this))([xml2json(r.responseText)], false, 0);
this.goNext();
}.createDelegate(this));
xhr_structure.request();
}.createDelegate(this));
xhr_data.request();
},
findStep: function() {
if (this.currentStep) {
if (this.currentStep.steps === false) {
return false;
}
var condition = '';
for (var i = 0, l = this.currentStep.steps[0].condition.length; i < l; i++) {
condition += (this.currentStep.selectedValue && this.currentStep.selectedValue.indexOf(i) !== -1) ? '1': '0';
}
var step = false;
this.currentStep.steps.forEach(function(el, i) {
if (el.condition === condition) {
step = el;
}
});
return step;
}
if (this.structure.length) {
return this.structure[this.structure.length - 1];
}
return false;
},
goPrev: function(parent) {
if (!this.currentStep || this.currentStep.parent === false) {
return false;
}
this.currentStep.stepElement.parentNode.removeChild(this.currentStep.stepElement);
delete this.currentStep.stepElement;
var step = this.currentStep.parent;
/* last step and current steps titles*/
if (typeof this.CurrentStepLi == 'undefined' ) {
this.CurrentStepLi= document.createElement('li');
document.getElementById('steps').getElementsByTagName('ul')[0].appendChild(this.CurrentStepLi);
}
this.CurrentStepLi.innerHTML = '步驟 ' + (this.currentStep.index);
/* --- */
if (step) {
//custom handler call
if (this.currentStep.info.handler && this.currentStep.info.handler.length) {
var handler_name = this.currentStep.info.handler[0].name;
if (this[handler_name]) {
this[handler_name](this.make_parameters(this.currentStep.info.handler[0]), 'back');
}
}
this.currentStep = step;
if (typeof parent !== 'undefined' && this.currentStep !== parent) {
this.goPrev(parent);
} else {
this.currentStep.info.UI.data = this.currentStep.info;
this.UI.setTitle(this.currentStep.info.title ? this.currentStep.info.title: '');
var type = (this.currentStep.info.type.length) ? this.currentStep.info.type[0]['#text'][0] : 'single';
var method = 'draw' + type.substr(0, 1).toUpperCase() + type.substr(1);
this.currentStep.info.UI[method](this.setValue.createDelegate(this), this.currentStep.selectedValue);
}
}
},
goNext: function() {
if (!this.canGoNext()) {
return;
}
var step = this.findStep();
if (step) {
if (this.currentStep && this.currentStep.info.handler && this.currentStep.info.handler.length) {
var handler_name = this.currentStep.info.handler[0].name;
if (this[handler_name]) {
//todo: pass here all found parameters
this[handler_name](make_parameters(this.currentStep.info.handler[0]), 'back');
}
}
this.currentStep = step;
this.currentStep.info.UI.data = this.currentStep.info;
this.UI.setTitle(this.currentStep.info.title ? this.currentStep.info.title: '');
//custom handler call
if (this.currentStep.info.handler && this.currentStep.info.handler.length) {
var handler_name = this.currentStep.info.handler[0].name;
if (this[handler_name]) {
//todo: pass here all found parameters
this[handler_name](this.make_parameters(this.currentStep.info.handler[0]));
}
}
if (typeof this.currentStep.info.type !== 'undefined') {
var type = (this.currentStep.info.type.length) ? this.currentStep.info.type[0]['#text'][0] : 'single';
var method = 'draw' + type.substr(0, 1).toUpperCase() + type.substr(1);
this.currentStep.info.UI[method](this.setValue.createDelegate(this), this.currentStep.selectedValue);
}
this.UI.updateNavigation(this.canGoPrev(), this.canGoNext());
/* last step and current steps titles*/
if (typeof this.CurrentStepLi == 'undefined' ) {
this.CurrentStepLi= document.createElement('li');
document.getElementById('steps').getElementsByTagName('ul')[0].appendChild(this.CurrentStepLi);
}
this.CurrentStepLi.innerHTML = '步驟 ' + (this.currentStep.index + 1);
if (JSLib.CSS.hasClass(Sizzle('#psg')[0], 'last')) { this.CurrentStepLi.innerHTML = '結果'}
/* --- */
if (this.currentStep.parent) {
var li = document.createElement('li');
var a = document.createElement('a');
a.href = '#';
a.innerHTML = '步驟 ' + (this.currentStep.parent.index + 1);
li.appendChild(a);
document.getElementById('steps').getElementsByTagName('ul')[0].insertBefore(li, document.getElementById('nextstep'));
this.currentStep.stepElement = li;
JSLib.Event.addListener(a, 'click', (function(parent) {
return function(e) {
this.goPrev(parent);
e.stop();
}.createDelegate(this);
}.createDelegate(this))(this.currentStep.parent));
}
}
},
make_parameters: function(parameters) {
var r = {};
if (parameters['name'] == 'getProductInfo') {
for (var i in parameters) {
if (parameters.hasOwnProperty(i) && i !== 'name' && i !== '#text' && typeof parameters[i] === 'object') {
if (typeof parameters[i][0]['#text'] === 'undefined') parameters[i][0]['#text'] = [];
r[i] = parameters[i][0]['#text'][0];
}
}
} else {
for (var n in parameters) {
if (n !== 'name' && n !== '#text' && typeof parameters[n] === 'object') {
for (var i in parameters[n]) {
r[i] = {};
for (var k in parameters[n][i]) {
if (parameters[n][i].hasOwnProperty(k) && k !== 'name' && k !== '#text' && typeof parameters[n][i][k] === 'object') {
if (typeof parameters[n][i][k][0]['#text'] === 'undefined') parameters[n][i][k][0]['#text'] = [];
r[i][k] = parameters[n][i][k][0]['#text'][0];
}
}
}
}
}
}
return r;
},
canGoPrev: function() {
return this.currentStep && this.currentStep.parent;
},
canGoNext: function() {
var step = this.findStep();
if (!step) {
return false;
}
if (this.currentStep === false) {
return true;
} else if (this.currentStep.id === step.id) {
//last step?
return false;
}
return !! true
//this.currentStep.selectedValue.length;
},
setValue: function(name, value, status) {
if (this.currentStep.info.type[0]['#text'][0] !== 'multiple') {
this.currentStep.selectedValue = [value];
} else {
var pos = this.currentStep.selectedValue.indexOf(value);
if (pos === -1 && status) {
this.currentStep.selectedValue.push(value);
} else if (!status) {
this.currentStep.selectedValue.splice(pos, 1);
}
}
this.UI.updateNavigation(this.canGoPrev(), this.canGoNext());
},
plain: function(properties, direction) {
if (direction && direction == 'back') {
JSLib.CSS.removeClass(this.el, 'last');
JSLib.CSS.removeClass(this.el, 'loading');
JSLib.CSS.removeClass(this.el, 'sorry');
// var body = document.getByClassName('body', 'div', this.el);
// body[0].style.backgroundImage = '';
} else {
JSLib.CSS.addClass(this.el, 'sorry');
JSLib.CSS.addClass(this.el, 'last');
// document.getElementById('description').getElementsByTagName('p')[0].innerHTML = properties.text;
}
},
recalculatePrice: function() {
var aur = JSLib.CSS.hasClass(Sizzle('#single')[0], 'aur') && Sizzle('#addon-aur input')[0].checked,
dedup = JSLib.CSS.hasClass(Sizzle('#single')[0], 'dedup') && Sizzle('#addon-deduplication input')[0].checked,
price = parseFloat(this.properties['price'], 10),
price_original = parseFloat(this.properties['price'], 10),
aur_price = this.properties['price-aur-original'],
dedup_price = this.properties['price-dedup-original'];
if (aur && dedup) {
aur_price = parseFloat(this.properties['price-aur-with-dedup'], 10);
// dedup_price = parseFloat(this.properties['price-dedup-with-aur'], 10);
price = aur_price;
Sizzle('#include-universal-restore')[0].innerHTML = (aur ? ('<span style="float: none; text-decoration: line-through;">' + this.properties['price-aur-original'] + '</span> ') : '') + format_currency(aur_price-price_original-dedup_price, this.properties['currency'], true);
Sizzle('#include-deduplication')[0].innerHTML = format_currency(dedup_price, this.properties['currency'], true);
//+ dedup_price; //Using only one because this two prices are equal for now
} else if (aur) {
aur_price = parseFloat(this.properties['price-aur'], 10);
price = aur_price;
Sizzle('#include-universal-restore')[0].innerHTML = (aur ? ('<span style="float: none; text-decoration: line-through;">' + this.properties['price-aur-original'] + '</span> ') : '') + format_currency(aur_price-price_original, this.properties['currency'], true);
} else if (dedup) {
price = parseFloat(this.properties['price-dedup'], 10);
Sizzle('#include-universal-restore')[0].innerHTML = format_currency(aur_price, this.properties['currency'], true);
Sizzle('#include-deduplication')[0].innerHTML = format_currency(dedup_price, this.properties['currency'], true);
} else {
Sizzle('#include-deduplication')[0].innerHTML = (dedup ? ('<span style="float: none; text-decoration: line-through;">' + this.properties['price-dedup-original'] + '</span> ') : '') + format_currency(dedup_price, this.properties['currency'], true);
Sizzle('#include-universal-restore')[0].innerHTML = (aur ? ('<span style="float: none; text-decoration: line-through;">' + this.properties['price-aur-original'] + '</span> ') : '') + format_currency(aur_price, this.properties['currency'], true);
}
var aud = JSLib.CSS.hasClass(Sizzle('#single')[0], 'aud') && Sizzle('#addon-aud input')[0].checked,
aud_price = this.properties['price-aud-original'];
if (aud) {
price = parseFloat(this.properties['price-aud'], 10);
}
var pp = JSLib.CSS.hasClass(Sizzle('#single')[0], 'pp') && Sizzle('#addon-pp input')[0].checked,
pp_price = this.properties['price-pp-original'];
if (pp) {
price= parseFloat(this.properties['price-pp'], 10);
}
Sizzle('#include-universal-deploy')[0].innerHTML = format_currency(aud_price, this.properties['currency'], false);
Sizzle('#include-power-pack')[0].innerHTML = format_currency(pp_price, this.properties['currency'], false);
Sizzle('#total-price')[0].innerHTML = format_currency(price, this.properties['currency'], false);
Sizzle('.buybutton ')[0].href = this.properties['url-buy' + (dedup ? '-dedup': '') + (aur ? '-aur': '') + (aud ? '-aud': '')+ (pp ? '-pp': '')];
if (!!parseFloat(price) == false) {
var ttlpricecontainer = Sizzle('#total-price')[0].parentNode;
var ttlprice=document.createElement('strong');ttlprice.id="total-price";
ttlpricecontainer.innerHTML = '線&nbsp;上&nbsp;購&nbsp;買';
ttlpricecontainer.appendChild(ttlprice);
}
else {
var ttlpricecontainer = Sizzle('#total-price')[0].parentNode;
var ttlprice=document.createElement('strong');ttlprice.id="total-price";
ttlpricecontainer.innerHTML = '立即購買 ';
ttlpricecontainer.appendChild(ttlprice);
Sizzle('#total-price')[0].innerHTML = format_currency(price, this.properties['currency'], false); 
}
if (!!this.properties['buy_from_sales'] == true) Sizzle('#total-price')[0].innerHTML ='';
},
recalculateAnyPrice: function(priceContainer, productid) {
var aur = JSLib.CSS.hasClass(priceContainer, 'aur') && Sizzle('.addon-aur input', priceContainer)[0].checked,
dedup = JSLib.CSS.hasClass(priceContainer, 'dedup') && Sizzle('.addon-deduplication input', priceContainer)[0].checked,
price = parseFloat(this.properties[productid]['price'], 10),
price_original = parseFloat(this.properties[productid]['price'], 10),
aur_price = this.properties[productid]['price-aur-original'],
dedup_price = this.properties[productid]['price-dedup-original'];
if (aur && dedup) {
aur_price = parseFloat(this.properties[productid]['price-aur-with-dedup'], 10);
// dedup_price = parseFloat(this.properties['price-dedup-with-aur'], 10);
price = aur_price;
Sizzle('.include-deduplication', priceContainer)[0].innerHTML = format_currency(dedup_price, this.properties[productid]['currency'], true);
Sizzle('.include-universal-restore', priceContainer)[0].innerHTML = (aur ? ('<span style="float: none; text-decoration: line-through;">' + this.properties[productid]['price-aur-original'] + '</span> ') : '') + format_currency(aur_price-price_original-dedup_price, this.properties[productid]['currency'], true);
//+ dedup_price; //Using only one because this two prices are equal for now
} else if (aur) {
aur_price = parseFloat(this.properties[productid]['price-aur'], 10);
price = aur_price;
Sizzle('.include-universal-restore', priceContainer)[0].innerHTML = (aur ? ('<span style="float: none; text-decoration: line-through;">' + this.properties[productid]['price-aur-original'] + '</span> ') : '') + format_currency(aur_price-price_original, this.properties[productid]['currency'], true);
} else if (dedup) {
price = parseFloat(this.properties[productid]['price-dedup'], 10);
Sizzle('.include-universal-restore', priceContainer)[0].innerHTML = format_currency(aur_price, this.properties[productid]['currency'], true);
Sizzle('.include-deduplication', priceContainer)[0].innerHTML = format_currency(dedup_price, this.properties[productid]['currency'], true);
}else {
Sizzle('.include-deduplication', priceContainer)[0].innerHTML = (dedup ? ('<span style="float: none; text-decoration: line-through;">' + this.properties[productid]['price-dedup-original'] + '</span> ') : '') + format_currency(dedup_price, this.properties[productid]['currency'], true);
Sizzle('.include-universal-restore', priceContainer)[0].innerHTML = (aur ? ('<span style="float: none; text-decoration: line-through;">' + this.properties[productid]['price-aur-original'] + '</span> ') : '') + format_currency(aur_price, this.properties[productid]['currency'], true);
}
var aud = JSLib.CSS.hasClass(priceContainer, 'aud') && Sizzle('#addon-aud input', priceContainer)[0].checked,
aud_price = this.properties[productid]['price-aud-original'];
if (aud) {
price = parseFloat(this.properties[productid]['price-aud'], 10);
}
var pp = JSLib.CSS.hasClass(priceContainer, 'pp') && Sizzle('.addon-pp input', priceContainer)[0].checked,
pp_price = this.properties[productid]['price-pp-original'];
if (pp) {
price = parseFloat(this.properties[productid]['price-pp'], 10);
}
Sizzle('.include-universal-deploy', priceContainer)[0].innerHTML = format_currency(aud_price, this.properties[productid]['currency'], false);
Sizzle('.include-power-pack', priceContainer)[0].innerHTML = format_currency(pp_price, this.properties[productid]['currency'], false);
Sizzle('.total-price', priceContainer)[0].innerHTML = format_currency(price, this.properties[productid]['currency'], false);
Sizzle('.buybutton ', priceContainer)[0].href = this.properties[productid]['url-buy' + (dedup ? '-dedup': '') + (aur ? '-aur': '') + (aud ? '-aud': '')+ (pp ? '-pp': '')];
if (!!this.properties[productid]['buy_from_sales'] == true) Sizzle('.total-price', priceContainer)[0].innerHTML='';
},
getProductInfo: function(properties, direction) {
JSLib.CSS.removeClass(this.el, 'double');
JSLib.CSS.replaceClass(this.el, 'questions', 'single');
if (direction && direction == 'back') {
JSLib.CSS.removeClass(this.el, 'last');
JSLib.CSS.removeClass(this.el, 'loading');
JSLib.CSS.replaceClass(this.el, 'single', 'questions');
JSLib.CSS.replaceClass(this.el, 'double', 'questions');
// var body = document.getByClassName('body', 'div', this.el);
// body[0].style.backgroundImage = '';
return;
}
this.properties = properties;
JSLib.CSS.addClass(this.el, 'last');
JSLib.CSS.addClass(this.el, 'loading');
JSLib.CSS.removeClass(this.el, 'next');
JSLib.CSS.removeClass(this.el, 'prev');
Sizzle('#single h4')[0].innerHTML = properties['title'];
Sizzle('#psg .buyblock-description p')[0].innerHTML = properties['description'];
Sizzle('#psg .buyblock-image img')[0].src = properties['box-image'];
Sizzle('#single .more')[0].href = properties['url-info'];
Sizzle('#single .download')[0].href = properties['url-trial'];
typeof properties['addons-note'] !== 'undefined' ? Sizzle('#addons-note')[0].innerHTML = properties['addons-note'] : Sizzle('#addons-note')[0].innerHTML = '';;
properties['aur'] === 'true' ? JSLib.CSS.addClass(Sizzle('#single')[0], 'aur') : JSLib.CSS.removeClass(Sizzle('#single')[0], 'aur');
properties['dedup'] === 'true' ? JSLib.CSS.addClass(Sizzle('#single')[0], 'dedup') : JSLib.CSS.removeClass(Sizzle('#single')[0], 'dedup');
properties['aud'] === 'true' ? JSLib.CSS.addClass(Sizzle('#single')[0], 'aud') : JSLib.CSS.removeClass(Sizzle('#single')[0], 'aud');
properties['pp'] === 'true' ? JSLib.CSS.addClass(Sizzle('#single')[0], 'pp') : JSLib.CSS.removeClass(Sizzle('#single')[0], 'pp');
this.recalculatePrice();
properties['aur'] === 'true' ? Sizzle('#addon-aur a')[0].href = properties['url-info']+'universal-restore.html' : false;
properties['aud'] === 'true' ? Sizzle('#addon-aud a')[0].href = properties['url-info']+'universal-deploy.html' : false;
properties['dedup'] === 'true' ? Sizzle('#addon-deduplication a')[0].href = properties['url-info']+'deduplication.html' : false;
properties['pp'] === 'true' ? Sizzle('#addon-addon-pp a')[0].href = properties['url-info']+'plus-pack.html' : false;
},
getDoubleProductInfo: function(properties, direction) {
JSLib.CSS.removeClass(this.el, 'single');
JSLib.CSS.replaceClass(this.el, 'questions', 'double');
if (direction && direction == 'back') {
JSLib.CSS.removeClass(this.el, 'last');
JSLib.CSS.removeClass(this.el, 'loading');
JSLib.CSS.replaceClass(this.el, 'single', 'questions');
JSLib.CSS.replaceClass(this.el, 'double', 'questions');
// var body = document.getByClassName('body', 'div', this.el);
// body[0].style.backgroundImage = '';
return;
}
this.properties = properties;
JSLib.CSS.addClass(this.el, 'last');
JSLib.CSS.addClass(this.el, 'loading');
JSLib.CSS.removeClass(this.el, 'next');
JSLib.CSS.removeClass(this.el, 'prev');
Sizzle('#firstp h4')[0].innerHTML = properties[0]['title'];
Sizzle('#firstp .buyblock-description p')[0].innerHTML = properties[0]['description'];
Sizzle('#firstp .buyblock-image img')[0].src = properties[0]['box-image'];
Sizzle('#firstp .more')[0].href = properties[0]['url-info'];
Sizzle('#firstp .download')[0].href = properties[0]['url-trial'];
typeof properties[0]['addons-note'] !== 'undefined' ? Sizzle('.addons-note')[0].innerHTML = properties[0]['addons-note'] : Sizzle('.addons-note')[0].innerHTML = '';;
properties[0]['aur'] === 'true' ? JSLib.CSS.addClass(Sizzle('#firstp')[0], 'aur') : JSLib.CSS.removeClass(Sizzle('#firstp')[0], 'aur');
properties[0]['dedup'] === 'true' ? JSLib.CSS.addClass(Sizzle('#firstp')[0], 'dedup') : JSLib.CSS.removeClass(Sizzle('#firstp')[0], 'dedup');
properties[0]['aud'] === 'true' ? JSLib.CSS.addClass(Sizzle('#firstp')[0], 'aud') : JSLib.CSS.removeClass(Sizzle('#firstp')[0], 'aud');
properties[0]['pp'] === 'true' ? JSLib.CSS.addClass(Sizzle('#firstp')[0], 'pp') : JSLib.CSS.removeClass(Sizzle('#firstp')[0], 'pp');
Sizzle('#secondp h4')[0].innerHTML = properties[1]['title'];
Sizzle('#secondp .buyblock-description p')[0].innerHTML = properties[1]['description'];
Sizzle('#secondp .buyblock-image img')[0].src = properties[1]['box-image'];
Sizzle('#secondp .more')[0].href = properties[1]['url-info'];
Sizzle('#secondp .download')[0].href = properties[1]['url-trial'];
typeof properties[1]['addons-note'] !== 'undefined' ? Sizzle('#addons-note')[0].innerHTML = properties[1]['addons-note'] : Sizzle('#addons-note')[0].innerHTML = '';;
properties[1]['aur'] === 'true' ? JSLib.CSS.addClass(Sizzle('#secondp')[0], 'aur') : JSLib.CSS.removeClass(Sizzle('#secondp')[0], 'aur');
properties[1]['dedup'] === 'true' ? JSLib.CSS.addClass(Sizzle('#secondp')[0], 'dedup') : JSLib.CSS.removeClass(Sizzle('#secondp')[0], 'dedup');
properties[1]['aud'] === 'true' ? JSLib.CSS.addClass(Sizzle('#secondp')[0], 'aud') : JSLib.CSS.removeClass(Sizzle('#secondp')[0], 'aud');
properties[1]['pp'] === 'true' ? JSLib.CSS.addClass(Sizzle('#secondp')[0], 'pp') : JSLib.CSS.removeClass(Sizzle('#secondp')[0], 'pp');
this.recalculateAnyPrice(Sizzle('#firstp')[0], 0);
this.recalculateAnyPrice(Sizzle('#secondp')[0], 1);
JSLib.Event.addListener(Sizzle('#firstp .addon-aur')[0], 'change', function(){this.recalculateAnyPrice(Sizzle('#firstp')[0],0)}, this);
JSLib.Event.addListener(Sizzle('#firstp .addon-aud')[0], 'change', function(){this.recalculateAnyPrice(Sizzle('#firstp')[0],0)}, this);
JSLib.Event.addListener(Sizzle('#firstp .addon-dedup')[0], 'change', function(){this.recalculateAnyPrice(Sizzle('#firstp')[0],0)}, this);
JSLib.Event.addListener(Sizzle('#firstp .addon-pp')[0], 'change', function(){this.recalculateAnyPrice(Sizzle('#firstp')[0],0)}, this);
JSLib.Event.addListener(Sizzle('#secondp .addon-aur')[0], 'change', function(){this.recalculateAnyPrice(Sizzle('#secondp')[0],1)}, this);
JSLib.Event.addListener(Sizzle('#secondp .addon-aud')[0], 'change', function(){this.recalculateAnyPrice(Sizzle('#secondp')[0],1)}, this);
JSLib.Event.addListener(Sizzle('#secondp .addon-dedup')[0], 'change', function(){this.recalculateAnyPrice(Sizzle('#secondp')[0],1)}, this);
JSLib.Event.addListener(Sizzle('#secondp .addon-pp')[0], 'change', function(){this.recalculateAnyPrice(Sizzle('#secondp')[0],1)}, this);
JSLib.Event.addListener(Sizzle('#firstp .addon-aur input')[0], 'click', function(){this.recalculateAnyPrice(Sizzle('#firstp')[0],0)}, this);
JSLib.Event.addListener(Sizzle('#firstp .addon-aud input')[0], 'click', function(){this.recalculateAnyPrice(Sizzle('#firstp')[0],0)}, this);
JSLib.Event.addListener(Sizzle('#firstp .addon-dedup input')[0], 'click', function(){this.recalculateAnyPrice(Sizzle('#firstp')[0],0)}, this);
JSLib.Event.addListener(Sizzle('#firstp .addon-pp input')[0], 'click', function(){this.recalculateAnyPrice(Sizzle('#firstp')[0],0)}, this);
JSLib.Event.addListener(Sizzle('#secondp .addon-aur input')[0], 'click', function(){this.recalculateAnyPrice(Sizzle('#secondp')[0],1)}, this);
JSLib.Event.addListener(Sizzle('#secondp .addon-aud input')[0], 'click', function(){this.recalculateAnyPrice(Sizzle('#secondp')[0],1)}, this);
JSLib.Event.addListener(Sizzle('#secondp .addon-dedup input')[0], 'click', function(){this.recalculateAnyPrice(Sizzle('#secondp')[0],1)}, this);
JSLib.Event.addListener(Sizzle('#secondp .addon-pp input')[0], 'click', function(){this.recalculateAnyPrice(Sizzle('#secondp')[0],1)}, this);
properties[0]['aur'] === 'true' ? Sizzle('#firstp .addon-aur a')[0].href = properties[0]['url-info']+'universal-restore.html' : false;
properties[0]['aud'] === 'true' ? Sizzle('#firstp .addon-aud a')[0].href = properties[0]['url-info']+'universal-deploy.html' : false;
properties[0]['dedup'] === 'true' ? Sizzle('#firstp .addon-dedup a')[0].href = properties[0]['url-info']+'deduplication.html' : false;
properties[0]['pp'] === 'true' ? Sizzle('#firstp .addon-pp a')[0].href = properties[0]['url-info']+'plus-pack.html' : false;
properties[1]['aur'] === 'true' ? Sizzle('#secondp .addon-aur a')[0].href = properties[1]['url-info']+'universal-restore.html' : false;
properties[1]['aud'] === 'true' ? Sizzle('#secondp .addon-aud a')[0].href = properties[1]['url-info']+'universal-deploy.html' : false;
properties[1]['dedup'] === 'true' ? Sizzle('#secondp .addon-dedup a')[0].href = properties[1]['url-info']+'deduplication.html' : false;
properties[1]['pp'] === 'true' ? Sizzle('#secondp .addon-pp a')[0].href = properties[1]['url-info']+'plus-pack.html' : false;
}
};
if ('undefined' === typeof JSLib) {
window.JSLib = {};
}
if ('undefined' === typeof JSLib.util) {
window.JSLib.util = {};
}
JSLib.XHR = function(url, parms, method, callback) {
this.url = url;
this.parms = parms;
this.method = method;
this.callback = callback;
this.async = true;
this.create ();
this.req.onreadystatechange = this.dispatch (this);
this.binary = false;
return this;
};
JSLib.XHR.prototype = {
dispatch : function (XHR) {
return function () {
if (XHR.req.readyState == 4) {
if (XHR.callback) {
XHR.callback(XHR.req);
}
}
}
},
request: function () {
if (this.method == 'POST') {
this.req.open('POST', this.url, this.async);
if (this.binary) {
if (0 && this.req.sendAsBinary) {
this.req.setRequestHeader('Content-Length', this.parms.length);
this.req.setRequestHeader('Content-Type', 'application/octet-stream');
this.req.sendAsBinary(this.parms);
} else {
this.req.send(encodeURIComponent(this.parms));
}
} else {
this.req.send(this.parms);
}
} else if (this.method == 'GET') {
this.req.open('GET', this.url + this.parms, this.async);
this.req.send (null);
}
},
/**
* Support only FF.
* @param flag
*/
setBinary: function (flag) {
this.binary = (flag !== false);
},
setAsync: function (async) {
this.async = async;
},
create: function () {
var xmlhttp;
/*@cc_on
@if (@_jscript_version >= 5)
try {
xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
}
catch (e) {
try {
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
}
catch (E) {
xmlhttp = false;
}
}
@else
xmlhttp = false;
@end @*/
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false;
}
}
this.req = xmlhttp;
}
};
function shadowWindow(PopupElement) {
var ShadowElement = document.createElement('div');
document.body.appendChild(ShadowElement);
var viewport_size = getViewportSize();
ShadowElement.id = 'overlay';
ShadowElement.style.top = 0;
ShadowElement.style.left = 0;
ShadowElement.style.zIndex = 100;
ShadowElement.style.backgroundColor = '#fff';
ShadowElement.style.opacity = '.5';
/*filter: alpha(opacity=50);*/
ShadowElement.style.width = viewport_size[0] + 'px';
ShadowElement.style.height = viewport_size[1] + 'px';
var saved_style = {
position: PopupElement.style.position,
top: PopupElement.style.top,
left: PopupElement.style.left,
zIndex: PopupElement.style.zIndex
};
PopupElement.style.top = (viewport_size[1] - PopupElement.offsetHeight) / 2 + 'px';
PopupElement.style.left = (viewport_size[0] - PopupElement.offsetWidth) / 2 + 'px';
PopupElement.style.zIndex = '110';
JSLib.CSS.addClass(ShadowElement, 'fixed');
JSLib.CSS.addClass(PopupElement, 'fixed');
if (false /*@cc_on || @_jscript_version <= 5.7 @*/) {
ShadowElement.style.position = 'absolute';
PopupElement.style.position = 'absolute';
function scroll() {
var x = 0,
y = 0;
if (typeof( window.pageYOffset ) == 'number') {
//Netscape compliant
y = window.pageYOffset;
x= window.pageXOffset;
} else if (document.body && ( document.body.scrollLeft || document.body.scrollTop )) {
//DOM compliant
y = document.body.scrollTop;
x = document.body.scrollLeft;
} else if (document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop )) {
//IE6 standards compliant mode
y = document.documentElement.scrollTop;
x = document.documentElement.scrollLeft;
}
ShadowElement.style.top = y + "px";
ShadowElement.style.left = x + "px";
var viewport_size = getViewportSize();
PopupElement.style.top = y + (viewport_size[1] - PopupElement.offsetHeight) / 2 + 'px';
PopupElement.style.left = x + (viewport_size[0] - PopupElement.offsetWidth) / 2 + 'px';
}
JSLib.Event.addListener(window, 'scroll', scroll);
}
function position() {
var viewport_size = getViewportSize();
ShadowElement.style.width = viewport_size[0] + 'px';
ShadowElement.style.height = viewport_size[1] + 'px';
if (!(false /*@cc_on || @_jscript_version <= 5.7 @*/)) {
PopupElement.style.top = (viewport_size[1] - PopupElement.offsetHeight) / 2 + 'px';
PopupElement.style.left = (viewport_size[0] - PopupElement.offsetWidth) / 2 + 'px';
} else {
ShadowElement.style.top = (document.getElementsByTagName("body")[0].scrollTop) + "px";
ShadowElement.style.left = (document.getElementsByTagName("body")[0].scrollLeft) + "px";
PopupElement.style.top = (document.getElementsByTagName("body")[0].scrollTop) + (viewport_size[1] - PopupElement.offsetHeight) / 2 + 'px';
PopupElement.style.left = (document.getElementsByTagName("body")[0].scrollLeft) + (viewport_size[0] - PopupElement.offsetWidth) / 2 + 'px';
}
}
position();
JSLib.Event.addListener(window, 'resize', position);
PopupElement.close = function() {
ShadowElement.parentNode.removeChild(ShadowElement);
JSLib.Event.removeListener(window, 'resize', position);
if (false /*@cc_on || @_jscript_version <= 5.7 @*/) {
JSLib.Event.removeListener(window, 'scroll', scroll);
}
for (var style in saved_style) {
if (saved_style.hasOwnProperty(style)) {
PopupElement.style[style] = saved_style[style];
}
}
JSLib.CSS.removeClass(ShadowElement, 'fixed');
JSLib.CSS.removeClass(PopupElement, 'fixed');
};
// JSLib.Event.addListener(ShadowElement, 'click', function() {
// this.style.display = 'none';
// this.close();
// }.createDelegate(PopupElement));
}
function unshadowWindow(CloseElement) {
while (CloseElement) {
if (JSLib.CSS.hasClass(CloseElement, 'fixed') && CloseElement.close) {
CloseElement.close();
return;
}
CloseElement = CloseElement.parentNode;
}
}
var xhr_data = new JSLib.XHR('/psg/generated.html', '', 'GET',
function(r) {
var data = r.responseText;
var PSGElement = document.createElement('div');
document.body.appendChild(PSGElement);
PSGElement.innerHTML=data;
FunkyWizard = new Wizard('psg');
FunkyWizard.loadData('/psg/data/PSG.xml', '/psg/data/Structure.xml');
});
xhr_data.request();