﻿// JavaScript Document


/*document.onclick= function(){
var obj = event.srcElement;
if(obj)
{

if(obj.name && obj.id == 'classname')
return ;
else
{
if(obj.tagName == 'A' && obj.parentNode.tagName == 'LI' && obj.parentNode.parentNode.parentNode.id=='classtree')
{

document.all['classname'].value = obj.children[0].innerText;

}

document.all['classtree'].style.display='none';

}
}
document.all['classtree'].style.display='none';
}
*/

var winajax = null;
function initmsg(iwdth, iheight)
{
	var innerHTML = '<div id="msg" style="width:100%;height:100%;background:#999999;border:1px solid #00;">';
		innerHTML += '<div style="padding:3px;font-weight:bold;font-size:13px">操作提示</div>';
		innerHTML +='<div id="msgcontent" style="width:100%;height:82%;background:#FFFFFF;text-align:center;font-size:9pt">';
		innerHTML +='<br><br><img border="0" src="/AdminManager/StaticResource/images/ajax_loading.gif" align="absmiddle">&nbsp;&nbsp;相关操作正在进行中，请等待...';
		innerHTML +='</div></div>';
		winajax = window.createPopup();
		winajax.document.body.innerHTML = innerHTML;
		var ix = (window.screen.availWidth - iwdth) / 2;
		var iy = (window.screen.availHeight - iheight) / 2;
		winajax.show(ix,iy,iwdth,iheight);
}

function ShowCompanyPageList(objname, pageindx, maxpage)
{
	var obj = null;
	displayobj = document.all[objname + pageindx];
	for(var i= 1; i <= maxpage; i++)
	{
		obj = document.all[objname + i];
		if(obj != null)
		{
			if(i == pageindx)
			{
				continue;
			}
			else
				obj.style.display = 'none';
		}
	}
	displayobj.style.display = '';
}

function initClassTree()
{
	initmsg(240, 120);
	EBLivWebApp.UserControls.ClassTree.ClassTreeControl.GetClassTree
	(
	 _tableclass,
	 _tablesingle,
	 _filterclassname,
	 _parentid,
	 _templatepath,
	 _pagesize,
	 _maxColum,
	 callbackresult1
	 );
	
}

function initClassTree1()
{
	initmsg(240, 120);
	EBLivWebApp.UserControls.ClassTree.ClassTreeControl.GetClassTree1
	(
	  _tablesingle,
	 _parentid,
	 _templatepath,
	 _pagesize,
	 1,
	 callbackresult2
	 );
	
}

function initClassTree2()
{
	initmsg(240, 120);
	EBLivWebApp.UserControls.ClassTree.ClassTreeControl.GetClassTree2
	(
	  _tablesingle,
	 _parentid,
	 _templatepath,
	 _pagesize,
	 _keyInfo,
	 1,
	 callbackresult3
	 );
	
}




function callbackresult2(result)
{
	//alert(result.value);
	var arry = result.value.split('|');
	if(arry.length == 1)
	{
		switch(result.value)
		{
		case "nopage" :
		case "nocount" :
			//showresult(240,120,"根据您查询条件数据库中找不到任何匹配结果!");
			document.all["pageList"].style.display = 'none';
			//document.all["AddUserInf"].disabled = '';
			var obj = document.all["msgcontent"];
			obj.innerHTML = '<center>目前类别下不存在任何有效数据,或是数据正在添加中.</center>';
		break;
		case "error" :
			location.href="/Error.aspx";
		break;
		default :
			//showresult(240,120,"您输入的查询条件的书写格式不正确!");
			var obj = document.all["msgcontent"];
			obj.innerHTML = '<center>您输入的查询条件的书写格式不正确!</center>';
			document.all["pageList"].style.display = 'none';
		break;
		}		
	}
	else
	{
		var obj = document.all["msgcontent"];
		obj.innerHTML = result.value.split("|")[2];
		showpageList4(result.value.split("|")[0],result.value.split("|")[1]);
		//document.all["AddUserInf"].disabled = '';
		//document.all["ToClassInfo"].selectedIndex = 0;
		
	}
	if(winajax != null && winajax.isOpen)
			winajax.hide();
	
}

