var Nav4 = document.layers;
var IE4 = document.all;
var Undefined;
var NoRightKey=false;

function Logout()
{
	this.location.href='home.aspx?Logout=1';
}
function bbb()
{
	if(NoRightKey)
	{
		return false;
	}
	else
		return true;
}
	if (document.all && window.print){document.oncontextmenu = bbb;}

function enterkey(e)
{
	if (Nav4)
	{
		keyPressed = String.fromCharCode(e.which);
	}
	
	else if (IE4)
	{
		keyPressed = String.fromCharCode(window.event.keyCode);
	}	

	if (keyPressed == "\r" || keyPressed == "\n")return (false);
}

function document.onkeydown()
{
  var e = event.srcElement;
  k=window.event.keyCode;
  bCtrl=window.event.ctrlKey;
  bShift=window.event.shiftKey;
  if(NoRightKey)
  {
  	if( ((k==67) && bCtrl)||( (k==45)&&bCtrl) )return false;
  }
  
  if (event.keyCode == 13)
  {
  	if(e.tagName == "INPUT" && (e.type == "button" || e.type=="submit"))
  	{
  		return true;
  	}
  	if(e.tagName == "TEXTAREA")return true;
  	
  	event.keyCode=9;
  	return true;
  }
}


winToBeFocused = false;
cancelInputFocus = false;
function delayWinFocus(win)
{
	winToBeFocused = win;
	cancelInputFocus = true;
	setTimeout("doWinFocus();",500);
}

function doWinFocus()
{
	if (winToBeFocused && !winToBeFocused.closed){
		winToBeFocused.focus();
	}
}

function showAttach(FileId)
{
	if(FileId==""||FileId=="0")return false;
	
	var w = 750;
	var h = 530;
	var l =(window.screen.availWidth-w)/2;
	var t = (window.screen.availHeight-h)/2;

	winopt = "location=no scrollbars=yes menubar=no status=no resizable=0 width="+w+" height="+h+" left="+l+" top="+t;
	urlParam = "../Tool/AttachView.aspx?NoHistory=1&FileId=" + FileId+"&n=3.txt";
	winName = "attach_view";
	newWin = window.open(urlParam,winName,winopt);
	delayWinFocus(newWin);
	return false;
}
function showTask(TaskType,TaskId)
{
	var s='';
	switch(TaskType)
	{
		case "Market":	
		case "Sell":
		case "Service":
		case "CareFor":
			s="EditTask.aspx?Id=" + TaskId + "&TaskType=" + TaskType;
			break;
	}
	if(s!='')
	{
		document.all.RedirectURL.value=s;
		document.forms[0].submit();
	}
}
function createTask()
{
	document.all.RedirectURL.value='';
	return true;
}
function showGoods(GoodsId)
{
	document.all.RedirectURL.value='EditGoods.aspx?Id=GoodsId';
	document.forms[0].submit();
}
//函数名：SelectDate  
//功能介绍：弹出窗口选择日期，返回值填充输入框
//参数说明：要填充的输入框
//返回值：
function SelectDate(Obj)
{
	var Undefined;
	var d=window.showModalDialog("/CRM/DateSelect.htm?" + new Date().valueOf(),Obj.value,"dialogWidth:175px;dialogHeight:180px;dialogLeft:250;DialogTop:100");
	if(d!=Undefined)
	{
		Obj.value=d;
	}
}
function printURL(Param)
{
	var s='/CRM/Frame/B_PrintFrm.asp?Main='+escape(Param + '&P=1');
	window.open(s,'',"fullscreen=1,dialogWidth:800px;dialogHeight:600px;dialogLeft:0;DialogTop:0'");
}
function goHidden(Param)
{
	document.all.printHiddenFrame.document.location.href=Param;
}
