//*************************
//页面予留
function page_onload_ini(){
//	window.self.focus();
	//flash_title();
	//forbid_mouse_menu();
}

function page_onload_rsv(){
	//在具体实际页面中，从新写一个该同名函数。
	//目的是可以执行<body onload="page_onload_ini();page_onload_rsv();">中的page_onload_rsv()。
}

//

function find_in_result0(form){
	var p  = form.p.value;
	var lp = form.lp.value;
	//if(p == lp || p == ''){
	if(p == ''){
		alert ('请输入搜索的关键词内容');
		form.p.focus();
		return false;
	} 
	form.p.value = p + ' ' + lp;
	form.submit();	
	return true;
}

function find_in_result(form){
	var p0  = form.p0.value;
	var lp = form.lp.value;
	//if(p == lp || p == ''){
	if(p0 == ''){
		alert ('请输入待搜索的关键词。多个关键词之间用空格 分开。');
		form.p0.focus();
		return false;
	} 
	form.q.value = p0 + ' ' + lp;
	form.submit();	
	return true;
}




/**全屏打开链接*/
function hideWin(){
	self.blur();
	window.moveTo(screen.availWidth,screen.availHeight);
}

//全屏打开链接
function openWinFull(targeturl){
	var tgt = window.open(targeturl,"","fullscreen,scrollbars");
	tgt.focus();
}

//窗口自动最大化
function openWinMax(){
	window.moveTo(0,0);
	window.resizeTo(screen.availWidth,screen.availHeight);
}

//定时窗口全屏
function openWinMax(delay_time){
	setTimeout('window.moveTo(0,0)',delay_time);
	setTimeout('window.resizeTo(screen.availWidth,screen.availHeight)',delay_time);
}

//*************************
function openWin(targeturl,tgt) {
	var tgt = window.open(targeturl,tgt);
	tgt.focus();
}

//*************************
function openWin0(targeturl,tgt) {
	var tgt = window.open(targeturl,tgt,'toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes');
	tgt.focus();
}

//*************************
function openWin1(targeturl,tgt,wd,hg) {
	var tgt = window.open(targeturl,tgt,'menubar=no,toolbar=no,location=no,width='+wd+',height='+hg+'');
	tgt.focus();
}
//*************************
function openWin2(targeturl,tgt) {
	var tgt = window.open(targeturl,tgt,'menubar=yes,toolbar=yes,location=no,scrollbars=yes,resizable=yes');
	tgt.focus();
}

//*************************
function openWinMid(targeturl,tgt,wd,hg) {
//	if(tgt) alert("111");
//	if(window.tgt) alert("222");
	var leftmar = (screen.width-wd)/2 ;
	var topmar = (screen.height-hg)/2 ;
	var tgt = window.open(targeturl,tgt,'menubar=no,toolbar=no,location=no,scrollbars=yes,status=no,left='+leftmar+',top='+topmar+',width='+wd+',height='+hg+'');
	if(tgt) tgt.focus();
}
//*************************
function openWinMid1(targeturl,tgt,wd,hg) {
	var leftmar = (screen.width-wd)/2 ;
	var topmar = (screen.height-hg)/2 - 60 ;
	var tgt = window.open(targeturl,tgt,'menubar=yes,toolbar=yes,scrollbars=yes,resizable=yes,left='+leftmar+',top='+topmar+',width='+wd+',height='+hg+'');
	tgt.focus();
}
//*************************
function openWinMid2(targeturl,tgt,wd,hg) {
	var leftmar = (screen.width-wd)/2 ;
	var topmar = (screen.height-hg)/2 ;	
	var tgt = window.open(targeturl,tgt,'menubar=no,toolbar=no,location=no,scrollbars=yes,status=no,left=(screen.width-'+wd+')/2,top=(screen.height-'+hg+')/2,width='+wd+',height='+hg+'');
	tgt.focus();
}

