﻿
/*=====================================
    DESCRIPTION??
=====================================*/
function UtilityClass(){}

UtilityClass.prototype.isNullOrEmpty = function(str)
{
    return (str == null || str.length == 0);
}

/*=====================================
    Returns the value for the querystring element "param".
=====================================*/
UtilityClass.prototype.qs = function(param)
{	
    param = param.toLowerCase();
    
	var qsParm = new Array();
	var query = window.location.search.substring(1);
	var parms = query.split( '&' );

	for (var i=0; i<parms.length; i++) 
	{
		var pos = parms[i].indexOf('=');
		if (pos > 0)
		{
			var key = parms[i].substring(0,pos).toLowerCase();
			var val = parms[i].substring(pos+1);
			qsParm[key] = val;
    }
  }
  if(qsParm[param] )
		return qsParm[param];
	else
		return null;
}

var Utilities = new UtilityClass();

/*=====================================
    Close window function
=====================================*/
function closeWindow()
{
    window.close();
}

/*****************************************************************************
   Pop window
*****************************************************************************/
UtilityClass.prototype.pop = function( url, width, height, resizable, scrollbars )
{	
	var left = Math.round( Math.round( screen.width / 2 ) - Math.round( width / 2 ) );	
	var top = Math.round( Math.round( screen.height / 2 ) - Math.round( height / 2 ) ) - 100;
	window.open( url, "", "width="+width+",height="+height+",left="+left+",top="+top+",resizable="+resizable+",menubar=no,location=no,scrollbars="+scrollbars+",status=no" );
}

/*=====================================
    DESCRIPTION??
=====================================*/
var checkflag = "false";

function check(field)
{
    if(checkflag == "false")
    {
        for (i = 0; i < field.length; i++)
        {
            var id = field[i].id;
            if(id.indexOf('A') != -1)
            {
                field[i].checked = true; 
            }
        }
        checkflag = "true";
        return true;
    }
    else
    {
        for (i = 0; i < field.length; i++)
        {
            var id = field[i].id;
            if(id.indexOf('A') != -1)
            {
                field[i].checked = false; 
            }
        }
        checkflag = "false";
        return true;
    }
}


/*=====================================
    Cookies
=====================================*/
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=/";
}

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 deleteCookie(name) 
{
	createCookie(name,"",-1);
}

