function getBrandList() {
  DownloadService.getBrandList(loadBrandList);
}

function closediv()
{
 	$("brandselect").disabled="";
    $("mobileType").disabled="";
    $("win1").style.display="none";
     

}
function loadBrandList(data) {
  dwr.util.addOptions("brand", data);
}

function getMobileTypeList(brand) {
  
	DownloadService.getTerminalByBrand(brand,loadMobileTypeList);
}
function getDownloadFile() {
  var id=$('mobileType').value;
  if(id!=0){
  		DownloadService.getTerminalById(id, loadDownloadfile1);
	}else{
		//$('brandselecttr').style.display="none";
		$('phoneimage').src ="/images/6260.jpg";
	}
}


function loadMobileTypeList1(data) {
	if(data==null||data.length==0){
		alert("No information on this type!");
	
		return;
	}
 
	for(var i=0;i<data.length;i++){
	 
	 	$('phoneimage').src =data[i].image;
	}
	
}

function loadDownloadfile(data){
	if(data){
		//$('choose_way').style.display="block";
		$('downloadPath').href="http://115.182.33.88:9999/mobile4/"+data.pcfile;
		$('downloadPath').setAttribute("onclick","downloadCount('"+data.platform+"');");
	}
}
function loadDownloadfile1(data){
	if(data){
			$('downloadPath1').href="/mobile/"+data.pcfile;
			DownloadService.getDownloadFileById(data.dfid, loadDownloadPath);
			$('phoneimage').src = data.image;
	}	
}
function loadDownloadPath(data){
	if(data){
			$('downloadPath1').href="http://115.182.33.88:9999/mobile4/"+data.pcfile;
	}
}
function loadDownloadfilePlatformSelect(){
		var pcfile = $('platformselect').value;
		if(pcfile!=0){
			$('downloadPath').href="http://115.182.33.88:9999/mobile4/"+pcfile;
			//$('platformselecttr').style.display="block";
		}else{
			//$('platformselecttr').style.display="none";
		
			
		}
}
//模糊查询
function dimserch(){
	var dimvalue=$('dimvalue').value;
	
	if(dimvalue!="enter the type of mobile phone "){
		DownloadService.getDimTerminal(dimvalue,loadMobileTypeList1);
	}else{
		alert("Enter keyword ");
	}
}
//提交未知终端


function mobileChoose(img,terminaltype,id)
{
	$('terminaltype').innerHTML=terminaltype;
	$('downloadImg').src=img;
	DownloadService.getDownloadFileById(id,loadDownloadfile);
}

function DownloadByImage(data)
{
   if(data){
			window.location.href='http://www.shangmail.com/mobile4/'+data.pcfile;
	}
}

var move=false; 
function StartDrag(obj) 
{
if(event.button==1&&event.srcElement.tagName.toUpperCase()=="DIV")
{
obj.setCapture();

move=true;
} 
}

function Drag(obj) 
{

if(move)
{
var oldwin=obj.parentNode;
oldwin.style.left=event.clientX-85;
oldwin.style.top=event.clientY-20;
}

}

function StopDrag(obj)
{

obj.releaseCapture();
move=false;
} 

function getMobileTypeList() {
	var brand = $('brandselect').value;
	
	if(brand != 0){
		
		UserAction.getTerminalByBrand(brand, loadMobileTypeList);
		$('phoneimage').src ="/images/6260.jpg";
	}else{
		$('phoneimage').src ="/images/6260.jpg";	
		
	}
}


function loadMobileTypeList(data) {
  dwr.util.removeAllOptions("mobileType");
  
  dwr.util.addOptions("mobileType",[{name:"Please choose phone model", value:0 }],'value','name');
  
// var mobileHTML =" <div id='uboxstyle2' ><select name='mobileType' id='mobileType' onchange='getDownloadFile()'><option value='0'>请选择</option>";
	for(var i=0;i<data.length;i++){
 	var type=data[i].mobiletype;
  	var id=data[i].id;
  //	mobileHTML+="<option value='"+id+"'>"+type+"</option>";*/
			   
    dwr.util.addOptions("mobileType",[{name:type, value:id }],'value','name');
  }
  //	mobileHTML+="</select></div>";
	//$("uboxstyle3").innerHTML=mobileHTML;
	//  alert("aa");
   /*bodyclick = document.getElementsByTagName('body').item(0);
	rSelects('mobileType');
	bodyclick.onclick = function(){
		for (i=0;i<selects.length;i++){	
			$('select_info_' + selects[i].name).className = 'tag_select';
		$('options_' + selects[i].name).style.display = 'none';
		}
	}*/
	
}


function showMobile()
{    
 	
    $("win1").style.display="block";
    
    var dimvalue=$('dimvalue').value;
	

   if(dimvalue!="enter the type of mobile phone "){
            UserAction.getDimTerminal(dimvalue,{callback:function(data){
            
            if(data==null||data.length==0){
		    alert("No information on this type!");
	
		     return;
	      }
 
            var j=0;
            var mobileHTML="";
            mobileHTML+="<table width='100%' cellpadding='0' cellspacing='0'>";
            mobileHTML+="<tr>";
			for(var i=0;i<data.length;i++)
			{
			   j++;
			   var type="\""+data[i].mobiletype+"\"";
			   var img="\""+data[i].image+"\"";
			   var id="\""+data[i].id+"\"";
			    var dfid="\""+data[i].dfid+"\"";
			  // var pcfile="\""+data[i].pcfile+"\"";
			    mobileHTML+="<td   align=left width=40><table cellpadding=0 cellspacing=0 width=100% height=100><tr><td   align=left><a href='javascript:mobileChoose("+dfid+");'><img width='60' height='95' border='0' src="+data[i].image+"></a></td></tr><tr><td >&nbsp;&nbsp;"+data[i].mobiletype+"</td></tr></table></td>";
			   if(j%4==0)
			   {
			     mobileHTML+="</tr><tr>";
			   }
			  
			}
			if(j%4!=0)
			{
			    for(var x=0;x<4-j%4;x++)
			    {
			       mobileHTML+="<td>&nbsp;</td>";
			    }
			    mobileHTML+="</tr>";
			}
			
			mobileHTML+="</table>";
			$("mt").innerHTML=mobileHTML;
			}});
   
}else{
		alert("Enter keyword ");
	}
}
function mobileChoose(dfid)
{
  DownloadService.getDownloadFileById(dfid, DownloadByImage);
}

function DownloadByImage(data)
{
  if(data){
			window.location.href='http://192.168.0.99:8029/mobile4/'+data.pcfile;
	}
}
