﻿function swapClass(obj, flag, optFlag) {    
    currentObj = document.getElementById((typeof (obj) == "string" ? obj : obj.id));
    if (currentObj) {
        currentClass = currentObj.className;
        if (!optFlag) {
            regExp = (flag.toString().toLowerCase() == "on") ? "Off" : "On";
        }
        else {
            regExp = optFlag;
        }
        newClass = currentClass.replace(regExp, flag);
        currentObj.className = newClass;        
    }
}

function changeSrc(obj, flag, optFlag) {
    objAux = document.getElementById((typeof (obj) == "string" ? obj : obj.id));
    if (objAux) {
        currentSrc = objAux.src;
        if (currentSrc) {
                   
            // PNG transparency - hacked to IE6
            if (objAux.filters) {
                if (objAux.filters[0]) {
                    currentSrc = objAux.filters[0].src;      
                }   
            }
            if (!optFlag) {
                regExp = (flag.toString().toLowerCase() == "on") ? "Off" : "On";
            }
            else {
                regExp = optFlag;
            }
            if (currentSrc) {
                newSrc = currentSrc.replace(regExp, flag);
                objAux.src = newSrc;
            }
        }
    }
}

function changeBG(obj, flag) {
    currentObj = document.getElementById((typeof (obj) == "string" ? obj : obj.id));
    if (currentObj) {
        currentObj.className = "signUpSelectionBoxBG grayText " + flag;
    }
}

function changeChkValue(obj, flag) {
    currentObj = document.getElementById((typeof (obj) == "string" ? obj : obj.id));
    if (currentObj) {
        currentObj.value = flag;
        currentObj.checked = checkChannel('channels', flag);
        currentObj.onclick = Function("addChannel('" + currentObj.id + "', '" + flag + "');");        
    }
}

function writeCookie(cname, cvalue, cexpire) {
    channelFound = false;
    if (cname == "channels") {
        cookies = loadCookies();
        if (cookies[cname] != null) {
            channelFound = checkChannel(cname, cvalue);
            if (!channelFound) {
                var currentValue = readCookie(cname);
                cvalue = currentValue + ',' + cvalue;
            }
        }
    }
    if (!channelFound) {
        document.cookie = cname + '=' + cvalue + '; path=/; ' +
	    (typeof cexpire == 'date' ? ' expires=' + cexpire.toGMTString() : '');
        if (cname == "channels") {
            updateShoppingCart(cname)
        }
    }
}

function delCookie(cname) {
    document.cookie = cname + '=; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/;';
}

function loadCookies() {
    var cr = []; 
    var ck = document.cookie.split('; ');
    for (var i = ck.length - 1; i >= 0; i--) {
        var cv = ck[i].split('=');
        cr[cv[0]] = cv[1];            
    }    
    return cr;
}

function readCookie(cname) {
    cookies = loadCookies();
    if (cookies[cname] != null) {
        return cookies[cname];
    }
}

function addChannel(cname, cvalue) {
    channelChk = document.getElementById((typeof (cname) == "string" ? cname : cname.id));    
    if (channelChk) {
        if (channelChk.checked) {
            writeCookie('channels', cvalue);
        }        
    }
}

function removeChannel(cname, cvalue) {
    cookies = loadCookies();
    newChannels = "";
    if (cookies[cname] != null) {
        channels = readCookie(cname).split(',');
        for (var i = 0; i <= channels.length - 1; i++) {
            if (channels[i] != cvalue) {
                newChannels += channels[i] + ",";
            }
        }
        newChannels = newChannels.substr(0, newChannels.lastIndexOf(","));
        delCookie(cname);
        if (newChannels != "") {
            writeCookie(cname, newChannels);
        }
    }
}

function checkChannel(cname, cvalue) {
    cookies = loadCookies();
    channelFound = false;
    if (cookies[cname] != null) {
        channels = readCookie(cname).split(',');
        for (var i = 0; i <= channels.length - 1; i++) {
            if (channels[i] == cvalue) {
                channelFound = true;
                break;
            }
        }
    }
    return channelFound;
}

