﻿// JScript File

var gbDHTML = (document.getElementById || document.all || document.layers);

function getObj(objectID)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(objectID);
	this.style = document.getElementById(objectID).style;
  }
  else if (document.all)
  {
	this.obj = document.all[objectID];
	this.style = document.all[objectID].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[objectID];
   	this.style = document.layers[objectID];
  }
}

function gGetObject(objectID)
{
   var obj = new getObj(objectID);
   return obj;
}

function gIsNull(obj)
{
    if(obj != null && typeof(obj) != 'undefined')
        return false;
    else
        return true;
}

function gSetColor(objectID, color)
{
    if(!gbDHTML)
        return;
    var obj = gGetObject(objectID);
    if(gIsNull(obj))
        return;
     obj.style.color = color;
}

function gSetVisible(objectID, bVisible)
{
    if(!gbDHTML)
        return;
    var obj = gGetObject(objectID);
    if(gIsNull(obj))
        return;
     obj.style.visibility  = bVisible? 'visible':'hidden';
}

function gSetFontStyle(objectID, strFontStyle)
{
    if(!gbDHTML)
        return;
    var obj = gGetObject(objectID);
    if(gIsNull(obj))
        return;
     obj.style.fontStyle  = strFontStyle; 
}

function gSetFontFamily(objectID, strFontFamily)
{
    if(!gbDHTML)
        return;
    var obj = gGetObject(objectID);
    if(gIsNull(obj))
        return;
     obj.style.fontFamily  = strFontFamily;
}

function gSetInnerHTML(objectID, strInnerHTML)
{
    if(!gbDHTML)
        return;
    var obj = gGetObject(objectID);
    if(gIsNull(obj))
        return;
     obj.obj.innerHTML  = strInnerHTML;
}


//============== 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();
		document.cookie = name+"="+value+expires+"; path=/";
	}
	else 
	{
	    var expires = "";
	    document.cookie = name+"="+value+expires+"; path=/";
	}
}

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;
}

function eraseCookie(name) 
{
	createCookie(name,"",-1);
}
