/**
 * @author 小崇
 */
 
function openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
 

//限制input输入框只允许输入数字
function regInput(obj, reg, inputStr)
{
	var docSel	= document.selection.createRange()
	if (docSel.parentElement().tagName != "INPUT")	return false
	oSel = docSel.duplicate()
	oSel.text = ""
	var srcRange	= obj.createTextRange()
	oSel.setEndPoint("StartToStart", srcRange)
	var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
	return reg.test(str)
}


function initAd() {
	$('ItemdetailInfo').style.posTop = 300;
//设置onLoad事件激发以后，广告层相对于固定后的y方向位置
	$('ItemdetailInfo').style.visibility = 'visible';//设置层为可见
	MoveLayer('ItemdetailInfo');//调用函数MoveLayer()
}

function MoveLayer(layerName) {

	var x = 600;//浮动广告层固定于浏览器的x方向位置
	var y = 300;//浮动广告层固定于浏览器的y方向位置

	var ScreenHeight	=	(isie ? document.body.scrollHeight : document.documentElement.scrollHeight)+'px';

		eval($('ItemdetailInfo')+".style.posTop = y");
		eval($('ItemdetailInfo')+".style.posLeft = x");//移动广告层
		//setTimeout("MoveLayer('ItemdetailInfo')", 20);//设置20毫秒后再调用函数MoveLayer()
}

function	GoUrl(urls)
{
	var	url	=	urls
	window.location = url;
}


function result(r)
{	
	//$('Loading').style.display		=	'none';
	var response					=	r.responseText;
	//var responseInfo				=	response.parseJSON();
	var responseInfo				=	eval('(' + response + ')');
	var ItemListShow				=	ShowItemList(responseInfo);
	if(responseInfo.itemList	==	"")
	{
		alert('Error');
	}
	else
	{
		$('result').innerHTML	=	ItemListShow;
		ItemRecordCount();
		setTimeout("showNavigation()",2000);
		//alert(recordCount+'3');
	}			
}


/****************************点击买继续**************************************/
function	First(ItemIds)
{
	tbdisabled();
	$('OutItemInfoDiv').style.left=((document.body.clientWidth/2)-270)+'px';
	$('OutItemInfoDiv').style.top=(document.body.scrollTop+document.body.clientHeight/2)+'px';
	$('OutItemInfoDiv').style.display='block';
	$('OutItemInfoDiv').innerHTML=showLoading();
	ShowItemInfo(ItemIds);
}				  

function	OutItem(ItemIds)
{
	tbdisabled();
	$('OutItemInfoDiv').style.left=((document.body.clientWidth/2)-270)+'px';
	$('OutItemInfoDiv').style.top=(document.body.scrollTop+document.body.clientHeight/2)+'px';
	$('OutItemInfoDiv').style.display='block';
	//$('OutItemInfoDiv').innerHTML=showLoading();
	BuyItemInfo(ItemIds);
	
}
/*****************************关闭********************************/
function	OutItemClose()
{
	$('ItemdetailInfo').style.display='none';
	$('OutItemInfoDiv').style.display='none';
	$('bg').style.display='none';	
}

function	ShowItemInfo(ItemIds)
{
	var	ItemId	=	ItemIds;
	var	Action	=	'itemShow';
	var	url		=	'itemEdit.php';
	var	pars	=	'Action='+Action+'&ItemId='+ItemId;

	var	OuteeShowAjax	=	new Ajax.Request(url,{
		method:'post',
		parameters:pars,
		onComplete:function(r)
		{
			$('OutItemInfoDiv').innerHTML	=	OutItemDefine(r.responseText);
		}
	}
	);	
}

/****************************输出常量定义**************************************/
function	OutItemDefine(info)
{
	var	OutDefine	=	'<div id=\"con\"><div class=\"head_l\"></div><div class=\"head_r\"><a href=\"#\" onclick=\"OutItemClose();\"><img src=\"../themes/default/images/bill/cart_01_02.gif\" border=\"0\" /></a></div><div class=\"left\"></div><div class=\"mid\">'+info+'</div><div class=\"right\"></div><div class=\"footer\"></div></div>';
	return	OutDefine;
}

function	BuyItemInfo(ItemIds)
{
	var	ItemId			=	ItemIds; 
	var Pm_Type			=   document.getElementById('Pm_Type').value;
	var	BuyAmount		=	document.getElementById('Amount').value;
	var	Action			=	'itemBuy';
	var	url				=	'itemEdit.php';
	var	pars			=	'Action='+Action+'&ItemId='+ItemId+'&Pm_Type='+Pm_Type+'&BuyAmount='+BuyAmount;
	$('OutItemInfoDiv').innerHTML=showLoading();
	var	OutItemShowAjax	=	new Ajax.Request(url,{
		method:'post',
		parameters:pars,
		onComplete:function(r)
		{
			$('OutItemInfoDiv').innerHTML	=	OutItemDefine(r.responseText);
		}
	}
	);
	
}