function getQueryStringVal(param) {
    // get the pairs of params fist
    var pairs = location.search.substring(1).split('&');
    // now iterate each pair
    for (var i = 0; i < pairs.length; i++) {
        var params = pairs[i].split('=');
        if (params[0].toLowerCase() == param.toLowerCase()) {
            // if the param doesn't have a value, like ?photos&videos, then return an empty srting
            return params[1] || '';
        }
    }
    //otherwise return undefined to signify that the param does not exist
    return undefined;
};




//Filmstrip
function FilmstripShowView(showId) {
    FilmstripShowView2(showId, true);
}

function FilmstripShowView2(showId, clearPager) {
    //Clear interval
    if (clearPager && filmstripInterval != null)
        window.clearInterval(filmstripInterval);

    //Get object to show, do nothing if visible
    var showObj = $("#" + showId);
    if (showObj.is(":visible"))
        return;

    //Hide all elements in parent
    var parent = showObj.parent();
    for (i = 0; i < parent.children().length; i++) {
        var obj = parent.children(":nth-child(" + (i + 1) + ")");
        if (obj != showObj && obj.is(":visible"))
            obj.fadeOut();
    }

    //Show showObj
    if (!showObj.is(":visible"))
        showObj.fadeIn();
}

var filmstripInterval = null;
function FilmstripSetInterval(parentId, delay) {
    filmstripInterval = window.setInterval("FilmstripShowNext('" + parentId + "')", delay);
}

function FilmstripShowNext(parentId) {
    //Find object to show
    var parent = $("#" + parentId);
    var allControls = parent.children().length;
    var showObj = null;

    for (i = 0; i < allControls; i++) {
        //Get next object after the first visible object
        //Get the first object if the last objet is the visible one
        var obj = parent.children(":nth-child(" + (i + 1) + ")");
        if (obj.is(":visible")) {
            if (i < allControls - 1)
                showObj = parent.children(":nth-child(" + (i + 2) + ")");
            else
                showObj = parent.children(":first-child");
        }

        //Use first obj if no object found
        if (showObj == null)
            showObj = parent.children(":first-child");
    }

    //Show object
    FilmstripShowView2(showObj.attr('id'), false);
}

//ProductConfig
//Define ProductConfigHelper class
function ProductConfigHelper(pcPID, pcProductConfigurationType, pcCanvasBarType, pcCanvasStretchType, pcCanvasFinishType, pcCanvasMaterialType, pcCanvasPaintedSideColor, pcPlaqueBoardType, pcPlaqueColorType, pcCroppingOptions) {
    this.pid = pcPID;
    this.productConfigurationType = pcProductConfigurationType;
    this.canvasBarType = pcCanvasBarType;
    this.canvasStretchType = pcCanvasStretchType;
    this.canvasFinishType = pcCanvasFinishType;
    this.canvasMaterialType = pcCanvasMaterialType;
    this.canvasPaintedSideColor = pcCanvasPaintedSideColor;
    this.plaqueBoardType = pcPlaqueBoardType;
    this.plaqueColorType = pcPlaqueColorType;
    this.croppingOptions = pcCroppingOptions;
}
ProductConfigHelper.prototype.toQueryString = function () {
    //Make sure all properties are not null
    if (this.pid == null) this.pid = -1;
    if (this.productConfigurationType == null) this.productConfigurationType = -1;
    if (this.canvasBarType == null) this.canvasBarType = -1;
    if (this.canvasStretchType == null) this.canvasStretchType = -1;
    if (this.canvasFinishType == null) this.canvasFinishType = -1;
    if (this.canvasMaterialType == null) this.canvasMaterialType = -1;
    if (this.canvasPaintedSideColor == null || this.canvasPaintedSideColor == "") this.canvasPaintedSideColor = "none";
    if (this.plaqueBoardType == null) this.plaqueBoardType = -1;
    if (this.plaqueColorType == null) this.plaqueColorType = -1;
    if (this.croppingOptions == null) this.croppingOptions = -1;

    //Build querystring
    var qs = "pid=" + this.pid + "&" +
				"c=" + this.productConfigurationType + "&" +
				"cb=" + this.canvasBarType + "&" +
				"cs=" + this.canvasStretchType + "&" +
				"cf=" + this.canvasFinishType + "&" +
				"cm=" + this.canvasMaterialType + "&" +
				"cp=" + this.canvasPaintedSideColor + "&" +
				"pb=" + this.plaqueBoardType + "&" +
				"pc=" + this.plaqueColorType + "&" +
				"co=" + this.croppingOptions;
    return qs;
}

function btnSearch_onclick() {
    return true;
}
