//跳轉
function showopmom(c){
	window.location = "/sportshowmom.php?momid=" + c;
}

//顯示icon
function showspicon(o,c){
	if(c==1){
		document.getElementById(o).style.display = "";	
	}else{
		document.getElementById(o).style.display = "none";	
	}
}

//設置圖片
function setface(str,obj){

	if(trim(obj.value) == "只限會員留言，請先按「Register」進行登記！"){
		obj.value = "";	
	}

	var content = obj;
	var contentLength=content.value.length;
	content.focus();

	if(typeof document.selection !="undefined"){
          document.selection.createRange().text=str;  
    }else{
          content.value=content.value.substr(0,content.selectionStart)+str+content.value.substring(content.selectionEnd,contentLength);
    }
}

//發表評論
function addmomcomment(){

	if(trim(document.getElementById("rpcontent").value)=='' || trim(document.getElementById("rpcontent").value)=='只限會員評論，請先按「Register」進行登記！'){
		alert("請輸入評論內容！");
		document.getElementById("rpcontent").focus();
		return false;
	}

	if(getLen(document.getElementById("rpcontent").value)>300){
		alert("回覆內容不能超過150個中文字符！");	
		document.getElementById("rpcontent").focus();
		return false;
	}

	if(document.getElementById("islogin").value==0){
		if(trim(document.getElementById("rpuname").value)==''){
			alert("請輸入Name！");	
			document.getElementById("rpuname").focus();
			return false;
		}

		if(trim(document.getElementById("rppass").value)==''){
			alert("請輸入Password！");	
			document.getElementById("rppass").focus();
			return false;
		}
	}

	//提交数据
	var stra="content="+encodeURIComponent(document.getElementById("rpcontent").value);
	stra=stra+"&username="+document.getElementById("rpuname").value;
	stra=stra+"&password="+document.getElementById("rppass").value;
	stra=stra+"&momid="+document.getElementById("momid").value;
	stra=stra+"&is_start="+document.getElementById("is_start").value;
	stra=stra+"&ajaxid=16";

	var temptext;

	xmlhttp.open("GET","ajax.php?"+stra,true);
	xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState==4 && xmlhttp.status==200){
			temptext=xmlhttp.responseText;

			if(temptext=='e1'){
				alert("用戶名和密碼不能為空！");
			}else if(temptext=='e2'){
				alert("用戶名或密碼錯！");
				document.getElementById("rppass").value="";
				document.getElementById("rppass").focus();
			}else if(temptext=='e3'){
				alert("此用戶未啟用！");
				document.getElementById("rppass"+id).value="";
			}else if(temptext=='true'){

				//調用統一登入
				document.getElementById("syndiscuz").src = "ucfunction.php?ucid=1&username=" + document.getElementById("rpuname").value + "&password=" + document.getElementById("rppass").value;
				document.getElementById("synuchome").src = "ucfunction.php?ucid=2&username=" + document.getElementById("rpuname").value + "&password=" + document.getElementById("rppass").value;
				document.getElementById("rpcontent").value='';
				document.getElementById("islogin").value="1";
				document.getElementById("showlogin").style.display="none";
				//ocument.getElementById("showreg").style.display="none";

				document.getElementById("rpcontent").value = "";

				alert("評論發表成功！");

				//调用列表函数
				showmomcomment('/momcomment.php?is_start='+document.getElementById('is_start').value+'&momid='+document.getElementById('momid').value+'&pagesize='+document.getElementById('jpage'+document.getElementById('is_start').value).value+"&page=9999");
			}
		}
	}

	xmlhttp.setRequestHeader("If-Modified-Since","0");
	xmlhttp.send(null);
}


//讀取評論列表
function showmomcomment(curl){

	$.ajax({
		type:"GET",
		url:curl,
		dataType:"html",
		cache:false,
		success:function(msg){	
			if(curl.indexOf("is_start=1")!=-1){
				$("#gamebefore").html(msg);
			}else{
				$("#gameafter").html(msg);
			}
		}
	});
	
}

//評分
function setmommark(uid,cid,flag){
	if(confirm("是否真的要評分？")==false){
		return false;
	}

	$.ajax({
		type:"GET",
		url:"ajax.php?ajaxid=17&uid=" + uid + "&cid=" + cid + "&flag=" + flag,
		dataType:"json",
		cache:false,
		success:function(msg){	
			if(msg['isSuccess']==false){
				alert(msg['msgCode']);
			}else{
				alert("評分成功！");	
			}
		}
	});

}


//顯示完整評論
function showmoretext(o,cid){
	o.innerHTML = document.getElementById("mtext"+cid).value;
}


//顯示日曆
function mom_calendar(curl){

	$.ajax({
		type:"GET",
		url:curl,
		dataType:"html",
		cache:false,
		success:function(msg){	
			$("#mymom").html(msg);
		}
	});
}

//顯示當天賽事 mom主頁
function mom_table(curl){

	$.ajax({
		type:"GET",
		url:curl,
		dataType:"html",
		cache:false,
		success:function(msg){	
			$("#momtable").html(msg);
		}
	});
}

//顯示當天賽事 sport out
function mom_showmom(curl){

	$.ajax({
		type:"GET",
		url:curl,
		dataType:"html",
		cache:false,
		success:function(msg){	
			$("#momtable").html(msg);
		}
	});
}