﻿function validate_required(field,alerttxt){
	with (field){
		if (value==null||value==""){
			alert(alerttxt);return false
		}
		else {return true}
	}
}

function validate_email(field,alerttxt){
	with (field){
		apos=value.indexOf("@")
		dotpos=value.lastIndexOf(".")
		if (apos<1||dotpos-apos<2){
			alert(alerttxt);return false}
		else {return true}
	}
}

function validate_form(thisform){
	with (thisform){
		// First Name
		if (validate_required(gname,"Please fill in all necessary information.")==false){
			gname.focus();return false}
		
		// Last Name
		if (validate_required(fname,"Please fill in all necessary information.")==false){
			fname.focus();return false}
		
		// Email address
		if (validate_required(email,"Please fill in all necessary information.")==false){
			email.focus();return false}
		if (validate_email(email,"Ticket email messages will be sent to you by mail, \nso please provide a correct e-mail address.")==false){
			email.focus();return false}
		
		if (thisform.os_version.value=="-none-"){
			os_version.focus();alert("Please select your OS and its version.");return false}
		
		if (thisform.product_edition.value=="-none-"){
			product_edition.focus();alert("Please select the product you install.");return false}
		
		// Product Version
		if (validate_required(product_version,"Please provide your product version.")==false){
			product_version.focus();return false}
			
		// Comments
		if (validate_required(comment,"Please describe the problems you encounter detailedly.")==false){
			comment.focus();return false}
	}
}

function ProductEdit(thisobj){
	var SltProduct = thisobj.value;
	if (SltProduct=="-SP-"){
		alert ("Please specify the product you install and its version in the Product Version field.\nThank you!");
		product_version.focus();
		return false;
	}
}