function focusOnFirstFormField() {
	try {
		var forms = document.getElementsByTagName("form");
		if(forms.length>0) {
			var inputs = forms[0].getElementsByTagName("input");
			for(i=0;i<inputs.length;i++) {
				if(inputs[i].type.toLowerCase() == "text") {
					inputs[i].focus();
					break;
				}
			}
		}
	
	}
	catch(e){}
}

function focusOnSecondFormField() {
	try {
		var forms = document.getElementsByTagName("form");
		//alert(forms.length);
		if(forms.length>1) {
			var inputs = forms[1].getElementsByTagName("input");
			for(i=0;i<inputs.length;i++) {
				if(inputs[i].type.toLowerCase() == "text") {
					inputs[i].focus();
					break;
				}
			}
		}
	
	}
	catch(e){}
}


function scaleFontSize(dir) {
	var divs = document.body.getElementsByTagName("div");
	var pageContents = document.body;
	for(var i = 0; i < divs.length; i++) {
		if( divs[i].className == "pageContents") {
			pageContents = divs[i];
		}
	}
    var size = pageContents.style.fontSize;
    if(/[0-9]{3}%/.test(size)) {
        size = (parseInt(size.replace(/[^0-9]/g, "")) + dir);
    } else {
        size = 100 + parseInt(dir);
    }	
		//while(/(<[^>]*style=.*font-size.\s*)(large|medium|small|larger|smaller|x-large|xx-large|x-small|xx-small)/.test(pageContents.innerHTML)) {
		var oldSizes = pageContents.innerHTML.match(/(<[^>]*style=.*font-size.\s*)(large|medium|small|larger|smaller|x-large|xx-large|x-small|xx-small|[0-9]+px)/g);
		var newSize  = 24;
		for(var i = 0; oldSizes != null && i < oldSizes.length; i++) {
			var oldSize = oldSizes[i].replace(/^.*font-size.\s*(large|medium|small|larger|smaller|x-large|xx-large|x-small|xx-small|[0-9]+px).*$/, "$1");
			switch(oldSize) {
				case "large":
				newSize  = 18/12*100;
				break;
				case "medium":
				newSize  = 16/12*100;
				break;
				case "small":
				newSize  = 12/12*100;
				break;
				case "larger":
				newSize  = 24/12*100;
				break;
				case "smaller":
				newSize  = 10/12*100;
				break;
				case "x-large":
				newSize  = 24/12*100;
				break;
				case "xx-large":
				newSize  = 36/12*100;
				break;
				case "x-small":
				newSize  = 10/12*100;
				break;
				case "xx-small":
				newSize  = 10/12*100;
				break;
				default:
					newSize  = (parseInt(oldSize.replace(/px/,""))/ ((size - dir)/100))*size/10 ;
					break;
				
			}
			pageContents.innerHTML = pageContents.innerHTML.replace(/(<[^>]*style=.*font-size.\s*)(large|medium|small|larger|smaller|x-large|xx-large|x-small|xx-small|[0-9]+px)/, "$1 " +  newSize + "%");
		}
		pageContents.innerHTML = pageContents.innerHTML.replace(/(<font[^>]*)size=.\d*.([^>]*>)/g, "$1$2");


    if(size >= 100 && size <= 1000) {
        pageContents.style.fontSize = size + "%";
    }
}

function recurse_scaleFont(elem, size) {
			
	for(var j = 0; j < elem.childNodes.length; j++) {
		if(elem.childNodes[j].nodeType == 1 && elem.childNodes[j].getAttribute("style") != null) {
			var fontSize = elem.childNodes[j].getAttribute("style").replace(".*font-size:\s*(large|medium|small|larger|smaller|x-large|xx-large|x-small|xx-small).*", "\1");
			switch(fontSize) {
				case "x-large":
					elem.childNodes[j].style.fontSize = 24*size/100 + "px";
					break;
					
			}
		} else if(typeof elem.childNodes[j].style != "undefined"){
			alert(elem.childNodes[j].style.fontSize);
		}
		if(elem.childNodes[j].childNodes.length > 0) {
			recurse_scaleFont(elem.childNodes[j], size);
		}
	}
}

var newWindow = null;
function makeWindow(url,width,height){
	//check if window already exists
	if ( !newWindow || newWindow.closed){
		//modify window variables
		var w = width;
		var h = height;
		var x = 100;
		var y = 150;
		if (document.all)
		{
			var xMax = screen.width, yMax = screen.height;
			x = ((xMax/2) - (w/2));
			y = ((yMax/2) - (h/2));
		}
		else if (document.layers) 
		{
			var xMax = window.outerWidth, yMax = window.outerHeight;
			x = ((xMax/2) - (w/2));
			y = ((yMax/2) - (h/2));
		}
		
		options = "screenX=" + x + ",screenY=" + y + ",top=" + y + ",left=" + x + ",toolbar=0,status=0,menubar=0,scrollbars=auto,resizable=0,width=" + w +",height=" + h;
	
		//store new window object in global variable
		newWindow = window.open(url,"modifyWindow",options);
		newWindow.document.close();
	} else {
			//window already exists, so bring it forward
			newWindow.document.close();
			newWindow = window.open(url,"modifyWindow",options);
			newWindow.focus();
	}
}