function callbackresult3(result)
{
	//alert(result.value);
	var arry = result.value.split('|');
	if(arry.length == 1)
	{
		switch(result.value)
		{
		case "nopage" :
		case "nocount" :
			//showresult(240,120,"根据您查询条件数据库中找不到任何匹配结果!");
			document.all["pageList"].style.display = 'none';
			//document.all["AddUserInf"].disabled = '';
			var obj = document.all["msgcontent"];
			obj.innerHTML = '<center style="padding-top:10px">根据您查询的条件,数据库中不存在任何有效的产品纪录!</center>';
		break;
		case "error" :
			location.href="/Error.aspx";
		break;
		default :
			//showresult(240,120,"您输入的查询条件的书写格式不正确!");
			var obj = document.all["msgcontent"];
			obj.innerHTML = '<center style="padding-top:10px">您输入的查询条件的书写格式不正确!</center>';
			document.all["pageList"].style.display = 'none';
		break;
		}		
	}
	else
	{
		var obj = document.all["msgcontent"];
		obj.innerHTML = result.value.split("|")[2];
		showpageList4(result.value.split("|")[0],result.value.split("|")[1]);
		//document.all["AddUserInf"].disabled = '';
		//document.all["ToClassInfo"].selectedIndex = 0;
		
	}
	if(winajax != null && winajax.isOpen)
			winajax.hide();
	
}


function callbackresult1(result)
{
	//alert(result.value);
	var arry = result.value.split('|');
	if(arry.length == 1)
	{
		switch(result.value)
		{
		case "nopage" :
		case "nocount" :
			//showresult(240,120,"根据您查询条件数据库中找不到任何匹配结果!");
			document.all["pageList"].style.display = 'none';
			//document.all["AddUserInf"].disabled = '';
			var obj = document.all["msgcontent"];
			obj.innerHTML = '<center>目前不存在任何有效的数据类别,或是数据正在添加中.</center>';
		break;
		case "error" :
			location.href="/Error.aspx";
		break;
		default :
			//showresult(240,120,"您输入的查询条件的书写格式不正确!");
			var obj = document.all["msgcontent"];
			obj.innerHTML = '<center>您输入的查询条件的书写格式不正确!</center>';
			document.all["pageList"].style.display = 'none';
		break;
		}		
	}
	else
	{
		var obj = document.all["msgcontent"];
		obj.innerHTML = result.value.split("|")[2];
		showpageList3(result.value.split("|")[0],result.value.split("|")[1]);
		//document.all["AddUserInf"].disabled = '';
		//document.all["ToClassInfo"].selectedIndex = 0;
		
	}
	if(winajax != null && winajax.isOpen)
			winajax.hide();
	
}



function articleinitPage()
{
	initmsg(240, 120);
	EBLivWebApp.UserControls.Information.InformationPageListControl.GetSearchButtonList
	(
	 		classid, 
			ntitle, 
			ikey, 
			pkey, 
			isNew,
			isHot,
			isjs,
			isindex,
			isanywhere,
			ispass,
			isimage,
			isextern,
			datestart,
			dateend,
			islike,
			islike1,
			islike2,
			nonestate,
			pagesize,
			itemfilepath,
			isDiv,
			articlecall
	);
}


function articleinitPage3()
{
	initmsg(240, 120);
	EBLivWebApp.UserControls.Message.MessageListControl.GetSearchButtonList
	(
	 		pagesize,
			itemfilepath,
			false,
			articlecall2
	);
}






function productinitPage()
{
	initmsg(240, 120);
	EBLivWebApp.UserControls.Product.ProductPageListControl.GetSearchButtonList
	(
	 		classid, 
			ntitle, 
			ikey, 
			pkey, 
			isNew,
			isHot,
			isjs,
			isindex,
			isanywhere,
			ispass,
			isextern,
			datestart,
			dateend,
			islike,
			islike1,
			islike2,
			nonestate,
			pagesize,
			itemfilepath,
			isDiv,
			productcall
	);
}






