﻿/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
these are generic functions that pass data to
the swfobject library to write flash modules
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
generic write flash to div id=flashcontent
*/
function displayFlash(swfSrc, swfName, swfW, swfH, swfVer, swfBg) {
	var so = new SWFObject("media/" + swfSrc, swfName, swfW, swfH, swfVer, swfBg);
    so.addParam("allowScriptAccess", "always");
    if (isFlash) {
        so.addParam("allowFullScreen", "true");
        so.addParam("wmode", "transparent");
        so.write("flashcontent");
    }
}
/*
generic write flash to any div using swfLocation
*/
function displayFlash2(swfLocation, swfSrc, swfName, swfW, swfH, swfVer, swfBg) {
	var so = new SWFObject(swfSrc, swfName, swfW, swfH, swfVer, swfBg);
    so.addParam("allowScriptAccess", "always");
    if (isFlash) {
        so.addParam("wmode", "transparent");
        so.addParam("allowFullScreen", "true");
        so.write(swfLocation);
    }
}
/*
generic write flash to div any div using swfLocation + pass variable name=value for addVariable
*/
function displayFlash3(swfLocation, swfSrc, swfName, swfW, swfH, swfVer, swfBg, swfVarName, swfVarValue) {
	var so = new SWFObject(swfSrc, swfName, swfW, swfH, swfVer, swfBg);
    so.addParam("allowScriptAccess", "always");
    so.addVariable(swfVarName, swfVarValue);
    if (isFlash) {
        so.addParam("allowFullScreen", "true");
        so.addParam("wmode", "transparent");
        so.write(swfLocation);
    }
}

//transparency
function displayFlash4(swfLocation, swfSrc, swfName, swfW, swfH, swfVer, swfBg) {
	var so = new SWFObject(swfSrc, swfName, swfW, swfH, swfVer, swfBg);
    so.addParam("allowScriptAccess", "always");
    if (isFlash) {
        so.addParam("wmode", "transparent");
        so.addParam("allowFullScreen", "true");
        so.write(swfLocation);
    }
}

//************************************************************
// cookies
// Derived from the Bill Dortch code at http://www.hidaho.com/cookies/cookie.txt
//************************************************************

function expDays(howMany) {
	var today = new Date();
	var expiry = new Date(today.getTime() + howMany * 24 * 60 * 60 * 1000);
	return expiry;
}

function getCookieVal(offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1) { endstr = document.cookie.length; }
	return unescape(document.cookie.substring(offset, endstr));
}

function getCookie(name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) {
			return getCookieVal (j);
		}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break; 
	}
	return null;
}

function deleteCookie(name,path,domain) {
	if (GetCookie(name)) {
		document.cookie = name + "=" +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

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" : "");
}