//*************************
function moveWinToMid(winwidth,winheight) {
	window.moveTo((screen.availWidth-winwidth)/2,(screen.availHeight-winheight)/2);
	window.resizeTo(winwidth,winheight);
}

//*************************
function moveWinTo(x0,y0) {
	//window.moveTo(x0,y0);
}


//关闭整个帧页面
function winFrameClose(){
if(window.parent) window.parent.close();
//if(window.opener) window.opener.close();
window.close();
self.close();
}


//*************************
function leave_to() {
	//setAsHomePage();
	//window.open('http://frank/','','toolbar=no,menubar=no,location=no,height=70,width=650');
}
//Usage: <body onunload="leave_to()">

//禁止鼠标右键
function mouse_menu(){ 
	window.event.returnValue=false; 
} 
function forbid_mouse_menu(){ 
	document.oncontextmenu=mouse_menu; 
} 


//add to favorite
function addFavorite() {
	if ( document.getElementById )	window.external.addFavorite('http://www.pifala.com/','★ 批发啦物流 www.pifala.com ★');
}

//*************************
function setAsHomePage() {
	//style.behavior= "url(#default#homepage)";
	//setHomePage("http:///") ;
	if (!hp.isHomePage('http://www.google.com/')) {
		document.write("<p><a href=\"#btm\" onClick=\"style.behavior='url(#default#homepage)';setHomePage('http://www.google.com/');\">将 Google 设为首页！</a>");
	}
}


//**********************
function chg_parent_ifrm(p_obj) {
	if(window.parent.document.getElementById(p_obj)) {	//如果父窗口存在
		window.parent.document.getElementById(p_obj).height=this.document.body.scrollHeight+10;
	}
}

function chg_parent_ifrm(p_obj,height_add) {
	if(window.parent.document.getElementById(p_obj)) {	//如果父窗口存在
		window.parent.document.getElementById(p_obj).height=this.document.body.scrollHeight+height_add;
	}
}

function chg_parent_parent_ifrm(pp_obj,p_obj) {
	if(window.parent.parent.document.getElementById(pp_obj)) {	//如果父窗口的父窗口存在
		window.parent.parent.document.getElementById(pp_obj).height=window.parent.document.body.scrollHeight+10;
	}
}






//**********************
function movr(src){
//	if (!src.contains(event.fromElement)) {
		src.style.cursor = 'hand';
		src.bgColor = '#FFFF00';
//	}
}

function mout(src)  {
//	if (!src.contains(event.toElement)) {
		src.style.cursor = 'default';
		src.bgColor = '#ffffff';
//	}
}


function mclk1(src,clrClk) {
//	if (!src.contains(event.fromElement)) {
		src.style.cursor = 'default';
		src.bgColor = 'clrClk';
//	}
}

function mclk2(src) {
//	if (!src.contains(event.fromElement)) {
		src.style.cursor = 'hand';
		src.bgColor = '#99FF99';
//	}
}


//*****************
function MM_jumpMenu(targ,selObj,restore){ //v3.0                         
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;                                    
}

//*************************
//change text profile
//function rollon() {
// if(window.event.srcElement.tagName == "A"){ 
//   window.event.srcElement.style.color = "red";
// }
//window.event.srcElement.style.textDecoration = "underline"; 
//} 
//
//function rolloff() {
// if(window.event.srcElement.tagName == "A"){ 
//   window.event.srcElement.style.color = "";
// }
// window.event.srcElement.style.textDecoration = "none";  
//} 
//
//document.onmouseover = rollon; 
//document.onmouseout = rolloff; 　
//*************************




//以下为IE标题栏闪烁开始
//*************************
var step=0;
oldtitle=document.title;
function flash_title(){
	step++;
	if (step==1) {document.title='★ '+ oldtitle;}
	if (step==2) {document.title='☆ '+ oldtitle;}
	if (step>=3) {step=0;}
	setTimeout("flash_title()",200);
}
//*************************
//以上为IE标题栏闪烁结束

