//
// Copyright 2009 innovation5 technologies
// Unauthorized distribution or modification prohibited
//

function redir(a) {
	switch(a) {
		case "SMB": 
		  window.location = "/small_business";
		  break;
		case "BUS": 
		  window.location = "/business";
		  break;
		case "NPO": 
		  window.location = "/non_profit";
		  break;
		default: alert("case select failed");
	};
};

function SelectType() {$.fn.colorbox({inline:true, href:"#ServiceChoice", open:true, title:"Select the option that fits you best."});};

function Cookies(){
	var cookieEnabled=(navigator.cookieEnabled)? true : false
	//if not IE4+ nor NS6+
	if (typeof navigator.cookieEnabled=="undefined" && !cookieEnabled){ 
	document.cookie="testcookie"
	cookieEnabled=(document.cookie.indexOf("testcookie")!=-1)? true : false
	}
	 return cookieEnabled;
};

function setCookie(c_name,value,expiredays) {
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
};

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
};

function SetType(b){
	var enabled = Cookies();
	if(enabled){
		setCookie('busType',b,7);
		redir(b);
	} else {
		redir(b);
	}
};

function CheckType(){
	var enabled = Cookies();
	var btype = getCookie('busType');
	
	if (enabled) {
			if (btype){
				redir(btype);
			} else {
				SelectType();
			}
		} else {
			SelectType();
		}
};