function updateShoppingCart(cname) {
    btnNextContainer = document.getElementById("BtnNextContainer");
    chPrice = channelPrice[currentCurrency];
    pkPrice = packagePrice[currentCurrency];
    total = 0;
    hasADLTV = false;
    shoppingCart = document.getElementById('ctl00_MainContentPlaceHolder_SignUpShoppingCart');
    if (shoppingCart) {
        cookies = loadCookies();
        if (cookies[cname] != null) {
            channels = readCookie(cname).split(',');
            channels = channels.sort();
            channelsTxt = "<div class='cartItem boldText'>";
            channelsTxt += "Channel";
            channelsTxt +="</div>";
            channelsTxt += "<div class='cartValue boldText'>";
            channelsTxt += "Amount";
            channelsTxt += "</div>";
            channelsTxt += "<div class='clear'></div>";
            channelsTxt += "<br />";
            for (var i = 0; i <= channels.length - 1; i++) {
                if (channels[i].search("AdultLive") >= 0 && !hasADLTV) {
                    hasADLTV = true;
                }
                price = (channels[i].search("AdultLive") >= 0 ? adultLiveChannelPrice[channels[i].charAt(9).toString()] : (channels[i].search("Package") >= 0 ? pkPrice : chPrice));
                channelsTxt += "<div class='cartGroup borderBt'>";
                channelsTxt += "<div class='cartItem'>";
                channelsTxt += channelDescription(channels[i]);
                channelsTxt += "</div>";
                channelsTxt += "<div class='cartValue'>"
                channelsTxt += currencySymbol(currentCurrency)
                channelsTxt += price.toFixed(2).toString();
                channelsTxt += (channels[i].search("AdultLive") >= 0 ? "**" : "*");                
                channelsTxt += "</div>";
                channelsTxt += "<div class='clear'></div>";
                channelsTxt += "</div>";                
                channelsTxt += "<div class='cartAction'>";
                channelsTxt += "<a href='javascript:removeChannel(\"channels\", \"";
                channelsTxt += channels[i];
                channelsTxt += "\"); updateShoppingCart(\"channels\"); cleanCheckboxes();'>";
                channelsTxt += "<img src='images/signup/Remove.jpg' alt='Remove' />";
                channelsTxt += "</a>";
                channelsTxt += "</div>";
                channelsTxt += "<div class='clear'></div>";
                total += price;
            }

            channelsTxt += "<br />";
            channelsTxt += "<div class='cartItem boldText rightAlign'>";
            channelsTxt += "Total:";
            channelsTxt += "</div>";
            channelsTxt += "<div class='cartValue boldText'>";
            channelsTxt += currencySymbol(currentCurrency) + total.toFixed(2).toString();
            channelsTxt += "</div>";
            channelsTxt += "<br /><br />";
            channelsTxt += "<div class='cartGroup centerText'>";
            if (currentCurrency != "GBP") {
                channelsTxt += "* Weekly price, billed monthly for your convenience.";
            }
            else {
                channelsTxt += "* Weekly price, billed monthly on credit card for your convenience.";
                channelsTxt += (hasADLTV ? "<br />** One-off payment." : "");                 
            }                        
            channelsTxt += "</div>";

            shoppingCart.innerHTML = channelsTxt;

            if (btnNextContainer) {
                swapClass(btnNextContainer, "On");
            }
        }
        else {
            shoppingCart.innerHTML = "<div class='boldText'>Please select your preferred Channels and add them to your Package.</div>";

            if (btnNextContainer) {
                swapClass(btnNextContainer, "Off");
            }
        }
    }
}

