﻿function SetUniqueRadioButton(nameregex, current) {
    re = new RegExp(nameregex);
    for (i = 0; i < document.forms[0].elements.length; i++) {
        elm = document.forms[0].elements[i]
        if (elm.type == 'radio') {
            if (re.test(elm.name)) {
                elm.checked = false;
            }
        }
    }
    current.checked = true;
}

//function sliceText(text, id) {
//    var v = document.getElementById(id);
//    if (text.length > 50) {
//        text = text.slice(0, 50);
//        text += "...";
//    }
//    v.innerHTML = text;
//}

//returns querystrings in array
function getYearIndex()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');

    for(var i = 0; i < hashes.length; i++) {
        hash = hashes[i].split('=');

        vars.push(hash[0]);

        vars[hash[0]] = hash[1];
    }
    var year = vars["Year"];
    for(var j=0;j<count;j++) {
        if (year == years[j]) {
            return j+ 1;
        }
    }
}
function getCategoryIndex() {
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');

    for (var i = 0; i < hashes.length; i++) {
        hash = hashes[i].split('=');

        vars.push(hash[0]);

        vars[hash[0]] = hash[1];
    }
    var category = vars["category"];
    return category;
}

var years = [];
var count=0;
function setYear(year) {
    years[count] = year;
    count++;    
}