
$(document).ready(function(){
				
	$("#tavlingslista").bind('change', function() {
		location.href = "avslutade-tavlingar.html?t="+$(this).val(); 
	});
	
});

function rgb2hex(rgb)
{
	if(!rgb.match(/^rgb/i)){return rgb;}

  rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
  function hex(x)
  {
    hexDigits = new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");
    return isNaN(x) ? "00" : hexDigits[(x - x % 16) / 16] + hexDigits[x % 16];
  }
  return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
}

function strpos(haystack, needle, offset)
{
	var i = (haystack+'').indexOf(needle, (offset ? offset : 0));
	return i === -1 ? false : i;
}

function substr(str, start, len)
{
    str += '';
    var end = str.length;
    if (start < 0)
    {
    	start += end;
    }
    end = typeof len === 'undefined' ? end : (len < 0 ? len + end : len + start);
    return start >= str.length || start < 0 || start > end ? !1 : str.slice(start, end);
}

function htmlspecialchars(string, quote_style, charset, double_encode)
{
  var optTemp = 0, i = 0, noquotes= false;
  if (typeof quote_style === 'undefined' || quote_style === null) {        quote_style = 2;
  }
  string = string.toString();
  if (double_encode !== false) { // Put this first to avoid double-encoding
      string = string.replace(/&/g, '&amp;');    }
  string = string.replace(/</g, '&lt;').replace(/>/g, '&gt;');

  var OPTS = {
      'ENT_NOQUOTES': 0,        'ENT_HTML_QUOTE_SINGLE' : 1,
      'ENT_HTML_QUOTE_DOUBLE' : 2,
      'ENT_COMPAT': 2,
      'ENT_QUOTES': 3,
      'ENT_IGNORE' : 4    };
  if (quote_style === 0) {
      noquotes = true;
  }
  if (typeof quote_style !== 'number') { // Allow for a single string or an array of string flags        quote_style = [].concat(quote_style);
      for (i=0; i < quote_style.length; i++) {
          // Resolve string input to bitwise e.g. 'PATHINFO_EXTENSION' becomes 4
          if (OPTS[quote_style[i]] === 0) {
              noquotes = true;            }
          else if (OPTS[quote_style[i]]) {
              optTemp = optTemp | OPTS[quote_style[i]];
          }
      }        quote_style = optTemp;
  }
  if (quote_style & OPTS.ENT_HTML_QUOTE_SINGLE) {
      string = string.replace(/'/g, '&#039;');
  }    if (!noquotes) {
      string = string.replace(/"/g, '&quot;');
  }

  return string;
}

function validateEmail(elementValue)
{
	var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;  
	return emailPattern.test(elementValue);
}


