<!-- BEGIN
//----------------------------------------------------------------------------//
function readCookie(name) {
        var the_cookie = document.cookie;
        var the_cookie = unescape(the_cookie);
        var all_cookies = the_cookie.split(";");
        for (var loop = 0; loop < all_cookies.length; loop++) {
                property_value = all_cookies[loop];
                var broken_info = property_value.split("=");
                var the_property = broken_info[0];
                var the_value = broken_info[1];

                the_property = the_property.replace( /^\s*/, "" );
                the_property = the_property.replace( /\s*$/, "" );
                if (the_property == name) {
                        return the_value;
                }
        }
        return false;
}
//----------------------------------------------------------------------------//
function GetCookie(Name) {
	var cookieStr = document.cookie;
	var arg = Name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (cookieStr.substring(i,j) == arg) {
			return GetCookieVal(j);
		}
		i = document.cookie.indexOf(" ",i) + 1;
		if (i == 0) break;
	}
	return null;
}
//----------------------------------------------------------------------------//
function GetCookieVal (offset) {
	var endstr = document.cookie.indexOf(";",offset);
	if (endstr == -1) { endstr = document.cookie.length; }
	return unescape(document.cookie.substring(offset, endstr));
}
//----------------------------------------------------------------------------//
function WriteCookie (cookieName, cookieValue, path, domain, expires, secure) {
	var curCookie = cookieName + "=" + escape(cookieValue) + ((expires) ? "; expires=" + expires.toGMTString() : "") +
  			((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");

	document.cookie = curCookie;
}
//----------------------------------------------------------------------------//
// END -->

<!-- BEGIN

var IEX = (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion > 4) ? true : false;
var IE4 = (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion == 4) ? true : false;
var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) == 4) ? true : false;
var NS6 = (navigator.appName == "Netscape" && navigator.appVersion == 6 || navigator.appCodeName == "Mozilla") ? true : false;
var CookieName = "selectedAds";
//var BaseURL = "http://intranet.chieftain.org";
var BaseURL = "http://www.pueblowestview.com";
//----------------------------------------------------------------------------//
function selectAd (id) {
	toggleImage(id);
	var cookieValue = GetCookie(CookieName);
	if (cookieValue != null) {
		if (FindClip(cookieValue, id)) {
			RemoveClip(id);
		} else {
			AppendClip(cookieValue, id);
		}
	} else {
		WriteCookie(CookieName,id);
	}
}
//----------------------------------------------------------------------------//
function toggleImage(id) {
	var adId = 'saveAd' + id;
	var adId2 = 'saveAd' + id + '-versions';
	var adImage = document.images['saveAd' + id];
	var imageSrcOff = new Image();
	var imageSrcOn = new Image();
	var imageSrcOff = BaseURL + '/graphics/adSelect.gif';
	var imageSrcOn = BaseURL + '/graphics/adSelected.gif';

	if (NS4) {
	} else {
		if ((IEX || NS6) && document.getElementById(adId)) document.getElementById(adId).className = (document.getElementById(adId).className == 'ad') ? 'ad_hilighted' : 'ad';
		if (IE4 && document.all(adId)) document.all(adId).className = (document.all(adId).className == 'ad') ? 'ad_hilighted' : 'ad';
		if ((IEX || NS6) && document.getElementById(adId2)) document.getElementById(adId2).className = (document.getElementById(adId2).className == 'ad') ? 'ad_hilighted' : 'ad';
		if (IE4 && document.all(adId2)) document.all(adId2).className = (document.all(adId2).className == 'ad') ? 'ad_hilighted' : 'ad';
	}

	if (document.images) {
		if (adImage)
			if (adImage.src == imageSrcOff) {
				adImage.src = imageSrcOn;
			} else {
				adImage.src = imageSrcOff;
			}
	}
}
//----------------------------------------------------------------------------//
function FindClip (cookieStr, id) {
	var clipFound = 0;
	var clips = cookieStr.split(",");
	var setSize = clips.length;
	if (setSize > 1) {
		for (var x = 0; x < setSize; x++) {
			if (clips[x] == id){
				clipFound=1;
			}
		}
	} else {
		if (cookieStr == id) {
			clipFound=1;
		}
	}
	return clipFound;
}
//----------------------------------------------------------------------------//
function AppendClip(cookieStr, itemToAppend) {
	var cookieValue = new String();
	if (cookieStr == "") {
		cookieValue = itemToAppend;
	} else {
		cookieValue = cookieStr + ',' + itemToAppend;
	}
	WriteCookie(CookieName, cookieValue);
}
//----------------------------------------------------------------------------//
function RemoveClip (itemToRemove) {
	var cookieStr = GetCookie(CookieName);
	var clips = cookieStr.split(',');
	var setSize = clips.length;
	var cookieValue = new String();
	if (setSize > 1) {
		for (var x = 0; x < setSize; x++) {
			if (clips[x] != itemToRemove)  {
				if (cookieValue == null || cookieValue == "") {
					cookieValue = clips[x];
				} else {
					cookieValue = cookieValue + ',' + clips[x];
				}
			}
		}
	}

  	WriteCookie(CookieName, cookieValue);
  	if (NS6 || IE6) {
		var d = document.getElementById(itemToRemove);
		if (d) d.style.display = 'none';
  	}
}
//----------------------------------------------------------------------------//
// END -->