// JavaScript Document
var hpflashCookie = "citationhp";

function cookieDelete(name){
	var expdate = new Date ();
	expdate.setTime = expdate.getTime()-1;
	document.cookie = name + "=; path='/'; expires=" + expdate.toGMTString();
}

function cookieRead(Name){
	var cookieValue = "";
	var search = Name + "=";
	if(document.cookie.length > 0){ 
		offset = document.cookie.indexOf(search);
		if (offset != -1){ 
			offset += search.length;
			end = document.cookie.indexOf(";", offset);
			if (end == -1)
				end = document.cookie.length;
			cookieValue = unescape(document.cookie.substring(offset, end))
		}
	}
	return cookieValue;
}

function cookieWrite(Name, Value, Hours){
	var expire = "";
	if(Hours != null){
		expire = new Date((new Date()).getTime() + Hours * 3600000);
		expire = "; expires=" + expire.toGMTString();
	}
	document.cookie = Name + "=" + escape(Value) + expire;
}

function cookieWriteFull(name, value, expires, path, domain, secure) {
	var curCookie = name + "=" + escape(value) +
	((expires) ? "; expires=" + expires.toGMTString() : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
	document.cookie = curCookie;
}

//Cross Browser Object Retrieval
function getObject(objectID){
	if (document.all!=null){
		return document.all[objectID];
	} else if (document.getElementById){
		return document.getElementById(objectID);
	}
}

function toggleHomePage(){
	var flashVersion = getObject("flashContent");
	var htmlVersion = getObject("htmlContent");
	if (cookieRead(hpflashCookie) == ""){
		htmlVersion.style.display = "none";
		flashVersion.style.display = "block";
		cookieWriteFull(hpflashCookie, "viewed");
	} else {
		htmlVersion.style.display = "block";
		flashVersion.style.display = "none";
	}
}