function productcall(result)
{
	//alert(result.value);
	var arry = result.value.split('|');
	if(arry.length == 1)
	{
		switch(result.value)
		{
		case "page0" :
		case "nocount" :
			//showresult(240,120,"根据您查询条件数据库中找不到任何匹配结果!");
			document.all["pageList"].style.display = 'none';
			//document.all["AddUserInf"].disabled = '';
			var obj = document.all["msgcontent"];
			obj.innerHTML = '<center>当前不存在任何有效数据,或者数据在录入过程中.</center>';
		break;
		case "error" :
			location.href="/Error.aspx";
		break;
		default :
			//showresult(240,120,"您输入的查询条件的书写格式不正确!");
			var obj = document.all["msgcontent"];
			obj.innerHTML = '<center>您输入的查询条件的书写格式不正确!</center>';
			document.all["pageList"].style.display = 'none';
		break;
		}		
	}
	else
	{
		var obj = document.all["msgcontent"];
		obj.innerHTML = result.value.split("|")[2];
		showpageList1(result.value.split("|")[0],result.value.split("|")[1]);
		//document.all["AddUserInf"].disabled = '';
		//document.all["ToClassInfo"].selectedIndex = 0;
		
	}
	if(winajax != null && winajax.isOpen)
			winajax.hide();
}


function articlecall(result)
{
	//alert(result.value);
	var arry = result.value.split('|');
	if(arry.length == 1)
	{
		switch(result.value)
		{
		case "page0" :
		case "nocount" :
			//showresult(240,120,"根据您查询条件数据库中找不到任何匹配结果!");
			document.all["pageList"].style.display = 'none';
			//document.all["AddUserInf"].disabled = '';
			var obj = document.all["msgcontent"];
			obj.innerHTML = '<center>当前不存在任何有效数据,或者数据在录入过程中.</center>';
		break;
		case "error" :
			location.href="/Error.aspx";
		break;
		default :
			//showresult(240,120,"您输入的查询条件的书写格式不正确!");
			var obj = document.all["msgcontent"];
			obj.innerHTML = '<center>您输入的查询条件的书写格式不正确!</center>';
			document.all["pageList"].style.display = 'none';
		break;
		}		
	}
	else
	{
		var obj = document.all["msgcontent"];
		obj.innerHTML = result.value.split("|")[2];
		showpageList(result.value.split("|")[0],result.value.split("|")[1]);
		//document.all["AddUserInf"].disabled = '';
		//document.all["ToClassInfo"].selectedIndex = 0;
		
	}
	if(winajax != null && winajax.isOpen)
			winajax.hide();
}

function articlecall2(result)
{
	//alert(result.value);
	var arry = result.value.split('|');
	if(arry.length == 1)
	{
		switch(result.value)
		{
		case "page0" :
		case "nocount" :
			//showresult(240,120,"根据您查询条件数据库中找不到任何匹配结果!");
			document.all["pageList"].style.display = 'none';
			//document.all["AddUserInf"].disabled = '';
			var obj = document.all["msgcontent"];
			obj.innerHTML = '<center>当前不存在任何有效数据,或者数据在录入过程中.</center>';
		break;
		
		case "close" :
		document.all["pageList"].style.display = 'none';
		var obj = document.all["msgcontent"];
			obj.innerHTML = '<center>留言板功能已经关闭.</center>';
		break;
		
		
		case "error" :
			location.href="/Error.aspx";
		break;
		default :
			//showresult(240,120,"您输入的查询条件的书写格式不正确!");
			var obj = document.all["msgcontent"];
			obj.innerHTML = '<center>您输入的查询条件的书写格式不正确!</center>';
			document.all["pageList"].style.display = 'none';
		break;
		}		
	}
	else
	{
		var obj = document.all["msgcontent"];
		obj.innerHTML = result.value.split("|")[2];
		showpageList00(result.value.split("|")[0],result.value.split("|")[1]);
		//document.all["AddUserInf"].disabled = '';
		//document.all["ToClassInfo"].selectedIndex = 0;
		
	}
	if(winajax != null && winajax.isOpen)
			winajax.hide();
}





function showpageList(maxpage, pageindex)
{
	document.all["pageList"].style.display = '';
	var result = pager('Getpage({p});', parseInt(pageindex), parseInt(maxpage));
	var obj1 = document.all["PageShow"].innerHTML = '当前第 '+ pageindex +' 页,共 '+ maxpage+' 页&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + result;
	
	//var obj2 = document.all["pageList"].innerHTML = result;
}

function showpageList1(maxpage, pageindex)
{
	document.all["pageList"].style.display = '';
	var result = pager('Getpage1({p});', parseInt(pageindex), parseInt(maxpage));
	var obj1 = document.all["PageShow"].innerHTML = '当前第 '+ pageindex +' 页,共 '+ maxpage+' 页&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + result;
	
	//var obj2 = document.all["pageList"].innerHTML = result;
}


