﻿function initXmlHttp() {
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
    return new XMLHttpRequest();
	} 
	else if (window.ActiveXObject) { // IE
    return new ActiveXObject("Microsoft.XMLHTTP");
	}
}

//vote  2008 - 01 -09 linchong start

function dovote(itvccode,ipond,flag)
{
	if(flag!="")
	{
		alert("你已经投过票了");
		return;
	}
	if((itvccode!="")||(ipond!="")||(!isNaN(itvccode)))
	{
		oBao=initXmlHttp();
	 	oBao.open("POST","ponds_ajax_vote.php?action=vote&itvccode="+itvccode+"&ipond="+ipond,false);
	  	oBao.send(null);
		alert("投票成功");
		//location.reload();
		var sreturn = unescape(oBao.responseText);
		var tvcary = sreturn.split("#");
		var aary = tvcary[0].split("@");
		document.getElementById("i_choisea").innerHTML = aary[0];
		document.getElementById('i_choisea_p').innerHTML ="<strong>"+aary[1]+"%</strong>";
		document.getElementById('img_a').style.width = aary[2]+"px";
		document.getElementById("bclick").innerHTML = "<img src=\"images/botten_tp.jpg\" width=\"44\" height=\"53\" border=\"0\" style=\"cursor:pointer\" onclick='alert(\"你已经投过票了\")'/>";
		document.getElementById("aclick").innerHTML = "<img src=\"images/botten_tp.jpg\" width=\"44\" height=\"53\" border=\"0\" style=\"cursor:pointer\" onclick='alert(\"你已经投过票了\")'/>";
		var bary = tvcary[1].split("@");
		document.getElementById("i_choiseb").innerHTML = bary[0];
		document.getElementById('i_choiseb_p').innerHTML ="<strong>"+bary[1]+"%</strong>";
		document.getElementById('img_b').style.width = bary[2]+"px";
	}
	else
	{
		return alert("出错了");
	}
}

// end 2008 - 01 -09 linchong end 

//参数名称唯一判断
function ajax_check_paraname(paraname)
{
	if(paraname!="")
	{
		oBao=initXmlHttp();
	 	oBao.open("POST","para_ajax_paraname.php?paraname="+paraname,false);
	  	oBao.send(null);
		return unescape(oBao.responseText);
	}
	else
	{
		return "false";
	}
}

function changePara1(iValue)
{	
	if(iValue=="1"&&iValue!="")
	{
	  oBao=initXmlHttp();
	  oBao.open("POST","ParaChange.php?action="+iValue,false);
	  oBao.send(null);
	  document.all.spanPara1.innerHTML = unescape(oBao.responseText);
	}
}

//省与城市
function CityChange(Province)
{	
	if(Province!="")
	{
		oBao=initXmlHttp();
		oBao.open("POST","ponds_Ajax_do.php?action=CityChange&Province="+Province,false);
		oBao.send(null);
		document.all.span_city.innerHTML = unescape(oBao.responseText);
	}
}


function CityChange1(Province,span_id)
{	
	if(Province!="")
	{
		var i=span_id.split('span_city_')[1];
		oBao=initXmlHttp();
		oBao.open("POST","ponds_Ajax_do.php?action=CityChange_name&Province="+Province+"&city_i="+i,false);
		oBao.send(null);
		document.getElementById(span_id).innerHTML = unescape(oBao.responseText);
	}
}


//注册昵称判断
function NicknameCheck(snick)
{
	if(snick!="")
	{
		oBao=initXmlHttp();
		oBao.open("POST","ponds_Ajax_do.php?action=nickname&snick="+snick,false);
		oBao.send(null);
		return unescape(oBao.responseText);
	}
	else
		return "nullstr";
}


//注册邮箱判断
function EmailCheck(semail)
{
	if(semail!="")
	{
		oBao=initXmlHttp();
		oBao.open("POST","ponds_Ajax_do.php?action=emailcheck&semail="+semail,false);
		oBao.send(null);
		return unescape(oBao.responseText);
	}
	else
		return "nullstr";
}

