﻿/*** LSO "Proxy" JS Code - Flash "Cookies" - Search for "LSOProxy" in this project for more info - By: Dan L. - 2009-05-19 ***/
function addLsoProxyToPage() {
	if (swfobject && !getMovieName("LSOProxy")) {
		var flashvars = {};
		var params = {};
		var attributes = {};

		swfobject.embedSWF("LSOProxy.swf", "LSOProxyContainer", "1", "1", "8.0.0", "LSOProxy.swf", flashvars, params, attributes);
	}
}
function initializeLsoFlash() {
	if (!swfobject) { alert("DEVELOPER NOTE: Add a script reference to:\nhttp://ajax.googleapis.com/ajax/libs/swfobject/2.1/swfobject.js"); }
	if (!$("LSOProxyContainer")) {
		$$("body")[0].insert("<div id=\"LSOProxyContainer\"></div>\n" +
		"<s" + "cript type=\"text/javascript\">addLsoProxyToPage();</s" + "cript>\n");
	}
}
/*** LSO "Proxy" JS Code - Flash "Cookies" - Search for "LSOProxy" in this project for more info - By: Dan L. - 2009-05-19 ***/
function setLsoCookie(name, value) {
	return $("LSOProxyContainer").setCookie(name, value);
	//Old: return getMovieName("LSOProxy").setCookie(name, value);
}
function getLsoCookie(name) {
	//Old: var cookieData = getMovieName("LSOProxy").getCookie(name);
	var cookieData = $("LSOProxyContainer").getCookie(name);
	return cookieData;
}
function getMovieName(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	} else {
	return document[movieName];
	}
}




/******************************************************************************
 qForm JSAPI: Cookie Library

 Author: Dan G. Switzer, II
 Build:  105
******************************************************************************/
// initialize workspace variables
var _c_dToday = new Date();
var _c_iExpiresIn = 90;
var _c_strName = self.location.pathname;

/******************************************************************************
 Required Functions
******************************************************************************/
// retrieve a cookie from the browser
function _getCookie(name){
	var iStart = document.cookie.indexOf(name + "=");
	var iLength = iStart + name.length + 1;
	if( (iStart == -1) || (!iStart && (name == document.cookie.substring(0)) ) ) return null;
	var iEnd = document.cookie.indexOf(";", iLength);
	if( iEnd == -1 ) iEnd = document.cookie.length;
	return unescape(document.cookie.substring(iLength, iEnd));
}

// set a cookie to the browser
/* Note: Only "name" and "value" are required parameters */
function _setCookie(name, value, expires, path, domain, secure) {
	//if (!expires) {expires = new Date(); expires = expires.setFullYear(2020, 01);}
	var d = new Date();
  d.setFullYear(d.getFullYear() + 1);
	//alert("d: " + d + "\n d.toUTCString: " + d.toUTCString());
	//alert("expires: " + expires + "\n expires.toUTCString: " + expires.toUTCString());
	
	document.cookie = name + "=" + escape(value) + 
	( (d) ? ";expires=" + d.toGMTString() : "") +
	( (path) ? ";path=" + path : "") + 
	( (domain) ? ";domain=" + domain : "") +
	( (secure) ? ";secure" : "");
	//alert("document.cookie: " + document.cookie + "\n====\n" + document.cookie.length);
}

function _deleteCookie(name, path, domain){
	if (_getCookie(name)) document.cookie = name + "=" +
		( (path) ? ";path=" + path : "") +
		( (domain) ? ";domain=" + domain : "") +
 		";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function _createCookiePackage(struct){
	var cookie = "";
	for( key in struct ){
		if( cookie.length > 0 ) cookie += "&";
		cookie += key + ":" + escape(struct[key]); 
	}
	return cookie;
}

function _readCookiePackage(pkg){
	struct = new Object();
	// break the package into key/value pairs
	var a = pkg.split("&");
	// loop through the array and seperate the key/value pairs
	for( i=0; i < a.length; i++ ) a[i] = a[i].split(":");
	// convert the values into a structure
	for( i=0; i < a.length; i++ ) struct[a[i][0]] = unescape(a[i][1]);
	// return the structure
	return struct;
}
















