function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function Show(locationid)
    {
	if(locationid==01)
	{	  //document.getElementById ("noneed0").style.display="none";
		    document.getElementById ("noneed1").style.display="none";
		   document.getElementById ("noneed2").style.display="none";
			document.getElementById ("noneed3").style.display="none";
			document.getElementById ("noneed4").style.display="none";
 document.FrontPage_Form1.UIS_SN.value="0000000000";
 document.FrontPage_Form1.UIS_MAC.value="000000000000";
 document.FrontPage_Form1.UIS_Firmware.value="000000";}
	else if(locationid==02)
	{//document.getElementById ("noneed0").style.display='';
		    document.getElementById ("noneed1").style.display='';
		    document.getElementById ("noneed2").style.display='';
			document.getElementById ("noneed3").style.display='';
			document.getElementById ("noneed4").style.display='';
 document.FrontPage_Form1.UIS_SN.value="";
 document.FrontPage_Form1.UIS_MAC.value="";
 document.FrontPage_Form1.UIS_Firmware.value="";	}
	
	var onecount;
onecount=0;
    
subcat = new Array();
subcat[0] = new Array("I Want to Buy MSNswitch Product","01","I Want to Buy MSNswitch Product");
subcat[1] = new Array("Tell Me More","01","Tell Me More");
subcat[2] = new Array("Wish List","01","Wish List");
subcat[3] = new Array("MSNSwitch Question","02","MSNSwitch Question");
//subcat[4] = new Array("iCAMView 3G Question","02","iCAMView 3G Question");

onecount=4;
    document.FrontPage_Form1.Subject.length = 0;

    var locationid=locationid;
    var i;
    document.FrontPage_Form1.Subject.options[0] = new Option('--= Select your email Subject =--','');
    for (i=0;i < onecount; i++)
        {
            if (subcat[i][1] == locationid)
            { 
            document.FrontPage_Form1.Subject.options[document.FrontPage_Form1.Subject.length] = new Option(subcat[i][0], subcat[i][2]);
            }        
        }
        
    }
	
var code;
function creatcod()
{
code="";
var temp;
var sum_num = [];
for(i=0;i<=5;i++)
{
temp =Math.random()*10;
sum_num[i] = Math.floor(temp);
code += sum_num[i];
}
var str='<img src="images/'+sum_num[0]+'.jpg" height="21" align=absmiddle><img src="images/'+sum_num[1]+'.jpg" height="21" align=absmiddle><img src="images/'+sum_num[2]+'.jpg" height="21" align=absmiddle><img src="images/'+sum_num[3]+'.jpg" height="21" align=absmiddle><img src="images/'+sum_num[4]+'.jpg" height="21" align=absmiddle><img src="images/'+sum_num[5]+'.jpg" height="21" align=absmiddle>';
document.getElementById ("right_number").innerHTML=str;
}	
	  
function checkform()
{
  if (document.sform.Subject1.value =="" && document.sform.Subject1.value.length < 1)
  {
    alert("Please choose what your email about.");
    document.sform.Subject1.focus();
    return false;
  }
  
 else if (document.sform.code.value == "")
  { 
    alert("please input a code.")
	creatcod();
	document.sform.code.focus();
	return false;
  }
  else if (document.sform.code.value != code)
  {
    alert("Please input a correct code.")
	creatcod();
	document.sform.code.focus();
	return false;
  } 
  
  else if (document.FrontPage_Form1.Name.value == "" && document.FrontPage_Form1.Name.value.length < 1)
  {
    alert("Please enter your name.");
    document.FrontPage_Form1.Name.focus();
    return false;
  }
 
  else if(!/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(document.FrontPage_Form1.eMail.value)) 
{ 
alert("Please enter a correct Email."); 
document.FrontPage_Form1.eMail.focus(); 
return false; 
}
  else if (document.FrontPage_Form1.Subject.value =="" && document.FrontPage_Form1.Subject.value.length < 1)
  {
    alert("Please choose your email subject.");
    document.FrontPage_Form1.Subject.focus();
    return false;
  }
  else if (document.FrontPage_Form1.Message.value == "" && document.FrontPage_Form1.Message.value.length < 1)
  {
    alert("Please enter your message.");
    document.FrontPage_Form1.Message.focus();
    return false;
  }
  else if (document.FrontPage_Form1.Subject.value=="MSNSwitch Question") 
  { 
 if (document.FrontPage_Form1.UIS_SN.value.length=="")
  {
    alert("Please enter a value for the \"MSNSwitch Serial Number\" field.");
	document.FrontPage_Form1.UIS_SN.focus();
	return false;
  }
  if (document.FrontPage_Form1.UIS_SN.value.length < 10)
  {
    alert("Please enter at least 10 characters in the \"MSNSwitch Serial Number\" field.");
    document.FrontPage_Form1.UIS_SN.focus();
    return false;
  }
  if (document.FrontPage_Form1.UIS_SN.value.length > 10)
  {
    alert("Please enter at most 10 characters in the \"MSNSwitch Serial Number\" field.");
    document.FrontPage_Form1.UIS_SN.focus();
    return false;
  }

  var checkOK = "0123456789-.,";
  var checkStr = document.FrontPage_Form1.UIS_SN.value;
  var allValid = true;
  var validGroups = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch == ".")
    {
      allNum += ".";
      decPoints++;
    }
    else if (ch == "," && decPoints != 0)
    {
      validGroups = false;
      break;
    }
    else if (ch != ",")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"MSNSwitch Serial Number\" field.");
    document.FrontPage_Form1.UIS_SN.focus();
    return false;
  }

  if (decPoints > 1 || !validGroups)
  {
    alert("Please enter a valid number in the \"UIS_SN\" field.");
    document.FrontPage_Form1.UIS_SN.focus();
    return false;
  }

  if (document.FrontPage_Form1.UIS_MAC.value == "")
  {
    alert("Please enter a value for the \"MSNSwitch MAC Address\" field.");
    document.FrontPage_Form1.UIS_MAC.focus();
    return false;
  }

  if (document.FrontPage_Form1.UIS_MAC.value.length < 12)
  {
    alert("Please enter at least 12 characters in the \"MSNSwitch MAC Address\" field.");
    document.FrontPage_Form1.UIS_MAC.focus();
    return false;
  }

  if (document.FrontPage_Form1.UIS_MAC.value.length > 12)
  {
    alert("Please enter at most 12 characters in the \"MSNSwitch MAC Address\" field.");
    document.FrontPage_Form1.UIS_MAC.focus();
    return false;
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-";
  var checkStr = document.FrontPage_Form1.UIS_MAC.value;
  var allValid = true;
  var validGroups = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letter and digit characters in the \"MSNSwitch MAC Address\" field.");
    document.FrontPage_Form1.UIS_MAC.focus();
    return false;
  }

 
  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-.";
  var checkStr = document.FrontPage_Form1.UIS_Firmware.value;
  var allValid = true;
  var validGroups = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letter, digit and \".\" characters in the \"UIS_Firmware\" field.");
    document.FrontPage_Form1.UIS_Firmware.focus();
    return false;
  }
  if (document.FrontPage_Form1.UIS_Firmware.value == "")
  {
    alert("Please enter a value for the \"MSNSwitch Firmware\" field.");
    document.FrontPage_Form1.UIS_Firmware.focus();
    return false;
  }
} 

else { return true;}
}
