﻿function StartYbBanner(path) {
    JQ.ajax({
        type: "GET",
        url: path + "/YBBanner.xml",
        dataType: "xml",
        success: function (xml) {
            var images = GetNodesVal(xml, "image", "name");

            for (var i = 0; i < images.length; i++) {
                var ybbnrpth = path + "/imgs/" + images[i];
                JQ(".slideshow").append("<img src='" + ybbnrpth + "' style='z-index:" + (images.length - i) + "' />");
            }
            JQ(document).ready(function () { JQ('.slideshow').cycle({ delay: 500, speed: 500 }); });
        }
    });    
}


function GetNodesVal(xmlDoc, nodeName, attrValue) {
    var i = 0, retValue = new Array();
    JQ(xmlDoc).find(nodeName).each(function () {
        if (JQ(this).attr(attrValue) != undefined) { retValue[i] = JQ(this).attr(attrValue); i++; }
    });
    return retValue;
}


function GetNodeVal(xmlDoc, nodeName, attrValue) {
    var retValue;
    JQ(xmlDoc).find(nodeName).each(function () {
        if (JQ(this).attr(attrValue) != undefined) {
            retValue = JQ(this).attr(attrValue); return false;
            //return false means we break the foreach loop. simple return would mean 'continue' loop            
        }
    });
    return retValue;
}
