function SetMode(Mode, Conditions)
{
	if (Mode == "QuickLink" || Mode == "Search")
	{
		if (Conditions != "")
			document.getElementById("SearchFor").value = Conditions;
		document.getElementById("Mode").value = "Search";
		document.getElementById("Conditions").value = Conditions;
		document.getElementById("TDS").submit();
	}
	else if (Mode == "EditSearch")
	{
		if (Conditions != "")
			document.getElementById("SearchFor").value = Conditions;
		document.getElementById("Mode").value = "EditSearch";
		document.getElementById("Conditions").value = Conditions;
		document.getElementById("TDS").submit();
	}	
	else if (Mode == "Delete" && confirm("Are you sure you want to Delete this Record?") != true)
		return false;
	else
	{
		document.getElementById("Mode").value = Mode;
		document.getElementById("Conditions").value = Conditions;
		document.getElementById("TDS").submit();		
	}
	return false;
}


function Refresh()
{
	SetMode(document.getElementById("Mode").value, document.getElementById("Conditions").value);
}

leftPos = 0
topPos = 0

if (screen)
{
	scrnWidth = screen.width
	scrnHeight = screen.height
}

function ViewHistory(table, group_id, header)
{
	var objHistory = window.open("HistoryLog.asp?Table=" + table + "&Group_Id=" + group_id + "&Header=" + header,"HistoryLog","status=yes,menubar=no,resizable=yes,toolbar=yes,scrollbars=yes,height=" + (scrnHeight - 320) + ",width=" + (scrnWidth - 80) + ",left=40, top=80, help=no");
	return false;
}

function ViewRowHistory(table, table_id, location_id, destination, ship_mode, other)
{
	//http://65.167.37.181/HistoryRowLog.asp?Table=InlandRow&Location_Id=H&Table_Id=1220
	//alert("HistoryRowLog.asp?Table=" + table + "&Location_Id=" + location_id + "&Table_Id=" + table_id + "&Destination=" + destination + "&ShipMode=" + ship_mode)	
	var objHistory = window.open("HistoryRowLog.asp?Table=" + table + "&Location_Id=" + location_id + "&Table_Id=" + table_id + "&Destination=" + destination + "&ShipMode=" + ship_mode + "&Other=" + other,"HistoryLog","status=yes,menubar=no,resizable=yes,toolbar=yes,scrollbars=yes,height=" + (scrnHeight - 320) + ",width=" + (scrnWidth - 80) + ",left=40, top=80, help=no");
	//var objHistory = window.open("HistoryRowLog.asp?Table=" + table + "&Location_Id=" + location_id + "&Table_Id=" + table_id,"HistoryLog","status=yes,menubar=no,resizable=yes,toolbar=yes,scrollbars=yes,height=" + (scrnHeight - 320) + ",width=" + (scrnWidth - 80) + ",left=40, top=80, help=no");
	return false;
}

function RulesPrivateNotes(Tbl_Id,orgName,orgNum,TName,TNum,Condn,header)
{
	var objNotes = window.open("RulesPrivateNotes.asp?Tbl_Id=" + Tbl_Id + "&orgName=" + orgName + "&orgNum=" + orgNum + "&TName=" + TName + "&TNum=" + TNum + "&Condn=" + Condn + "&Header=" + header,"HistoryLog","status=yes,menubar=no,resizable=yes,toolbar=yes,scrollbars=yes,height=" + (scrnHeight - 320) + ",width=" + (scrnWidth - 80) + ",left=40, top=80, help=no");
	return false;
}

function CommodityPrivateNotes(Comm_Id,header)
{

	var objCom = window.open("CommodityPrivateNotes.asp?Comm_Id=" + Comm_Id + "&Header=" + header,"HistoryLog","status=yes,menubar=no,resizable=yes,toolbar=yes,scrollbars=yes,height=" + (scrnHeight - 320) + ",width=" + (scrnWidth - 80) + ",left=40, top=80, help=no");
	return false;
}

function TRIPrivateNotes(Condn,header)
{
	var objTRI = window.open("TRIPrivateNotes.asp?Condn=" + Condn + "&Header=" + header,"HistoryLog","status=yes,menubar=no,resizable=yes,toolbar=yes,scrollbars=yes,height=" + (scrnHeight - 320) + ",width=" + (scrnWidth - 80) + ",left=40, top=80, help=no");
	return false;
}

function ServiceContractPrivateNotes(Tbl_Id,orgName,orgNum,TName,TNum,header)
{
	var objSevice = window.open("ServiceContractPrivateNotes.asp?Tbl_Id=" + Tbl_Id + "&orgName=" + orgName + "&orgNum=" + orgNum + "&TName=" + TName + "&TNum=" + TNum + "&Header=" + header,"HistoryLog","status=yes,menubar=no,resizable=yes,toolbar=yes,scrollbars=yes,height=" + (scrnHeight - 320) + ",width=" + (scrnWidth - 80) + ",left=40, top=80, help=no");
	return false;
}

//function for the popup window
function PopUpWindow(urlString, name, w, h, perc) 
{
	var winX = 0;
	var winY = 0;
	if (parseInt(navigator.appVersion) >= 4) 
	{
		winX = (screen.availWidth - w)*perc*.01;
		winY = (screen.availHeight - h)*perc*.01;
	}
	//popupWin = window.open(urlString, name, 'width=' + w + ',height=' + h + ',left=' + winX + ',top=' + winY +', scrollbar.visible=true,scrollbars=yes,resizable=no,maximize=no');
         window.location.href = urlString; 

}


function UpdateNotes(urlString) 
 {
//	alert(urlString);
	UpdateNotes = window.open(urlString);
 }



function SortCol(Column)
{
	var mode = document.getElementById("Mode").value;
	
	if(mode != "Search" || mode != "ViewInlandTable")
		mode = "Initial";
		
	document.getElementById("Column").value = Column;
	
	if(document.getElementById("Descending").value == "true")
		document.getElementById("Descending").value = "false";
	else
		document.getElementById("Descending").value = "true";
		
	document.getElementById("TDS").submit();
}

function validateUndo()
{		
	var undoCount = 0;
	if(typeof(document.all.txtUndoChange[0]) == "object")
	{
		for(i=0;i<document.all.txtUndoChange.length;i++)
		{
			if(document.all.txtUndoChange[i].value=="1")
			{
				undoCount++;
			}		
		}
	}
	else
	{
		undoCount = 1;
	}
	if(undoCount>0)
	{
		var cancelUndo = confirm("You are about to remove " + undoCount + " pending Row(s) for this Table!");
		if (cancelUndo==false){
			return false;
		}		
		return true;
	}
	else
	{
		alert('There are no row(s) selected for undo!');
	}
}
	
