var Comparison = {
filledSlots:0,
slots: new Array(5),
productHtml:[],
init:function(){
Comparison.slots[0] = "";
Comparison.slots[1] = "";
Comparison.slots[2] = "";
Comparison.slots[3] = "";
Comparison.slots[4] = "";
document.getElementById("removeAll").onclick = function() { return Comparison.removeAll(); }
document.getElementById("removeAll").style.color = "#BBBBBB";
/*
Warning: Invalid argument supplied for foreach() in /dsk/mainweb/root/11073/products/video/selector/js/compare.js/index.php on line 18
*/
},
addToCompare:function(obj, imgObj, imgPath, prodName, prodLink, prodId, setCookie){
//alert(prodId);
if(this.filledSlots < 5){
//adds the object to the 5 slot comparison on top of page
productDiv = "product_"+prodId;
if(document.getElementById("plus_"+prodId))
document.getElementById("plus_"+prodId).style.display="none";
htmlToKeep = document.getElementById(productDiv).innerHTML;
prodDetailsArray = [obj, imgObj, imgPath, prodName, prodLink];
Comparison.productHtml[prodId] = prodDetailsArray;
if(document.getElementById("listTypeImg").checked)
document.getElementById(productDiv).innerHTML = '
'+htmlToKeep;
else
document.getElementById(productDiv).innerHTML = ''+htmlToKeep;
if(prodName.substring(0,4) != "AXIS")
axisprefix = "AXIS ";
else
axisprefix = "";
if(document.getElementById(imgObj))
imgSrc = "
";
else
imgSrc = "
";
if(Comparison.slots[0] == ""){
Comparison.slots[0] = prodId;
document.getElementById("cph1").innerHTML = ""+imgSrc+"
- Remove
";
}
else if(Comparison.slots[1] == ""){
Comparison.slots[1] = prodId;
document.getElementById("cph2").innerHTML = ""+imgSrc+"
- Remove
";
}
else if(Comparison.slots[2] == ""){
Comparison.slots[2] = prodId;
document.getElementById("cph3").innerHTML = ""+imgSrc+"
- Remove
";
}
else if(Comparison.slots[3] == ""){
Comparison.slots[3] = prodId;
document.getElementById("cph4").innerHTML = ""+imgSrc+"
- Remove
";
}
else if(Comparison.slots[4] == ""){
Comparison.slots[4] = prodId;
document.getElementById("cph5").innerHTML = ""+imgSrc+"
- Remove
";
}
qstring = Comparison.buildQueryString();
document.getElementById("comparisonForm").action = "processQuery.php"+qstring;
//document.getElementById("cph"+(this.filledSlots+1)).innerHTML = "testing
- Remove
";
if(setCookie){
var stringToCookie = "";
for(i = 0; i < Comparison.slots.length; i++){
if(Comparison.slots[i] != ""){
if(stringToCookie != "")
stringToCookie += ",";
stringToCookie += Comparison.slots[i];
}
}
_set_session_cookie('prodSelectorCookie', stringToCookie);
//alert(_get_cookie('prodSelectorCookie'));
}
this.filledSlots++;
}else{
alert("You can only compare 5 products at a time.");
}
document.getElementById("removeAll").style.color = "#3366CC";
return;
},
removeFromCompare:function(obj){
//alert(obj.id);
temp = obj.id.split("remove_");
temp2 = temp[1].split("_");
productDiv = "product_"+temp2[0]; // temp2[0] contains the unique product id
//cph = temp2[1];
cph = obj.parentNode.id;
// alert(productDiv);
if(document.getElementById(productDiv)){
allHtml = document.getElementById(productDiv).innerHTML;
//document.getElementById(productDiv).innerHTML = Comparison.productHtml[temp2[0]];
if(document.getElementById("listTypeImg").checked){ // just remove the grayed out div
node = document.getElementById(productDiv);
//alert(document.getElementById(productDiv).firstChild.className);
//alert(document.getElementById(productDiv).className);
for(i=0; i < node.childNodes.length; i++){ //needed to work in firefox
if(node.childNodes[i].className == "grayedOutDiv"){
node.removeChild(node.childNodes[i]);
break;
}
}
//node.removeChild(document.getElementById(productDiv).firstChild);
//alert("test");
if(document.getElementById("plus_"+temp2[0]))
document.getElementById("plus_"+temp2[0]).style.display="";
}else{ // print the full inner html
prodDetailsArray = Comparison.productHtml[temp2[0]];
document.getElementById(productDiv).innerHTML = "AXIS "+ prodDetailsArray[3]+" Product page »";
}
}
document.getElementById(cph).innerHTML = "
";
if(cph == "cph1")
Comparison.slots[0] = "";
else if(cph == "cph2")
Comparison.slots[1] = "";
else if(cph == "cph3")
Comparison.slots[2] = "";
else if(cph == "cph4")
Comparison.slots[3] = "";
else if(cph == "cph5")
Comparison.slots[4] = "";
//left-shift the products in the comparison slots
for(i = 0; i < 4; i++){
if(Comparison.slots[i] == ""){
if(Comparison.slots[i+1] != ""){
document.getElementById("cph"+(i+1)).innerHTML = document.getElementById("cph"+(i+2)).innerHTML;
document.getElementById("cph"+(i+2)).innerHTML = "
";
Comparison.slots[i] = Comparison.slots[i+1];
Comparison.slots[i+1] = "";
}
}
}
qstring = Comparison.buildQueryString();
document.getElementById("comparisonForm").action = "processQuery.php"+qstring;
var stringToCookie = "";
for(i = 0; i < Comparison.slots.length; i++){
if(Comparison.slots[i] != ""){
if(stringToCookie != "")
stringToCookie += ",";
stringToCookie += Comparison.slots[i];
}
}
_set_session_cookie('prodSelectorCookie', stringToCookie);
this.filledSlots--;
if(this.filledSlots <= 0){
document.getElementById("removeAll").style.color = "#BBBBBB";
}
},
resetCompare:function(){
Comparison.slots[0] = "";
Comparison.slots[1] = "";
Comparison.slots[2] = "";
Comparison.slots[3] = "";
Comparison.slots[4] = "";
Comparison.filledSlots = 0;
document.getElementById("removeAll").style.color = "#BBBBBB";
document.getElementById("cph1").innerHTML = "
";
document.getElementById("cph2").innerHTML = "
";
document.getElementById("cph3").innerHTML = "
";
document.getElementById("cph4").innerHTML = "
";
document.getElementById("cph5").innerHTML = "
";
},
removeAll:function(){
if(Comparison.slots[0] != ""){ //run only if there's at least 1 item added to comparison
Comparison.resetCompare();
sendAjaxRequest("placeholder", "placeholder");
var stringToCookie = "";
for(i = 0; i < Comparison.slots.length; i++){
if(Comparison.slots[i] != ""){
if(stringToCookie != "")
stringToCookie += ",";
stringToCookie += Comparison.slots[i];
}
}
_set_session_cookie('prodSelectorCookie', stringToCookie);
}
return false;
},
buildQueryString:function(){
qstring = "?";
pType = document.getElementById("prodType").value;
qstring += "product_type=" + pType;
for(i=0; i