/************************************************
 * Date: 03/04/05                               *
 * Author: Luis Gonzalez                        *
 * (c) 2005 by CDP Systems. All Rights Reserved *
 ************************************************/

// var declaration
var intExpires  	= 14; 				 // Cookie expiration in days
var strLoadPage 	= "vbreminder.html"; // Virus and Backup reminder
var strWinLoadProp  = "width=500,height=405,location=no,toolbar=no,menubar=no,scrollbars=yes,resizable=no,left=20,top=20"; // Windows Properties to load
var objExpDate      = new Date();

// main code section 
objExpDate.setTime(objExpDate.getTime() + (intExpires*24*60*60*1000));

function SetCookie (strName, strValue, strExpires) { // start SetCookie
	var strCookieArgV = SetCookie.arguments; // SetCookie Argument Values
	var strCookieArgC = SetCookie.arguments.length; // SetCookie Argument Length
	var strExpDate    = (strCookieArgC > 2)? strCookieArgV[2]: null;
	var strPath       = (strCookieArgC > 3)? strCookieArgV[3]: null;
	var strDomain     = (strCookieArgC > 4)? strCookieArgV[4]: null;
	var strSecure     = (strCookieArgC > 5)? strCookieArgV[5]: false;
	
	document.cookie = strName + "=" + escape(strValue) + ((strExpDate == null)? "": ("; expires=" + strExpDate.toGMTString())) + ((strPath == null)? "": ("; path=" + strPath)) + ((strDomain == null)? "": ("; domain=" + strDomain)) + ((strSecure == null)? "; Secure": "");
} // end of SetCookie

function GetCookie (strName) { // start GetCookie
	var strCookieArg    = strName + "="; // Arguments Array
	var intCookieArgL   = strCookieArg.length; // Argument Length
	var strCookieLength = document.cookie.length; 
	var intIndex1       = 0;
	while (intIndex1 < strCookieLength) {
		var intIndex2 = intIndex2 + intCookieArgL
		if (document.cookie.substring(intIndex1, intIndex2) == strCookieArg) {
			return (getCookieVal(intIndex2))
		}
		intIndex1 = document.cookie.indexOf(" ", intIndex1) + 1;
		if (intIndex1 == 0){
			break;
		}
	}
	return null;
} // end of GetCookie

function DelCookie (strName) { // start DelCookie
	var strExpDate = new Date();
	strExpDate.setTime(strExpDate.getTime() - 1);
	var strCookieVal = GetCookie(strName);
	
	document.cookie = strName + "=" + strCookieVal + "; expires=" + strExpDate.toGMTString();
} // end of DelCookie

function NumVisits () { // start NumVisits
	var strCookieName = "CDP_Cookie";
	var Cookie = GetCookie(strCookieName);
	
	if (Cookie == null) {
		Cookie = 1;
		SetCookie(strCookieName, Cookie, objExpDate);
		window.open(strLoadPage, "", strWinLoadProp);
	}
	else {
		Cookie++;
		SetCookie(strCookieName, Cookie, objExpDate);
	}
} // end of NumVisits

function getCookieVal (intOffSet) { // start getCookieVal
	var endstr = document.cookie.indexOf (";", intOffSet);
	
	if (endstr == -1) {
		endstr = document.cookie.length;
	}
	return unescape(document.cookie.substring(intOffSet, endstr));
} // end of getCookieVal