function currentSelection(pageSelected, obj1, obj2, obj3, obj4, obj5, obj6, obj7, obj8, obj9, obj10, obj11, obj12, obj13, obj14, obj15, obj16, obj17, obj18) {
    cookie = readCookie("current_selection");
    cookie2 = readCookie("last_channel");

    pageSelected = (pageSelected ? pageSelected : cookie2);

    if (obj1 && obj2 && obj3 && obj4 && obj5 && obj6 && obj7 && obj8 && obj9 && obj10 && obj11 && obj12 && obj13 && obj14 && obj15 && obj16 && obj17 && obj18) {
    
        // obj1 = ChannelPickerList (div)
        // obj2 = PackageList (div)
        // obj3 = ChannelPicker (img)
        // obj4 = ChannelPackage (img)
        // obj5 = SignUpPriceLabel (img)
        // obj6 = SignUpPackagePriceLabel (img)
        // obj7 = SignUpSelection (div)
        // obj8 = SignUpCheckBox (input - checkbox)
        // obj9 = SignUpPackagesFound (div)
        // obj10 = SignUpPackagesFoundBox (div)
        // obj11 = PackageCheckBox (input - checkbox)
        // obj12 = AddToCartImg (img)
        // obj13 = SignUpSuggestion (div)
        // obj14 = SignUpSuggestionBox (div)
        // obj15 = ADLTVTickets (div)
        // obj16 = ADLTVFridayChk (input - checkbox)
        // obj17 = ADLTVSaturdayChk (input - checkbox)
        // obj18 = ADLTVWeekendChk (input - checkbox)

        if (cookie == "packages") {
//            objChange1 = document.getElementById((typeof (obj1) == "string" ? obj1 : obj1.id));
//            objChange2 = document.getElementById((typeof (obj2) == "string" ? obj2 : obj2.id));
//            objChange3 = document.getElementById((typeof (obj3) == "string" ? obj3 : obj3.id));
//            objChange4 = document.getElementById((typeof (obj4) == "string" ? obj4 : obj4.id));
//            objChange5 = document.getElementById((typeof (obj5) == "string" ? obj5 : obj5.id));
//            objChange6 = document.getElementById((typeof (obj6) == "string" ? obj6 : obj6.id));
//            objChange7 = document.getElementById((typeof (obj7) == "string" ? obj7 : obj7.id));
//            objChange8 = document.getElementById((typeof (obj8) == "string" ? obj8 : obj8.id));
//            objChange9 = document.getElementById((typeof (obj9) == "string" ? obj9 : obj9.id));
//            objChange10 = document.getElementById((typeof (obj10) == "string" ? obj10 : obj10.id));
//            objChange11 = document.getElementById((typeof (obj11) == "string" ? obj11 : obj11.id));
//            objChange12 = document.getElementById((typeof (obj12) == "string" ? obj12 : obj12.id));
//            objChange13 = document.getElementById((typeof (obj13) == "string" ? obj13 : obj13.id));
//            objChange14 = document.getElementById((typeof (obj14) == "string" ? obj14 : obj14.id));
//            objChange15 = document.getElementById((typeof (obj15) == "string" ? obj15 : obj15.id));
//            objChange16 = document.getElementById((typeof (obj16) == "string" ? obj16 : obj16.id));
//            objChange17 = document.getElementById((typeof (obj17) == "string" ? obj17 : obj17.id));
//            objChange18 = document.getElementById((typeof (obj18) == "string" ? obj18 : obj18.id));
//            if (objChange1) {
//                swapClass(objChange1, "Off");
//            }
//            if (objChange2) {
//                swapClass(objChange2, "On");
//            }
//            if (objChange3) {
//                changeSrc(objChange3, "Off");
//                swapClass(objChange3, "Off");
//                objChange3.onmouseover = Function("changeSrc('" + objChange3.id + "', 'On');");
//                objChange3.onmouseout = Function("changeSrc('" + objChange3.id + "', 'Off');");
//                onclickStr = "delCookie('last_channel'); writeCookie('current_selection', 'channels'); currentSelection('Diablo', '";
//                onclickStr += objChange1.id;
//                onclickStr += "', '";
//                onclickStr += objChange2.id;
//                onclickStr += "', '";
//                onclickStr += objChange3.id;
//                onclickStr += "', '";
//                onclickStr += objChange4.id;
//                onclickStr += "', '";
//                onclickStr += objChange5.id;
//                onclickStr += "', '";
//                onclickStr += objChange6.id;
//                onclickStr += "', '";
//                onclickStr += objChange7.id;
//                onclickStr += "', '";
//                onclickStr += objChange8.id;
//                onclickStr += "', '";
//                onclickStr += objChange9.id;
//                onclickStr += "', '";
//                onclickStr += objChange10.id;
//                onclickStr += "', '";
//                onclickStr += objChange11.id;
//                onclickStr += "', '";
//                onclickStr += objChange12.id;
//                onclickStr += "', '";
//                onclickStr += objChange13.id;
//                onclickStr += "', '";
//                onclickStr += objChange14.id;
//                onclickStr += "', '";
//                onclickStr += objChange15.id;
//                onclickStr += "', '";
//                onclickStr += objChange16.id;
//                onclickStr += "', '";
//                onclickStr += objChange17.id;
//                onclickStr += "', '";
//                onclickStr += objChange18.id;
//                onclickStr += "');"
//                objChange3.onclick = Function(onclickStr);
//            }
//            if (objChange4) {
//                changeSrc(objChange4, "On");
//                swapClass(objChange4, "On");
//                objChange4.onmouseover = Function("return false;");
//                objChange4.onmouseout = Function("return false;");
//                objChange4.onclick = Function("return false;");
//            }
//            if (objChange5) {
//                swapClass(objChange5, "Off");                
//            }
//            if (objChange6) {
//                swapClass(objChange6, "On");
//            }
//            if (objChange7) {
//                changeBG(objChange7, pageSelected);
//            }
//            if (objChange8) {                
//                changeChkValue(objChange8, pageSelected);
//            }
//            if (objChange9) {
//                swapClass(objChange9, "Off");
//            }
//            if (objChange12) {
//                swapClass(objChange12, "packageCart", "channelCart");
//                changeSrc(objChange12, "Package", "Channel");
//            }
//            if (objChange13 && objChange14) {
//                hasSuggestions = (channelSuggestions(pageSelected) != "");
//                swapClass(objChange13, (hasSuggestions ? "On" : "Off"));
//                if (hasSuggestions) {
//                    suggestionsContent = "";
//                    suggestions = channelSuggestions(pageSelected).split(',');
//                    for (var i = 0; i < suggestions.length; i++) {
//                        suggestionsContent += "<img id='ImgSuggestion";
//                        suggestionsContent += i;
//                        suggestionsContent += "' src='images/channels/thumbs/";
//                        suggestionsContent += suggestions[i];
//                        suggestionsContent += ".jpg' class='suggestionThumbOff' alt='";
//                        suggestionsContent += channelDescription(suggestions[i]);
//                        suggestionsContent += "' onmouseover='javascript:swapClass(\"ImgSuggestion";
//                        suggestionsContent += i;
//                        suggestionsContent += "\", \"On\");' onmouseout='javascript:swapClass(\"ImgSuggestion";
//                        suggestionsContent += i;
//                        suggestionsContent += "\", \"Off\");' onclick='javascript:";
//                        suggestionsContent += "delCookie(\"last_channel\"); writeCookie(\"current_selection\", \"channels\"); writeCookie(\"last_channel\", \"";
//                        suggestionsContent += suggestions[i];
//                        suggestionsContent += "\"); currentSelection(\"";
//                        suggestionsContent += suggestions[i];
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange1.id;
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange2.id;
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange3.id;
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange4.id;
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange5.id;
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange6.id;
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange7.id;
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange8.id;
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange9.id;
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange10.id;
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange11.id;
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange12.id;
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange13.id;
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange14.id;
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange15.id;
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange16.id;
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange17.id;
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange18.id;
//                        suggestionsContent += "\");";
//                        suggestionsContent += "' />";
//                    }
//                    objChange14.innerHTML = suggestionsContent;
//                }
//            }
//            if (objChange15) {
//                swapClass(objChange15, "Off");
//            }
//            if (objChange16) {
//                changeChkValue(objChange16, pageSelected);
//            }
//            if (objChange17) {
//                changeChkValue(objChange17, pageSelected);
//            }
//            if (objChange18) {
//                changeChkValue(objChange18, pageSelected);
//            }
        }
        else {
            // obj1 = ChannelPickerList (div)
            // obj2 = PackageList (div)
            // obj3 = ChannelPicker (img)
            // obj4 = ChannelPackage (img)
            // obj5 = SignUpPriceLabel (img)
            // obj6 = SignUpPackagePriceLabel (img)
            // obj7 = SignUpSelection (div)
            // obj8 = SignUpCheckBox (input - checkbox)
            // obj9 = SignUpPackagesFound (div)
            // obj10 = SignUpPackagesFoundBox (div)
            // obj11 = PackageCheckBox (input - checkbox)
            // obj12 = AddToCartImg (img)
            // obj13 = SignUpSuggestion (div)
            // obj14 = SignUpSuggestionBox (div)
            // obj15 = ADLTVTickets (div)
            // obj16 = ADLTVFridayChk (input - checkbox)
            // obj17 = ADLTVSaturdayChk (input - checkbox)
            // obj18 = ADLTVWeekendChk (input - checkbox)
            
            objChange1 = document.getElementById((typeof (obj2) == "string" ? obj2 : obj2.id));
            objChange2 = document.getElementById((typeof (obj1) == "string" ? obj1 : obj1.id));
            objChange3 = document.getElementById((typeof (obj4) == "string" ? obj4 : obj4.id));
            objChange4 = document.getElementById((typeof (obj3) == "string" ? obj3 : obj3.id));
            objChange5 = document.getElementById((typeof (obj6) == "string" ? obj6 : obj6.id));
            objChange6 = document.getElementById((typeof (obj5) == "string" ? obj5 : obj5.id));
            objChange7 = document.getElementById((typeof (obj7) == "string" ? obj7 : obj7.id));
            objChange8 = document.getElementById((typeof (obj8) == "string" ? obj8 : obj8.id));
            objChange9 = document.getElementById((typeof (obj9) == "string" ? obj9 : obj9.id));
            objChange10 = document.getElementById((typeof (obj10) == "string" ? obj10 : obj10.id));
            objChange11 = document.getElementById((typeof (obj11) == "string" ? obj11 : obj11.id));
            objChange12 = document.getElementById((typeof (obj12) == "string" ? obj12 : obj12.id));
            objChange13 = document.getElementById((typeof (obj13) == "string" ? obj13 : obj13.id));
            objChange14 = document.getElementById((typeof (obj14) == "string" ? obj14 : obj14.id));
            objChange15 = document.getElementById((typeof (obj15) == "string" ? obj15 : obj15.id));
            objChange16 = document.getElementById((typeof (obj16) == "string" ? obj16 : obj16.id));
            objChange17 = document.getElementById((typeof (obj17) == "string" ? obj17 : obj17.id));
            objChange18 = document.getElementById((typeof (obj18) == "string" ? obj18 : obj18.id));
            if (objChange1) {            
                swapClass(objChange1, "Off");
            }
            if (objChange2) {
                swapClass(objChange2, "On");
            }
            if (objChange3) {
//                changeSrc(objChange3, "Off");
//                swapClass(objChange3, "Off");
//                objChange3.onmouseover = Function("changeSrc('" + objChange3.id + "', 'On');");
//                objChange3.onmouseout = Function("changeSrc('" + objChange3.id + "', 'Off');");
//                onclickStr = "delCookie('last_channel'); writeCookie('current_selection', 'packages'); currentSelection('Package1', '";
//                onclickStr += objChange2.id;
//                onclickStr += "', '";
//                onclickStr += objChange1.id;
//                onclickStr += "', '";
//                onclickStr += objChange4.id;
//                onclickStr += "', '";
//                onclickStr += objChange3.id;
//                onclickStr += "', '";
//                onclickStr += objChange6.id;
//                onclickStr += "', '";
//                onclickStr += objChange5.id;
//                onclickStr += "', '";
//                onclickStr += objChange7.id;
//                onclickStr += "', '";
//                onclickStr += objChange8.id;
//                onclickStr += "', '";
//                onclickStr += objChange9.id;
//                onclickStr += "', '";
//                onclickStr += objChange10.id;
//                onclickStr += "', '";
//                onclickStr += objChange11.id;
//                onclickStr += "', '";
//                onclickStr += objChange12.id;
//                onclickStr += "', '";
//                onclickStr += objChange13.id;
//                onclickStr += "', '";
//                onclickStr += objChange14.id;
//                onclickStr += "', '";
//                onclickStr += objChange15.id;
//                onclickStr += "', '";
//                onclickStr += objChange16.id;
//                onclickStr += "', '";
//                onclickStr += objChange17.id;
//                onclickStr += "', '";
//                onclickStr += objChange18.id;
//                onclickStr += "');";
//                objChange3.onclick = Function(onclickStr);
            }
            if (objChange4) {
                changeSrc(objChange4, "On");
                swapClass(objChange4, "On");
                objChange4.onmouseover = Function("return false;");
                objChange4.onmouseout = Function("return false;");
                objChange4.onclick = Function("return false;");
            }
            if (objChange5) {
                swapClass(objChange5, "Off");
            }
            if (objChange6) {
                swapClass(objChange6, "On");
            }            
            if (objChange7) {
                changeBG(objChange7, pageSelected);
            }            
            if (objChange8) {                
                changeChkValue(objChange8, pageSelected);
            }            
            if (objChange9 && objChange10 && objChange11) {
//                var channelPackage = new Array();
//                channelPackage[1] = "YouPornHoneys,SuperMarino,JohnnyRebel";
//                channelPackage[2] = "LegalPink,Typhoon,Diablo";

//                showPackages = false;
//                for (var i = 1; i <= 3; i++) {
//                    if (channelPackage[i].search(pageSelected) > -1) {
//                        showPackages = true;
//                        break;
//                    }
//                }

//                swapClass(objChange9, (showPackages ? "On" : "Off"));
//                objChange10.className = "signUpSelectionBoxBG grayText Package" + i;
//                changeChkValue(objChange11, "Package" + i);
            }            
            if (objChange12) {
                swapClass(objChange12, "channelCart", "packageCart");
                changeSrc(objChange12, "Channel", "Package");
            }
//            if (objChange13 && objChange14) {
//                hasSuggestions = (channelSuggestions(pageSelected) != "");
//                swapClass(objChange13, (hasSuggestions ? "On" : "Off"));
//                if (hasSuggestions) {
//                    suggestionsContent = "";
//                    suggestions = channelSuggestions(pageSelected).split(',');
//                    for (var i = 0; i < suggestions.length; i++) {
//                        suggestionsContent += "<img id='ImgSuggestion";
//                        suggestionsContent += i;
//                        suggestionsContent += "' src='images/channels/thumbs/";
//                        suggestionsContent += suggestions[i];
//                        suggestionsContent += ".jpg' class='suggestionThumbOff' alt='";
//                        suggestionsContent += channelDescription(suggestions[i]);
//                        suggestionsContent += "' onmouseover='javascript:swapClass(\"ImgSuggestion";
//                        suggestionsContent += i;
//                        suggestionsContent += "\", \"On\");' onmouseout='javascript:swapClass(\"ImgSuggestion";
//                        suggestionsContent += i;
//                        suggestionsContent += "\", \"Off\");' onclick='javascript:";
//                        suggestionsContent += "delCookie(\"last_channel\"); writeCookie(\"current_selection\", \"channels\"); writeCookie(\"last_channel\", \"";
//                        suggestionsContent += suggestions[i];
//                        suggestionsContent += "\"); currentSelection(\"";
//                        suggestionsContent += suggestions[i];
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange2.id;
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange1.id;
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange4.id;
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange3.id;
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange6.id;
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange5.id;
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange7.id;
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange8.id;
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange9.id;
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange10.id;
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange11.id;
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange12.id;
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange13.id;
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange14.id;
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange15.id;
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange16.id;
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange17.id;
//                        suggestionsContent += "\", \"";
//                        suggestionsContent += objChange18.id;
//                        suggestionsContent += "\");";  
//                        suggestionsContent += "' />";
//                    }
//                    objChange14.innerHTML = suggestionsContent;
//                }
//            }            
            if (pageSelected.search("AdultLive") > -1) {                
                swapClass(objChange6, "Off");
                swapClass(objChange12, "Off");             
                swapClass(objChange15, "On");
            }
            else {
                swapClass(objChange6, "On");
                swapClass(objChange12, "On");
                swapClass(objChange15, "Off");
            }
            if (objChange16) {
                changeChkValue(objChange16, pageSelected + "F");
            }
            if (objChange17) {
                changeChkValue(objChange17, pageSelected + "S");
            }
            if (objChange18) {
                changeChkValue(objChange18, pageSelected + "W");
            }
        }
    }
}

