// Javascript by Specific Impulse, Inc.

// Sets cookie values (generic).

function setCookie(name, value, expires, path, domain, secure) {
	document.cookie = name + "=" + escape(value) +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");

}


function setParams(myParameters) {
	  var today = new Date()
	  var expires = new Date()
	  expires.setTime(today.getTime() + 1000*60*60*24*90) //90 days
	  setCookie("sotracking", myParameters, expires, "/");
}


// Determines which landing page the visitor used to enter the promo page

function whereFrom(landing_page) {
	  var today = new Date()
	  var expires = new Date()
	  expires.setTime(today.getTime() + 1000*60*60*24*90) //90 days
	  setCookie("solanding", landing_page, expires, "/");
}


// The following function returns a cookie value, given the name of the cookie

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 notify() {
	if (location.search) {
		searchstring = location.search;
		alert(searchstring);
		mypage=location.href;
		alert(mypage);
	}
	else {
		alert("no string present")
	}
}

function showCookie() {
  	if (getCookie('sotracking')) {
		foo = getCookie('sotracking')
		alert("cookie is: " + foo)
	}
}