function showpageList00(maxpage, pageindex)
{
	document.all["pageList"].style.display = '';
	var result = pager('Getpage00({p});', parseInt(pageindex), parseInt(maxpage));
	var obj1 = document.all["PageShow"].innerHTML = '当前第 '+ pageindex +' 页,共 '+ maxpage+' 页&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + result;
	
	//var obj2 = document.all["pageList"].innerHTML = result;
}

function showpageList3(maxpage, pageindex)
{
	document.all["pageList"].style.display = '';
	var result = pager('Getpage3({p});', parseInt(pageindex), parseInt(maxpage));
	var obj1 = document.all["PageShow"].innerHTML = '当前第 '+ pageindex +' 页,共 '+ maxpage+' 页&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + result;
	
	//var obj2 = document.all["pageList"].innerHTML = result;
}

function showpageList4(maxpage, pageindex)
{
	document.all["pageList"].style.display = '';
	var result = pager('Getpage4({p});', parseInt(pageindex), parseInt(maxpage));
	var obj1 = document.all["PageShow"].innerHTML = '当前第 '+ pageindex +' 页,共 '+ maxpage+' 页&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + result;
	
	//var obj2 = document.all["pageList"].innerHTML = result;
}

function Getpage1(pageIndex)
{
	
	if(document.all["WhereStr"] != null)
	{
		EBLivWebApp.UserControls.Product.ProductPageListControl.GetPage
		(
		 pageIndex, 
		 document.all["WhereStr"].innerText ,
		 pagesize,
		 itemfilepath,
		 isDiv,
		 productcall
		 );	
	}
}

function Getpage(pageIndex)
{
	
	if(document.all["WhereStr"] != null)
	{
		EBLivWebApp.UserControls.Information.InformationPageListControl.GetPage
		(
		 pageIndex, 
		 document.all["WhereStr"].innerText ,
		 pagesize,
		 itemfilepath,
		 isDiv,
		 articlecall
		 );	
	}
}

function Getpage3(pageIndex)
{
	
	if(document.all["WhereStr"] != null)
	{
		
	EBLivWebApp.UserControls.ClassTree.ClassTreeControl.GetPageString
	(
	 _tableclass,
	 _tablesingle,
	 _templatepath,
	 _pagesize,
	 pageIndex,
	 document.all["WhereStr"].innerText,
	 callbackresult1
	 );
	}
}


function Getpage4(pageIndex)
{
	//alert('dasdasda');
	if(document.all["WhereStr"] != null)
	{
		
	
	if(document.all["WhereStr"].innerText == null)
	{
		document.all["WhereStr"].innerText = _wherestring;
	}
	EBLivWebApp.UserControls.ClassTree.ClassTreeControl.GetPageString1
	(
	 _tablesingle,
	 _templatepath,
	 _pagesize,
	 pageIndex,
	 document.all["WhereStr"].innerText,
	 1,
	 callbackresult2
	 );
	}
	
}


function showresult(iwdth,iheight,result)
{
	if(winajax == null)
	{
		var innerHTML = '<div id="msg" style="width:100%;height:100%;background:#999999;border:1px solid #00;">';
		innerHTML += '<div style="padding:3px;font-weight:bold;font-size:13px">操作提示</div>';
		innerHTML +='<div id="msgcontent" style="width:100%;height:82%;background:#FFFFFF;text-align:center;font-size:9pt">';
		innerHTML +='<br><br>' + result;
		innerHTML +='</div></div>';
		winajax = window.createPopup();
		winajax.document.body.innerHTML = innerHTML;
		var ix = (window.screen.availWidth - iwdth) / 2;
		var iy = (window.screen.availHeight - iheight) / 2;
		winajax.show(ix,iy,iwdth,iheight)
	}
	else
	{
		winajax.document.all["msgcontent"].innerHTML = "<br/></br>"+ result;
		if(!winajax.isOpen)
		{
			var ix = (document.body.offsetWidth - iwdth) / 2;
			var iy = (window.screen.availHeight - iheight) / 2;
			winajax.show(ix,iy,iwdth,iheight);
		}
		
	}
	
}
function CheckAdd(obj)
{
	obj.disabled = 'disabled';
	initmsg(240, 120);
	var obj1 = document.all["frommail"].value;
	var obj2 = document.all["subject"].value;
	var obj3 = document.all["mailbody"].innerText;
	var pattern = /^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@(([0-9a-zA-Z])+([-\w]*[0-9a-zA-Z])*\.)+[a-zA-Z]{2,9})$/g;
	if(obj1 == '' || obj1.match(pattern) == null)
	{
		showresult(240,120,"发件人邮箱地址不正确!");
		obj.disabled= "";
		return;
	}
	if(obj2 == '' || obj3 == '')
	{
		showresult(240,120,"留言标题和留言的内容均不能为空!");
		obj.disabled= "";
		return;
	}
	EBLivWebApp.Online.SendMail.SendMial(obj1, obj2, obj3, mailcallback);
}