function append_win_title(win_title){
	document.title=win_title +" ----- "+ oldtitle;
}
function replace_win_title(win_title){
	document.title=win_title;
}

/*	Randy Peterman
	10-01-02
	Trim function for removing leading and trailing whitespaces.
	Accepts form element name and string both.
	Returns the trimmed string back to the user.
*/

function trim(inputString) 
	{
	if(inputString.type == "text")
		{
		inputString = inputString.value;
		};
	for (var i=0; i<document.forms[0].length; i++)
		{
		if (document.forms[0].elements[i].name == inputString)
			{
			inputString = document.forms[0].elements[i].value;
			break;
			};
		}
	if (typeof inputString != "string")
		{
		return inputString;
		};
	var retValue = inputString;
	var ch = retValue.substring(0, 1);
	while (ch == " ")
		{
		// Check for spaces at the beginning of the string
		retValue = retValue.substring(1, retValue.length);
		ch = retValue.substring(0, 1);
		};
	ch = retValue.substring(retValue.length-1, retValue.length);
	while (ch == " ") 
		{
		// Check for spaces at the end of the string
		retValue = retValue.substring(0, retValue.length-1);
		ch = retValue.substring(retValue.length-1, retValue.length);
		};
	while (retValue.indexOf("  ") != -1)
		{
		// Note that there are two spaces in the string - look for multiple spaces within the string
		retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); 
		// Again, there are two spaces in each of the strings
	   };
	return retValue; 
	}
	
	////////////////////////
function get_srv_domainname(){

    var urlori=self.location.toString();
    var s2=urlori.indexOf("//")+2;
    var s3=urlori.indexOf('/',s2);
    var urltmp2=urlori.substring(s2,s3);
    document.write(urltmp2);
    //return urlori;
}



//**************************	
//发送给朋友
function send_to_frd(msg_title){
	win_url = "/inc/send_to_frd/send_to_frd_form.jsp?msg_url="+self.location+"&msg_title="+msg_title;
	//alert(win_url);
	win_send_to_frd = window.open(win_url,"win_send_to_frd","toolbar=no,scrollbars=no,menubar=no,width=520,height=300");
}	



// BannerAD 随机显示图片广告

var ad_dir ="/images/adver/"
var max_ad_num = 10;

var ad_array=new Array(30); 
ad_array[0]=new Array("andafa_ppm_ad01.png","100个某产品的精确的平均预估制造成本是多少？安达发PPM精准成本利润分析系统精确分析每个产品、每张订单的制造成本，让企业明明白白的赚钱！","/f52/1216010.html");
ad_array[1]=new Array("andafa_apsabe_ad02.png","业界一流、功能强大、使用简单、买得起的，精益制造与高级计划管理系统=安达发Apsabe","/f52/1210001.html");
ad_array[2]=new Array("andafa_apsabe_ad01.jpg","生产排程了吗？试试Apsabe高级计划管理！","/f52/1211001.html");
ad_array[3]=new Array("andafa_aps_ad02.png","使用ERP了吧？订单变更时很烦吧？还在用手工Excel做生产计划吧？计划只能到车间级，无法到机台、班组吧？","/f52/1211010.html");
ad_array[4]=new Array("andafa_apsabe_ad03.png","安达发Apsabe先进精益制造管理系统解决方案，以自动详细生产计划为核心，构建准时、精良、敏捷的制造管理信息系统。","/f52/1210010.html");
ad_array[5]=new Array("andafa_apsabe_ad04.png","制造业的核心价值在哪里？您最应该实施什么信息系统？","/f52/1210001.html");
ad_array[6]=new Array("andafa_dms_ad01.png","如何在1秒钟内找到某个文件所有早期的历史版本？ 安达发DMS文档管理系统有效解决企业电子文件多、变更快的问题。","/f52/1212010.html");
ad_array[7]=new Array("andafa_pdm_ad01.png","安达发提供业界首创的PDM产品工艺数据管理系统它以图形化鼠标拖动的方式，非常方便的提供产品工艺的维护、分发、变更、应用、权限等一系列原本非常复杂的管理功能。","/f52/1213010.html");
ad_array[8]=new Array("andafa_aps_ad03.png","库存呆滞品一大堆？物料需求与生产计划脱节？无法根据分批生产计划来采购和备料？安达发APS高级计划管理带给您JIT式的分批生产和物料需求计划。恰到好处、杜绝浪费、精益求精！","/f52/1211010.html");
ad_array[9]=new Array("andafa_soft_lease_ad01.png","怕贵？没预算？暂时买不起？怕不好用？怕风险？不敢买？试试安达发软件出租、租赁服务。花最少的钱，立即用上最好的系统，并且没有风险。","/f52/1224006.html");

