//URL Encode (UTF-8)
function encodeURL(str) {
  var character = '';
  var unicode   = '';
  var string    = '';
  var i         = 0;

  for (i = 0; i < str.length; i++) {
    character = str.charAt(i);
    unicode   = str.charCodeAt(i);

    if (character == ' ') {
      string += '+';
    } else {
      if (unicode == 0x2a || unicode == 0x2d || unicode == 0x2e || unicode == 0x5f || ((unicode >= 0x30) && (unicode <= 0x39)) || ((unicode >= 0x41) && (unicode <= 0x5a)) || ((unicode >= 0x61) && (unicode <= 0x7a))) {
        string = string + character;
      } else {
        if ((unicode >= 0x0) && (unicode <= 0x7f)) {
          character   = '0' + unicode.toString(16);
          string += '%' + character.substr(character.length - 2);
        } else if (unicode > 0x1fffff) {
          string += '%' + (oxf0 + ((unicode & 0x1c0000) >> 18)).toString(16);
          string += '%' + (0x80 + ((unicode & 0x3f000) >> 12)).toString(16);
          string += '%' + (0x80 + ((unicode & 0xfc0) >> 6)).toString(16);
          string += '%' + (0x80 + (unicode & 0x3f)).toString(16);
        } else if (unicode > 0x7ff) {
          string += '%' + (0xe0 + ((unicode & 0xf000) >> 12)).toString(16);
          string += '%' + (0x80 + ((unicode & 0xfc0) >> 6)).toString(16);
          string += '%' + (0x80 + (unicode & 0x3f)).toString(16);
        } else {
          string += '%' + (0xc0 + ((unicode & 0x7c0) >> 6)).toString(16);
          string += '%' + (0x80 + (unicode & 0x3f)).toString(16);
        }
      }
    }
  }

  return string;
}


function Hyoji() {
	
	var select_size = document.myform.select_size.value;
	
	if(document.myform.input_size_on.checked == true){
		
		if(document.myform.tate.value > 1000){
			window.alert("縦幅が大きすぎます");
			document.myform.tate.value = "";
		}else if(document.myform.yoko.value > 1000){
			window.alert("横幅が大きすぎます");
			document.myform.yoko.value = "";
		}else if(document.myform.tate.value < 100){
			window.alert("縦幅が小さすぎます");
			document.myform.tate.value = "";
		}else if(document.myform.yoko.value < 100){
			window.alert("横幅が小さすぎます");
			document.myform.yoko.value = "";
		}
		
		
		var tate = document.myform.tate.value;
		var yoko = document.myform.yoko.value;
	}else{
	if(select_size == "small"){
		var yoko = "270";
		var tate = "270";
		document.myform.yoko.value = "270";
		document.myform.tate.value = "270";
	}else if(select_size == "large"){
		var yoko = "500";
		var tate = "500";
		document.myform.yoko.value = "500";
		document.myform.tate.value = "500";
	}
	}

	tate = "&tate=" + tate;
	yoko = "&yoko=" + yoko;
	
	var id = document.myform.id.value;
	id = "?id=" + id;
	
	var html_tag = "<script type=\"text/JavaScript\" src=\"http://mobie.jp/blog.cgi" + id + tate + yoko + "\"></script>";


	document.myform.html_tag.value = html_tag;
	
	var html_tag_enco = document.myform.html_tag.value;
	html_tag_enco = encodeURL(html_tag_enco);

	var stHtml = "";
	stHtml = stHtml + '<A HREF=\"http://mobie.jp/blog_sample.cgi?blog_sample=';
	stHtml = stHtml + html_tag_enco;
	stHtml = stHtml + '\" target=\"_blank\">';
	stHtml = stHtml + '貼り付けイメージ';
	stHtml = stHtml + '</a>';

	document.getElementById("blog_sample").innerHTML = stHtml;

	
	
}

function radioValue(obj){
  var i;
  for(i=0;i<obj.length;i++){
    if(obj[i].checked){
      return obj[i].value;
    }
  }
  return '';
}




function new_window(){

	window.open('image.html', 'mywindow2', 'width=800, height=800, location=no, status=no, menubar=no, toolbar=no, scrollbars=yes');

}


function new_window_mobie_player_script(){

	window.open('mobie_player_script.html', 'mywindow2', 'width=425, height=800, location=no, status=no, menubar=no, toolbar=no, scrollbars=no');

}

function new_window_mobie_player_movie(){

	window.open('mobie_player_movie.html', 'mywindow2', 'width=570, height=600, location=no, status=no, menubar=no, toolbar=no, scrollbars=no');

}



function Mail() {
	
	if(document.mailform.mail.value == "メールアドレスを入力して送信ボタンを押してください"){
		document.mailform.mail.value = "";
	}
}


function Blog() {
	document.myform.html_tag.select();
}

