function Obj(o){
	return document.getElementById(o);
}
function say(text){
	alert(text);
}

function gourl(url){
window.open(url);
}

function echo(text){
document.write(text);
}

/*取小数点*/
function getNum(n,len)
{
    var tmpN = n.toString()
    var firstNum = tmpN.split(".")[0]
    var lastNum = tmpN.split(".")[1].substring(0,len)
    var newNum = firstNum+"."+lastNum
    return newNum
}



function xmlhttprequest(){
	if(window.ActiveXObject){
		xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
	}
	else if(window.XMLHttpRequest){
		xmlHttp = new XMLHttpRequest();
	}
	else{
		say('您的浏览器不支持Ajax技术！');
	}
}


/*投票~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function clicknum(softid){
	var NameOfCookie="click"+softid;
	var c = document.cookie.indexOf(NameOfCookie+"="); 
	if (c != -1)
	{
	  say('您已经对他(她)投过票了，感谢您的参与！');
	  return;
	}
	var file='checkall.php?id='+softid+'&a='+Math.random();
    xmlhttprequest();
	xmlHttp.open("GET", file, true);
	xmlHttp.onreadystatechange =function(){
		if(xmlHttp.readyState == 4 && xmlHttp.status == 200){
			Obj('text'+softid).innerHTML=xmlHttp.responseText;
		}
	}
	xmlHttp.send(null);	
}


/*投票End~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

/*评论~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

function show_list(){
	var id=Obj('id').value;
	var file='comment_do.php?action=list&id='+id+'&a='+Math.random();
    xmlhttprequest();
	xmlHttp.open("GET", file, true);
	xmlHttp.onreadystatechange = show_list_done;
	xmlHttp.send(null);	
}

function show_lista(){
	var id=Obj('id').value;
	var file='comment_do.php?action=list&id='+id+'&a='+Math.random();
	xmlHttp.open("GET", file, true);
	xmlHttp.onreadystatechange = show_list_done;
	xmlHttp.send(null);	
}

//输出列表
function show_list_done(){
	if(xmlHttp.readyState == 1){
		Obj('pllist').innerHTML="<div class='loading'><img src='manage/templets/images/loading.gif'>读取列表中...</div>";
	}
	if(xmlHttp.readyState == 4 && xmlHttp.status == 200){
		Obj('pllist').innerHTML=xmlHttp.responseText;
	}
}

function pagelist(page, tid, attr, keyword,urlstring){
	var url = 'comment_do.php?'+'id='+tid+'&attr='+attr+'&page='+page+'&keyword='+keyword+'&a='+Math.random()+'&'+urlstring;
	xmlhttprequest();
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = show_list_done;
	xmlHttp.send(null);
}


function fb(){
var commentContact=Obj('commentContact');
var commentContent=Obj('commentContent');
var id=Obj('id');
　　if (commentContact.value.length<2)
　　{
       commentContact.focus();
	   Obj('commentContacta').innerText='昵称最少2个字符';
       return false;
　　}else{
	   Obj('commentContacta').innerText='';
    }
　　if (commentContent.value.length<1)
　　{
       commentContent.focus();
	   Obj('commentContenta').innerText='评论内容不能为空';
       return false;
　　}else{
	Obj('commentContenta').innerText='';
    }
	xmlhttprequest();
	var file = 'comment_do.php?action=add&commentContent='+encodeURI(commentContent.value)+'&commentContact='+encodeURI(commentContact.value)+'&id='+id.value+'&a='+Math.random();
	xmlHttp.open("GET", file, true);
	xmlHttp.onreadystatechange = fbshow;
	xmlHttp.send(null);
    commentContent.value="";
    commentContact.value="";
}

function fbshow(){
	var msg=Obj('msg');
    if(xmlHttp.readyState == 1){
			msg.innerText="读取中...";
	}
		if(xmlHttp.readyState == 4 && xmlHttp.status == 200){
			msg.innerText=xmlHttp.responseText;
			show_list();
	}
}
/*评论End~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

/*对比~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function add_contrast(id){
	var NameOfCookie="contrast"+id;
	if ($.Cookie.get(NameOfCookie))
	{
	  say('该型号已在对比栏中！');
	  return;
	}
	var file='products_do.php?action=add&id='+id+'&a='+Math.random();
    xmlhttprequest();
	xmlHttp.open("GET", file, true);
	xmlHttp.onreadystatechange =function(){
		if(xmlHttp.readyState == 4 && xmlHttp.status == 200){
			$("#contrast_list_ul").append(xmlHttp.responseText);
			show_contrast_list();
		}
	}
	xmlHttp.send(null);	
}

function del_contrast(id){
	$('#contrast_list_ul #'+id+'').remove();
	var file='products_do.php?action=del&id='+id+'&a='+Math.random();
    xmlhttprequest();
	xmlHttp.open("GET", file, true);
	xmlHttp.send(null);
}

function del_contrast_go(id){
	$('#contrast_list_ul #'+id+'').remove();
	var file='products_do.php?action=del&id='+id+'&a='+Math.random();
    xmlhttprequest();
	xmlHttp.open("GET", file, true);
	xmlHttp.send(null);
	window.location.reload();
}

function show_contrast_list(){
	var NameOfCookie="contrastarray";
	if ($.Cookie.get(NameOfCookie))
	{
	  $('#contrast_list_small').fadeOut(200);
	  $('#contrast_list').fadeIn(200);
	}else{
	  say('对比栏中没有信息！');
	  return;
	}
}


function hide_contrast_list(){
	$('#contrast_list').fadeOut(200);
	$('#contrast_list_small').fadeIn(200);
}
function clear_both(){
    $('#contrast_list_ul').empty();
	var file='products_do.php?action=delall'+'&a='+Math.random();
    xmlhttprequest();
	xmlHttp.open("GET", file, true);
	xmlHttp.send(null);
}
function nowCompare(){
	gourl('contrast.php')
}
/*对比End~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/


/*注册~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

function submitform(action){
var uname=Obj('uname');
var unamea=Obj('unamea');
var pwd=Obj('pwd');
var rpwd=Obj('rpwd');
if($("#c1").attr("checked")==true){
   var c1='true';	
}else{
   var c1='';
}
var c2=Obj('c2');
var c3=Obj('c3');
if($("#c4").attr("checked")==true){
   var c4='true';
}else{
   var c4='';
}
//var c5=Obj('c5');
//var c6=Obj('c6');
var vdcode=Obj('vdcode');

	xmlhttprequest();
	var file = 'checkall.php?action='+action+
			   '&uname='+encodeURI(uname.value)+
			   '&unamea='+encodeURI(unamea.value)+
			   '&pwd='+encodeURI(pwd.value)+
			   '&rpwd='+encodeURI(rpwd.value)+
	           '&c1='+encodeURI(c1)+
			   '&c2='+encodeURI(c2.value)+
			   '&c3='+encodeURI(c3.value)+
			   '&c4='+encodeURI(c4)+
			   //'&c5='+encodeURI(c5.value)+
//			   '&c6='+encodeURI(c6.value)+
			   '&vdcode='+encodeURI(vdcode.value)+
			   '&a='+Math.random();
			   //alert(file);
	xmlHttp.open("GET", file, true);
	xmlHttp.onreadystatechange = action_true;
	xmlHttp.send(null);
}


function action_true(){
	if(xmlHttp.readyState == 4 && xmlHttp.status == 200){
	q=xmlHttp.responseText.replace(/^\s*|\s*$/g,"");
	$(".loading").fadeOut();
		if(q=="登録成功！（ログイン後メールボックスを確認するために必須）"){
			$("#action_true").removeClass("action_false");
			$("#action_true").addClass("action_true");
			Obj('action_true').innerHTML=q;
		}else{
			$("#action_true").removeClass();
			$("#action_true").addClass("action_false");
			Obj('action_true').innerHTML=q;
		}
	$(document).ready(function(){
		$("#action_true").fadeIn();
	});
	}else{
		$(".loading").fadeIn()
	}
	
}
function action_true_hidden(){
	$(document).ready(function(){$("#action_true").fadeOut();});
}


/*注册end ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

/*买卖游戏币~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function check_buy_form(formname){
	var url=Obj('url').value;
	switch(formname){
	   case "buy1":
	        var paytype = $("input[name='paytype']:checked").val();
			if(!paytype){
			 $("#action_true").removeClass();
			 $("#action_true").addClass("action_false");
			 Obj('action_true').innerHTML="ご購入手段を選択してください。";
			 $("#action_true").fadeIn();
			 return false;
			}
			var paytypevalue=Obj('paytype'+paytype+'').value;
			xmlhttprequest();
			var file = 'checkall.php?action=check'+formname+''+
					   '&paytype='+encodeURI(paytype)+
					   '&paytypevalue='+encodeURI(paytypevalue)+
					   '&'+encodeURI(url)+
					   '&a='+Math.random();
			 //alert(file);
	   break	
	   
	   case "buy2":
	        var banktype = $("input[name='banktype']:checked").val();
			var wmnumber=Obj('wmnumber').value;
			if(!wmnumber){
			 $("#action_true").removeClass();
			 $("#action_true").addClass("action_false");
			 Obj('action_true').innerHTML="入力されたWM番号に誤りがあります。";
			 $("#action_true").fadeIn();
			 return false;
			}
			wmnumber=wmnumber.replace(/\r\n/g,","); 
			xmlhttprequest();
			var file = 'checkall.php?action=check'+formname+''+
					   '&wmnumber='+encodeURI(wmnumber)+
					   '&'+encodeURI(url)+
					   '&a='+Math.random();
			 //alert(file);
	   break
	   
	   case "buy3":
	        var pname=Obj('pname').value;
			var truename=Obj('truename').value;
			xmlhttprequest();
			var file = 'checkall.php?action=check'+formname+''+
					   '&pname='+encodeURI(pname)+
					   '&truename='+encodeURI(truename)+
					   '&'+encodeURI(url)+
					   '&a='+Math.random();
			 //alert(file);
	   break
	}
	xmlHttp.open("GET", file, true);
	xmlHttp.onreadystatechange = function (){
			if(xmlHttp.readyState == 4 && xmlHttp.status == 200){
			q=xmlHttp.responseText.replace(/^\s*|\s*$/g,"");
			$(".loading").fadeOut();
			   switch(q){
				case "true":
					Obj(formname).submit();
				break
				
				case "less1":
					$("#action_true").removeClass();
					$("#action_true").addClass("action_false");
					Obj('action_true').innerHTML="未満ではない 1 口";
				break 
				
				case "erro_count":
					$("#action_true").removeClass();
					$("#action_true").addClass("action_false");
					Obj('action_true').innerHTML="正しい番号を入力してください";
				break
				
				case "noInventory":
					$("#action_true").removeClass();
					$("#action_true").addClass("action_false");
					Obj('action_true').innerHTML="在庫数が不足しているか、他のお客様がご予約になられています,申し訳ありませんが口数を調整頂き、再度ご入力ください";
				break
				
				case "erro_wmnumber":
					$("#action_true").removeClass();
					$("#action_true").addClass("action_false");
					Obj('action_true').innerHTML="入力されたWM番号に誤りがあります。";
				break
				
				case "erro_pname":
					$("#action_true").removeClass();
					$("#action_true").addClass("action_false");
					Obj('action_true').innerHTML="入力されたフリガナに誤りがあります。";
				break
				
				case "erro_truename":
					$("#action_true").removeClass();
					$("#action_true").addClass("action_false");
					Obj('action_true').innerHTML="入力された振込名義人に誤りがあります。";
				break
				
			   }
			$("#action_true").fadeIn();
			}else{
				$(".loading").fadeIn()
			}
		}
	xmlHttp.send(null);
}

/*买卖游戏币end~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

/*在线调查~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

function survey_sub(){

    var surveyvalue = $("input[name='survey']:checked").val();
	var file='include/survey_do.php?action=sub&value='+surveyvalue+'&a='+Math.random();
    xmlhttprequest();
	xmlHttp.open("GET", file, true);
	xmlHttp.onreadystatechange =function(){
		if(xmlHttp.readyState == 4 && xmlHttp.status == 200){
			say(xmlHttp.responseText);
		}
	}
	xmlHttp.send(null);	
}

function survey_show(){

	Obj("graybg").style.display = "block";
	Obj("survey_window").style.display = "block";
	$('#survey_window' ).scrollFollow();
	
	var file='include/survey_do.php?action=show&a='+Math.random();
    xmlhttprequest();
	xmlHttp.open("GET", file, true);
	xmlHttp.onreadystatechange =function(){
		if(xmlHttp.readyState == 1){
		    $('.survey_loading').fadeIn();
		}
		if(xmlHttp.readyState == 4 && xmlHttp.status == 200){
			$('.survey_loading').fadeOut();
			a=xmlHttp.responseText.replace(/^\s*|\s*$/g,"");
			var q=a.split(',');
			var imgwith=330;
			qcount=parseInt(q[0])+parseInt(q[1])+parseInt(q[2])+parseInt(q[3])
			q0=Math.round( parseInt(q[0]) / qcount *100);
			q1=Math.round( parseInt(q[1]) / qcount *100);
			q2=Math.round( parseInt(q[2]) / qcount *100);
			q3=Math.round( parseInt(q[3]) / qcount *100);
			
			$('#survey_list #a0').animate({width:parseInt(imgwith*(q0/100)+1)},"slow");
			$('#survey_list #a1').html(q[0]);
			$('#survey_list #a2').html(q0+'%');
			
			$('#survey_list #b0').animate({width:parseInt(imgwith*(q1/100)+1)},"slow");
			$('#survey_list #b1').html(q[1]);
			$('#survey_list #b2').html(q1+'%');
			
			$('#survey_list #c0').animate({width:parseInt(imgwith*(q2/100)+1)},"slow");
			$('#survey_list #c1').html(q[2]);
			$('#survey_list #c2').html(q2+'%');
			
			$('#survey_list #d0').animate({width:parseInt(imgwith*(q3/100)+1)},"slow");
			$('#survey_list #d1').html(q[3]);
			$('#survey_list #d2').html(q3+'%');
		}
	}
	xmlHttp.send(null);	
}

function survey_hidden(){
	Obj("graybg").style.display = "none";
	Obj("survey_window").style.display = "none";
}
/*在线调查end~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/






