function body_load() {
  if(typeof parent.IsChild != "function")
    location.href = get_model_url();

  parent.adjust_iframe_right_height(document.body.scrollHeight);  
  timerID = setInterval("hide_loading()",500);
}

function CopyLink() {
  IE = (document.all && navigator.userAgent.indexOf("Opera") == -1);

  if (IE) {
    r = document.getElementById(arguments[0]).createTextRange();
    r.select();
    r.execCommand("copy"); 
    alert(document.getElementById("hld_shortcut_ok").value);
  }
}

function downloadfile() {
	IE       = (navigator.appName.toLowerCase() == "microsoft internet explorer");
	Netscape = (navigator.appName.toLowerCase() == "netscape");

	if (IE) {
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		xmlhttp.open("GET", "download_check_bandwidth.aspx?model=" + arguments[1] + "&f_pos=" + arguments[2], false);
		xmlhttp.send();	
	}
	else //For Non-IE browser
	{
		xmlhttp = new XMLHttpRequest();
		xmlhttp.open("GET", "download_check_bandwidth.aspx?model=" + arguments[1] + "&f_pos=" + arguments[2], false);
		xmlhttp.send(null);
		result = xmlhttp.responseText;
	}
	
	result = xmlhttp.responseText;
	if(result == "0"){ //asus traffic
	  counter_no = "2";
	  //將空白以"%20"取代
	  url ="";
		url = "http://" + document.getElementById("hld_AsusURL").value + "/pub/ASUS/" + arguments[2].replace(/ /, "%20");
	}
	else{
	  url ="";
	  if(Math.floor(Math.random()*101) < 50) //取亂數, 僅將1/2的流量導回ASUS
	  {
			counter_no = "1"; //cdn traffic
			url = "http://" + document.getElementById("hld_AkamaiURL").value + "/pub/ASUS/" + arguments[2].replace(/ /, "%20");
	  }		
		else
		{
			counter_no = "2"; //asus traffic
			url = "http://" + document.getElementById("hld_AsusURL").value + "/pub/ASUS/" + arguments[2].replace(/ /, "%20");
		}
	}

  dlcount(arguments[0], arguments[3], arguments[4], arguments[5], arguments[6], arguments[7], counter_no);  
	
  ext = JustExt(arguments[2]);
  ext = ext.toLowerCase();
  if (ext == "pdf") {
    arguments[0].target = "_blank";
		subwin = window.open(url,"","");
  }
  else {
		document.getElementById("ifr_download").src = url;
		if(IE)
			setTimeout("chk_url_exist()",1000);
		}  
}

function MemberLogin() {
	wx = 650;
	wy = 260;
	x = (screen.width  - wx) / 2;
	y = (screen.height - wy) / 2;
	url = 'http://vip.asus.com/forum/login.aspx?Slanguage='+document.getElementById("langNormal").value+'&f_type='+arguments[5]+'&product='+arguments[0]+'&model='+document.getElementById("hldModel").value+'&f_name='+escape(arguments[4]);
	subwin = window.open(url,"sub","toolbar=no, location=no, scrollbars=yes, left="+x+",top="+y+",width="+wx+",height="+wy);
}

function a_close_click() {
  document.all("tbl_bios_history").style.display = "none";
}
function a_close2_click() {
  document.all("tbl_bios_warnning").style.display = "none";
}

function show_bios_warnning(){
  parent.parent.show_bios_warnning();
}

