var  thumb1h = 0;

// JavaScript Document
function resizeImage(obj, MaxW, MaxH,oType){
	var imageObject = obj;
    var state = imageObject.readyState;
	if(state!='complete') {
		setTimeout("resizeImage("+imageObject+","+MaxW+","+MaxH+","+oType+")",50);
		return;
    }
    var oldImage = new Image();
    oldImage.src = imageObject.src;
    var dW = oldImage.width; 
    var dH = oldImage.height;
	wWidth=oldImage.width+20;
	wHeigh=oldImage.height+100;
	if(dW>0 && dH>0) {
		a = dW/MaxW; b = dH/MaxH;
        if( b>a ) a = b;
        dW = dW/a; dH = dH/a;
    }
	if(dW > 0 && dH > 0) {
        imageObject.width = dW;
		imageObject.height = dH;
	}
	//alert(obj.name);
	if(obj.name=='span1img') {
		//alert("span1 "+dW);
		$('span1').style.width = 400-dW;
	}
	else if(obj.name=='span2img'){
		//alert("span2 "+dW);
		$('span2').style.width = 400-dW;
	}
	else if(obj.name=='thumb1') {
		//alert("span2 height" +(dH+17));
		$('span2').style.marginTop = -dH-17;
	}
    /*
	if(dW>0 && dH>0 && dH<=400) {
		a = dW/MaxW; b = dH/MaxH;
        if( b>a ) a = b;
        dW = dW/a; dH = dH/a;
    }
	else{
		a = dW/300;
		dW = 300;
        dH = dH/a;
	}
	if(dW > 0 && dH > 0) {
        imageObject.width = dW;
		imageObject.height = dH;
	}
	var filename = "";
	if(oType!=0 && dH!=600){
		if(oType==1)  filename = "/shared/css/p01.css";
		else filename = "/shared/css/p02.css";
		var fileref=document.createElement("link");
		fileref.setAttribute("rel", "stylesheet");
		fileref.setAttribute("type", "text/css");
		fileref.setAttribute("href", filename);
	}
	*/
	//document.getElementById("elementID").style.left = -642px
}

function checkF1(){
	var current_form = document.dwellingSearch1;
	//alert(current_form.landarea.selectedIndex);
	if(current_form.landarea.selectedIndex==0 && current_form.landtype.selectedIndex==0 && current_form.landprice.selectedIndex==0){
		alert("検索条件を選択してください!");
	}
	else current_form.submit();
}

function checkF2(){
	var current_form = document.dwellingSearch2;
	//alert(current_form.landarea.selectedIndex);
	if(current_form.officearea.selectedIndex==0 && current_form.officeprice.selectedIndex==0){
		alert("検索条件を選択してください!");
	}
	else current_form.submit();
}

function $() { 
  var elements = new Array(); 
  for (var i = 0; i < arguments.length; i++) 
  { 
    var element = arguments[i]; 
    if (typeof element == 'string') 
      element = document.getElementById(element); 
    if (arguments.length == 1) 
      return element; 
    elements.push(element); 
  } 
  return elements; 
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function radio_active(radio_group) {
    // Run through the group
    for (var counter = 0; counter < radio_group.length; counter++) {
        // When we find the activated button, return the index
        if (radio_group[counter].checked) {
            return counter;
        }
    }
    // If no button is activated, return -1
    return -1;
}

function detail_open_left(id){
	wo = window.open('/showtopland.php?id=' + id , '詳細','width=640 height=500 toolbar=yes location=no scrollbars=yes resizable=yes');
	wo.window.moveTo(1,1);
	wo.focus();
}