function addtoPortfolio(NameOfCookie, value) {

setCookie(NameOfCookie, value);
cookieString = document.cookie.split("; ");
cookieCount=0;
for (i=0; i < cookieString.length; i++) { 
	cookieCount++;
}
document.getElementById('portfolioCount').innerHTML=cookieCount;
//history.go(0);
location.reload(true);

}

function loadPortfolio() {

if (document.cookie == "") {
      cookieCount = 0; 
   } else {
	cookieString = document.cookie.split("; ");
	cookieCount=0;
	for (i=0; i < cookieString.length; i++) {
		if (cookieString[i].indexOf("loggedin")) {
		cookieCount++;
		}
	}
//alert(cookieCount);
}
document.getElementById('portfolioCount').innerHTML=cookieCount;
//if (cookieCount > 0) {
//	document.getElementById('viewButton').innerHTML='<a href="my-portfolio.html"><img src="images/viewp.gif" width="85" height="19" border="0"></a>';
//}
//history.go(0);
}

function setCookie(NameOfCookie, value) {

// Three variables are used to set the new cookie. 
// The name of the cookie, the value to be stored,
// and finally the number of days until the cookie expires.
// The first lines in the function convert 
// the number of days to a valid date.

//var ExpireDate = new Date ();
//ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));

// The next line stores the cookie, simply by assigning 
// the values to the "document.cookie" object.
// Note the date is converted to Greenwich Mean time using
// the "toGMTstring()" function.
var expire_days = 5
var expire_date = new Date()
//var ms_from_now = expire_days * 24 * 60 * 60 * 1000
var ms_from_now = expire_days * 1000
expire_date.setTime(expire_date.getTime() + ms_from_now)
var expire_string = expire_date.toGMTString()

document.cookie = NameOfCookie + "=" + escape(value)+"; path=/";
}

function getCookie(NameOfCookie)
{

// First we check to see if there is a cookie stored.
// Otherwise the length of document.cookie would be zero.

if (document.cookie.length > 0) 
{ 

// Second we check to see if the cookie's name is stored in the
// "document.cookie" object for the page.

// Since more than one cookie can be set on a
// single page it is possible that our cookie
// is not present, even though the "document.cookie" object
// is not just an empty text.
// If our cookie name is not present the value -1 is stored
// in the variable called "begin".

begin = document.cookie.indexOf(NameOfCookie+"="); 
if (begin != -1) // Note: != means "is not equal to"
{ 

// Our cookie was set. 
// The value stored in the cookie is returned from the function.

begin += NameOfCookie.length+1; 
end = document.cookie.indexOf(";", begin);
if (end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(begin, end)); } 
}
return null; 

// Our cookie was not set. 
// The value "null" is returned from the function.

}

function delCookie(NameOfCookie) {

// The function simply checks to see if the cookie is set.
// If so, the expiration date is set to Jan. 1st 1970.

if (getCookie(NameOfCookie)) {
	//alert(NameOfCookie);
	var expire_days = -30
	var expire_date = new Date()
	var ms_from_now = expire_days * 24 * 60 * 60 * 1000
	expire_date.setTime(expire_date.getTime() + ms_from_now)
	var expire_string = expire_date.toGMTString()
	document.cookie = NameOfCookie + "="+"; expires="+expire_string+"; path=/";
	location.reload() 
}
}
//function checkForOpera() {

//if(navigator.userAgent.indexOf("Opera")!=-1){
//var versionindex=navigator.userAgent.indexOf("Opera")+6
//if (parseInt(navigator.userAgent.charAt(versionindex))>=8)
//alert("You are using Opera 8 or 9")
//}

