//二级连动方式处理

/**
 *从数据源中绑定厂商列表数据
 */
function bindVendorData(vendorIndex){
    document.getElementById('vendor').innerHTML='';
	for(i in arr){
		vendorName = arr[i][1];
		document.getElementById('vendor').options[document.getElementById('vendor').length] = new Option(vendorName,i);
	}
    document.getElementById('vendor').options[vendorIndex].selected=true;
	bindModelData(vendorIndex);
	document.getElementById("model").style.display="";
	document.getElementById("mb_brand").style.display="none";
	$("#stepShow").addClass("stepShow s2");
	//document.getElementById("stepShow").setAttribute("class","stepShow s2");
	
}
function bindVendorData2(){
    document.getElementById('mb_brand').innerHTML='';
	for(i in arr){
	    vendorClass= arr[i][0];
		vendorName = arr[i][1];
		vhref="javascript:bindVendorData("+i+")";
		if(vendorName=='iPhone')
	       vhref="javascript:Select_mobile_window.openIphoneLayer();";
        var li = document.createElement("LI"); 
		//li.setAttribute("onclick",vhref);
		var li_a =document.createElement("A");
		li_a.setAttribute("class",vendorClass);
	    li_a.setAttribute("href",vhref);
	    li_a.innerText=vendorName;
		li.appendChild(li_a);
		document.getElementById("mb_brand").appendChild(li);
	}
}

/**
 * 从数据源中,选择指定的厂商的机型,并与机型列表框进行绑定
 * vendorIndex为下厂商下拉列表的顺序号
 */
function bindModelData(vendorIndex){
        document.getElementById('mb_model').innerHTML='';
		vendorEnName = arr[vendorIndex][0]; //厂商id
		for(i in arr){
			if(i != vendorIndex) continue;
			for(j in arr[i][2]){
				mName = arr[i][2][j][1];
				pkgId = arr[i][2][j][2];
		        var hrefUrl = arrPKG[pkgId][0];
		        vhref="javascript:select_mobile_window.downloadFile('"+hrefUrl+"');";
				var li = document.createElement("LI"); 
				var li_a =document.createElement("A");
				li_a.setAttribute("href",vhref); 
				li_a.innerText=mName;
				li.appendChild(li_a);
			//    li.setAttribute("onclick",vhref);
		//	    li.innerText=mName;
				document.getElementById('mb_model').appendChild(li);
			}
		}
}
function   isIE(){ 
      if   (window.navigator.userAgent.toString().toLowerCase().indexOf("msie") >=1)
        return   true;
      else
        return   false;
}

if(!isIE()){   //firefox   innerText   define
      HTMLElement.prototype.__defineGetter__(           "innerText",
        function(){
          var   anyString   =   "";
          var   childS   =   this.childNodes;
          for(var   i=0;   i <childS.length;   i++)   {
            if(childS[i].nodeType==1)
              anyString   +=   childS[i].tagName=="BR"   ?   '\n'   :   childS[i].innerText;
            else   if(childS[i].nodeType==3)
              anyString   +=   childS[i].nodeValue;
          }
          return   anyString;
        }
      );
      HTMLElement.prototype.__defineSetter__("innerText",
        function(sText){
          this.textContent=sText;
        }
      ); 
} 