ad_array[99]=new Array("andafa_sap.jpg","安达发SAP技术支持与维护外包","/f52/1221019.html");

//随机取得广告
function get_rand_ad() { 
	var rand_num = 0;
	rand_num = Math.random();
	rand_num = Math.floor(rand_num*max_ad_num);
	return rand_num;
}

//显示广告图片
function show_ad() { 
alert("ok");
/*	var ad_index = get_rand_ad();	
　　while(ad_index==0 || ad_index>=ad_array.length) {ad_index = get_rand_ad();}

	var ad_str = "<a href=\""+ad_array[ad_index][2]+"\" target=_blank><img src=\""+ad_dir+ad_array[ad_index][0]+"\" alt=\""+ad_array[ad_index][1]+"\" width=\"468\" height=\"60\" border=\"0\"></a>";
	document.write(ad_str);
	*/
} 


//显示广告图片
function change_ad() { 
	var ad1_index = get_rand_ad();
　　while(ad1_index>=ad_array.length) {ad1_index = get_rand_ad();}

	if(this.document.getElementById("ad1")){
		this.document.getElementById("ad1").src = ad_dir+ad_array[ad1_index][0];
		this.document.getElementById("ad1").alt = ad_array[ad1_index][1];
	}
	
	if(this.document.getElementById("aad1")){
		this.document.getElementById("aad1").href = ad_array[ad1_index][2];
	}
	
	var ad2_index = get_rand_ad();
　　while(ad2_index>=ad_array.length || ad2_index==ad1_index) {ad2_index = get_rand_ad();}

	if(this.document.getElementById("ad2")){
		this.document.getElementById("ad2").src = ad_dir+ad_array[ad2_index][0];
		this.document.getElementById("ad2").alt = ad_array[ad2_index][1];
	}
	
	if(this.document.getElementById("aad2")){
		this.document.getElementById("aad2").href = ad_array[ad2_index][2];
	}

	var ad3_index = get_rand_ad();
　　while(ad3_index>=ad_array.length || ad3_index==ad1_index || ad3_index==ad2_index) {ad3_index = get_rand_ad();}
	if(this.document.getElementById("ad3")){
		this.document.getElementById("ad3").src = ad_dir+ad_array[ad3_index][0];
		this.document.getElementById("ad3").alt = ad_array[ad3_index][1];
	}
	
	if(this.document.getElementById("aad3")){
		this.document.getElementById("aad3").href = ad_array[ad3_index][2];
	}
	
} 

//结束广告


//剩余天数
function days_left(timenow) { 
	
	var urodz= new Date(timenow);
	var s="";
	
	var now = new Date();
	var ile = urodz.getTime() - now.getTime();
	var dni = Math.floor(ile / (1000 * 60 * 60 * 24))+1;
	var dni2 ="<b>"+ dni +"</b>";
	
	if (dni >= 1)
	document.write(s+"只剩"+dni2 +"天啦！")
	else if (dni = 0)
	document.write(s+"今天是最后1天啦！");
	else
	document.write("已经过期啦！");
}


//*************************

