<!--//

function close_win(){
var nvua = navigator.userAgent;
if(nvua.indexOf('MSIE') >= 0){
if(nvua.indexOf('MSIE 5.0') == -1) {
top.opener = '';
}
}
else if(nvua.indexOf('Gecko') >= 0){
top.name = 'CLOSE_WINDOW';
wid = window.open('','CLOSE_WINDOW');
}
top.close();
}

function changeImg(iName,img){
	document.images[iName].src=img;
}

function _JumpURLnewWin(url,sizeX,sizeY) 
{
  if (url != ''){
    win=window.open(url,"a","scrollbars=1,resizable=yes,width=" + sizeX + ",height=" + sizeY);
  }
}
function _TargetWinOpen(url,sizeX,sizeY,target) 
{
  if (url != ''){
    win=window.open(url,target,"scrollbars=1,resizable=yes,width=" + sizeX + ",height=" + sizeY);
  }
}
function SelectJumpURL(obj) 
{
  url = obj.options[obj.selectedIndex].value;
  if (url != '')
  {
    window.location = url;
  }
}
function mOvr(src,clrOver){ 
	if (!src.contains(event.fromElement)){
		src.style.cursor = 'hand'; 
		src.bgColor = clrOver; 
	} 
} 
function mOut(src,clrIn){ 
	if (!src.contains(event.toElement)){ 
		src.style.cursor = 'default'; 
		src.bgColor = clrIn; 
	} 
} 


//showLayer
function showLay(idName){ 
	if(document.getElementById){//NN6,Mozilla,IE5用
		document.getElementById(idName).style.visibility = 'visible';
	}else if(document.all){//IE4用
		document.all(idName).style.visibility = 'visible';
	}else if(document.layers){//NN4用
		document.layers[idName].visibility = 'show';
	}
}

//hideLayer
function hideLay(idName){ 
	if(document.getElementById){//NN6,Mozilla,IE5用
		document.getElementById(idName).style.visibility = 'hidden';
	}else if(document.all){//IE4用
		document.all(idName).style.visibility = 'hidden';
	}else if(document.layers){//NN4用
		document.layers[idName].visibility = 'hide';
	}
}

// 画像のonLoad
var url = new Array(


"/common/footerNvg01_on.gif",
"/common/footerNvg02_on.gif",
"/common/footerNvg03_on.gif"

);

var theImages = new Array;
function preLoad(){
	for(var i = 0; i < url.length; i++){
		theImages[i] = new Image;
		theImages[i].src = url[i];
	}
}

function disp(url){

window.open(url, "window_name", "width=545,height=650,scrollbars=yes");

} 

// スムーススクロール
function SmoothScroll(targetID){
  if( !document.getElementById ) {return true;}
  var step=10;  //初速度
  var max=400;  //最高速度
  var accel=4;  //加速度
  var interval=30;  //加速インターバル
  var current_y = document.body.scrollTop  || document.documentElement.scrollTop;
  var element=document.getElementById(targetID);
  if (!element){return true;}
  var target_y = 0;
  for (i = element;i.offsetParent;i=i.offsetParent ){
    target_y += i.offsetTop;
  }
  var count=0;
  if ( current_y > target_y ){ step = -(step); accel = -(accel);}
  var timerid = setInterval( function(){
    if (step<max) step += (count*accel);
    if ( Math.abs(current_y-target_y) < Math.abs(step) ){
      window.scrollTo((document.body.scrollTop  || document.documentElement.scrollTop),target_y);
      clearInterval(timerid);
      return false;
    }else{
      window.scrollBy(0,step);
      current_y += step;
      count++;
    }
  },interval);
  return false;
}


function area_map(stNUM,areacd){
	if(document.area_box.area_name01.value == stNUM){
		Duplicate();
	}else if(document.area_box.area_name02.value == stNUM){
		Duplicate();
	}else if(document.area_box.area_name03.value == stNUM){
		Duplicate();
	}else{
	
		if(document.area_box.area_name01.value == ""){
			document.area_box.area_name01.value = stNUM;
			document.area_box.area_cd01.value = areacd;
		}else if(document.area_box.area_name02.value == ""){
			document.area_box.area_name02.value = stNUM;
			document.area_box.area_cd02.value = areacd;
		}else if(document.area_box.area_name03.value == ""){
			document.area_box.area_name03.value = stNUM;
			document.area_box.area_cd03.value = areacd;
		}else{
			Overflow();
		}
	}
}