function channelDescription(cname) {
    if (cname) {
        var descriptions = new Array();
        //descriptions["AdultLiveF"] = "Adult Live TV: Ticket for Friday show";
        //descriptions["AdultLiveS"] = "Adult Live TV: Ticket for Saturday show";
        //descriptions["AdultLiveW"] = "Adult Live TV: Ticket for Weekend shows";
        //descriptions["Diablo"] = "Diablo";
        descriptions["DigitalSinNewSensations"] = "Digital Sin &amp; New Sensations";
        //descriptions["H2"] = "H2 Video";
        descriptions["Harmony"] = "Harmony";
        descriptions["LegalPink"] = "Legal Pink";
        descriptions["MatrixHD"] = "Matrix HD";
        descriptions["Private"] = "Private";
        //descriptions["Pumpkin"] = "Pumpkin Films";
        //descriptions["PureXXX"] = "PureXXX Films";
        descriptions["Relish"] = "Relish";
        //descriptions["SuperMarino"] = "Super Marino's Road Trips";
        descriptions["Visage"] = "Visage";
        descriptions["Vivid"] = "Vivid Europe";
        //descriptions["XplicitXXX"] = "Xplicit XXX";
        //descriptions["YouPornHoneys"] = "YouPorn Honeys";
        //descriptions["Dom"] = "Dom Promotions";
        //descriptions["JohnnyRebel"] = "Johnny Rebel";
        //descriptions["LoadXXXGrannies"] = "LoadXXX British Grannies";
        //descriptions["LoadXXXRentBoy"] = "LoadXXX Rent Boy";
        //descriptions["PocoLoco"] = "Poco Loco";
        //descriptions["TabooTV"] = "Taboo TV";
        //descriptions["Telsev"] = "Telsev";
        //descriptions["Typhoon"] = "Typhoon";        
        
        //descriptions["Package1"] = "Package 1: YouPorn Honeys + Super Marino's Road Trips + Johnny Rebel";
        //descriptions["Package2"] = "Package 2: Legal Pink + Typhoon + Diablo";
        
        return descriptions[cname];
    }
    else {
        return cname;   
    }    
}

