<!--

// ----------------------------------------------
// StyleSwitcher functions written by Paul Sowden
// http://www.idontsmoke.co.uk/ss/
// - - - - - - - - - - - - - - - - - - - - - - -
// For the details, visit ALA:
// http://www.alistapart.com/stories/alternate/

function setActiveStyleSheet(title) {
  var i, a, main;
  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;
    }
  }
}

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);

// Membership

function getCookie(Name) {
	var search = Name + "="
	if (document.cookie.length > 0) { // if there are any cookies
		offset = document.cookie.indexOf(search) 
		if (offset != -1) { // if cookie exists 
			offset += search.length 
			// set index of beginning of value
			end = document.cookie.indexOf(";", offset) 
			// set index of end of cookie value
			if (end == -1) 
				end = document.cookie.length
			return unescape(document.cookie.substring(offset, end))
		} 
	}
}

function showLogin(loginpage, whereami) {
  var cookie=getCookie("fc_firstname");
  if (cookie) {
    //var cookiep=getCookie("inc_perm");
    document.write('<p id="unlocked">Hi '+cookie+'. <a href="http://www.fastcompany.com/mbr/profile/fc/main?origin='+whereami+'">View Your Profile</a> | <a href="http://www.fastcompany.com/mbr/logout/fc/main?origin='+whereami+'">Sign Off</a></p>');
  } else {
    document.write('<p id="locked"><a href="http://www.fastcompany.com/mbr/login/fc/main?origin='+whereami+'">Members sign in</a> | Not a member? <a href="http://www.fastcompany.com/mbr/profile/fc/main?origin='+whereami+'">Sign up</a></p>');
  }
}

// Company of Friends functions

function showLoginCoF(whereami) {
  var cookie=getCookie("fc_firstname");
  if (cookie) {
    //var cookiep=getCookie("inc_perm");
    document.write('<p id="unlocked">Hi '+cookie+'. <a href="http://www.fastcompany.com/mbr/profile/fc/cof?origin='+whereami+'">View Your Profile</a> | <a href="http://www.fastcompany.com/mbr/logout/fc/cof?origin='+whereami+'">Sign Off</a></p>');
  } else {
    document.write('<p id="locked"><a href="http://www.fastcompany.com/mbr/login/fc/cof?origin='+whereami+'">Members sign in</a> | Not a member? <a href="http://www.fastcompany.com/mbr/profile/fc/cof?origin='+whereami+'">Sign up</a></p>');
  }
}

function launch_bizcard(id) {
   bizCard = window.open('http://www.fastcompany.com/cof/business_card.jsp?id='+id,'bizcard','dependent=yes,directories=no,height=550,width=550,hotkeys=no,location=no,menubar=no,personalbar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
   bizCard.focus();
}

function launch_bizcard_from_lyrisid(id) {
   bizCard = window.open('http://www.fastcompany.com/cof/business_card.jsp?lyrisid='+id,'bizcard','dependent=yes,directories=no,height=550,width=550,hotkeys=no,location=no,menubar=no,personalbar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
   bizCard.focus();
}

function launch_search_page() {
   searchPage = window.open('http://www.fastcompany.com/cof/member_search.jsp?nowrap=1','search','dependent=yes,directories=no,height=550,width=500,hotkeys=no,location=no,menubar=no,personalbar=no,resizable=yes,scrollbars=yes,status=yes,toolbar=no');
   searchPage.focus();
}

// end CoF functions

// Breadcrumb

function lastGuide() {
	var last_guide = "last_guide="
	if (document.cookie.length > 0) { // if there are any cookies
		offset = document.cookie.indexOf(last_guide) 
		if (offset != -1) { // if cookie exists 
			offset += last_guide.length 
			// set index of beginning of value
			end = document.cookie.indexOf(";", offset) 
			// set index of end of cookie value
			if (end == -1) 
				end = document.cookie.length
			return unescape(document.cookie.substring(offset, end))
		} 
		else { return ""; }
	}
	else { return ""; }
}

// Div toggle

function toggle( targetId ){
  if (document.getElementById){
  		target = document.getElementById( targetId );
  			if (target.style.display == "none"){
  				target.style.display = "";
  			} else {
  				target.style.display = "none";
  			}
  	}
}

// Featured Services

function showFeatured() {
    document.write('<ul class="styled">');
   	document.write('<li><strong>Microsoft</strong> <a href="http://www.inc.com/partners/businessinsights/">Visit the New Business Insight Center on Inc.com</a></li>');
	document.write('<li><strong>ClassesUSA</strong> <a href="http://trax.fastcompany.com/k/w/featuredserv/classesusa">Find an Online Degree Program from an Accredited University.</a></li>');
	document.write('<li><strong>Business.com</strong> <a href="http://trax.fastcompany.com/k/w/featuredserv/bcom">Directory of 400,000+ cataloged business-oriented web sites.</a></li>');
	document.write('<li><strong>Oracle</strong> <a href="http://trax.fastcompany.com/k/w/oracle/microsite">Visit the Business Challenges Center sponsored by Oracle.</a></li>');
	document.write('<li><strong>Google AdSense</strong> <a href="http://www.google.com/getadsense">Dollars and Sense: Earn money serving ads that are relevant to your content.</a></li>');
	document.write('<li><strong>IBM</strong> <a href="http://ad.doubleclick.net/clk;6634148;8625337;r?http://www.ibm.com/software/smb/retail6">Middleware is Everywhere.  See it with IBM software</a></li>');
	document.write('<li><strong>IBM How I Did It</strong> <a href="http://trax.inc.com/k/w/howididit">How do you grow a business 12,753&? Find out at How I Did It.</a></li>');
	document.write('<li><strong>American Airlines</strong> <a href="http://trax.inc.com/k/w/americanairlines/textlink">Next time, fly American. More flights to fit your needs.</a></li>');
	document.write('<li><strong>Microsoft</strong> <a href="http://trax.fastcompany.com/k/w/services/ms-secure-depend">Get your free eSecurity Guide for Small Business CD from Microsoft today</a></li>');
	document.write('</ul>');
}
//-->
