/******************************************************************************
* Dropdowns
******************************************************************************/
/* dropdown
*
* select -
*/
function dropdown(select) {
if (url = select.options[select.selectedIndex].value) {
if (select.form.target) {
target = parent[select.form.target];
} else {
target = window;
}
if (! target) return true;
target.location = url;
}
return false;
}
/******************************************************************************
* Popups
******************************************************************************/
/* popupWindow
*
* url - the calling object or a string representing the URL
* name - name of the popup window
* [properties] - 
*/
function popupWindow(url, name, properties)
{
if (! window.focus) return true;
if (typeof(url) == 'string') {
href = url;
} else {
href = url.href;
}
window.open(href, name, properties);
return false;
}
/* popupForm
*
* form - the calling form
* name - name of the popup window
* [properties] - 
*/
function popupForm(form, name, properties) {
if (! window.focus) return true;
window.open('', name, properties);
form.target = name;
return true;
}
/******************************************************************************
* Cookies 
******************************************************************************/
/* setCookie
*
* name - name of cookie
* value - value of cookie
* [expires] - expiration date of cookie (? end of current session ?)
* [path] - path under which cookie is valid (? path of calling document ?)
* [domain] - domain for which cookie is valid (? domain of calling document ?)
* [secure] - boolean indicating if secure transmission required (? false ?)
*/
function setCookie(name, value, expires, path, domain, secure) {
if ('boolean' == typeof(expires) && !expires) {
expires = 365;
}
if ('string' == typeof(expires)) {
if ('NEVER' == expires) {
expires = 'Wed, 29-Oct-42 00:00:01 GMT';
} else { // validate Date string
expries = expires.toGMTString();
}
} else if ('number' == typeof(expires)) {
expires = new Date((new Date()).getTime() + expires * 86400000);
expires = expires.toGMTString();
}
document.cookie = name + '=' + escape(value) +
((expires) ? '; expires=' + expires : '') +
'; path=' + ((path) ? path : '/') +
((domain) ? '; domain=' + domain : '') +
((secure) ? '; secure' : '');
}
/* getCookie
* return value of cookie or empty string if cookie does not exist
*
* name - name of cookie
*/
function getCookie(name) {
c = document.cookie;
if (0 == (begin = c.indexOf(name + '='))) {
begin += name.length + 1;
} else {
if (-1 != (begin = c.indexOf('; ' + name + '='))) {
begin += name.length + 3;
} else {
return '';
}
}
if (-1 == (end = c.indexOf(';', begin))) {end = c.length;}
return unescape(c.substring(begin, end));
}
function getChip(name, cookie) {
if ('' != (c = getCookie(cookie))) {
if (0 == (begin = c.indexOf(name + '='))) {
begin += name.length + 1;
} else {
if (-1 != (begin = c.indexOf('&' + name + '='))) {
begin += name.length + 2;
} else {
return '';
}
}
if (-1 == (end = c.indexOf('&', begin))) {end = c.length;}
return c.substring(begin, end);
} else {
return '';
}
}
/* deleteCookie
*
* name - name of cookie
* [path] - path of cookie (must be path set with cookie)
* [domain] - domain of cookie (must be domain set with cookie)
*/
function deleteCookie(name, path, domain) {
if (value = getCookie(name)) {
document.cookie = name + '=' + escape(value) +
'; expires=Wed, 29-Oct-80 00:00:01 GMT' +
'; path=' + ((path) ? path : '/') +
((domain) ? '; domain=' + domain : '');
}
return;
}
/******************************************************************************
* Other
******************************************************************************/
function newImage(arg) {
if (document.images) {
rslt = new Image();
rslt.src = arg;
return rslt;
}
}
function changeImages() {
if (document.images) {
for (var i=0; i < changeImages.arguments.length; i += 2) {
document[changeImages.arguments[i]].src = changeImages.arguments[i + 1];
}
}
}
