function InitSlideShow(strContID, strTabCs, strItemCs) {
    var TabLinks = $('#' + strContID + " h2.tablink a");
    var OpacityItems = $('#' + strContID + " .overlay");
    try {
        for (var i = 0; i < TabLinks.length; i++) {
            if (TabLinks[i].getAttribute('href') != null) {
                TabLinks[i].setAttribute('href', '#x');
                TabLinks[i].onclick = function() {
                ChangeImg(this.rel, strContID, strTabCs, strItemCs);
                }
            }
        }
    }
    catch (err) {
        //alert(err + " - This is casued by the link re-writer, there are no links to find in the paramater element");
    }
    // Add opacity to overlay dynamically (otherwise CSS will be invalid)
    opasatise("", '#' + strContID + " .overlay", 50);
    opasatise("", '#' + strContID + " .slide h3", 65);
    // Activate the controls
    var pasuebtn = $get('slidepause');
    var nxtbtn = $get('slidenext');
    var prebtn = $get('slidepre');
    pasuebtn.onclick = function() { pauseSlide(strContID); }
    nxtbtn.onclick = function() { moveSlide(strContID, true); }
    prebtn.onclick = function() { moveSlide(strContID, false); }
}

function opasatise(strObjID, strSelForArray, intOpLv) {
    if (strObjID != "") {
        var objItem = $get(strObjID);
        objItem.setAttribute("style", "opacity:0." + intOpLv + ";");
        if (objItem.style.setAttribute) { //For IE
            objItem.style.setAttribute("filter", "alpha(opacity=" + intOpLv + ");");
        }
    }
    if (strSelForArray != "") {
        var ArrItems = $(strSelForArray);
        for (var i = 0; i < ArrItems.length; i++) {
            var oe = ArrItems[i];
            oe.setAttribute("style", "opacity:0." + intOpLv + ";")
            if (oe.style.setAttribute) //For IE
                oe.style.setAttribute("filter", "alpha(opacity=" + intOpLv + ");")
        }
    }
}


function pauseSlide(strContID) {
}
function moveSlide(strContID, bolIsNext) {
    // get an array of active slides
    var ImageSet = $('#' + strContID + " .active div.slide");
    // get ID of active slide image
    var ActiveImg = $('#' + strContID + " .active .visible")[0];
    //alert("ActiveImg=" + ActiveImg.id + " ImageSet.length=" + ImageSet.length)
    // find the item to show next
    var ItemToShow = null;
    for (i = 0; i < ImageSet.length; i++) {
        //alert("i=" + i + " ImageSet.length=" + ImageSet.length + " ImageSet[i].id=" + ImageSet[i].id + " ActiveImg.id=" + ActiveImg.id);
        if (ImageSet[i].id == ActiveImg.id) {
            if (bolIsNext) {
                if (i == ImageSet.length) {
                    ItemToShow = ImageSet[0];
                    //alert("1");
                }
                else {
                    ItemToShow = ImageSet[(i + 1)];
                    //alert("2");
                }
            }
            else {
                if (i == 0) {
                    ItemToShow = ImageSet[(ImageSet.length)];
                    //alert("3");
                }
                else {
                    ItemToShow = ImageSet[(i - 1)];
                    //alert("4");
                }
            }
            break;
        }
    }
    //opasatise(ItemToShow.id, "", 00)
    //ItemToShow.fadeIn(250);
    //$('#' + ItemToShow.id).fadeIn(250);
    //$('#' + ActiveImg.id).fadeOut(250, function () {
        ActiveImg.className = 'slide hidden';
        //$('#' + ItemToShow.id).fadeIn(250, function () {
            ItemToShow.className = 'slide visible';
        //})
    //})
}


// Function to change tabs
function ChangeImg(tcmid, strContID, strTabCs, strItemCs) {
    var Tab = $('#' + strContID + " ." + strTabCs);
    var TabImages = $('#' + strContID + " ." + strItemCs);
    var ControlContain = $get('ssctrl');
    var ActiveTabClientID = ""

    for (i = 0; i < Tab.length; i++) {
        var EleID = Tab[i].id;
        Tab[i].className = 'htmlslide';
        if ((EleID.indexOf(tcmid) != -1)) {
            Tab[i].className = 'htmlslide active';
            ActiveTabClientID = EleID;
        }
    }
    for (i = 0; i < TabImages.length; i++) {
        TabImages[i].className = 'slide hidden';
    }
    var ActiveTabImages = $('#' + ActiveTabClientID + " ." + strItemCs);
    try {
        ActiveTabImages[0].className = 'slide visible';
        if (ActiveTabImages.length > 1) {
            //ControlContain.className = 'visible';
        }
    }
    catch (err) {}
}
