/*-------- FUNCTION LIBRARY FOR WWW.DATACODES.NET -----------------------*/
function validEmail(email){
	if(email.indexOf("@") != -1)
	{
		mailSplit = email.split("@") 
		if (mailSplit[1].indexOf(".") != -1)
		{
			return true
		}		
	}
	return false 
}
//-------------------------------------------------
function admReqs(){
var vendor,version
	if(navigator.appName == "Netscape"){
		vendor = "Netscape";
		version = navigator.appVersion;	
	}else if(navigator.userAgent.indexOf("MSIE") != -1){
		vendor = "Internet Explorer";
		aryUserAgent = navigator.userAgent.split(";");
		version = aryUserAgent[1].substr(5,aryUserAgent[1].length);
	}
	return (vendor == "Internet Explorer" && version >= 5)
}
//-------------------------------------------------
function browserName(){
var vendor,version
	if(navigator.appName == "Netscape"){
		vendor = "Netscape";
		version = navigator.appVersion;	
	}else if(navigator.userAgent.indexOf("MSIE") != -1){
		vendor = "Internet Explorer";
		aryUserAgent = navigator.userAgent.split(";");
		version = aryUserAgent[1].substr(5,aryUserAgent[1].length);
	}
	return vendor + " " + version;
}
//---------------------------------------------
function popUp(url,h,w){
	props = "height=" + h + ",width=" + w;
	newWin = window.open(url,"winder1",props);
	newWin.focus();
}
//-----------------------------------------------
function answer(url){
	ansWin = window.open("faq/" + url,"winder2","width=600,height=400,scrollbars,resizable");
	ansWin.focus();
}
//------------------------------------------------
///////////////   FUNCTIONS FOR CONTACT FORM    ///////////////
function validateContact(form){
	strFix = '';
	index = 1;
	if(form.name.value.length <= 0){
		strFix = strFix + index + '. Name Required\n' ;
		index += 1;
	}
	if(form.title.value.length <= 0){
		strFix = strFix + index + '. Title Required\n' ;
		index += 1;
	}
	if(form.company.value.length <= 0){
		strFix = strFix + index + '. Company Required\n' ;
		index += 1;
	}
	if(form.address.value.length <= 0){
		strFix = strFix + index + '. Address Required\n' ;
		index += 1;
	}
	if(form.city.value.length <= 0){
		strFix = strFix + index + '. City Required\n' ;
		index += 1;
	}
	if(form.state.value.length <= 0){
		strFix = strFix + index + '. State Required\n' ;
		index += 1;
	}
	if(form.zip.value.length <= 0){
		strFix = strFix + index + '. Zip Required\n' ;
		index += 1;
	}
	if(form.phone.value.length <= 0){
		strFix = strFix + index + '. Phone Required\n' ;
		index += 1;
	}
	if(!validEmail(form.email.value)){
		strFix = strFix + index + '. Invalid Email Address\n' ;
		index += 1;
	}
	if(form.BusinessType.options.selectedIndex == 0){
		strFix = strFix + index + '. Select your Business Type\n' ;
		index += 1;
	}
	if(form.seeking.value.length <= 0){
		strFix = strFix + index + '. Tell us what solutions you are seeking.\n' ;
		index += 1;
	}
	if(strFix != ''){
		alert('The following errors occured: \n' + strFix);
	}else{
		form.submit();
	}
}
///////////////   FUNCTIONS FOR PROBLEMS FORM    ///////////////
function validateProbs(form){
	strFix = '';
	index = 1;
	if(form.product.options.selectedIndex == 0){
		strFix = strFix + index + '. Select a product\n' ;
		index += 1;
	}
	if(form.module.options.selectedIndex == 0){
		strFix = strFix + index + '. Select a module\n' ;
		index += 1;
	}
	if(form.description.value.length <= 0){
		strFix = strFix + index + '. Describe The Problem\n' ;
		index += 1;
	}
	if(form.reproduce.value.length <= 0){
		strFix = strFix + index + '. Tell us how to reproduce the problem\n' ;
		index += 1;
	}
	if(form.name.value.length <= 0){
		strFix = strFix + index + '. Name Required\n' ;
		index += 1;
	}
	if(!validEmail(form.email.value)){
		strFix = strFix + index + '. Invalid Email Address\n' ;
		index += 1;
	}
	if(form.phone.value.length <= 0){
		strFix = strFix + index + '. Phone Number Required\n' ;
		index += 1;
	}
	if(strFix != ''){
		alert('The following errors occured: \n' + strFix);
	}else{
		form.submit();
	}
}
///////////////   FUNCTIONS FOR SUGGESTION FORM    ///////////////
function validateSuggestion(form){
	strFix = '';
	index = 1;
	if(form.comment.value.length <= 0){
		strFix = strFix + index + '. No comments were entered\n' ;
		index += 1;
	}
	if(form.name.value.length <= 0){
		strFix = strFix + index + '. Name Required\n' ;
		index += 1;
	}
	if(!validEmail(form.email.value)){
		strFix = strFix + index + '. Invalid Email Address\n' ;
		index += 1;
	}
	if(form.phone.value.length <= 0){
		strFix = strFix + index + '. Phone Number Required\n' ;
		index += 1;
	}
	if(strFix != ''){
		alert('The following errors occured: \n' + strFix);
	}else{
		form.submit();
	}
}
///////////////   FUNCTIONS FOR SUPPORT APPLICATION    ///////////////

