function ajaxFunction(div, string)
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
      document.getElementById(div).innerHTML = xmlHttp.responseText;
      }
    }
  xmlHttp.open("GET",string,true);
  xmlHttp.send(null);
  }

function popupDiv(content, divWidth, divHeight){

var divID = 'popupDiv';
var box;

if(document.getElementById(divID)){
box = document.getElementById(divID);
}

else{
box = document.createElement("div");
box.setAttribute("id",divID);
document.body.appendChild(box);
}


	var scrollingLeft = Math.round((document.documentElement.clientWidth/2)-(box.style.width/2)) - (divWidth / 2);
	var scrollingTop = Math.round((document.documentElement.clientHeight/2)-(box.style.height/2)+document.documentElement.scrollTop) - (divHeight / 2);

	box.style.width = divWidth+'px';
	box.innerHTML = content;
	box.style.display = 'block';
	box.style.position = 'absolute';
	box.style.top = scrollingTop+'px';
	box.style.left = scrollingLeft+'px';
	box.style.zIndex = '1';

	return hideShowSelects('hidden');

}

function popupDisplayNone(div){
document.getElementById(div).style.display = 'none';
document.getElementById(div).style.width = '';
hideShowSelects('visible');
}

function hideShowSelects(toggle){

if(navigator.appName == 'Microsoft Internet Explorer'){

var e=document.getElementsByTagName("select");

	for(var i=0;i<e.length;i++)
	{
	e[i].style.visibility = toggle;
	}

return false;
}

else{
return false;
}

}

function onlyNumbers(e)
			{
	var iKeyCode;
	if (!e) {
		var e = window.event;
	}
	if (e.keyCode) {
		iKeyCode = e.keyCode;
	} else {
		if (e.which) {
			iKeyCode = e.which;
		}
	}
	switch(iKeyCode) {
		case 8:
		case 9:
		case 35:
			break;
		case 36:
			break;
		case 37:
		case 38:
		case 39:
		case 40:
		case 46:
			break;
		case 48:
		case 49:
		case 50:
		case 51:
		case 52:
		case 53:
		case 54:
		case 55:
		case 56:
		case 57:
			if (e.shiftKey || e.altKey){
				return false;
			}
			break;
		case 96:
		case 97:
		case 98:
		case 99:
		case 100:
		case 101:
		case 102:
		case 103:
		case 104:
		case 105:
			//return correct numeric from keypad
			return iKeyCode - 48; break;
		case 110:
		//case 190:
			//if you are supporting decimal points
		//	return '.';	break;
		default: return false;
	}
}

function validate(formElements, frm)
{

var notValid = 0;
var elementId;
var element;

for (x in formElements)
{

elementId = formElements[x];
element = document.getElementById(elementId);

	if(element.value.length == 0){
	notValid = 1;
	element.style.border = '1px solid #cc0000';
	}
	else{
	element.style.border = '1px solid #cccccc';
	}

}

if(notValid > 0){
return false;
}

else{
document.forms[frm].submit();
}

}

function scrollToFunc(el){

if(el == 'top'){

window.scrollTo(0,0);
return false;

}

else{

var el = document.getElementById(el);
var curtop = 0;

if(el.offsetParent){

	do{curtop += el.offsetTop;} while (el = el.offsetParent);

}

window.scrollTo(0,curtop);

return false;

}

}

// DOM READY

window.onload = (function(){

for(x in document.links){

linkStr = String(document.links[x]);

if(linkStr.substring(0,document.URL.length+1) == document.URL+'#' && linkStr.length > document.URL.length+1){

// document.links[x].setAttribute('href','javascript:void(0)');
// document.links[x].setAttribute('onclick','return scrollToFunc(\''+linkStr.substring(document.URL.length+1)+'\'); return false;');

document.links[x].onclick = function(){

var el = this.href.substring(document.URL.length+1);

if(el == 'top'){

window.scrollTo(0,0);
return false;

}

else{

var el = document.getElementById(el);
var curtop = 0;

if(el.offsetParent){

	do{curtop += el.offsetTop;} while (el = el.offsetParent);

}

window.scrollTo(0,curtop);

return false;

}

};

}

}

});
