var agt = navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_nav = ((agt.indexOf('mozilla') != -1) && (agt.indexOf('spoofer') == -1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera') == -1) && (agt.indexOf('webtv') == -1));
var is_nav4up = (is_nav && (is_major >= 4));
var is_ie = (agt.indexOf("msie") != -1);
var is_ie3 = (is_ie && (is_major < 4));
var is_ie4 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5") == -1) && (agt.indexOf("msie 6") == -1) && (agt.indexOf("msie 7") == -1));
var is_ie4up = (is_ie && (is_major >= 4));
var is_ie5up = (is_ie  && !is_ie3 && !is_ie4);
var is_mac = (agt.indexOf("mac") != -1);
var is_gecko = (agt.indexOf("gecko") != -1);
var is_opera = (agt.indexOf("opera") != -1);

function grabObject(id) {
	if (is_ie4) {
		var view = eval(id);
	}
	if (is_ie5up || is_gecko || is_nav || is_nav4up || is_opera) {
		var view = document.getElementById(id);
	}
	return view;
}

var Pics = new Array();
var PicsOver = new Array();

function LoadPics(num,pic,picover) {
	Pics[num] = new Image();
	Pics[num].src = pic;
	PicsOver[num] = new Image();
	PicsOver[num].src = picover;
}

function ShowPic(num) {
	if (document.images) {
		eval("document.img" + num + ".src = Pics[" + num + "].src;");
		return true;
	} else return false;
}

function ShowPicOver(num) {
	if (document.images) {
		eval("document.img" + num + ".src = PicsOver[" + num + "].src;");
		return true;
	} else return false;
}

function pagesubmit(who, id) {
	document.getElementById("__aspnetForm").who.value = who;
	document.getElementById("__aspnetForm").id.value = id;
	document.getElementById("__aspnetForm").submit();
	return false;
}

function pagesubmit(who, id, scrollname) {
	document.getElementById("__aspnetForm").who.value = who;
	document.getElementById("__aspnetForm").id.value = id;
	
	if (scrollname != null)
	{
		if (scrollname.length != null)
		{
			if (scrollname.length > 0)
			{
				var sFormAction = document.getElementById("__aspnetForm").action;
				var iCardinalIndex = sFormAction.lastIndexOf("#");
				if (iCardinalIndex == -1)
					sFormAction = sFormAction + "#" + scrollname;
				else
					sFormAction = sFormAction.substr(0, iCardinalIndex + 1) + scrollname;
				document.getElementById("__aspnetForm").action = sFormAction;
			}
		}
	}
	
	document.getElementById("__aspnetForm").submit();
	return false;
}

function keypress3(who, id, scrollname) {
	if (event.keyCode == 13)
	{
		pagesubmit(who, id, scrollname);
		return false;
	}
	else
		return true;
}

function showBlock(blk) 
{
	var y;
	eval("y = document.all." + blk + ".style.display;");
	if (y == "none") {
		eval("document.all." + blk + ".style.display = 'block';");
	} else {
		eval("document.all." + blk + ".style.display = 'none';");
	}
	return false;
}

function ChangeSize(img, iMaxWidth, iMaxHeight) {
	var iNewWidth;
	var iNewHeight;
	
	var img2 = new Image();
	img2.src = img.src;
	
	iNewWidth = img2.width;
	iNewHeight = img2.height;
	
	if (iMaxWidth > 0 && iNewWidth > iMaxWidth)
	{
		iNewHeight = iNewHeight * (iMaxWidth / iNewWidth);
		iNewWidth = iMaxWidth;
	}	
	if (iMaxHeight > 0 && iNewHeight > iMaxHeight)
	{
		iNewWidth = iNewWidth * (iMaxHeight / iNewHeight);
		iNewHeight = iMaxHeight;
	}
	
	img.width = iNewWidth;
	img.height = iNewHeight;
	img.style.display = 'inline';
}

function keypress(i) {
	if (event.keyCode == 13)
		pagesubmit(i,0);
	return true;
}

var today = new Date();
var expiry = new Date(today.getTime() + 7776000000);

function setCookie(name, value) {
	if (value != null && value != "")
		document.cookie = name + "=" + escape(value) + "; expires=" + expiry.toGMTString();
}
	
function showTable(tbl) 
{
	var y;
	eval("y = document.all." + tbl + ".style.display;");
	if (y == "none") {
		eval("document.all." + tbl + ".style.display = 'block';");
		setCookie(tbl, "1");
	} else {
		eval("document.all." + tbl + ".style.display = 'none';");
		setCookie(tbl, "0");
	}
	return false;
}

function showConfirm(msg, who, id) {
	if (confirm(msg)) {
		pagesubmit(who,id,'');
	}
	return false;
}