﻿function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function checkMessage()
{
otitle=document.getElementById("txtTitle");
ocontent=document.getElementById("txtContent");
if(otitle.value=="")
{
alert("请填写标题~！");
otitle.focus();
return false;
}

if(ocontent.value=="")
{
alert("请填写标题内容~！");
ocontent.focus();
return false;
}

}



var canSub = true;
function TexFocus(o){
	if ('请输入您要评论的内容'==o.value){
	 o.value='';}
	if('block'!=document.getElementById('code_pic').style.display){ 
		document.getElementById('code_pic').src='/ValidateImage.aspx';
		document.getElementById('code_pic').style.display='block';
	}
}
function submitForm(e) {
	try{
		e = e ? e : window.event;
		if(e.ctrlKey&&e.keyCode==13)
		return true;
	}catch(e){}
	return false
} 		
function commSubmit(form)
{
	if (!canSub)return false;
	if ('请输入您要评论的内容' == document.getElementById('comment_text').value)
	{
		document.getElementById('comment_text').focus();
		return false;
	}
	if (document.getElementById('comment_text').value.length > 500 || document.getElementById('comment_text').value.length < 4)
	{
		alert("评论的字数必须在4到500之间！");
		document.getElementById('comment_text').focus();
		return false;
	}
//	if (!(/^[a-z]|[0-9]|[A-Z]{4}document.getElementById/.test(document.getElementById('validate').value)))
//	{
//		alert("请输入4位的验证码");
//		document.getElementById('validate').focus();
//		return false;
//	}
	canSub = false;
	postfeeback();
}

//ajax load freeback list..
function loadfeeback(id,arctype,page){
	var URL = "/ajax_feedback.aspx";
	var pars = 'arcID=' + id + '&arctype='+arctype+'&p='+page+'&action=show&rnd='+Math.random();
	new Ajax.Updater(
		{success: 'comm_content'},
		URL, {method: "get",parameters:pars}
	);	
}
//ajax submit data....
function postfeeback(){
	var opt = {
		method: 'post',
		postBody: 'action=send&arctype='+document.getElementById('arctype').value+'&arcID='+document.getElementById('arcID').value
			+'&notuser=1&isconfirm=1&msg='+document.getElementById('comment_text').value
			+'&username='+document.getElementById('username').value+'&validate='+document.getElementById('validate').value,
		onSuccess: function(t) {
			Element.update(document.getElementById('ajaxBackMsg'), t.responseText);
			loadfeeback(document.getElementById('arcID').value,document.getElementById('arctype').value,1);		
			canSub = true;
			document.getElementById('comment_text').value = '';
			document.getElementById('username').value = '';
			document.getElementById('validate').value = '';
			document.getElementById('code_pic').src = '/ValidateImage.aspx';
		},
		on404: function(t) {document.getElementById('ajaxBackMsg').update('服务器错误，请稍后再试！')},
		onFailure: function(t) {document.getElementById('ajaxBackMsg').update('提交失败，请稍后再试')}
	};
	new Ajax.Request("/ajax_feedback.aspx", opt);
}

//ajax good and bad
function postGoodBad(i,a,d){
	var opt = {
		method: 'post',
		postBody: 'fid='+i+'&action='+a+'&arcID='+d+'&rnd='+Math.random(),
		onSuccess: function(t) {document.getElementById(i + 'span' + a).update(t.responseText)},
		on404: function(t) {},
		onFailure: function(t) {}
	};
	new Ajax.Request("/ajax_feedback.aspx", opt);
}
//评论总数
function comCount(id,arctype){
	var URL = "/ajax_feedback.aspx";
	var pars = 'arcID=' + id + '&arctype='+arctype+'&action=comCount&rnd='+Math.random();
	new Ajax.Updater(
		{success: 'comm_count'},
		URL, {method: "get",parameters:pars}
	);	
}

//新闻的点击数
function newClickNum(id){
	var URL = "/js/newClick.aspx";
	var pars = 'newsId=' + id+'&rnd='+Math.random();
	new Ajax.Updater(
		{success: 'newClick'},
		URL, {method: "get",parameters:pars}
	);	
}

//文字大小
function ChangeSize(zoom)
{var zoom;
var oTmep=document.getElementById("news_content14");
oTmep.style.fontSize=zoom;
}

//产品的点击数
function productClickNum(id){
	var URL = "/js/productClick.aspx";
	var pars = 'productId=' + id+'&rnd='+Math.random();
	new Ajax.Updater(
		{success: 'productClick'},
		URL, {method: "get",parameters:pars}
	);	
}


//
function UserLogin(userName,password,valiDate){
	var URL = "/js/loginAjax.aspx";
	var pars = 'userName=' + userName+'&password='+password+'&valiDate='+valiDate+'&rnd='+Math.random();
	new Ajax.Updater(
		{success: 'loginState'},
		URL, {method: "post",parameters:pars}
	);	
}

