function getCookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
		return null;
	}
	if ( start == -1 ) return "";
	var end = document.cookie.indexOf( ';', len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}

function setCookie( name, value, expires, path, domain, secure ) {
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires ) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name+'='+escape( value ) +
		( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) + //expires.toGMTString()
		( ( path ) ? ';path=' + path : '' ) +
		( ( domain ) ? ';domain=' + domain : '' ) +
		( ( secure ) ? ';secure' : '' );
}

function findLiveHeight(){
    if(window.innerHeight != null)
        return window.innerHeight;
    if (document.documentElement.clientHeight != null)
        return document.documentElement.clientHeight;
    return (null);
}
function findLiveWidth(){
    if(window.innerWidth != null)
        return window.innerWidth;
    if (document.documentElement.clientWidth != null)
        return document.documentElement.clientWidth;
    return (null);
}

function findPosX(obj)
{   var curleft=0;
	if (obj.offsetParent)
	{   while(obj.offsetParent){curleft+=obj.offsetLeft;obj=obj.offsetParent;}}
	else if(obj.x)curleft+=obj.x;
	return curleft;
}

function findPosY(obj)
{	var curtop=0;
	if (obj.offsetParent)
	{	while (obj.offsetParent){curtop += obj.offsetTop;obj=obj.offsetParent;}}
	else if(obj.y)curtop+=obj.y;
	return curtop;
}


function QueryString() 
{
	// PROPERTIES
	this.arg = new Array;
	this.status = false;
	
	// METHODS
	this.clear = Clear;
	this.getQueryString = Get;
	this.getAll = GetAll;
	this.getStatus = GetStatus;
	this.read = Read;
	
	// FUNCTIONS
	
	// Clears the array, this.arg, of all query string data
	function Clear()
	{	this.arg = new Array;
	}
	
	// Returns a named value from the query string
	function Get(sName)
	{	return this.arg[sName];
	}
	
	// Return all data as an associative array
	function GetAll()
	{	return this.arg;
	}
	
	function GetStatus()
	{	return this.status;
	}
	
	// Reads the query string into an array named this.arg
	function Read(sUrl) 
	{	var aArgsTemp, aTemp, sQuery;
		// You can pass in a URL query string
		if(sUrl)
		{	sQuery = sUrl.substr(sUrl.lastIndexOf("?")+1, sUrl.length);
		}
		// Or read it from the browser location
		else
		{	sQuery = window.location.search.substr(1, window.location.search.length);
		}
		// Check that query string exists and contains data
		// If not (length < 1) then return
		if(sQuery.length < 1) {return;}
		// Else set this.status to true and proceed
		else {this.status = true;}
		//
		aArgsTemp = sQuery.split("&");	
		for (var i=0 ; i<aArgsTemp.length; i++)
		{	aTemp = aArgsTemp[i].split("=");
			this.arg[aTemp[0]] = aTemp[1];
		}
	}
}
