function opencommentadd(id) {
	window.open("/ranking/commentadd/"+id,"", "width=700,height=400,menubar=no,toolbar=no,location=no,status=no,left=700,scrollbars=yes");
}


//ソーシャル用
function plus(id,plus_minus){
	var url = '/content/socialchange';
	url = url + '/' + id + '/' + plus_minus;
	
	var xmlhttp = false;
	if(typeof ActiveXObject != "undefined"){
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {
			xmlhttp = false;
		}
	}
	if(!xmlhttp && typeof XMLHttpRequest != "undefined") {
		xmlhttp = new XMLHttpRequest();
	}
	
	xmlhttp.open('get',url,true);
	if(plus_minus==1 || plus_minus==2 | plus_minus==3){ 
		xmlhttp.onreadystatechange = function(){
										if(xmlhttp.readyState == 4 && xmlhttp.status==200){
											point_data=xmlhttp.responseText.split('|');
											i = 0;
											while (i < point_data.length) {
												if(i == (point_data.length - 1)){
													j=0
													while(j<10){
														change_data(point_data[i],'sweetheartpoint',j,'main');
														j++;
													}
												}else{
											    	change_data(point_data[i],id,i,'main');
											    }
											   	i++;
											}
										}
									}
	}
	
	if(plus_minus==4 || plus_minus==5){ 
		xmlhttp.onreadystatechange = function(){
										if(xmlhttp.readyState == 4 && xmlhttp.status==200){
											point_data=xmlhttp.responseText.split('|');
											i = 0;
											while (i < point_data.length) {
										    	change_data(point_data[i],id,i,'sub');
											   	i++;
											}
										}
									}
	}
	
	xmlhttp.send(null);

}

function change_data(str,id,name,mainsub){
	var strid = String(id);
	var strname = String(name);
	var e1 = document.getElementById('__'+mainsub+strid+strname);
	e1.innerHTML = str;
}

/*
function change_data_sweetheartpoint(sweetheartpoint,id){
	var e1 = document.getElementById('__sweetheartpoint'+id);
	e1.innerHTML = sweetheartpoint;
}*/

function mainadd(form){
	if(!chkMaxLength(form.comment.value,100)){
		window.alert('100文字以内です');
		return false;
	}
}

function subadd(form){
	var url = '/content/socialsubadd';
	
	url = url + '?item_id=' + form.item_id.value;
	url = url + '&uriparam=' + form.uriparam.value;
	if(form.anonymous.checked){
		url = url + '&anonymous=' + 1;
	}else{
		url = url + '&anonymous=' + 0;
	}
	url = url + '&comment=' + encodeURIComponent(form.comment.value);
	

	if(chkMaxLength(form.comment.value,40)){
	
		xmlhttp = new XMLHttpRequest();
		xmlhttp.open('get',url,true);
		xmlhttp.onreadystatechange = function(){
										if(xmlhttp.readyState == 4 && xmlhttp.status==200){
											//window.alert(xmlhttp.responseText);
											change_subdatalist(xmlhttp.responseText,form.item_id.value);
										}
									 }
		xmlhttp.send(null);
		form.comment.value = '';
		form.anonymous.checked = false;
	}else{
		window.alert('40文字以内です');
	}
}

function change_subdatalist(str,item_id){
	var e1 = document.getElementById('__subdatalist' + item_id);
	e1.innerHTML = str;
}

function show(showname){
	showname2 = document.getElementById(showname);
	if(showname2.style.display == 'none'){
		showname2.style.display = "block";
	}else{
		showname2.style.display = "none";
	}
}

function chkMaxLength(obj,strLength){
    var tmpLength=obj.length;
    if(tmpLength > strLength){
    	return 0;
    }else{
    	return 1;
    }
}
