﻿// JScript 文件]
//  2009.10.23 建立

//获取指定ID控件
//例如:var username = $("txt_UserName").value;获取当前页面的UserName控件
//  2009.10.23
function $(id)
{
    return document.getElementById(id);
}      


function Reset()
{
    var  input=document.getElementsByTagName("input"); 
    for(var   i=0;i <input.length;i++) 
    { 
        if   (e[i].type== "text") 
        { 
            e[i].value = '';
        } 
    } 
}


//获取Url中的参数值 
//例如:var keyword = $G("keyword");获取当前页面的keyword参数的值
//  2009.10.23
function $G()
{
    var Url=window.location.href;//如果想获取框架顶部的url可以用 top.window.location.href
    var u,g,StrBack='';
    if(arguments[arguments.length-1]=="#")
       u=Url.split("#");
    else
       u=Url.split("?");
       
    if (u.length==1) 
       g='';
    else 
      g=u[1];
      
    if(g!='')
    {
       gg=g.split("&");
       var MaxI=gg.length;
       str = arguments[0]+"=";
       for(xm=0;xm<MaxI;xm++)
       {
          if(gg[xm].indexOf(str)==0) 
          {
            StrBack=gg[xm].replace(str,"");
            break;
          }
       }
    }
    return StrBack;
 }  
 
 //定义字符串的trim方法
 //  2009.10.23
String.prototype.trim= function()
{  
   return this.replace(/(^\s*)|(\s*$)/g, "");  
}

//定义字符串转整形方法
//张陆扬 091118
String.prototype.ToInt= function()
{  
   var numString = this.trim();
   var num = parseInt(numString);
   if(isNaN(num))
   {
      return -1;  
   }else
   {
       return num; 
   }
}


/*
* 定义遮罩层 ID 为 maskLayer ,并写在 bodayOnload 中 new
* 张陆扬 091113
*/
var maskLayer = function()
{
   
   var layer = null;
   var contentLayer = null;
   var navDivLayer = null;
   var iframeLayer = null;
       function resesizeWindow ()
       {
            layer.style.width = Math.max(document.documentElement.scrollWidth, document.documentElement.clientWidth) + "px";
            layer.style.height = Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight) + "px";
       } 

    this.create = function(lyrID,contentLayerID)
    {
        layer = document.body.insertBefore(document.createElement("div"), document.body.childNodes[0]);
     
        contentLayer = document.body.insertBefore(document.createElement("div"), document.body.childNodes[0]);
       
        contentLayer.id =  contentLayerID;
        
        navDivLayer= document.createElement("div");
       
        iframeLayer= document.createElement("div");
        
        
        navDivLayer.innerHTML = "<a style='cursor:hand' onclick=\"mask.hideContent() \">Close</a>"
        
        contentLayer.appendChild(navDivLayer);
        
        contentLayer.appendChild(iframeLayer);

        
        layer.id = lyrID;
        with(layer.style)
        { 
               display = "none"; zIndex = -1; 
               left = top = 0; position = "absolute"; 
               width = height = "100%"; 
        }
        
        with(contentLayer.style)
        {
              display = "none"; zIndex = - 2;
              left = top = 0; position = "absolute";
              width = "300px"; height = "200px"
        }
        

        window.onresize = resesizeWindow;
    }
 
       this.show = function()
        {
           with(layer.style)
            { 
                   display = ""; zIndex = 1000; 
                   left = top = 0; 
                   position = "absolute"; 
                   width = Math.max(document.documentElement.scrollWidth, document.documentElement.clientWidth) + "px";
                   height = Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight) + "px"; 
                   backgroundColor= "Gray";
                   filter="alpha(opacity=80)";
                   opacity=0.8 ;
            }
        }
        
        this.showContent = function(html)
        {
             iframeLayer.innerHTML = "";
             iframeLayer.innerHTML = html;
             
             with(layer.style)
             { 
                   display = ""; zIndex = 1000; 
                   left = top = 0; 
                   position = "absolute"; 
                   width = Math.max(document.documentElement.scrollWidth, document.documentElement.clientWidth) + "px";
                   height = Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight) + "px"; 
                   backgroundColor= "Gray";
                   filter="alpha(opacity=80)";
                   opacity=0.8 ;
             }
             with(contentLayer.style)
             {
                   display = ""; zIndex = 1001;    
                   position = "absolute"; 
                   width = "400px";   // --------------------------------------------.
                   height = "300px";  // ---------------------------------------------.
                   top = ( 768/2 - 300/2) + "px";
                   left = (document.body.scrollLeft + document.body.clientWidth/2 - 400/2) + "px";
                   
                   //top = (document.body.scrollTop + document.body.clientHeight/2 - 300/2) + "px";
                   //left = (document.body.scrollLeft + document.body.clientWidth/2 - 400/2) + "px";
             }
             
        }
        
        this.hideContent = function()
        {
             with(layer.style)
             { 
                   display = "none"; zIndex = -1; 
             }
             
            with(contentLayer.style)
             {
                   display = "none"; zIndex = -2;    
             }
        }   

}

