// JavaScript Document
<!--
if (window.Event) 
document.captureEvents(Event.MOUSEUP); 

function nocontextmenu() 
{
 event.cancelBubble = true
 event.returnValue = false;
 return false;
}
 
function norightclick(e) 
{
 if (window.Event) 
 {
  if (e.which == 2 || e.which == 3)
   return false;
 }
 else
  if (event.button == 2 || event.button == 3)
  {
   event.cancelBubble = true
   event.returnValue = false;
   return false;
  }
}
 
document.oncontextmenu = nocontextmenu;  // for IE5+
document.onmousedown = norightclick;  // for all others


function chkform()
{
var Caution;
var a=b=c=d=e=f=0;
Caution="Please complete the following files:";

if (document.form.O_Name.value==""){
Caution=Caution+"\n"+"- Name";
a=1;
}
if(document.form.Company.value==""){
Caution=Caution+"\n"+"- Company";
b=1;
}
if(document.form.Email.value==""){
Caution=Caution+"\n"+"- Email";
c=1;
}
if(document.form.Phone.value==""){
Caution=Caution+"\n"+"- Phone";
f=1;
}
if(document.form.Height.value==""&&document.form.Width.value==""){
Caution=Caution+"\n"+"- Height or Width";
e=1;
}

if (Caution!="Please complete the following files:"){
alert(Caution);
if (a==1){
document.form.O_Name.focus();
}else if(b==1){
document.form.Company.focus();
}else if(c==1){
document.form.Email.focus();
}else if(f==1){
document.form.Phone.focus();
}else if(e==1){
document.form.Width.focus();
}
return false;
}

var chkright="Please check the following files:";
var x=y=m=n=0;

//var rule=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
var rule=/^([a-z0-9A-Z-_.]*)@([a-z0-9A-Z\-]*\.[a-z0-9A-Z\-\.]*)$/i;
if (document.form.Email.value!="" && !rule.exec(document.form.Email.value)){
//alert("Incorrect email address, please recheck it.");
//document.form.Email.focus();
//return false;
m=1;
chkright=chkright+"\n- Incorrect email address, please recheck it.";
}

if(document.form.Phone.value!=""){
var i=document.form.Phone.value.length;
var j;
for (j=0;j<i;j++){
var strunit=document.form.Phone.value.substring(j,j+1);
//alert (strunit);
if(isNaN(strunit) && strunit!="-" && strunit!="(" && strunit!=")" && strunit!="_"){
//alert("Phone is incorrect,please check!");
//document.form.Phone.focus();
//return false;
n=1;
chkright=chkright+"\n- Phone is incorrect,please check!";
break;
}
}
}

var testNum=/^[0-9]*\s?[0-9]*\/?[0-9]*(\"?|\''?|in|inch|IN|Inch|INCH|In|mm|MM|Mm|mM)$/;        //正则表达式，判断是否为分数
if (document.form.Height.value!=""){
	if (!testNum.exec(document.form.Height.value) && isNaN(document.form.Height.value)){
//	if(isNaN(document.form.Design_Width.value)){
//	alert("Design Width accept number only,please check.");
//	document.form.Design_Width.focus();
//	return false;
x=1;
chkright=chkright+"\n- Design Height accept number only,please check.";
	}
	//}
	}
if (document.form.Width.value!=""){
	if(!testNum.exec(document.form.Width.value) && isNaN(document.form.Width.value)){
//	alert("Design Height accept number only,please check.");
//	document.form.Design_Height.focus();
//	return false;
y=1;
chkright=chkright+"\n- Design Width accept number only,please check.";
	}
	}


if(chkright!="Please check the following files:"){
alert(chkright);
	if(m==1){
	document.form.Email.focus();
	}else if(n==1){
	document.form.Phone.focus();
	}else if(x==1){
	document.form.Width.focus();
	}else if(y==1){
	document.form.Height.focus();
	}
	return false;
}
}

function chkform_writus()
{
var Caution;
var a=b=c=d=e=0;
Caution="Please complete the following files:";
if (document.form.name.value==""){
Caution=Caution+"\n"+"- Your Name";
a=1;
}
if(document.form.tel.value==""){
Caution=Caution+"\n"+"- Your Company Name";
b=1;
}
if(document.form.email.value==""){
Caution=Caution+"\n"+"- Your Email Address:";
c=1;
}
if(document.form.phone.value==""){
Caution=Caution+"\n"+"- Phone";
d=1;
}
if(document.form.address.value==""){
Caution=Caution+"\n- Message:";
e=1;
}

//验证邮箱
var rule=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
if (document.form.email.value!="" && !rule.exec(document.form.email.value)){
//alert("Incorrect email address, please recheck it.");
//document.form.email.focus();
//return false;
c=1;
Caution=Caution+"\n- Incorrect email address, please recheck it.";
}

//验证电话号码
if(document.form.phone.value!=""){
var i=document.form.phone.value.length;
var j;
for (j=0;j<i;j++){
var strunit=document.form.phone.value.substring(j,j+1);
//alert (strunit);
if(isNaN(strunit)&&strunit!="-"&&strunit!="("&&strunit!=")"){
//alert("Phone is incorrect,please check!");
//document.form.phone.focus();
//return false;
d=1;
Caution=Caution+"\n- Phone is incorrect,please check!";
break;
}
}
}


if (Caution!="Please complete the following files:" && Caution!="Please check the following files:"){
alert(Caution);
if (a==1){
document.form.name.focus();
}else if(b==1){
document.form.tel.focus();
}else if(c==1){
document.form.email.focus();
}else if(d==1){
document.form.phone.focus();
}else if(e==1){
document.form.address.focus();
}
return false;
}



}

//增加上传文件的控件
var i=1;
function add_att(){
//检查浏览器的类型，不同的浏览器设置不同的lineHeight
if (navigator.userAgent.indexOf("Firefox")>0){
document.getElementById("att_text").style.lineHeight="21px";
}

var att_div=document.getElementById("att");//获取file所在的层，也就是file的父层
var img=document.createElement("input");//新建一个file，以下为设置file的各种属性
img.type="file";
img.name="image";
img.id="img"+i;
att_div.appendChild(img);//添加这个file到所在的层里


add_att_text(i);
i++;
}

function add_att_text(num){
var att_text=document.getElementById("att_text").innerHTML;
att_text+="<br><a href='javascript:del_att("+num+");' id='text"+num+"'>Remove</a>";
document.getElementById("att_text").innerHTML=att_text;
}

function del_att(I){
var att_div=document.getElementById("att");
var a=document.getElementById("img"+I);
att_div.removeChild(a);
var strHtml=document.getElementById("att_text").innerHTML;
strHtml=strHtml.toLowerCase();
var i=strHtml.indexOf("text"+I);
var strHtmlB=strHtml.substring(0,i);
strHtmlB=strHtmlB.substring(0,strHtmlB.lastIndexOf("<br"));
//alert(strHtmlB);
//alert(strHtml);
var len=strHtml.length;
var strHtmlA=strHtml.substring(i+1,len);
//alert(strHtmlA);

if(strHtmlA.indexOf("<br")>0){
	strHtmlA=strHtmlA.substring(strHtmlA.indexOf("<br"),strHtmlA.length);
	}
else if(strHtmlA.indexOf("<br")<=0){
	strHtmlA="";
	}
	//alert(strHtmlA);
strHtml=strHtmlB+strHtmlA;
//alert(strHtml);
strHtml=strHtml.replace(/remove/g,"Remove");
strHtml=strHtml.replace(/add attachment/g,"Add Attachment");
//strHtml=strHtml.replace(/style24/g,"STYLE24");
//alert(strHtml);
document.getElementById("att_text").innerHTML=strHtml;
}