function channelSuggestions(channel) {
    if (channel) {
        var arrSuggestions = new Array();
//        arrSuggestions["AdultLive"] = "";
//        arrSuggestions["Diablo"] = "H2,Telsev,Pumpkin";
//        arrSuggestions["DigitalSinNewSensations"] = "Visage,Vivid,MatrixHD";
//        arrSuggestions["H2"] = "PureXXX,Pumpkin,Typhoon";
//        arrSuggestions["Harmony"] = "Vivid,MatrixHD,Private";
//        arrSuggestions["LegalPink"] = "MatrixHD,Visage,YouPornHoneys";
//        arrSuggestions["MatrixHD"] = "Harmony,Visage,DigitalSinNewSensations";
//        arrSuggestions["Private"] = "Vivid,Harmony,MatrixHD";
//        arrSuggestions["Pumpkin"] = "Relish,PureXXX,SuperMarino";
//        arrSuggestions["PureXXX"] = "Pumpkin,Relish,XplicitXXX";
//        arrSuggestions["Relish"] = "Pumpkin,PureXXX,Harmony";
//        arrSuggestions["SuperMarino"] = "Pumpkin,H2,Diablo";
//        arrSuggestions["Visage"] = "MatrixHD,DigitalSinNewSensations,Relish";
//        arrSuggestions["Vivid"] = "Private,Harmony,MatrixHD";
//        arrSuggestions["XplicitXXX"] = "Relish,PureXXX,Pumpkin";
//        arrSuggestions["YouPornHoneys"] = "LegalPink,H2,PureXXX";
//        arrSuggestions["Dom"] = "TabooTV,LoadXXXGrannies,PocoLoco";
//        arrSuggestions["JohnnyRebel"] = "PocoLoco,Pumpkin,Telsev";
//        arrSuggestions["LoadXXXGrannies"] = "Telsev,PocoLoco,Dom";
//        arrSuggestions["LoadXXXRentBoy"] = "";
//        arrSuggestions["PocoLoco"] = "Telsev,Typhoon,JohnnyRebel";
//        arrSuggestions["TabooTV"] = "Dom,LoadXXXGrannies,Telsev";
//        arrSuggestions["Telsev"] = "JohnnyRebel,PocoLoco,Typhoon";
//        arrSuggestions["Typhoon"] = "Telsev,JohnnyRebel,TabooTV";        

//        arrSuggestions["Package1"] = "LegalPink,Pumpkin,PocoLoco";
//        arrSuggestions["Package2"] = "MatrixHD,Telsev,H2";

        return arrSuggestions[channel];
    }
    else {
        return "";
    }
}