function imageOnLoad(ele,width,height)
{// 47 78
    ele.resized=false;
    if(ele.height > ele.width*0.75 && ele.height>height)
    {
        ele.resized=true; ele.height=height;
    }

    if(ele.resized==false && ele.width >width)
    {
        ele.resized=true; ele.width=width;
    } 

}
// 图片加载链接错误 处理
// 张陆扬 2009.11.18
function imageError(ele)
{
    var linkEle = ele.parentNode;
    var container = linkEle.parentNode;
    linkEle.innerHTML = "";
    container.removeChild(linkEle);
}

//单DIV卷提 动态效果  用于CarPortalVariant.aspx 页面
//吴天荣 2009.12.03 重写
function coll(id) 
{
	if($('ul_' + id).style.display == 'none') 
	{
		$('ul_' + id).style.display = 'block';
		$('img_' + id).src = '/images2/btn_expand1.gif';
	}
	else 
	{
		$('ul_' + id).style.display = 'none';
		$('img_' + id).src = '/images2/btn_expand2.gif';
	}
}

//全DIV卷提 动态效果  用于CarPortalVariant.aspx 和 CompareResults.aspx 页面
// 2009.11.18  重写
function collall(value) 
{  
	if(value==1) 
	{
	    for(var id=1;id<=12;id++)
	    {
		    $('ul_' + id).style.display = '';
		    $('img_' + id).src = '/images2/btn_expand1.gif';
		}
		$("closeAll").style.display="";
		$("expandAll").style.display="none";
		
	}
	else 
	{
	    for(var id=1;id<=12;id++)
	    {
		    $('ul_' + id).style.display = 'none';
		    $('img_' + id).src = '/images2/btn_expand2.gif';
		}    
		$("closeAll").style.display="none";
		$("expandAll").style.display="";
	}
}

//单DIV卷提 动态效果  用于CompareResults.aspx 页面
// 2009.11.18 
function collCompareL(id) 
{
	if($('ul_' + id).style.display == 'none') 
	{
		$('ul_' + id).style.display = '';
		$('img_' + id).src = 'images/jian_1.jpg';
	    $('div_' + id).className="compare-results_con1_left1_con2 border1";
	}
	else 
	{
		$('ul_' + id).style.display = 'none';
		$('img_' + id).src = 'images/jian_2.jpg';
		$('div_' + id).className="compare-results_con1_left1_con2";
	}
}

//单DIV卷提 动态效果  用于 CompareResults.aspx 页面
// 2009.11.18 
function collCompareR(id) 
{
	if($('ul_' + id).style.display == 'none') 
	{
	    if($('ul1_' + id)!=null)
	    {
		    $('ul1_' + id).style.display = '';
		}
		if($('ul2_' + id)!=null)
	    {
		    $('ul2_' + id).style.display = '';
		}
		if($('ul3_' + id)!=null)
	    {
		    $('ul3_' + id).style.display = '';
		}
		if($('ul4_' + id)!=null)
	    {
		    $('ul4_' + id).style.display = '';
		}
	}
	else 
	{
		if($('ul1_' + id)!=null)
	    {
		    $('ul1_' + id).style.display = 'none';
		}
		if($('ul2_' + id)!=null)
	    {
		    $('ul2_' + id).style.display = 'none';
		}
		if($('ul3_' + id)!=null)
	    {
		    $('ul3_' + id).style.display = 'none';
		}
		if($('ul4_' + id)!=null)
	    {
		    $('ul4_' + id).style.display = 'none';
		}
	}
}


