var isNav, isIE;
var coll = "";
var styleObj = "";
if (parseInt(navigator.appVersion) >= 4) {
	if (navigator.appName == "Netscape") {
		isNav = true;
	} else {
		isIE = true;
		coll = "all.";
		styleObj = ".style";
	}
}

function ShowMsg(Msg)
{
	if (Msg.length > 0)
		alert(Msg);
}

function Post(field, value)
{
	document.forms[0].action += '&' + field + '=';
	if (value != null)
		document.forms[0].action += value;
	else
		document.forms[0].action += 'Yes';

	if (typeof(Validate) == 'undefined' || Validate())
		document.forms[0].submit();
}

function Get(field, value)
{
	var url = document.forms[0].action += '&' + field + '=';
	if (value != null)
		url += value;
	else
		url += 'Yes';
	document.location = url;
}

function SetOption(name, value)
{
	for (var i=0; i<document.forms[0].length; i++)
	{
		if (document.forms[0].elements[i].name == name)
			var element = document.forms[0].elements[i];
	}
	if (element == null)
		return;

	if (element.type == 'checkbox')
	{
		if (element.value == value)
			element.checked = true;
	}
	else if (element.type == 'radio')
	{
		for (var i=0; i<document.forms[0].length; i++)
		{
			if (document.forms[0].elements[i].name == name &&
				document.forms[0].elements[i].value == value)
				document.forms[0].elements[i].checked = true;
		}
	}
	else if (element.type == 'select-one')
	{
		for (var i=0; i<element.length; i++)
		{
			if (element.options[i].value == value)
				element.selectedIndex = i;
		}
	}
	else if (element.type == 'text')
	{
		element.value = value;
	}
}

/* List View Functions */
function Sort(SortKey)
{
	var F=document.forms[0];
	if (F.Sort.value.indexOf(SortKey) == -1)
		F.Sort.value = SortKey;
	else
	{
		if (F.Sort.value.indexOf('Rev') == -1)
			F.Sort.value = 'Rev' + SortKey;
		else
			F.Sort.value = SortKey;
	}
	F.submit(); 
}

function SelectAll() {
	for (var i=0;i<document.forms[0].elements.length;i++) {
		var e=document.forms[0].elements[i];
		e.checked=!e.checked;
	}
}

function ChangeFolder() {
	var F=document.forms[0];
	F.DestFolder.selectedIndex=F.BottomFolder.selectedIndex;
}

function ChangeBottomFolder() {
	var F=document.forms[0];
	F.BottomFolder.selectedIndex=F.DestFolder.selectedIndex;
}

/* Message View Functions */
function Print(url) {
	window.open(url,'Print','height=400,width=600,scrollbars=yes,status=yes,resizable=1,toolbar=yes,menubar=yes');
}

function Source(url) {
	window.open(url,'Source','height=400,width=600,scrollbars=yes,status=yes,resizable=1');
}

/*!!!*/
function OpenLink(url) {
	window.open(url);
}

function OpenDetails(frm, itm, fk) {
	url="/Run.aspx?F="+frm+"&I="+itm+"&L="+fk+"&V=F&Cmd=P";
	dw=window.open(url, 'Details', 'height=350,width=650,scrollbars=no,resizable=1');
	dw.focus();
}

function CloseDetails() {
	opener.location.reload();
	this.close();
}

function SaveCloseDetails() {
	document.forms[0].submit();
	opener.location.reload();
	this.close();
}

/* Act on in/out/click of fields */
function oN(obj) {
	obj.style.background = "#ffffff";
}

function oF(obj) {
	obj.style.background = "#E0E8F1";
}
function oC(obj) {
//	if (document.all) eval("location.href = " + obj + ".href"); 
//	else location.href = document.links[obj].href;
	if (document.all) eval("parent.Frame_2.location.href = " + obj + ".href"); 
}
function oC2(obj, frm) {
	if (document.all) eval("parent."+frm+".location.href = " + obj + ".href"); 
}

/* Submit login to server */
function Login() {
	//url="http://www.minipoint.com";
	//url="http://www.minipoint.com?"+document.forms[0].elements["UserName"].value;
	//document.forms[0]["UserName"];
	//window.open(url);
	//document.location = url;
	document.forms[0].submit();
}

function GoToForm(frm, itm, viw) {
	url="/Run.aspx?F="+frm+"&I="+itm+"&V="+viw;
	document.location = url;
//	dw=window.open(url, 'Details', 'height=350,width=650,scrollbars=yes,resizable=1');
//	dw.focus();
	document.forms[0].action=url;
	document.forms[0].submit();
}

function PopUpForm(frm, itm, viw, whr) {
	url="/Run.aspx?F="+frm+"&I="+itm+"&V="+viw+"&W="+whr;
	dw=window.open(url, 'Select', 'height=350,width=450,scrollbars=yes,resizable=1');
	dw.focus();
}

function SetFormPos(x, y, w, h) {
	//if (window.screenLeft==0) {
		window.moveTo(x,y);
	//}
	window.resizeTo(w,h);
}

