
function initlocation() {
	// initiates the object for sending and receiving data
	httplocation = location_getHTTPObject();
	oRemovedNode = document.getElementById("locationBlock");
	oRemovedNode.parentNode.removeChild(oRemovedNode);
	document.body.appendChild(oRemovedNode);
	
	locationLnk = document.getElementById('locationLink');
	if(locationLnk) {
		locationLnk.onclick = function() {
			if (document.getElementById('locationBlock').style.display == 'block'){
				document.getElementById('locationBlock').style.display = 'none';
			}else{
				document.getElementById('locationBlock').style.display = 'block';
			}
			
			ws = location_windowsize();
			w = parseInt(document.getElementById('locationBlock').offsetWidth);
			h = parseInt(document.getElementById('locationBlock').offsetHeight);
			locationTopOffset =0;
			if(document.body.scrollTop) {
				locationTopOffset = document.body.scrollTop;
			} else if(document.documentElement.scrollTop){ 
				locationTopOffset = document.documentElement.scrollTop;
			}
			
			document.getElementById('locationBlock').style.top =  50+"px" ;
			document.getElementById('locationBlock').style.left =  ((ws.x/2)-20 )+"px";
			return false;
		}
	}
}

function location_Close() {
	document.getElementById('locationBlock').style.display = 'none';
//	document.getElementById('locationBlock').style.visibility = 'hidden';		
	return false;
}
function location_Reset() {

	document.getElementById('locationBlock').style.display = 'none';
//	document.getElementById('locationBlock').style.visibility = 'hidden';	
}
function location_Error(locationErrorArr) {
	document.getElementById('locationLblFromName').style.color = "inherit";
	document.getElementById('locationLblFromMail').style.color = "inherit";
	document.getElementById('locationLblToName').style.color = "inherit";
	document.getElementById('locationLblToMail').style.color = "inherit";
	
	for(i = 0; i < locationErrorArr.length; i++) {
		document.getElementById(locationErrorArr[i]).style.color = '#ff0000';
	}
	
}

//returns the window size 
function location_windowsize() {
	var x,y;
	if (self.innerHeight) // all except Explorer
	{
		x = self.innerWidth;
		y = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}
	retval = new Object;
	retval.x = x;
	retval.y = y; 
	return retval;
}
//initiates and handles the XMLHttpRequest object
//as found here: http://www.webpasties.com/xmlHttpRequest

function location_getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}


// brothercake's generic onload
// http://www.brothercake.com/site/resources/scripts/onload/

if(typeof window.addEventListener != 'undefined')
{
	//.. gecko, safari, konqueror and standard
	window.addEventListener('load', initlocation, false);
}
else if(typeof document.addEventListener != 'undefined')
{
	//.. opera 7
	document.addEventListener('load', initlocation, false);
}
else if(typeof window.attachEvent != 'undefined')
{
	//.. win/ie
	window.attachEvent('onload', initlocation);
}