﻿/*
 * Common javascript functions.
 * 2007-04-11
 */

/*
 * Creates a popup window.
 */
function PopupWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}

/*
 * Toggles object none/block
 */
function toggle(obj)
{
    if (obj.style.display == 'none')
        obj.style.display = 'block';
    else
        obj.style.display = 'none';
        
    return false;
}

/*
 * Saves a controls toggle state.
 */
function saveToggleState(strObjectId)
{
    var id = strObjectId;
    var state = document.getElementById(id).style.display;
    
    createCookie(strObjectId, state, 1);
}

/*
 * Sets the toggle state of the control.
 */
function setToggleState(strObjectId)
{
    var id = strObjectId;
    var state = readCookie(id);
    
    if (state != null)
        document.getElementById(id).style.display = state;
}

/*
 * Sets a cookie
 */
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

/*
 * Reads a cookie.
 */
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

/*
 * Erases a cookie.
 */
function eraseCookie(name) {
	createCookie(name,"",-1);
}

/*
 * Toggle div
 */
 function ShowDate(obj)
 {
    if (obj.style.display == 'none')
        obj.style.display = 'block';
    else
        obj.style.display = 'none';
        
    return false;
 }