function Duplicate(){
//	alert("クリックした駅は既に選択済みです。");
}
function Overflow(){
	flag = confirm("これ以上選択できません。エリア選択を解除しますか？");
	if(flag){
		document.area_box.area_name01.value = "";
		document.area_box.area_cd01.value = "";
		document.area_box.area_name02.value = "";
		document.area_box.area_cd02.value = "";
		document.area_box.area_name03.value = "";
		document.area_box.area_cd03.value = "";
	}
}
// smartRollover
function GoBack(){
	if(document.area_box.area_name03.value != ""){
		document.area_box.area_name03.value = "";
		document.area_box.area_cd03.value = "";
	}else if(document.area_box.area_name02.value != ""){
		document.area_box.area_name02.value = "";
		document.area_box.area_cd02.value = "";
	}else if(document.area_box.area_name01.value != ""){
		document.area_box.area_name01.value = "";
		document.area_box.area_cd01.value = "";
	}
}


// smartRollover

function smartRollover() {
	if(document.getElementsByTagName) {
		var images = document.getElementsByTagName("img");

		for(var i=0; i < images.length; i++) {
			if(images[i].getAttribute("src")=="null"){
				break;
			}
			
			if(images[i].getAttribute("src").match("_rll."))
			{
				images[i].onmouseover = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_rll.", "_on."));
				}
				images[i].onmouseout = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_on.", "_rll."));
				}
			}
		}
	}
}

if(window.addEventListener) {
	window.addEventListener("load", smartRollover, false);
}
else if(window.attachEvent) {
	window.attachEvent("onload", smartRollover);
}

function LineMap(StName,LiStdat){
	for(i = 0; i < 10; i++){
		if(document.line_box['station' + i].value == StName){
			if(document.line_box['st_stock' + i].value == LiStdat){
				Duplicate();
				break;
			}
		}
		if(document.line_box['station' + i].value == ""){
			StDat = LiStdat.split("_");
			for(y = 0; y < StDat.length; y++){
				if(document.getElementById(StDat[y]).checked == false){
					document.getElementById(StDat[y]).checked = true;
				}
			}
			document.line_box['station' + i].value = StName;
			document.line_box['st_stock' + i].value = LiStdat;
			break;
		}
		if(i == 9){
			if(document.line_box.elements[i].value != ""){
				alert("10個以上は選択できません。");
			}
		}
	}
	var item = $('LineMap');
	Element.scrollTo(item);
}

function ClearAll(){
	flag = confirm("全てリセットします。よろしいですか？");
	if(flag){
		for(i = 0; i < 10; i++){
			StDat = document.line_box['st_stock' + i].value.split("_");
			for(y = 0; y < StDat.length; y++){
				if(document.getElementById(StDat[y]).checked == true){
					document.getElementById(StDat[y]).checked = false;
				}
			}
			document.line_box['station' + i].value = "";
			document.line_box['st_stock' + i].value = "";
		}
	}
}

function ClearOne(){
	for(i = 9; i >= 0; i--){
		if(document.line_box.elements[i].value != ""){
			StDat = document.line_box['st_stock' + i].value.split("_");
			for(y = 0; y < StDat.length; y++){
				if(document.getElementById(StDat[y]).checked == true){
					document.getElementById(StDat[y]).checked = false;
				}
			}
			document.line_box['station' + i].value = "";
			document.line_box['st_stock' + i].value = "";
			break;
		}
	}
}

function RequestArea(plc,acd){
	if(acd == ''){
		var isMSIE = /*@cc_on!@*/false;
		if(isMSIE){
			$(plc).outerHTML = '<select name="' + plc + '" id="' + plc + '" onChange="javascript:chk_area(\'td_area\',\'td_station\');ctl_enter();"><option value="">指定なし</option></select>';
		
		}else{
			$(plc).innerHTML = '<option value="">指定なし</option>';
		}
	}else{
		new Ajax.Request("ajax_detail.php",{
			method: "get",
			parameters: "area_cd="+acd,
			onSuccess: function(httpObj){
				if(httpObj.responseText != ''){
					var isMSIE = /*@cc_on!@*/false;
					if(isMSIE){
						$(plc).outerHTML = '<select name="' + plc + '" id="' + plc + '" onChange="javascript:chk_area(\'td_area\',\'td_station\');ctl_enter();">' + httpObj.responseText + '</select>';
					
					}else{
						$(plc).innerHTML = httpObj.responseText;
					}
				
				}
				chk_area('td_area','td_station');
			},
			onFailure:function(httpObj){
				alert("接続できませんでした。");
			}
		});
	}
	chk_area('td_area','td_station');

}

