﻿// JScript 檔


//比較個案 --------------------------------------------------------------------------------
var value1 = 0;
window.status="本網站最佳瀏覽解析度為1024x768，建議使用IE6.0版本瀏覽器。";

function BuildCompare(){
    var x=0;
    var strSERNO="";
    var checkBox=document.forms[0].chkCompare;
    for(var i=0;i<checkBox.length;i++) 
    {
        //alert("checkBox.checked="+checkBox[i].checked);
        if(true==checkBox[i].checked){
            x+=1;
            strSERNO+=checkBox[i].value+",";
        }
    }
    
    if(x>3)
    {
        //alert("x="+x);
        alert("比較的建案不可超過三個!!");
    }
    else if(x<=0)
    {
        //alert("x="+x);
        alert("請選擇建案!!");
    }
    else
    {
        //alert("x="+x);
        window.open('../BuildQuery/BuildCompare.aspx?strSERNO='+strSERNO,target='_self');
    }
}

function chkCount(strID){
    //alert(document.form1.iCount.value);
    var i=document.form1.iCount.value;
    if (strID.checked == true)
        {
            i=parseInt(i)+1;
            //alert(strID.value);
        }
    else
        {
            i=parseInt(i)-1;
            //alert(i);
        }
    if (i > 3)
    {
        alert("個案不可超過三個");
        strID.checked = false;
        i=3;
    }
    document.form1.iCount.value = i;
}

function chkBuyReason()
{
	var querystring = decodeURIComponent(document.URL + '?');
	var pairs=querystring.split('?')[1].split('&');
	
	for (var i=0; i < pairs.length; i++) {
		var pairsValues = pairs[i].split('=');
		if (pairsValues[0] == "prePage")
			prePage = pairsValues[1];
	}
	
	if(prePage != null && prePage != "" && prePage != undefined)
	{
		alert("請輸入購屋原因!!");
		window.open(prePage + ".aspx",target="_self");
	}
}
//--------------------------------------------------------------------------------------------------

//都計圖放大縮小-----------------------------
function MapOrgSize() {
	document.location.href = document.URL;			
 }

function getMap(elImage) 
{
    // Be sure that a map is specified for the image.
    if (null != elImage.useMap) {
       // Remove the leading # from the bookmark.
       var strMap = elImage.useMap.substring(1);
       // Return the element with the specified name.
       return document.all[strMap];
    }
    else
       return null;
 }

var newWidthRate = 0;
var newHeightRate = 0;
    
function zoomImage(elImage, amount) 
{
    // Expand the image the specified amount.
    var elMap = getMap(elImage);
    
    
    //alert('elImage.width=' + elImage.width + ',elImage.height=' + elImage.height);
    elImage.width *= amount;
    elImage.height *= amount;
    
    //alert('newWidthRate=' + newWidthRate + ',newHeightRate=' + newHeightRate);
    if(amount == 1.2)
    {
		newHeightRate = 1.2;
		if(newWidthRate == 0)
		{
			newWidthRate = 1.439;
		} else {
			newWidthRate = 1.2;
		}
    }
    
    if(amount == .8)
    {
		newHeightRate = 0.8;
		if(newWidthRate == 0)
		{
			newWidthRate = 0.64;
		} else {
			newWidthRate = 0.8;
		}
    }
    
	var img=document.getElementsByTagName("img");
	
	for(var i=0;i<img.length;i++)
	{
		if(img[i].id.substring(0,6) == "dotImg")
		{
			var newWidth = 0;
			var newHeight = 0;
			
			if(img[i].id !=undefined && img[i].id !=null && img[i].id !="" && img[i].id != "imgMap" )
			{
				newWidth = Math.round(img[i].width * amount);
				newHeight = Math.round(img[i].height * amount);
				
				img[i].width = newWidth;
				img[i].height = newHeight;
			}
		}
	}


	var divs = document.all.tags("div");
	var divsLength = divs.length;
	
	for (var i=0; i<divsLength; i++) 
	{
		//alert('div=' + divs[i].id.substring(0,5));
		if(divs[i].id.substring(0,5) == "Layer")
		{
			divs[i].style.top = (divs[i].style.pixelTop - document.all.imgMap.offsetTop) * newWidthRate + document.all.imgMap.offsetTop + "px";
			divs[i].style.left = (divs[i].style.pixelLeft - document.all.imgMap.offsetLeft) * newHeightRate + document.all.imgMap.offsetLeft + "px";
		}
	}
 }

 function swapButtons(b1, b2) {
    // Swap the enabled/disabled buttons.
    document.all[b1].disabled = true;
    document.all[b2].disabled = false;
 }
 

