/***************************************************************************************************/
/*										URL FUNCTIONS											   */			
/***************************************************************************************************/

function GetPageMainUrl()
{
	var arr_urlParts = document.location.href.split('/');
	var str_mainURL = "http://";
	
	for(i = 2; i < (arr_urlParts.length - 1); i++) 
	{
		str_mainURL += arr_urlParts[i];
		if(i != (arr_urlParts.length - 2)) str_mainURL += '/';
	}
	
	return str_mainURL;
}


function cleanURL(stringURL)
{
	stringURL = stringURL.replace(/%/g,'%25')
	return stringURL;
}


// retrieve url without query string
function getPageURL()
{
	var str_completeUrl = document.location.href;				// get full URL
	str_pageUrl 		= str_completeUrl.split("?")[0];		// retrieve url without query string
	
	return str_pageUrl;
}


function getRequestParameter(str_paramName)
{
	var str_paramValue 	= "";							// value of the specified request variable
	var str_url 		= document.location.href;		// get full URL
	var str_request 	= str_url.split("?")[1];		// retrieve GET request string without "?"
	str_request			= str_request.replace(/(#$)/, "");
	
	var arr_params	= str_request.split("&");
	
	for(var ix = 0; ix < arr_params.length; ix++)
	{
		var arr_paramParts = arr_params[ix].split("=");
		
		if(arr_paramParts[0].toUpperCase() == str_paramName.toUpperCase())
		{
			str_paramValue = arr_paramParts[1];
		}
	}
	
	return str_paramValue;
}

/***************************************************************************************************/


function showObjectProperties(object)
{
	//*******************************  Initialize objects  ***********************************//
	
    var txt = "";
    
    //************************************  BEGIN  *******************************************//
    
    for(i in object)
	{
	  txt += "<b>"+ i + ":</b> " + object.getAttribute(i) + "<br/>";
	}
	return txt;
}


function CloneObject(myObject)
{
	for (i in myObject) 
	{
        if (typeof myObject[i] == 'object') 
        {
            this[i] = new cloneObject(myObject[i]);
        }
        else this[i] = myObject[i];
    }
}


//********************************************** COOKIE FUNCTIONS *******************************************************

function GetCookieParams(str_cookieName)
{
	var cookies = document.cookie;
	var prefix = Trim(str_cookieName) + "=";
	var begin = cookies.indexOf("; " + prefix);
  
	if(begin == -1)			// cookie is first in assembly of cookies
	{
		begin = cookies.indexOf(prefix);
		if (begin != 0) return "";
	} 
	else  begin += 2;
	
	var end = cookies.indexOf(";", begin);
	if (end == -1) end = cookies.length;
	
	return cookies.substring(begin + prefix.length, end);
}

function clearCookie(str_cookieName)
{
	// replace old cookievalues with empty string
	document.cookie = str_cookieName + "=; path=/";	
	return true;
}


function addCookieParam(str_cookieName, cookieParam)
{
	// save old cookie values
	var cookieValues = "";
	cookieValues = Trim(GetCookieParams(str_cookieName));
	
	// replace old cookievalues with the combination of the old values with the new cookie parameter added
	if(cookieValues != "") cookieValues += "||";
	document.cookie = str_cookieName + "=" + cookieValues  + cookieParam + "; path=/";
	
	return true;
}


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 = "";
	var ck = name+"="+value+expires+"; path=/";
	if (days != -1) alert('Cookie\n' + ck + '\ncreated');
	document.cookie = ck;
}


function eraseCookie(name)
{
	createCookie(name,"",-1);
}

//********************************************** END COOKIE FUNCTIONS *******************************************************


function isNumeric(str_number)
{
	var stringNumericExp = new RegExp(/^ *(\d+)([.,]\d+)? *$/g);
	return stringNumericExp.test(str_number);			// use "exec" function to return matched parts from the parentheses
}


function isInteger(str_number)
{ 
	var stringNumericExp = new RegExp(/^ *(\d+) *$/g);
	return stringNumericExp.test(str_number);			// use "exec" function to return matched parts from the parentheses
}

 
function setDecimals(str_number, int_nrOfDecimals)
{
	try
	{
		var floatNumber = parseFloat(str_number.replace(',','.'));
		if(! isNaN(floatNumber)) return parseFloat(str_number.replace(',','.')).toFixed(int_nrOfDecimals);
		else return '';
	}
	catch(ex) { return '';}
}

// ****************************************** BEGIN DATE / TIME FUNCTIONS ****************************************************


// add a specified number of months to date (dd-MM-yyyy format)
// days are reset to last month day if they exceed the number of days in a month 
function date_addMonths(str_date, int_months)
{
	try
	{
		var dateParts	= str_date.split("-");
		
		var int_day		= parseInt(dateParts[0].replace(/^0/, ""));
		var int_month	= parseInt(dateParts[1].replace(/^0/, "")) + int_months;
		var int_year	= parseInt(dateParts[2]);
		
		if(int_month > 12)
		{
			int_year	+= parseInt(int_month / 12);
			int_month	= (int_month % 12);
		}
		
		// if the old day exceed the number of days in the new month,
		// the day is reset to the number of days in the new month
		var int_monthDays = date_daysInMonth(int_month, int_year);
		if(int_day > int_monthDays) int_day = int_monthDays;
		
		var str_day = int_day >= 10?int_day:"0"+int_day;
		var str_month = int_month >= 10?int_month:"0"+int_month;
	
		return str_day + "-" + str_month + "-" + int_year;
	}
	catch(ex)
	{
		return '';
	}
}


// determine how many days there are in a month (returns integer)
// int_month = month number (1-12)
function date_daysInMonth(int_month, int_year)
{
	if(IsInteger(int_month) &&  IsInteger(int_year) && int_month >= 1 && int_month <= 12)
	{
		var arr_monthDays = new Array();
		arr_monthDays[0] = 31;
		arr_monthDays[1] = 28;
		arr_monthDays[2] = 31;
		arr_monthDays[3] = 30;
		arr_monthDays[4] = 31;
		arr_monthDays[5] = 30;
		arr_monthDays[6] = 31;
		arr_monthDays[7] = 31;
		arr_monthDays[8] = 30;
		arr_monthDays[9] = 31;
		arr_monthDays[10] = 30;
		arr_monthDays[11] = 31;
		
		if(int_month == 2 && date_isLeapYear(int_year))	// leap year
		{
			return arr_monthDays[int_month - 1] + 1;
		}
		else return arr_monthDays[int_month - 1];
	}
	else return 0;
}


// determine whether a year is a leap-year or not (returns boolean)
function date_isLeapYear(int_year)
{
	/* 
	Check for leap year ..
	1.Years evenly divisible by four are normally leap years, except for... 
	2.Years also evenly divisible by 100 are not leap years, except for... 
	3.Years also evenly divisible by 400 are leap years. 
	*/
	if((int_year % 4) == 0)
	{
		if ((int_year % 100) == 0 && (int_year % 400) != 0) return false;
		
		return true;
	}
	return false;
}

// determine whether a year is a leap-year or not (returns boolean)
function date_isLeapYear(int_year)
{
	/* 
	Check for leap year ..
	1.Years evenly divisible by four are normally leap years, except for... 
	2.Years also evenly divisible by 100 are not leap years, except for... 
	3.Years also evenly divisible by 400 are leap years. 
	*/
	if((int_year % 4) == 0)
	{
		if ((int_year % 100) == 0 && (int_year % 400) != 0) return false;
		
		return true;
	}
	return false;
}


// validate if a certain string complys with the given data format
// possible formats:
//		- dd-MM-yyyy	(01-12-2005)
//		- dd/MM/yyyy	(01/12/2005)
function date_validateFormat(str_date, str_format)
{
	switch(str_format)
	{
		case "dd-MM-yyyy":
				// test for global format (correct separator and numeric); semantic meaning of date is not taken in account
				var regexp_date = /^\d{2}-\d{2}-\d{4}$/g;
				if(regexp_date.test(str_date))
				{
					// check date semantics (ex. day not greater then number of days in month)
					var arr_dateParts = str_date.split("-");
					
					var int_day		= arr_dateParts[0].replace(/^0/, "");
					var int_month	= arr_dateParts[1].replace(/^0/, "");
					var int_year	= arr_dateParts[2];
				
					return date_validateSemantics(int_day, int_month, int_year);
				}
				break;
		
		case "dd/MM/yyyy":
				// test for global format (correct separator and numeric); semantic meaning of date is not taken in account
				var regexp_date = /^\d{2}\/\d{2}\/\d{4}$/g;
				if(regexp_date.test(str_date))
				{
					// check date semantics (ex. day not greater then number of days in month)
					var arr_dateParts = str_date.split("/");
					
					var int_day		= arr_dateParts[0].replace(/^0/, "");
					var int_month	= arr_dateParts[1].replace(/^0/, "");
					var int_year	= arr_dateParts[2];
					return date_validateSemantics(int_day, int_month, int_year);
				}
				break;
		
		default: break;
	}
	
	return false;
}


// check date semantics (ex. day not greater then number of days in month)
function date_validateSemantics(int_day, int_month, int_year)
{
	if(int_day >= 1 && int_month >= 1 && int_month <= 12)
	{
		var int_daysInMonth = date_daysInMonth(int_month, int_year);
		
		if(int_day <= int_daysInMonth) return true;
	}
	return false;
}


// transform a numeric month to string format
function date_monthToString(int_month, str_language)
{
	if(IsInteger(int_month) && int_month >= 1 && int_month <= 12)
	{
		var arr_months	= new Array();
		
		switch(str_language)
		{
			case "NL":
					arr_months[0]	= "januari";
					arr_months[1]	= "februari";
					arr_months[2]	= "maart";
					arr_months[3]	= "april";
					arr_months[4]	= "mei";
					arr_months[5]	= "juni";
					arr_months[6]	= "juli";
					arr_months[7]	= "augustus";
					arr_months[8]	= "september";
					arr_months[9]	= "oktober";
					arr_months[10]	= "november";
					arr_months[11]	= "december";
					break;
					
			case "US":
					arr_months[0]	= "january";
					arr_months[1]	= "february";
					arr_months[2]	= "march";
					arr_months[3]	= "april";
					arr_months[4]	= "may";
					arr_months[5]	= "june";
					arr_months[6]	= "july";
					arr_months[7]	= "august";
					arr_months[8]	= "september";
					arr_months[9]	= "october";
					arr_months[10]	= "november";
					arr_months[11]	= "december";
					break;
					
			case "FR":
					arr_months[0]	= "janvier";
					arr_months[1]	= "février";
					arr_months[2]	= "mars";
					arr_months[3]	= "avril";
					arr_months[4]	= "mai";
					arr_months[5]	= "juin";
					arr_months[6]	= "juillet";
					arr_months[7]	= "aout";
					arr_months[8]	= "septembre";
					arr_months[9]	= "octobre";
					arr_months[10]	= "novembre";
					arr_months[11]	= "décembre";
					break;
			
			default:
					return "language not supported";
					break;
		}
		
		return arr_months[int_month];
	}
	return "wrong month format (1 <= integer <= 12)";
}


// ****************************************** END DATE / TIME FUNCTIONS ******************************************************


// set the hover functionality of LI-items in a CSS-drive menu to enable submenu's to flip out (ie work-around)
function SetMenuHoverStyle()
{
	// if (window.attachEvent) window.attachEvent("onload", SetMenuHoverStyle);
	if (window.attachEvent)
	{
		var sfEls = document.getElementById("menu").getElementsByTagName("LI");
		for (var i=0; i < sfEls.length; i++)
		{
			sfEls[i].onmouseover	= function() {	this.className += " sfhover"; }
			sfEls[i].onmouseout		= function() {	this.className = this.className.replace(new RegExp(" sfhover\\b"), "");	}
		}
	}
}


// build table object with specified row and column count 
// if row or col <= 0, the value wil then be reset to 1
function buildTable(int_rows, int_cols, str_tableID, bln_equalCellWidth, arr_cellwidth)
{
	var obj_table = document.createElement("TABLE");
	var obj_tableBody = document.createElement("TBODY");
	var str_colWidth = parseFloat(100/parseInt(int_cols)).toFixed(0) + "%";
	
	if(str_tableID.trim() != "") obj_table.setAttribute("id", str_tableID);
	obj_table.appendChild(obj_tableBody);
	
	if(int_rows <= 0) int_rows = 1;
	if(int_rows <= 0) int_cols = 1;

	for(i = 0; i < int_rows; i++)
	{
		var obj_tableRow = document.createElement("TR");
		
		for(j = 0; j < int_cols; j++)
		{
			var obj_tableCell = document.createElement("TD");
			if(bln_equalCellWidth) obj_tableCell.width = str_colWidth;
			else 
			{
				if(arr_cellwidth[j]) obj_tableCell.width = parseInt(arr_cellwidth[j]) + "%";
				else obj_tableCell.width = "1%";
			}
			obj_tableRow.appendChild(obj_tableCell);
		}
		obj_tableBody.appendChild(obj_tableRow);
	}

	return obj_table;
}


// close or open a section of a table
function collapseTableSection(str_sectionID)
{
	// find parent table object
	var obj_img = window.event.srcElement;
	var obj_table = obj_img;
	var obj_row = null;
	
	//determine whether section is closed or not
	var regExp_Image = /mapopen.gif$/;
	var closeSection = true;
	
	if(regExp_Image.test(obj_img.getAttribute("src"))) 
	{
		obj_img.setAttribute("src", "images/map.gif");
		obj_img.setAttribute("alt", "open table section");
	}
	else
	{
		obj_img.setAttribute("src", "images/mapopen.gif");
		obj_img.setAttribute("alt", "close table section");
		closeSection = false;
	}
	
	while(obj_table.tagName.toUpperCase() != "TABLE")
	{
		obj_table = obj_table.parentNode;
	}
	
	for(i = 0; i < obj_table.rows.length; i++)
	{
		obj_row = obj_table.rows[i];
		
		// section header must stay visible only section rows must become invisible
		if(!obj_row.getAttribute("sectionheader"))
		{		
			if(obj_row.getAttribute("section") && obj_row.getAttribute("section").toUpperCase() == str_sectionID.toUpperCase())
			{
				if(closeSection) obj_row.style.display = "none";
				else obj_row.style.display = "";
			}
		}
	}
}


// set the options of a select box from an array of elements
// - values must be ordered ascendingly
// - if a non-emtpy default value has been supplied, it will be added as first select option in the list
function SetDDLSelectOptions(obj_selectBox, arr_options, str_crntItem, str_defaultValue)
{
	var optionValue;
	var str_currentValue = Trim(str_crntItem);
	var str_defValue = Trim(str_defaultValue);
	var index = 0;
	var selectIndex = -1;
	
	obj_selectBox.options.length = 0;
	
	if(str_defValue != "")
	{
		obj_selectBox.options[index] = new Option(str_defValue, str_defValue);
		selectIndex = 0;
		index++;
	}
  
	for (ix = 0; ix < arr_options.length; ix++)
	{
		if(arr_options[ix]) optionValue = Trim(arr_options[ix]);
		else optionValue = "";	// catch empty values
		
		if(optionValue != str_defValue)
		{
			// add current value to option list if the value doesn't occur between the array values
			// and current value is not equal to default value
			if(selectIndex == -1 && str_currentValue != "" && str_defValue != str_currentValue && str_currentValue < optionValue)
			{
				obj_selectBox.options[index] = new Option(str_currentValue, str_currentValue);
				selectIndex = index++;
			}
			
			obj_selectBox.options[index] = new Option(optionValue, optionValue);
			if (str_currentValue.toUpperCase() == optionValue.toUpperCase()) selectIndex = index;
			index++;
		}
	}
  
	// current element doesn't occur between the values and is last in list 
	// and still needs to be added to option list
	if(selectIndex == -1 && str_currentValue != "")
	{
			obj_selectBox.options[index] = new Option(str_currentValue, str_currentValue);
			selectIndex = index;
	}
	else if(obj_selectBox.options.length > 0)
	{
		selectIndex = 0;
	}
	  
	obj_selectBox.selectedIndex = selectIndex;
}



// show a progress window and save the reference to it in a global variable
var obj_progressWin			= null;		// waiting window while loading data

function showProgressWindow(str_waitMsg, int_crntStep, int_maxStep)
{
	var x = parseInt(screen.availWidth / 2) - 200; 
	var y = parseInt(screen.availHeight / 2) - 50; 
			
	obj_progressWin = window.open("ProgressWindow.htm", "progress",
					"left=" + x + ",top=" + y +
					",height=150,width=400,fullscreen=no,toolbar=no," + 
					"status=no,menubar=no,scrollbars=no,resizable=no," + 
					"directories=no,location=no");
	
	obj_progressWin.onfocuslost = obj_progressWin.focus();
	window.status = str_waitMsg;
	document.body.style.cursor = 'wait'

	while(obj_progressWin.document.readyState != "complete" || obj_progressWin.document.body.readyState != "complete")
	{
		// halt program execution 'till progress window has been fully constructed
	}
}


// close the active progress window
function closeProgressWindow()
{
	window.status = 'Done';
	document.body.style.cursor = 'default'

	try
	{
		if(obj_progressWin != null && ! obj_progressWin.closed)
		{
			obj_progressWin.close();
		}
	}
	catch(e)
	{}
}


// pause the script processing for a specified number of seconds; while showing a status bar message
function wait(int_milliseconds, str_statusMsg)
{
	// show window status message
	var str_windowStatus = str_statusMsg.trim();

	if(str_windowStatus != "" ) window.status = str_windowStatus;
	
	// determine start time
	var startDate	= new Date();
	var startTime	= startDate.getTime();	// the number of milliseconds since January 1, 1970
	
	// loop till time interval has passed
	do
	{
		var curDate	= new Date();
		var curTime	= curDate.getTime();
	}
	while(curTime < startTime + int_milliseconds)
	
	// clear window status
	window.status = "";
}


function encodeBase64(input)
{
	var keyStr = "ABCDEFGHIJKLMNOP" +
					"QRSTUVWXYZabcdef" +
					"ghijklmnopqrstuv" +
					"wxyz0123456789+/" +
					"=";

	//input = escape(input);
	var output = "";
	var chr1, chr2, chr3 = "";
	var enc1, enc2, enc3, enc4 = "";
	var i = 0;

	do {
		chr1 = input.charCodeAt(i++);
		chr2 = input.charCodeAt(i++);
		chr3 = input.charCodeAt(i++);

		enc1 = chr1 >> 2;
		enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
		enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
		enc4 = chr3 & 63;

		if (isNaN(chr2)) {
		enc3 = enc4 = 64;
		} else if (isNaN(chr3)) {
		enc4 = 64;
		}

		output = output + 
		keyStr.charAt(enc1) + 
		keyStr.charAt(enc2) + 
		keyStr.charAt(enc3) + 
		keyStr.charAt(enc4);
		chr1 = chr2 = chr3 = "";
		enc1 = enc2 = enc3 = enc4 = "";
      } while (i < input.length);

      return output
}

function decodeBase64(input)
{
      var output = "";
      var chr1, chr2, chr3 = "";
      var enc1, enc2, enc3, enc4 = "";
      var i = 0;

      // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
      var base64test = /[^A-Za-z0-9\+\/\=]/g;
      if (base64test.exec(input)) {
         alert("There were invalid base64 characters in the input text.\n" +
               "Valid base64 characters are A-Z, a-z, 0-9, '+', '/', and '='\n" +
               "Expect errors in decoding.");
      }
      input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

      do {
         enc1 = keyStr.indexOf(input.charAt(i++));
         enc2 = keyStr.indexOf(input.charAt(i++));
         enc3 = keyStr.indexOf(input.charAt(i++));
         enc4 = keyStr.indexOf(input.charAt(i++));

         chr1 = (enc1 << 2) | (enc2 >> 4);
         chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
         chr3 = ((enc3 & 3) << 6) | enc4;

         output = output + String.fromCharCode(chr1);

         if (enc3 != 64) {
            output = output + String.fromCharCode(chr2);
         }
         if (enc4 != 64) {
            output = output + String.fromCharCode(chr3);
         }

         chr1 = chr2 = chr3 = "";
         enc1 = enc2 = enc3 = enc4 = "";

      } while (i < input.length);

      return unescape(output);
   }


//Base64 API
function encode64(input)
{
	var keyStr = "ABCDEFGHIJKLMNOP" +
					"QRSTUVWXYZabcdef" +
					"ghijklmnopqrstuv" +
					"wxyz0123456789+/" +
					"=";

	//input = escape(input);
	var output = "";
	var chr1, chr2, chr3 = "";
	var enc1, enc2, enc3, enc4 = "";
	var i = 0;

	do {
		chr1 = input.charCodeAt(i++);
		chr2 = input.charCodeAt(i++);
		chr3 = input.charCodeAt(i++);

		enc1 = chr1 >> 2;
		enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
		enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
		enc4 = chr3 & 63;

		if (isNaN(chr2)) {
		enc3 = enc4 = 64;
		} else if (isNaN(chr3)) {
		enc4 = 64;
		}

		output = output + 
		keyStr.charAt(enc1) + 
		keyStr.charAt(enc2) + 
		keyStr.charAt(enc3) + 
		keyStr.charAt(enc4);
		chr1 = chr2 = chr3 = "";
		enc1 = enc2 = enc3 = enc4 = "";
      } while (i < input.length);

      return output
}

function decode64(input)
{
    var output = "";
    var chr1, chr2, chr3 = "";
    var enc1, enc2, enc3, enc4 = "";
    var i = 0;

    // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
    var base64test = /[^A-Za-z0-9\+\/\=]/g;
    if (base64test.exec(input)) {
        alert("There were invalid base64 characters in the input text.\n" +
            "Valid base64 characters are A-Z, a-z, 0-9, '+', '/', and '='\n" +
            "Expect errors in decoding.");
    }
    input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

    do {
        enc1 = keyStr.indexOf(input.charAt(i++));
        enc2 = keyStr.indexOf(input.charAt(i++));
        enc3 = keyStr.indexOf(input.charAt(i++));
        enc4 = keyStr.indexOf(input.charAt(i++));

        chr1 = (enc1 << 2) | (enc2 >> 4);
        chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
        chr3 = ((enc3 & 3) << 6) | enc4;

        output = output + String.fromCharCode(chr1);

        if (enc3 != 64) {
        output = output + String.fromCharCode(chr2);
        }
        if (enc4 != 64) {
        output = output + String.fromCharCode(chr3);
        }

        chr1 = chr2 = chr3 = "";
        enc1 = enc2 = enc3 = enc4 = "";

    } while (i < input.length);

    return unescape(output);
}


function getAbsoluteTop(o)
{
	for (var absTop = 0; o != document.body; o = o.offsetParent)
	{
		absTop += o.offsetTop;
	}
	return absTop;
}


function getAbsoluteLeft(o)
{
	for (var absLeft = 0; o != document.body; o = o.offsetParent)
	{
		absLeft += o.offsetLeft;
	}
	return absLeft;
}


function getClientWidth()
{
	if (self.innerWidth) return self.innerWidth;
	if (document.documentElement && document.documentElement.clientWidth) return document.documentElement.clientWidth;
	if (document.body) return document.body.clientWidth;
}


function getClientHeight()
{
	if (self.innerHeight) return self.innerHeight;
	if (document.documentElement && document.documentElement.clientHeight) return document.documentElement.clientHeight;
	if (document.body) return document.body.clientHeight;
}


// cross-browser function to return event object
function getEvent(obj_browserEvent)
{
	if(obj_browserEvent) return obj_browserEvent;
	else if(window.event) return window.event;
	else return null;
}


// cross-browser function to return event source object
function getEventSource(obj_browserEvent)
{
	var obj_event 	= getEvent(obj_browserEvent);
	var obj_source 	= null;

	if(obj_event)
	{
		if(obj_event.target) obj_source = obj_event.target;
		else if(obj_event.srcElement) obj_source = obj_event.srcElement;
	}
	
	return obj_source;
}


function getMousePosition()
{
	var int_posx = 0;
	var int_posy = 0;
		
	if(!e) var e = window.event;
	
	if (e.pageX || e.pageY)
	{
		int_posx = e.pageX;
		int_posy = e.pageY;
	}
	else if (e.clientX || e.clientY)
	{
		int_posx = e.clientX + document.body.scrollLeft;
		int_posy = e.clientY + document.body.scrollTop;
	}
	// posx and posy contain the mouse position relative to the document
	
	return [int_posx, int_posy];
}


// show an image in a separate absolute positioned DIV on the place of the mouse
function showImageLayer(obj_source)
{
	var obj_thumb = null;
	var obj_child = null;
	
	for(var ix = 0; ix < obj_source.childNodes.length; ix++)
	{
		obj_child = obj_source.childNodes[ix];
		
		if(obj_child.nodeType == 1 && obj_child.tagName.toUpperCase() == "IMG")
		{
			obj_thumb = obj_child;
		}
	}

	if(obj_thumb)
	{
		var str_image	= obj_thumb.getAttribute("src");
		var obj_image 	= document.createElement("IMG");
		obj_image.setAttribute("src", str_image);
		
		showLayer(obj_image);
	}
}

// show content in a separate absolute positioned DIV on the place of the mouse
var obj_activeLayer = null;

function showLayer(obj_content)
{
	// hide any previous active layer
	hideLayer();
	
	var obj_layer = document.createElement("DIV");
	obj_layer.appendChild(obj_content);
	obj_layer.className = "info_blockSolo";
	
	// append layer directly to body
	document.body.appendChild(obj_layer);
	
	var arr_mousePosition 	= getMousePosition();
	var int_posLeft			= arr_mousePosition[0];
	var int_posTop			= arr_mousePosition[1];
	var int_width			= obj_content.clientWidth;
	var int_height			= obj_content.clientHeight;
	var int_bodyWidth		= document.body.scrollWidth;
	var int_bodyHeight		= document.body.scrollHeight;
	
	obj_layer.style.width = (int_width + 20) + "px";
	
	// try to center to content on the mouse position
	int_posLeft -= (int_width/2);
	int_posTop 	-= (int_height/2);
	
	// verify that layer won't succeed the screen dimensions (calculation margin of 15px)
	if((int_posLeft + int_width) >= int_bodyWidth) int_posLeft = int_bodyWidth - (int_width + 15);
	if((int_posTop + int_height) >= int_bodyHeight) int_posTop = int_bodyHeight - (int_height + 15);
	
	// postion layer
	obj_layer.style.position 	= "absolute";
	obj_layer.style.left 		= (int_posLeft - 10) + "px";	// -10 for margin by layer class
	obj_layer.style.top 		= (int_posTop - 10) + "px";		// -10 for margin by layer class
	
	// set events
	obj_layer.onmouseout = hideLayer;
	
	// save reference to layer
	obj_activeLayer = obj_layer;
}


function hideLayer()
{
	if(obj_activeLayer)
	{
		document.body.removeChild(obj_activeLayer);
		obj_activeLayer = null;
	}
}