function RequestStation(plc,scd){
	if(scd == ''){
		var isMSIE = /*@cc_on!@*/false;
		if(isMSIE){
			$(plc).outerHTML = '<select name="' + plc + '" id="' + plc + '" onChange="javascript:chk_area(\'td_area\',\'td_station\');ctl_enter();"><option value="">指定なし</option></select>';
		}else{
			$(plc).innerHTML = '<option value="">指定なし</option>';
		}
	}else{
		new Ajax.Request("ajax_detail.php",{
			method: "get",
			parameters: "line_cd="+scd,
			onSuccess: function(httpObj){
				if(httpObj.responseText != ''){
					var isMSIE = /*@cc_on!@*/false;
					if(isMSIE){
						$(plc).outerHTML = '<select name="' + plc + '" id="' + plc + '" onChange="javascript:chk_area(\'td_area\',\'td_station\');ctl_enter();">' + httpObj.responseText + '</select>';
					}else{
						$(plc).innerHTML = httpObj.responseText;
					}
					chk_area('td_area','td_station');
				}
			},
			onFailure:function(httpObj){
				alert("接続できませんでした。");
			}
		});
	}
	chk_area('td_area','td_station');
}

function formConfirm(type) {
	if (type == "comfirm") {
		rtn = confirm("送信します。\nよろしいですか？");
	}
	if (rtn) {
		return true;
		}else{
		return false;
	}
}
/* ブラウザにより使用オブジェクトを識別 */
function createXMLHttpRequest(){
	/* XMLHttpRequest オブジェクトを作成する   */
	if(window.addEventListener){
		/* FireFox 用 */
		return new XMLHttpRequest();
	}else{
		/* IE 用 */
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
}

/* 投稿サーバ通信処理 */
function XMLHttpRequest_ZipNo(zip1,zip2,add1,add2){

	var request = createXMLHttpRequest();

	/* ステータス( 読み込み中なのか完了したのか) が変更されたらreadyStateChangeHandler を実行 */
	request.onreadystatechange = readyStateChangetweet;
	request.open("GET", "http://www.coldwell.jp/member/ajax_getzipno.php?zn1="+document.getElementById(zip1).value+"&zn2="+document.getElementById(zip2).value+"" , true);
	request.setRequestHeader( "Content-Type","application/x-www-form-urlencoded");
	request.send();

	function readyStateChangetweet(){
		switch(request.readyState){
			case 4:
				if(request.status == 200){
					//値 0:正常 1:テキスト未入力 2:未ログイン 3:通信エラー 4：通信エラー
					var ret = request.responseText;
					var data = ret.split(',');

					if(data[0]=="1"){
						alert('郵便番号が未設定です。');
					}else if(data[0]=="2"){
						alert('郵便番号の形式が不正です。');
					}else{
						if(data[1]=="" || data[1]=="undefined"){
							alert('入力された郵便番号は存在しません。');
						}else{
							document.getElementById(add1).value=decodeURIComponent(data[1]);
							document.getElementById(add2).value=decodeURIComponent(data[2]);
							
							if(document.getElementById('ol_contact')){
								ol_check('b_address01');
								ol_check('b_address02');
								ol_check('address01');
								ol_check('address02');
								ctl_enter();
							}else if(document.getElementById('contact_normal')){
								ol_check('zip1');
								ol_check('zip2');
								ctl_enter();
							}else if(document.getElementById('ol_area_select')){
								url="http://www.coldwell.jp/contact_o/?";
								url=url + "area=" + data[1];
								url=url + "&area_detail=" + data[2];
								location.href=url;
								
								return ;
							}else{
								if(document.getElementById('address01')){
									ol_check('address01');
									ol_check('address02');
								}
								if(document.getElementById('b_address01')){
									ol_check('b_address01');
									ol_check('b_address02');
								}
								if(document.getElementById('zip1')){
									ol_check('zip1');
									ol_check('zip2');
								}
								ctl_enter();
							}
						}
					}
				}else{
					alert('通信エラーが発生しました。インターネット接続を確認してください。');
				}
				
				break;
		}
	}
	
	return;
}

//-----会員登録入力チェック用関数-----
//物件種別
function chk_kind($ids){
	if(document.getElementById('chk_kind_1').checked==true || 
		document.getElementById('chk_kind_2').checked==true || 
		document.getElementById('chk_kind_3').checked==true) {
		
		document.getElementById($ids).style.backgroundColor='#ffffff';
	}else{
		document.getElementById($ids).style.backgroundColor='#ff99cc';
	}
}
//希望種類
function chk_class($ids){
	if(document.getElementById('chk_class_1').checked==true || 
		document.getElementById('chk_class_2').checked==true) {
		
		document.getElementById($ids).style.backgroundColor='#ffffff';
	}else{
		document.getElementById($ids).style.backgroundColor='#ff99cc';
	}
}

//エリア・路線
function chk_area($ids1,$ids2){
	if( document.getElementById('request_area01').value=="" && 
		document.getElementById('request_area02').value=="" && 
		document.getElementById('request_area03').value=="" && 
		document.getElementById('request_area04').value=="" && 
		document.getElementById('line01').value=="" && 
		document.getElementById('line02').value=="" && 
		document.getElementById('line03').value=="" && 
		document.getElementById('line04').value=="" ){

		document.getElementById($ids1).style.backgroundColor='#ff99cc';
		document.getElementById($ids2).style.backgroundColor='#ff99cc';
	}else{
		document.getElementById($ids1).style.backgroundColor='#ffffff';
		document.getElementById($ids2).style.backgroundColor='#ffffff';
	}
}

//漢字・カナ
function chk_2_col($ids,$obj1,$obj2){
	if(document.getElementById($obj1).value=="" || 
		document.getElementById($obj2).value=="") {
		
		document.getElementById($ids).style.backgroundColor='#ff99cc';
	}else{
		document.getElementById($ids).style.backgroundColor='#ffffff';
	}
}

//TEL
function chk_tel($ids,$obj1,$obj2,$obj3){
	if(document.getElementById($obj1).value=="" || 
		document.getElementById($obj2).value=="" || 
		document.getElementById($obj3).value=="") {
		
		document.getElementById($ids).style.backgroundColor='#ff99cc';
	}else{
		document.getElementById($ids).style.backgroundColor='#ffffff';
	}
}

//住所
function chk_1_col($ids,$obj1){
	if(document.getElementById($obj1).value=="" ) {
		
		document.getElementById($ids).style.backgroundColor='#ff99cc';
	}else{
		document.getElementById($ids).style.backgroundColor='#ffffff';
	}
}
//物件種別
function chk_contact($ids,$obj1,$obj2,$obj3,$obj4){
	if(document.getElementById($obj1).checked==true || 
		document.getElementById($obj2).checked==true || 
		document.getElementById($obj3).checked==true || 
		document.getElementById($obj4).checked==true) {
		
		document.getElementById($ids).style.backgroundColor='#ffffff';
	}else{
		document.getElementById($ids).style.backgroundColor='#ff99cc';
	}
}
//メール
function chk_2_col_conf($ids1,$ids2,$obj1,$obj2){
	if(document.getElementById($obj1).value=="" || 
		document.getElementById($obj2).value=="") {
		
		document.getElementById($ids1).style.backgroundColor='#ff99cc';
		document.getElementById($ids2).style.backgroundColor='#ff99cc';
	}else{
		document.getElementById($ids1).style.backgroundColor='#ffffff';
		document.getElementById($ids2).style.backgroundColor='#ffffff';
	}
}
//メール
function same_add(){
	if(document.getElementById("chk_same_add").checked==true ){
		document.getElementById('tr_zip').style.display='none';
		document.getElementById('tr_add1').style.display='none';
		document.getElementById('tr_add2').style.display='none';
	}else{
		document.getElementById('tr_zip').style.display='';
		document.getElementById('tr_add1').style.display='';
		document.getElementById('tr_add2').style.display='';
		
	}
}

//オンライン無料査定用
function ol_b_add1(){
	if(document.getElementById("b_address01").checked=="" ){
		if(document.getElementById('b_address01').value==""){
			document.getElementById('b_address01').style.backgroundColor='#ff99cc';
		}
	}else{
		document.getElementById('b_address01').style.backgroundColor='#ffffff';
	}
}
function ol_b_add2(){
	if(document.getElementById("b_address02").checked=="" ){
		if(document.getElementById('b_address02').value==""){
			document.getElementById('b_address02').style.backgroundColor='#ff99cc';
		}
	}else{
		document.getElementById('b_address02').style.backgroundColor='#ffffff';
	}
}
function ol_check(ol_id){
	if(document.getElementById(ol_id).value==""){
		document.getElementById(ol_id).style.backgroundColor='#ff99cc';
	}else{
		document.getElementById(ol_id).style.backgroundColor='#ffffff';
	}
}


//-->