function _upemailcheck(oldemail,newemail)
{
	if(oldemail!=newemail)
	{
		return unescape(EmailCheck(newemail));
	}
	else
		return "true";
}
//start linchong 2008-01-21

//申领手机号码判断
function _MobileCheck(smobile)
{
	if(smobile!="")
	{
		oBao=initXmlHttp();
		oBao.open("POST","ponds_Ajax_do.php?action=mobilecheck&mobile="+smobile,false);
		oBao.send(null);
		return unescape(oBao.responseText);
	}
	else
		return "error";
}

//邮箱判断
function _EmailCheck(semail)
{
	if(semail!="")
	{
		oBao=initXmlHttp();
		oBao.open("POST","ponds_Ajax_do.php?action=actemailcheck&semail="+semail,false);
		oBao.send(null);
		return unescape(oBao.responseText);
	}
	else
		return "error";
}


//柜台选择
function _ACcityChange(stype,spc)
{
	if(spc!="")
	{
		oBao=initXmlHttp();
		oBao.open("POST","ponds_Ajax_do.php?action=actcheck&stype="+stype+"&spc="+spc,false);
		oBao.send(null);
		if(stype=="sprovince")
			document.all.span_city.innerHTML = unescape(oBao.responseText);
		else
			document.all.span_counter.innerHTML = unescape(oBao.responseText);
	}
	else
		return "error";
}

// end linchong 2008-01-21

function tvc_next(id)
{
	if(id!="")
	{
		if(id!=5)id++;
		
		oBao=initXmlHttp();
	 	oBao.open("POST","tvc_next.php?id="+id,false);
	  	oBao.send(null);
		if (unescape(oBao.responseText)=="done")
		{
			//alert(unescape(oBao.responseText));
			//alert(id);
			for(i=1;i<=id;i++)
			{	
				//alert(i);
				document.getElementById("div_tvc_list"+i).style.display="block";
			}
		}
		//return unescape(oBao.responseText);
	}
	else
	{
		//return "false";
	}
}


//vote  2008 - 03 -24 linchong start

function _dovote(ipond,flag)
{
	if(flag!="")
	{
		alert("你已经投过票了");
		return;
	}
	if((ipond!="")||(!isNaN(ipond)))
	{
		oBao=initXmlHttp();
	 	oBao.open("POST","ponds_ajax_tvcvote.php?action=vote&ipond="+ipond,false);
	  	oBao.send(null);
		alert("投票成功");

		var sreturn = unescape(oBao.responseText);
		var tvcary = sreturn.split("#");
		
		var aary = tvcary[0].split("@");
		document.getElementById("i_choisea").innerHTML = aary[0];
		document.getElementById('i_choisea_p').innerHTML ="<strong>"+aary[1]+"%</strong>";
		document.getElementById('img_a').style.width = aary[2]+"px";

		var bary = tvcary[1].split("@");
		document.getElementById("i_choiseb").innerHTML = bary[0];
		document.getElementById('i_choiseb_p').innerHTML ="<strong>"+bary[1]+"%</strong>";
		document.getElementById('img_b').style.width = bary[2]+"px";

		var cary = tvcary[2].split("@");
		document.getElementById("i_choisec").innerHTML = cary[0];
		document.getElementById('i_choisec_p').innerHTML ="<strong>"+cary[1]+"%</strong>";
		document.getElementById('img_c').style.width = cary[2]+"px";

		document.getElementById("aclick").innerHTML = "<img src=\"images/botten_tp.jpg\" width=\"44\" height=\"53\" border=\"0\" style=\"cursor:pointer\" onclick='alert(\"你已经投过票了\")'/>";
		document.getElementById("bclick").innerHTML = "<img src=\"images/botten_tp.jpg\" width=\"44\" height=\"53\" border=\"0\" style=\"cursor:pointer\" onclick='alert(\"你已经投过票了\")'/>";
		document.getElementById("cclick").innerHTML = "<img src=\"images/botten_tp.jpg\" width=\"44\" height=\"53\" border=\"0\" style=\"cursor:pointer\" onclick='alert(\"你已经投过票了\")'/>";

	}
	else
	{
		return alert("出错了");
	}
}

// end 2008 - 03 -24 linchong end 