function ShowXY() {
	var scrollX, scrollY;
	if (document.all)
	{
		scrollX = event.clientX + document.body.scrollLeft;
		scrollY = event.clientY + document.body.scrollTop;
	}
	else
	{
	  scrollX = window.pageXOffset;
	  scrollY = window.pageYOffset;
	}
	
	//alert('X=' + (parseInt(scrollX) - 6) + ',Y=' + (parseInt(scrollY) - 5));
	//alert('ImageTop=' + document.all.imgMap.offsetTop + ',Left=' + document.all.imgMap.offsetLeft);
 }
 
 function Resize() {
	//alert('imgMap.width=' + document.all.imgMap.width);
	//alert('imgMap.height=' + document.all.imgMap.height);
	zoomImage(document.all.imgMap,.8 );
	zoomImage(document.all.imgMap,.8 );
	zoomImage(document.all.imgMap,.8 );
	zoomImage(document.all.imgMap,.8 );
//			zoomImage(document.all.imgMap,.8 );
//			zoomImage(document.all.imgMap,.8 );
 }

 function SetPos() {
 
	var divs = document.all.tags("div");
	var divsLength = divs.length;
	
	for (var i=0; i<divsLength; i++) 
	{
		if(divs[i].id.substring(0,5) == "Layer")
		{
			//alert('document.all.imgMap.offsetTop=' + document.all.imgMap.offsetTop + ',document.all.imgMap.offsetLeft=' + document.all.imgMap.offsetLeft);
			divs[i].style.top = (divs[i].style.pixelTop + document.all.imgMap.offsetTop) + "px";
			divs[i].style.left = (divs[i].style.pixelLeft + document.all.imgMap.offsetLeft) + "px";
		}
	}
 }
//-------------------------------------------------------------------------
		 
function swapTab(TabIndex)
{
	//顯示投票區的頁籤
	if(TabIndex=="tab1")
	{
		//alert("tab1");
		document.getElementById('tab1').style.display = '';
		document.getElementById('tab2').style.display = 'none';
	}
	else
	{
		//alert("tab2");
		document.getElementById('tab1').style.display ='none';
		document.getElementById('tab2').style.display ='';
	}
}

//-----------------------------------------------------------------------
function GetVoteValue()
{
    //alert( 'length=' + document.form1.VoteOptions.length);
    for (var i=0; i < document.form1.VoteOptions.length; i++)
    {
        if (document.form1.VoteOptions[i].checked)
        {
            var rad_val = document.form1.VoteOptions[i].value;
            var rad_val1=rad_val.split('*')
//            for (var i=0; i < rad_val1.length; i++) {
//		        alert('value = ' + rad_val1[i]);
//	         }
//            alert('value = ' + rad_val);
            window.open("../Vote/VoteValue.aspx?QuestionID=" + rad_val1[0] + "&OptionID=" + rad_val1[1]  ,target='_blank','left=1500,top=1500,width=1,height=1,toolbar=no');
        }
    }
}


function ChecktheForm(){
var boxes=document.getElementsByName("VoteOptions")
//checkedBox= 0 ;
checkedBox='請選擇';
for(var i=0;i<boxes.length;i++){
  if(boxes[i].checked){
   GetVoteResult(1);
   //checkedBox=i;
   return; // No need to check the rest since only one can be checked.
  } 
   
}
alert(checkedBox);
}

//function ChecktheForm(){
//var codekey=document.getElementById("codekey");
//	if(codekey.value == "") {
//		alert("請輸入檢核碼");
//		codekey.focus();
//		return;
//	}
     
   //GetVoteResult(1);
//}


function GetVoteResult(j)
{
   if(j==2){
    for (var i=0; i < document.form1.VoteOptions.length; i++)
    {
        if (document.form1.VoteOptions[i].checked)
        {
            var rad_val = document.form1.VoteOptions[i].value;
            var rad_val1=rad_val.split('*')
            window.open('../Vote/VoteResult.aspx?check=2&QuestionID=' + rad_val1[0] ,target='_blank','width=500,height=380,toolbar=no');
        }
    }
   }
   if(j==1){
    for (var i=0; i < document.form1.VoteOptions.length; i++)
    {
        if (document.form1.VoteOptions[i].checked)
        {
            var rad_val = document.form1.VoteOptions[i].value;
            var rad_val1=rad_val.split('*')
//            for (var i=0; i < rad_val1.length; i++) {
//		        alert('value = ' + rad_val1[i]);
//	         }
//            alert('value = ' + rad_val);
            window.open("../Vote/VoteResult.aspx?check=1&QuestionID=" + rad_val1[0] + "&OptionID=" + rad_val1[1]  ,target='_blank','width=500,height=380,toolbar=no');
        }
    }
   }
   
	
  
}

    var y=0; 

　　function myRefresh() 

　　{ 
    
　　var httpRequest = new ActiveXObject("microsoft.xmlhttp"); 

　　httpRequest.open("GET", "../test.aspx", false); 

　　httpRequest.send(null); 

　　y++; 

　　if(y<60) //60次，也就是Session真正的过期时间是30分钟 

　　{ 

　　setTimeout("myRefresh()",30*1000); //30秒 
    
　　} 

　　} 

　　myRefresh(); 