function currencySymbol(currency) {
    csr = "$";
    if (currency) {
        var cs = Array();
        cs["SMS"] = "&pound;";
        cs["GBP"] = "&pound;";
        cs["EUR"] = "&euro;";
        cs["USD"] = "$";
        csr = cs[currency];
    }
    return csr;
}

function cleanCheckboxes() {
    chk1 = document.getElementById("ctl00_MainContentPlaceHolder_SignUpCheckBox");
    chk2 = document.getElementById("ctl00_MainContentPlaceHolder_PackageCheckBox");
    if (chk1) {
        chk1.checked = false;
    }
    if (chk2) {
        chk2.checked = false;
    }    
}

function addFlashMoviePlayer(objId, objMovie, objWidth, objHeight, objClass, objLogo, objImage, objLink, objAutoStart, objLinkFromDisplay, objShowBar) {
    // Required parameters: objId, objMovie, objWidth, objHeight
    var playerId = "";
    playerId = "mpswf_" + objId;    
    document.write('<div id="' + objId + '" class="' + objClass + '">');
    var objLocation = location.href.substr(0, location.href.lastIndexOf('/') + 1);
    var so = new SWFObject('flash/MediaPlayer.swf', playerId, objWidth, objHeight, '7');    
    so.addParam('allowfullscreen','true'); 
    so.addParam('allowscriptaccess','always'); 
    so.addVariable('javascriptid',playerId);
    so.addVariable('autostart',objAutoStart);
    so.addVariable('showdigits','false');
    // Local file or stream?
    if (objMovie.substr(0,4) == "http" || objMovie.substr(0,3) == "mms") {
        so.addVariable('file',objMovie); 
    }
    else {
        so.addVariable('file',objLocation + objMovie); 
    }
    if (objImage) {
        so.addVariable('image',objLocation + objImage);     
    }
    so.addVariable('height',objHeight);
    so.addVariable('width',objWidth);
    so.addVariable('backcolor','0x222222');
    so.addVariable('frontcolor','0x000000');
    so.addVariable('lightcolor','0x3995AF');
    if (objLogo) {    
        so.addVariable('logo',objLocation + objLogo); 
    }
    so.addVariable('enablejs','true');
    if (objLink) {
        so.addVariable('link',objLocation + objLink);    
    }
    so.addVariable('linkfromdisplay',objLinkFromDisplay);    
    so.addVariable('shownavigation',objShowBar);
    so.write(objId);
    playerId = document.getElementById(playerId);
    document.write('</div>');    
}

