var lastColorUsed;
function DG_changeBackColor(row, highlight)
{
  if (highlight)
  {
    lastColorUsed = row.style.backgroundColor;
    row.style.backgroundColor = 'Orange';
  }
  else
    row.style.backgroundColor = lastColorUsed;
}

function DG_changeForeColor(row, hightlight)
{
  if (hightlight)
  {
	row.style.ForeColor = 'Orange';
  }
  else
	row.style.ForeColor = 'Navy';
}

function DG_changeBackColorWeb(row, highlight)
{
  if (highlight)
  {
    lastColorUsed = row.style.backgroundColor;
    row.style.backgroundColor = 'D6DEFA';
  }
  else
    row.style.backgroundColor = lastColorUsed;
}

function imgUP (image) {
image.style.borderStyle="outset";
image.style.borderWidth="1";
}

function imgDown (image) {
image.style.borderStyle="inset";
image.style.borderWidth="1";
}

function imgNormal (image) {
image.style.borderStyle="";
image.style.borderWidth="0";
}

///////////////////////////////////////////////////////////
//
// Returns true if the string passed in is a valid number (no alpha characters)
//
///////////////////////////////////////////////////////////

function ForceNumber(objField)
{
	var strField = new String(objField.value);
	
	var i = 0;

	for (i = 0; i < strField.length; i++)
		if (strField.charAt(i) < '0' || strField.charAt(i) > '9') {
			objField.focus();
			return true;
		}

	return false;
	
}

////////////////////////////////////////////////




function setTitle(title)
{
	var con;
	con = document.all("PM_HEADER_lblTitle");
	con.innerText = title;
	
}


function OpenClientFile()
{
	var cID;
	var ClientDDL = document.all("drplist_client");
	if (ClientDDL.selectedIndex <= 0)
	{
		//cID = 1
		ClientDDL.selectedInfex = 1;
		cID = ClientDDL.value;
		
	}
	else{
		cID = ClientDDL.value;
	}
	NewWindow("../sys/clientInfo.aspx?cID="+ cID, "ClientInfo", "410", "300", 'no', 'center'); 
}

function OpenClientFile1()
{
	var cID;
	var ClientDDL = document.all("ddlClient");
	if (ClientDDL.selectedIndex <= 0)
	{
		//cID = 1
		ClientDDL.selectedInfex = 1;
		cID = ClientDDL.value;
		
	}
	else{
		cID = ClientDDL.value;
	}
	NewWindow("../sys/clientInfo.aspx?cID="+ cID, "ClientInfo", "410", "300", 'no', 'center'); 
}

function OpenProjectInfo(ctlName)
{
	var pID;
	var ProjectDDL = document.all(ctlName);
	if (ProjectDDL.selectedIndex <= 0)
	{
		//cID = 1
		return
		
	}
	else{
		pID = ProjectDDL.value;
	}
	NewWindow("../project/ProjectInfoCS.aspx?pID="+ pID, "ProjectInfo", "410", "300", 'no', 'center'); 
}



function OpenProjectFileList()
{
	var pID;
	var lblID = document.all("txt_pj_id");
	pID = lblID.innerText;
	if (pID != "")
	{
		NewWindow("../project/ProjectDoc.aspx?pID=" + pID, "ProjectDoc", "600", "500", 'no', 'center');
	}
}

var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.availWidth)?Math.floor(Math.random()*(screen.availWidth-w)):50;TopPosition=(screen.availHeight)?Math.floor(Math.random()*((screen.availHeight-h)-75)):50;}
if(pos=="center"){LeftPosition=(screen.availWidth)?(screen.availWidth-w)/2:50;TopPosition=(screen.availHeight)?(screen.availHeight-h)/2:50;}
if(pos=="default"){LeftPosition=50;TopPosition=50}
else if((pos!="center" && pos!="random" && pos!="default") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);
if(win.focus){win.focus();}}
function CloseNewWin(){if(win!=null && win.open)win.close()}
window.onfocus=CloseNewWin;






function ListBoxAddItem(SourceID, DestID)
{
	var ls = document.all(SourceID);
	var ld = document.all(DestID);
	if (ls.selectedIndex!=-1)
	{
		var optionSelected = ls.options[ls.selectedIndex];
		AddOption(ld, optionSelected.text, optionSelected.value);
		optionSelected.selected = false;
		ListBoxAddItem(SourceID, DestID);
	}
	setListValues(DestID, "txtListValues");
	return false;
}

function AddOption(ld, optionText, optionValue)
{
	if (!CheckOptionExist(ld, optionText, optionValue))
	{
		var optionNew = new Option(optionText,optionValue);
		var optionRank = ld.options.length;
		ld.options[optionRank]=optionNew;
	}
}

function CheckOptionExist(selectObject, optionText, optionValue)
{
	var sltbool = false;
	for (i=0; i<selectObject.options.length; i++){
		if (optionText == selectObject.options[i].text ||  optionValue == selectObject.options[i].value ){
			sltbool = true;
			break;
		}
	} 
	return sltbool;	
}

function DeleteOption(ListID)
{
	var selectObject = document.all(ListID);
	if (selectObject.options.length!=0)
	{
		if (selectObject.selectedIndex!=-1)
		{
			selectObject.options[selectObject.selectedIndex] = null;
		}
	}
	setListValues(ListID, "txtListValues");
	return false;
}

function setListValues(ListID, txtID)
{
	var selectObject = document.all(ListID);
	var txtObject = document.all(txtID);
	var intCount = selectObject.options.length; 
	var elements = "";
	for (i = 0; i < intCount; i++) 
    { 
        elements += selectObject.options[i].value + ';';
    } 
    txtObject.value = elements;
}