function dlcount() {
	IE       = (navigator.appName.toLowerCase() == "microsoft internet explorer");
	Netscape = (navigator.appName.toLowerCase() == "netscape");
  
  strXML = "<?xml version='1.0'?>" + 
            "<root>" + 
              "<l1_id>" + arguments[1] + "</l1_id>" + 
              "<l2_id>" + arguments[2] + "</l2_id>" + 
              "<l3_id>" + arguments[3] + "</l3_id>" + 
              "<m_id>" + arguments[4] + "</m_id>" + 
              "<f_name>" + unescape(arguments[5]) + "</f_name>" + 
              "<dl_from>" + arguments[6] + "</dl_from>" + 
            "</root>";
              
  if (IE) {//for IE
    xmldoc = new ActiveXObject("Microsoft.XMLDOM");
    
    xmldoc.async = false;
    
              
    xmldoc.loadXML(strXML);
  
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    xmlhttp.open("POST","download_item_dlcount.aspx",true);
    xmlhttp.send(xmldoc);
    
    ext = JustExt(arguments[5]);
    ext = ext.toLowerCase();
    
    if (ext == "pdf") {
      arguments[0].target = "_blank";
    }
    else {
      arguments[0].target = "ifr_download";
      setTimeout("chk_url_exist()",1000);
    }
  }
  else {// Firefox, Opera 8.0+, Safari
		var xmlhttp=null;
		try
		{
			xmlhttp = new XMLHttpRequest();
		}
		catch (e)
		{
			try// Internet Explorer
 			{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e)
			{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
    
    xmlhttp.open("POST", "download_item_dlcount.aspx", false);
    xmlhttp.setRequestHeader("Content-Type", "text/xml");
    xmlhttp.send(strXML);    
  
    ext = JustExt(arguments[5]);
    ext = ext.toLowerCase();
  
    if (ext == "pdf")
      arguments[0].target = "_blank";
  }
}

function gethtml() {
  try {
    r_text = document.getElementById("ifr_download").Document.documentElement.innerHTML;
  }
  catch(e) {
    r_text = "null";
  }     
  
  if (r_text.indexOf("404") > 0 || r_text == "null") {
    alert(document.getElementById("hldTooManyUser").value);
    r_text = "";
    document.getElementById("ifr_download").src = "blank.htm";
  }
}

function chk_url_exist() {
  if (document.getElementById("ifr_download").readyState == "complete")
    gethtml();
  else
    setTimeout("chk_url_exist()",1000);
}

function get_model_url() {
  var s = location.href;
  var i = s.indexOf("download_item.aspx");
  s = s.substring(0,i);
  return s + "download.aspx?model=" + document.getElementById("msg_model").innerHTML + "&SLanguage=" + document.getElementById("langNormal").value;
}

function AddFavorite() {
  IE = (document.all && navigator.userAgent.indexOf("Opera") == -1);
  
  if (IE) {
    document.getElementById("copyArea").value = get_model_url();
    r = document.getElementById("copyArea").createTextRange();
    r.select();
    r.execCommand("copy"); 
    parent.window.scrollTo(0,0);
    alert(document.getElementById("hld_shortcut_ok").value);
  }
}

function AddShortcut() {
  IE = (document.all && navigator.userAgent.indexOf("Opera") == -1);
  
  if (IE)
    window.external.AddFavorite(get_model_url(),"ASUS Support--Download(" + document.getElementById("msg_model").innerHTML + ")");
}

function imgOK_Click() {
  var model   = document.getElementById("select2").value;
  var product = document.getElementById("hldProduct").value;    
  var langID  = document.getElementById("langNormal").value
  
  if (model == "0") {
    return;
  }
    
  document.getElementById("msg_model").innerText  = model;
  document.getElementById("msg_model2").innerText = model;
  
  var url = "download_item.aspx?product=" + product + 
                              "&model=" + model + 
                              "&SLanguage=" + langID;
  
  location.href = url;                              
}

function All_Click()
{
 parent.document.getElementById("ifr_user_right").src = "download_item.aspx?product="+document.getElementById("hldProduct").value+"&model="+document.getElementById("msg_model").innerHTML+"&type=All&Slanguage="+document.getElementById("langNormal").value; 
}

function Map_Click()
{
 parent.document.getElementById("ifr_user_right").src = "download_item.aspx?product="+document.getElementById("hldProduct").value+"&model="+document.getElementById("msg_model").innerHTML+"&type=Map&Slanguage="+document.getElementById("langNormal").value; 
}

function Submit_Click()
{
	alert("123");
}