function initWMP(objID, objStream, objWidth, objHeight) {
    if (objStream) {
        objID = (objID) ? objID : "MyWMP";
        objWidth = (objWidth) ? objWidth : "664";
        objHeight = (objHeight) ? objHeight : "418";
        document.writeln("<object id='" + objID + "' type='video/x-ms-wvx' data='" + objStream + "' width='" + objWidth + "' height='" + objHeight + "'>");
        document.writeln("<param name='src' value='" + objStream + "' />");
        document.writeln("<param name='uiMode' value='none' />");
        document.writeln("<param name='width' value='" + objWidth + "' />");
        document.writeln("<param name='height' value='" + objHeight + "' />");
        document.writeln("<param name='controller' value='true' />");
        document.writeln("<param name='controller' value='1' />");
        document.writeln("<param name='autoStart' value='true' />");
        document.writeln("<param name='autoStart' value='1' />");
        document.writeln("<param name='allowChangeDisplaySize' value='true' />");
        document.writeln("<param name='allowChangeDisplaySize' value='1' />");
        document.writeln("<param name='transparentatStart' value='true' />");
        document.writeln("<param name='transparentatStart' value='1' />");
        document.writeln("<param name='animationatStart' value='false' />");
        document.writeln("<param name='animationatStart' value='0' />");
        document.writeln("<param name='showControls' value='false' />");
        document.writeln("<param name='showControls' value='0' />");
        document.writeln("<param name='showStatusBar' value='false' />");
        document.writeln("<param name='showStatusBar' value='0' />");
        document.writeln("<param name='autoSize' value='false' />");
        document.writeln("<param name='autoSize' value='0' />");
        document.writeln("<param name='displaySize' value='false' />");
        document.writeln("<param name='displaySize' value='0' />");
        document.writeln("</object>");
    }
}