function mailcallback(result)
{
	//alert(result.value[0]);
	if(result.value[0])
	{
		showresult(240,120,"成功发送留言信息!");
		window.setTimeout("location.reload();", 2000);
		return;
	}
	else
	{
		if(result.value.length == 2)
		{
			location.href="/Error.aspx";
		}
		else
		{
			showresult(240,120,"发送留言信息失败,可能是系统网络设置有问题,您可以尝试联系客服人员!");
			document.all["SendMail"].disabled = '';
			return;
				
		}
	}
}


function ShowProductListRow()
{
	initmsg(240, 120);
	EBLivWebApp.UserControls.ClassTree.ClassTreeControl.GetProductList
	(
	 	_tablename,
		_maxRow,
		_maxColum,
		_templatepath,
		articlecall22
	);
	
}

function articlecall22(result)
{
	var arry = result.value.split('|');
	if(arry.length == 1)
	{
		switch(result.value)
		{
		case "nopage" :
		case "nocount" :
		case "sqlnone" :
			//showresult(240,120,"根据您查询条件数据库中找不到任何匹配结果!");
			document.all["pageList"].style.display = 'none';
			//document.all["AddUserInf"].disabled = '';
			var obj = document.all["msgcontent"];
			obj.innerHTML = '<center style="padding-top:10px">根据您查询的条件,数据库中不存在任何有效的产品纪录!</center>';
		break;
		case "error" :
			location.href="/Error.aspx";
		break;
		default :
			//showresult(240,120,"您输入的查询条件的书写格式不正确!");
			var obj = document.all["msgcontent"];
			obj.innerHTML = '<center style="padding-top:10px">您输入的查询条件的书写格式不正确!</center>';
			document.all["pageList"].style.display = 'none';
		break;
		}		
	}
	else
	{
		var obj = document.all["msgcontent"];
		obj.innerHTML = result.value.split("|")[2];
		showpageList5(result.value.split("|")[0],result.value.split("|")[1]);
		//document.all["AddUserInf"].disabled = '';
		//document.all["ToClassInfo"].selectedIndex = 0;
		
	}
	if(winajax != null && winajax.isOpen)
			winajax.hide();	
	
}

function showpageList5(maxpage, pageindex)
{
	document.all["pageList"].style.display = '';
	var result = pager('Getpage5({p});', parseInt(pageindex), parseInt(maxpage));
	var obj1 = document.all["PageShow"].innerHTML = '当前第 '+ pageindex +' 页,共 '+ maxpage+' 页&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + result;
	
	//var obj2 = document.all["pageList"].innerHTML = result;
}


function Getpage5(pageIndex)
{
	//alert('dasdasda');
	if(document.all["WhereStr"] != null)
	{
		
	
	if(document.all["WhereStr"].innerText == null)
	{
		document.all["WhereStr"].innerText = _wherestring;
	}
	EBLivWebApp.UserControls.ClassTree.ClassTreeControl.GetPageProduct
	(
	 	_tablename,
		_templatepath, 
		_maxRow, 
		pageIndex, 
		document.all["WhereStr"].innerText, 
		_maxColum,
		articlecall22
	);
	
	}
	
}


function Getpage00(pageIndex)
{
	
	if(document.all["WhereStr"] != null)
	{
		EBLivWebApp.UserControls.Message.MessageListControl.GetPage
		(
		 pageIndex, 
		 document.all["WhereStr"].innerText ,
		 pagesize,
		 itemfilepath,
		 isDiv,
		 articlecall2
		 );	
	}
}