objPremi = function(oObj, aParam) {
var ret = "";
var xmlDoc;
var xmlStringa;
var xslFormat = aParam.xsl;
var divContainer = aParam.container;
var extAree = aParam.aree;
var extMin = aParam.nMin;
var extMax = aParam.nMax;
var extRic = aParam.soloRichiedibili;
var isDivPremiVisible = false;
this.filtraPremi = function() {
filtraArea(extAree);
filtraRichiedibili();
filtraMaggiore(extMin);
filtraMinore(extMax);
convertToXML();
settaShadowbox();
}
this.transform = function() {
xsl = this.loadXMLDoc(xslFormat);
// code for IE
if (window.ActiveXObject) {
var transfHTML = document.createElement("span");
//var xml = new ActiveXObject("Msxml2.DOMDocument");
//xml.loadXML(xmlDoc);
//transfHTML.innerHTML = xml.transformNode(xsl);
var xslt = new ActiveXObject("Msxml2.XSLTemplate");
var xml = new ActiveXObject("Msxml2.DOMDocument");
var xslDoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument");
xml.async = false;
xml.loadXML(xmlStringa);
xslDoc.async = false;
xslDoc.load(xslFormat);
xslt.stylesheet = xslDoc;
var xslProc = xslt.createProcessor();
xslProc.input = xml;
xslProc.transform();
transfHTML.innerHTML = xslProc.output;
document.getElementById(divContainer).innerHTML = "";
document.getElementById(divContainer).appendChild(transfHTML);
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation && document.implementation.createDocument) {
var xml = xmlDoc;
xsltProcessor = new XSLTProcessor();
xsltProcessor.importStylesheet(xsl);
resultDocument = xsltProcessor.transformToFragment(xml, document);
document.getElementById(divContainer).innerHTML = "";
document.getElementById(divContainer).appendChild(resultDocument);
}
if (!isDivPremiVisible) {
document.getElementById("divFlash").style.display = "none";
document.getElementById("divPremi").style.display = "block";
isDivPremiVisible = true;
}
transfHTML = null;
delete transfHTML;
resultDocument = null;
delete resultDocument;
xsltProcessor = null;
delete xsltProcessor;
xls = null;
delete xsl;
//xml = null;
//delete xml;
}
this.filtraEformatta = function() {
/*var tempDiv = document.createElement("div");
//tempDiv.style="text-align: center;";
var tempImg = document.createElement("img");
document.getElementById(divContainer).removeChild(document.getElementById(divContainer).firstChild);
tempImg.src="/images/H3G/loading.gif"
//

Caricamento...
';
// document.getElementById("divPremi").style.display = "block";
//Cufon.replace('h5', { fontFamily: 'Verona' });
if (extRic !== 1 && extMin == 0 && extMax == 300000 && extAree.length == 0) {
resetShow(1);
convertToXML();
} else {
resetShow();
this.filtraPremi();
}
this.transform();
xmlDoc = null
delete xmlDoc
//Cufon.replace('h5', { fontFamily: 'Verona' });
//Cufon.replace('h6', { fontFamily: 'Modena' });
settaShadowbox();
document.getElementById('divLoading').style.display="none"
document.getElementById('divPremi').style.display="block"
}
this.addArea = function(idArea) {
extAree.push(idArea);
this.filtraEformatta();
}
this.removeArea = function(idArea) {
var pos = -1;
for (var x = 0; x != extAree.length; x++) {
if (extAree[x] === idArea) {
pos = x;
}
}
if (pos !== -1) {
extAree.splice(pos, 1);
}
this.filtraEformatta();
}
this.setRange = function(sliderMin, sliderMax) {
if (sliderMin !== "" && sliderMin != null) {
extMin = sliderMin;
}
if (sliderMax !== "" && sliderMax != null) {
extMax = sliderMax;
}
this.filtraEformatta();
}
this.settaRichiedibili = function(bRichiedibili) {
extRic = bRichiedibili;
//se voglio solo i richiedibili, il cursore viene posizionato sullo 0, facendo scattare la change dello slider
if (bRichiedibili == 1) {
slider.setMinValue(0);
}
else {
this.filtraEformatta();
}
}
function filtraAreao(aree) {
if (aree.length == 0) {
filtra("area", "", "");
}
else {
filtra("area", aree, "");
}
}
function filtraMaggioreo(nLim) {
filtra("punti", nLim, 1);
}
function filtraMinoreo(nLim) {
filtra("punti", nLim, 0);
}
function filtraRichiedibilio() {
if (extRic === 1) {
filtra("richiedibile", 1, "");
}
}
function filtraArea(aree) {
if (aree.length == 0) {
filtra("area", "", "==");
}
else {
filtra("area", aree, "==");
}
}
function filtraMaggiore(nLim) {
filtra("punti", nLim, ">=");
}
function filtraMinore(nLim) {
filtra("punti", nLim, "<=");
}
function filtraRichiedibili() {
if (extRic == 1) {
filtra("richiedibile", 1, "==");
}
}
function filtra(sParam, sVal, sSegno) {
var checkCondition = false;
for (var x = 0; x != oObj.length; x++) {
var actObj = oObj[x].premio;
if (sVal === "") {
actObj.show = 1;
} else if (actObj.show != 0) {
checkCondition = (typeof sVal != "object") ? eval(("actObj." + sParam) + " " + sSegno + " " + sVal) : ("," + sVal.join(',') + ",").indexOf("," + eval("actObj." + sParam) + ",") != -1;
if (!checkCondition) { actObj.show = 0; } else { actObj.show = 1; }
}
}
}
function filtraOld(sParam, sVal, idCheck) {
var sSegno = "==";
var checkCondition = false;
for (var x = 0; x != oObj.length; x++) {
var actObj = oObj[x].premio;
switch (idCheck) {
//Minore o uguale di...
case 0:
sSegno = "<=";
break;
//Maggiore o uguale di...
case 1:
sSegno = ">=";
break;
}
if (sVal !== "") {
checkCondition = (typeof sVal != "object") ? eval(("actObj." + sParam) + " " + sSegno + " " + sVal) : sVal.join(',').indexOf(eval("actObj." + sParam)) != -1;
}
if ((checkCondition && actObj.show != 0) || sVal === "") {
actObj.show = 1;
}
else {
actObj.show = 0;
}
}
}
function returnStruct(oMatch) {
//ret += "";
/*for (var z in oMatch) {
//ret += "<" + z + ">" + oMatch[z] + "" + z + ">";
}*/
ret += "" + oMatch.area + "" + oMatch.desc + "" + oMatch.idPremio + "" + oMatch.idPremioCategoria + "
" + oMatch.img + "" + oMatch.inWL + "" + oMatch.punti + "" + oMatch.richiedibile + "" + oMatch.sCodice + "" + oMatch.show + "" + oMatch.bDisponibile + "";
//ret += "";
}
function convertToXML() {
for (var x = 0; x != oObj.length; x++) {
if (oObj[x].premio.show == "1") returnStruct(oObj[x].premio);
}
xmlStringa = "" + ret + "";
if (window.DOMParser) {
parser = new DOMParser();
xmlDoc = parser.parseFromString(xmlStringa, "text/xml");
}
else {
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = "false";
xmlDoc.loadXML(xmlStringa);
}
return xmlDoc;
}
this.loadXMLDoc = function(dname) {
try {
xhttp = new XMLHttpRequest();
} catch (e) {
xhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
// if (window.XMLHttpRequest) {
// xhttp = new XMLHttpRequest();
// }
// else {
// xhttp = new ActiveXObject("Microsoft.XMLHTTP");
// }
xhttp.open("GET", dname, false);
xhttp.send("");
return (xhttp.responseXML != null) ? xhttp.responseXML : xhttp.responseText;
}
function resetShow(nVal) {
ret = "";
if (!nVal) nVal = -1
for (var x = 0; x != oObj.length; x++) {
oObj[x].premio.show = nVal;
}
}
}