//全DIV卷提 动态效果  用于 CompareResults.aspx 页面
// 2009.11.18  重写
function collCompareAll(value) {
    ///<<<---Added By DongTai on 2009-12-03
    return;
    ///--->>>Added By DongTai on 2009-12-03
	if(value==1) 
	{
	    for(var id=1;id<=14;id++)
	    {
	    
	        $('ul_' + id).style.display = '';
	        $('img_' + id).src = 'images/jian_1.jpg';
            $('div_' + id).className="compare-results_con1_left1_con2 border1";
	        
		    if($('ul1_' + id)!=null)
	        {
		        $('ul1_' + id).style.display = '';
		    }
		    if($('ul2_' + id)!=null)
	        {
		        $('ul2_' + id).style.display = '';
		    }
		    if($('ul3_' + id)!=null)
	        {
		        $('ul3_' + id).style.display = '';
		    }
		    if($('ul4_' + id)!=null)
	        {
		        $('ul4_' + id).style.display = '';
		    } 
		    
		      if($('ul5_' + id)!=null)
	        {
		        $('ul5_' + id).style.display = '';
		    }
		    if($('ul6_' + id)!=null)
	        {
		        $('ul6_' + id).style.display = '';
		    }
		    if($('ul7_' + id)!=null)
	        {
		        $('ul7_' + id).style.display = '';
		    }
		    if($('ul8_' + id)!=null)
	        {
		        $('ul8_' + id).style.display = '';
		    }
		    
		     if($('ul9_' + id)!=null)
	        {
		        $('ul9_' + id).style.display = '';
		    }
		    if($('ul10_' + id)!=null)
	        {
		        $('ul10_' + id).style.display = '';
		    }
		    if($('ul11_' + id)!=null)
	        {
		        $('ul11_' + id).style.display = '';
		    }
		    if($('ul12_' + id)!=null)
	        {
		        $('ul12_' + id).style.display = '';
		    }
		    
		     if($('ul13_' + id)!=null)
	        {
		        $('ul13_' + id).style.display = '';
		    }
		    if($('ul14_' + id)!=null)
	        {
		        $('ul14_' + id).style.display = '';
		    }
	       
		}
	}
	else 
	{
	    for(var id=1;id<=14;id++)
	    {
		   $('ul_' + id).style.display = 'none';
	       $('img_' + id).src = 'images/jian_2.jpg';
	       $('div_' + id).className="compare-results_con1_left1_con2";
	       
	        if($('ul1_' + id)!=null)
	        {
		        $('ul1_' + id).style.display = 'none';
		    }
		    if($('ul2_' + id)!=null)
	        {
		        $('ul2_' + id).style.display = 'none';
		    }
		    if($('ul3_' + id)!=null)
	        {
		        $('ul3_' + id).style.display = 'none';
		    }
		    if($('ul4_' + id)!=null)
	        {
		        $('ul4_' + id).style.display = 'none';
		    }
		    
		     if($('ul5_' + id)!=null)
	        {
		        $('ul5_' + id).style.display = 'none';
		    }
		    if($('ul6_' + id)!=null)
	        {
		        $('ul6_' + id).style.display = 'none';
		    }
		    if($('ul7_' + id)!=null)
	        {
		        $('ul7_' + id).style.display = 'none';
		    }
		    if($('ul8_' + id)!=null)
	        {
		        $('ul8_' + id).style.display = 'none';
		    }
		    
		     if($('ul9_' + id)!=null)
	        {
		        $('ul9_' + id).style.display = 'none';
		    }
		    if($('ul10_' + id)!=null)
	        {
		        $('ul10_' + id).style.display = 'none';
		    }
		    if($('ul11_' + id)!=null)
	        {
		        $('ul11_' + id).style.display = 'none';
		    }
		    if($('ul12_' + id)!=null)
	        {
		        $('ul12_' + id).style.display = 'none';
		    }
		    
		     if($('ul13_' + id)!=null)
	        {
		        $('ul13_' + id).style.display = 'none';
		    }
		    if($('ul14_' + id)!=null)
	        {
		        $('ul14_' + id).style.display = 'none';
		    }
		}    
	}
}