function validateSupportApp(form){
	strFix = '';
	index = 1;
	if(form.company.value.length <= 0){
		strFix = strFix + index + '. Company Name Required\n' ;
		index += 1;
	}
	if(form.clientNumber.value.length <= 0){
		strFix = strFix + index + '. Client Number Required\n' ;
		index += 1;
	}
	if(form.phone.value.length <= 0){
		strFix = strFix + index + '. Phone Number Required\n' ;
		index += 1;
	}
	if(!validEmail(form.email.value)){
		strFix = strFix + index + '. Invalid Email Address\n' ;
		index += 1;
	}
	if(strFix != ''){
		alert('The following errors occured: \n' + strFix);
	}else{
		form.submit();
	}
}
///////////////   FUNCTION TO CONFIRM DELETES    ///////////////
function confirmDelete(id)
{
	if(confirm("ARE YOU SURE YOU WANT TO DELETE THE ENTRY?"))
	{	
		document.forms[0].id.value = id;
		document.forms[0].method = 'POST';
		document.forms[0].submit();
	}
}
//------------------------------------------------
///////////////   FUNCTIONS FOR ECIConverter FORM    ///////////////
function validateECIConverter(form){
	strFix = '';
	index = 1;
	if(form.name.value.length <= 2){
		strFix = strFix + index + '. Name Required\n' ;
		index += 1;
	}
	if(form.title.value.length <= 1){
		strFix = strFix + index + '. Title Required\n' ;
		index += 1;
	}
	if(form.company.value.length <= 2){
		strFix = strFix + index + '. Company Required\n' ;
		index += 1;
	}
	if(form.address.value.length <= 0){
		strFix = strFix + index + '. Address Required\n' ;
		index += 1;
	}
	if(form.city.value.length <= 2){
		strFix = strFix + index + '. City Required\n' ;
		index += 1;
	}
	if(form.state.value.length <= 1){
		strFix = strFix + index + '. State Required\n' ;
		index += 1;
	}
	if(form.zip.value.length <= 4){
		strFix = strFix + index + '. Zip Required\n' ;
		index += 1;
	}
	if(form.phone.value.length <= 6){
		strFix = strFix + index + '. Phone Required\n' ;
		index += 1;
	}
	if(!validEmail(form.email.value)){
		strFix = strFix + index + '. Invalid Email Address\n' ;
		index += 1;
	}
	if(form.ServerOS.options.selectedIndex == 0){
		strFix = strFix + index + '. No Operating System specified\n' ;
		index += 1;
	}
	if(form.Timeframe.options.selectedIndex == 0){
		strFix = strFix + index + '. No Conversion Timeframe specified\n' ;
		index += 1;
	}
	if(form.HP4TestPath.value.length <= 0){
		strFix = strFix + index + '. No Test Path specified.\n' ;
		index += 1;
	}
	if(form.HP4TestPath.value == '\\\\server\\volume\\share\\HP4\\Test'){
		strFix = strFix + index + '. You did not specify YOUR Test Path.\n' ;
		index += 1;
	}
	if(form.HP4ProdPath.value.length <= 0){
		strFix = strFix + index + '. No Production Path specified.\n' ;
		index += 1;
	}
	if(form.HP4ProdPath.value == '\\\\server\\volume\\share\\HP4\\Prod'){
		strFix = strFix + index + '. You did not specify YOUR Prod Path.\n' ;
		index += 1;
	}
	if(strFix != ''){
		alert('The following errors occurred: \n' + strFix);
	}else{
		form.submit();
	}
}
//------------------------------------------------
///////////////   FUNCTIONS FOR DataCodes ORDERS FORM    ///////////////
function validateDCorder(form){
	strFix = '';
	index = 1;
	if(form.name.value.length <= 0){
		strFix = strFix + index + '. Name Required\n' ;
		index += 1;
	}
	if(form.title.value.length <= 0){
		strFix = strFix + index + '. Title Required\n' ;
		index += 1;
	}
	if(form.company.value.length <= 0){
		strFix = strFix + index + '. Company Required\n' ;
		index += 1;
	}
	if(form.address.value.length <= 0){
		strFix = strFix + index + '. Address Required\n' ;
		index += 1;
	}
	if(form.city.value.length <= 0){
		strFix = strFix + index + '. City Required\n' ;
		index += 1;
	}
	if(form.state.value.length <= 0){
		strFix = strFix + index + '. State Required\n' ;
		index += 1;
	}
	if(form.zip.value.length <= 0){
		strFix = strFix + index + '. Zip Required\n' ;
		index += 1;
	}
	if(form.phone.value.length <= 0){
		strFix = strFix + index + '. Phone Required\n' ;
		index += 1;
	}
	if(!validEmail(form.email.value)){
		strFix = strFix + index + '. Invalid Email Address\n' ;
		index += 1;
	}
	if(form.musers.value.length <= 0){
		strFix = strFix + index + '. Number of Medical Users is Required\n' ;
		index += 1;
	}
	if(form.dusers.value.length <= 0){
		strFix = strFix + index + '. Number of Dental Users is Required\n' ;
		index += 1;
	}
	if(strFix != ''){
		alert('The following errors occured: \n' + strFix);
	}else{
		form.submit();
	}
}
