//自动大图调整
function ResizeImage(imageid,limitWidth,limitHeight) 
{     
    var image = new Image(); 
    image.src = imageid.src; 
     
    if(image.width <= 0 && image.height <= 0) return; 
     
    if(image.width/image.height >= limitWidth/limitHeight) 
    { 
        if(image.width > limitWidth) 
        { 
            imageid.width = limitWidth; 
            imageid.height = (image.height*limitWidth)/image.width; 
        } 
    } 
    else if(image.height > limitHeight) 
    { 
            imageid.height = limitHeight; 
            imageid.width = (image.width*limitHeight)/image.height;      
    } 
     
    if (imageid.parentElement.tagName != "A") 
    { 
        imageid.onclick = function(){window.open(this.src);} 
        imageid.style.cursor = "hand"; 
    } 
} 

window.onload = function(){Init();}; 

function Init() 
{ 
    var maxWidth = 500; 
    var maxHeight = 800; 
    var obj=document.getElementById('autoimageresize');
	if(obj==null) return;
    var imgs = obj.getElementsByTagName("img"); 
     
    for(var i=0; i < imgs.length; i++) 
    { 
        var img = imgs[i]; 
         
        if(img.width>maxWidth||img.height>maxHeight) 
            ResizeImage(img, maxWidth, maxHeight); 
    } 
	
}

function submitform(formid)
{
	var obj=document.getElementById(formid);
	if(obj!=null)
	{
		obj.submit();
	}
}

function setlists0(response)
{
	var response=eval('(' + response + ')');
	if(response!='none')
	{
		//处理片区
		if(response.sections.length>0)
		{
			$("#section0").get(0).options.length=0;
			$("#section0").get(0).disabled=false;
			$("#section0").get(0).options.add(new Option('片区不限',''));
			for(var i=0;i<response.sections.length;i++)
			{
				$("#section0").get(0).options.add(new Option(response.sections[i],response.sections[i]));
			}
		}
		else
		{
			$("#section0").get(0).options.length=0;
			$("#section0").get(0).options.add(new Option('片区不限',''));
			$("#section0").get(0).disabled=true;
		}
	}
	else
	{
			$("#section0").get(0).options.length=0;
			$("#section0").get(0).options.add(new Option('片区不限',''));
	}
}
function setlists(response)
{
	var response=eval('(' + response + ')');
	if(response!='none')
	{
		//处理片区
		if(response.sections.length>0)
		{
			$("#section").get(0).options.length=0;
			$("#section").get(0).disabled=false;
			$("#section").get(0).options.add(new Option('片区不限',''));
			for(var i=0;i<response.sections.length;i++)
			{
				$("#section").get(0).options.add(new Option(response.sections[i],response.sections[i]));
			}
		}
		else
		{
			$("#section").get(0).options.length=0;
			$("#section").get(0).options.add(new Option('片区不限',''));
			$("#section").get(0).disabled=true;
		}
	}
	else
	{
			$("#section").get(0).options.length=0;
			$("#section").get(0).options.add(new Option('片区不限',''));
	}
}
function setlistsandcoms(response)
{
	var response=eval('(' + response + ')');
	if(response!='none')
	{
		//处理片区
		if(response.sections.length>0)
		{
			$("#section").get(0).options.length=0;
			$("#section").get(0).disabled=false;
			$("#section").get(0).setAttribute('dataType','Require');
			$("#section").get(0).setAttribute('msg','必须选择所在片区');
			$("#section").get(0).options.add(new Option('请选择所在片区',''));
			for(var i=0;i<response.sections.length;i++)
			{
				$("#section").get(0).options.add(new Option(response.sections[i],response.sections[i]));
			}
		}
		else
		{
			$("#section").get(0).setAttribute('dataType','');
			$("#section").get(0).setAttribute('msg','');
			$("#section").get(0).options.length=0;
			$("#section").get(0).options.add(new Option('暂未划分片区',''));
			$("#section").get(0).disabled=true;
		}
		
		
		//处理小区
		if(response.communities.length>0)
		{
			$("#community").get(0).options.length=0;
			$("#community").get(0).disabled=false;
			$("#community").get(0).setAttribute('dataType','Require');
			$("#community").get(0).setAttribute('msg','必须选择小区/楼盘');
			$("#community").get(0).options.add(new Option('请选择所在小区/楼盘',''));
			for(var i=0;i<response.communities.length;i++)
			{
				$("#community").get(0).options.add(new Option(response.communities[i].name,response.communities[i].name));
			}
				$("#community").get(0).options.add(new Option('其他','其他'));
		}
		else
		{
			$("#community").get(0).setAttribute('dataType','');
			$("#community").get(0).setAttribute('msg','');
			$("#community").get(0).options.length=0;
			$("#community").get(0).options.add(new Option('暂未划分片区',''));
			$("#community").get(0).disabled=true;
		}
	}
	else
	{
			$("#section").get(0).options.length=0;
			$("#section").get(0).options.add(new Option('请先选择城区',''));
			$("#community").get(0).options.length=0;
			$("#community").get(0).options.add(new Option('请先选择城区',''));
	}
}