function createInnerConfirm(message,title,x,y) {
	var innerWindow = document.createElement("div");
	var windowHeight = 480;
	var windowWidth = 640;
	innerWindow.style.position = "absolute";
	if(typeof window.innerHeight !== 'undefined' && typeof window.innerWidth !== 'undefined' ) {
		windowHeight = window.innerHeight;
		windowWidth = window.innerWidth;
	} else 
	if(typeof document.documentElement.clientHeight !== 'undefined' && typeof document.documentElement.clientWidth !== 'undefined' ) {
		windowHeight = document.documentElement.clientHeight;
		windowWidth = document.documentElement.clientWidth;
	} else 
	if(typeof document.body.clientHeight !== 'undefined' && typeof document.body.clientWidth !== 'undefined' ) {
		windowHeight = document.body.clientHeight;
		windowWidth = document.body.clientWidth;
	}
	
	innerWindow.style.top = parseInt((windowHeight-y)/2,10) + "px";
	innerWindow.style.left = parseInt((windowWidth-x)/2,10) + "px";
	innerWindow.style.width = x+"px";
	innerWindow.style.height = y+"px";
	innerWindow.style.zIndex = "50";
	innerWindow.style.border = "2px solid #0B52A0";
	innerWindow.style.backgroundColor= "#FFFFFF";
	innerWindow.setAttribute("title","title");
	innerWindow.setAttribute("id","innerWindow");
	
	
	var element = document.body.getElementsByTagName("table")[0];
	if(typeof element.style.filter !== 'undefined' ){
		document.body.backgroundColor="teal";
		element.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=50)";
	} else if (typeof element.style.opacity !== 'undefined' ) {
		element.style.opacity = ".5";
	}

	innerWindow.style.visibility = "visible";
	//alert("Website: "+location.href.replace(new RegExp("http://([^/]*)/.*"),"$1")+"\nYour Session is about to be timed out.");
	window.focus();
	document.body.appendChild(innerWindow);
	innerWindow.innerHTML += message;
	
}
function createMediaWindow(message,title,x,y) {
	var innerWindow = document.createElement("div");
	var windowHeight = 480;
	var windowWidth = 640;
	innerWindow.style.position = "absolute";
	if(typeof window.innerHeight !== 'undefined' && typeof window.innerWidth !== 'undefined' ) {
		windowHeight = window.innerHeight;
		windowWidth = window.innerWidth;
	} else 
	if(typeof document.documentElement.clientHeight !== 'undefined' && typeof document.documentElement.clientWidth !== 'undefined' ) {
		windowHeight = document.documentElement.clientHeight;
		windowWidth = document.documentElement.clientWidth;
	} else 
	if(typeof document.body.clientHeight !== 'undefined' && typeof document.body.clientWidth !== 'undefined' ) {
		windowHeight = document.body.clientHeight;
		windowWidth = document.body.clientWidth;
	}
	
	innerWindow.style.top = parseInt((windowHeight-y)/2,10) + "px";
	innerWindow.style.left = parseInt((windowWidth-x)/2,10) + "px";
	innerWindow.style.width = (parseInt(x) + parseInt(60))+"px";
	innerWindow.style.height = (parseInt(y) + parseInt(60))+"px";
	innerWindow.style.zIndex = "50";
	innerWindow.style.backgroundColor= "transparent";
	innerWindow.setAttribute("title","title");
	innerWindow.setAttribute("id","innerWindow");
	
	var overlay = document.createElement("div");
	overlay.setAttribute("id", "mediaOverlay");
	overlay.style.width = windowWidth + "px";
	overlay.style.height = windowHeight + "px";
	overlay.style.position = "absolute";
	overlay.style.top = "0px";
	overlay.style.left = "0px";
	overlay.style.zIndex = "40";
	overlay.style.backgroundColor="black";
	if(typeof overlay.style.filter !== 'undefined' ){
		overlay.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=5.0)";
	} else if (typeof overlay.style.opacity !== 'undefined' ) {
		overlay.style.opacity = ".5";
	}

	//alert("Website: "+location.href.replace(new RegExp("http://([^/]*)/.*"),"$1")+"\nYour Session is about to be timed out.");
	window.focus();
	document.body.appendChild(innerWindow);
	innerWindow.style.visibility = "visible";
	var html = "";
	html += "<table cellspacing=\"0\" cellpadding=\"0\">";
	html += "<tr><td style=\"width:29px;height:29px;background:url(/images/mediacorners.png);\"></td>";
	html += "<td style=\"width:" + x + "px;height:29px;background:black;text-align:right;color:white;\"><span style=\"cursor:pointer;\" id=\"closeMediaWindow\">close [x]&nbsp;</span></td>";
	html += "<td style=\"width:29px;height:29px;background:url(/images/mediacorners.png) top right;\"></td>";
	html += "</tr><tr>";
	html += "<td style=\"width:29px;height:" + y + ";background:black;\"></td><td style=\"background-color:black;\">";
	html += message;
	html += "</td><td style=\"width:29px;height:" + y + ";background:black;\"></td></tr>";
	html += "<tr><td style=\"width:29px;height:29px;background:url(/images/mediacorners.png) bottom left;\"></td>";
	html += "<td style=\"width:" + x + "px;height:29px;background:black;\"></td>";
	html += "<td style=\"width:29px;height:29px;background:url(/images/mediacorners.png) bottom right;\"></td>";
	html += "</tr></table>";
	document.body.appendChild(overlay);
	innerWindow.innerHTML += html;
	document.getElementById("closeMediaWindow").onclick =  function() {
		document.body.removeChild(document.getElementById("innerWindow"));
		document.body.removeChild(document.getElementById("mediaOverlay"));
	};
	
}
	
var originalClass='';
function changeRowClass(row,cssClass) {
	originalClass=row.className;
	row.className=cssClass;
}
	
