
 





/* SHOW/HIDE */

function show(id)

{

	d = document.getElementById(id);

	d.style.display = "block";

}



function hide(id)

{

	d = document.getElementById(id);

	d.style.display = "none";

}

function rrtoggle(id)
{
	ele = document.getElementById(id);
	stl = ele.style.display;
	if (stl == 'none')
	{
		ele.style.display = 'block';
	} else {
		ele.style.display = 'none';
	}
}



//STYLE SWITCHER//


function setActiveStyleSheet(title) {
  var i, a, styles;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
 // alert('ssd');
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}




function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);

function globalNavCheck (){
	var yeti = readCookie("style");
	//alert(yeti);
	
	if (document.yeti  == "styles" ){
		show('textSm');hide('textMd');hide('textLg');
	}
	
	if (yeti  == "styles+" ){
		show("textMd");hide('textSm');hide('textLg');
	}
	
	if (yeti  == "styles++" ){
		show("textLg");hide('textMd');hide('textSm');
	}	
	
		
}

//jquery extension to get querystring values
$.extend({
    getUrlVars: function () {
        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];
        }
        return vars;
    },
    getUrlVar: function (name) {
        return $.getUrlVars()[name];
    }
});

/* Seminars */
function goToSeminars(zip) {
    window.location = 'seminars.html?zipcode=' + zip;
}

function isZip(s) {
    // Check for correct zip code
    reZip = new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/);
    if (!reZip.test(s)) {
        return false;
    }
    return true;
}


