/* Copyright (c) 2007 wildfireweb.com
* All rights reserved
* This copyright notice MUST stay intact
* Developed by Stephen Sweet
*/

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 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;
}

// adjust  iframe windows to fit text
function adjustIFrameSize(aID, extraheight) {
	var obj, height;
	var isSafari;
	var ua = navigator.userAgent.toLowerCase();
	isSafari = false;
	if (ua.indexOf('safari')+1) isSafari=true;

	if (extraheight == -1) {
		extraheight = 0;
	}
	else if (!extraheight) {
		if (isSafari) 
			extraheight=0;
		else
			extraheight=50;
	} 

	if (document.getElementById) {
		obj = document.getElementById(aID);

		 if (obj) {// if contentDocument exists, W3C compliant (Mozilla)
		  if (obj.contentDocument){
			height1=obj.contentDocument.body.scrollHeight;
			height2=obj.contentDocument.documentElement.scrollHeight;

			height = (height1 > height2) ? height2 : height1;
			height += extraheight;

			obj.style.height = height + 'px';
			obj.height = height;
		  } else {
		  // IE
			height=document.frames[aID].document.body.scrollHeight+extraheight
			obj.style.height = height + 'px';
			obj.height = height;
		  }
		}
	}
}
 
var loginshowing = 0;

function toggleLoginBox() // 1 visible, 0 hidden 
{ 
  var iState;
  if (loginshowing) loginshowing = 0;
  else loginshowing = 1;

  if(document.layers) { 
    document.layers['loginbox'].visibility = loginshowing ? "show" : "hide"; 
  } 
  else if(document.getElementById) { 
    var obj = document.getElementById('loginbox'); 
    obj.style.visibility = loginshowing ? "visible" : "hidden"; 
	if (loginshowing) document.getElementById('username').focus();
  } 
  else if(document.all) { 
    document.all['loginbox'].style.visibility = loginshowing ? "visible" : "hidden"; 
  } 
}

var xmlhttp;

function ajaxRequest(url, query, response) {	
	if (window.XMLHttpRequest) xmlhttp=new XMLHttpRequest();
	else if (window.ActiveXObject) xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	else return;

	if (xmlhttp) {
		xmlhttp.onreadystatechange=response;
		xmlhttp.open("POST",url,true);
		xmlhttp.setRequestHeader("User-Agent", "Mozilla/4.0");
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlhttp.setRequestHeader("Content-Length", query.length);
		xmlhttp.send(query);
	}
}

function reloadResponse()
{
	if (xmlhttp.readyState==4) {
		window.location.reload( false );
	}
}


