<!--

//function returns true is subject or comments is invalid, false if valid
function ValidChar(item)
{
var i;
if (item.length<1)
	{
	return false
	}
for (i=0; i<item.length; i++)
	{
	if (item.charAt(i)!=' ')
		return true;
	}
return false
}

function HaveChar(item)
{
var i;
if (item.length<1)
	{
	return false
	}
if (item.length>0)
	{
	return true
	}
}



//function for changing status line if subject is incorrect
function VChar(item)
{
var i;
if (item.length<1)
	{
	window.status="Required Field Invalid: AREA OF INTEREST."
	return false
	}
for (i=0; i<item.length; i++)
	{
	if (item.charAt(i)!=' ')
		{
		window.status=""
		return true
		}
	}
		
window.status="Required Field Invalid: AREA OF INTEREST."
return false	
}


//function for changing status line if comments is incorrect
function VChar2(item)
{
var i;
if (item.length<1)
	{
	window.status="Please DESCRIBE YOUR ENQUIRY."
	return false
	}
for (i=0; i<item.length; i++)
	{
	if (item.charAt(i)!=' ')
		{
		window.status=""
		return true
		}
	}
window.status="Please DESCRIBE YOUR ENQUIRY."
return false	
}

function VChar3(item)
{
var i;
if (item.length<1)
	{
	window.status="you must type: YES"
	return false
	}
for (i=0; i<item.length; i++)
	{
	if (item.charAt(i)!=' ')
		{
		window.status=""
		return true
		}
	}
		
window.status="You only entered spaces for the YES field."
return false	
}


//function for changing status line if email is incorrect
function VEmail(item)
{
if (item.length<7 || 
	item.indexOf("@")==-1 || 
	item.indexOf(".") == -1 ||
	item.indexOf(" ") != -1)
	{
	window.status="Required Field Invalid: EMAIL ADDRESS."
	return true
	}
window.status=""
return false
}

//function for validating phone number
function VName(item)
{
isInteger = /\D/;
if (item.length<8 || isInteger.test(item)!=1)
	{
	window.status="Required Field Invalid: FULL NAME."
	return true;
	}
return false;
}

//function for validating phone number
function VPhone(item)
{
isInteger = /\D/;
if (item.length >= 1)
{item = item.replace(/ /g, "");}
if (item.length >= 1)
{item = item.replace(/\(/g, "");}
if (item.length >= 1)
{item = item.replace(/\)/g, "");}
if (item.length >= 1)
{item = item.replace(/\-/g, "");}

if (item.length<8 || isInteger.test(item)!=0)
	{
	return true;
	window.status="Required Field Invalid: PHONE NUMBER."
	}
return false;
}

//function returns true is email is invalid, false if valid
function ValidEmail(item)
{
if (item.length<7 || item.indexOf("@")==-1 || item.indexOf(".") == -1 ||item.indexOf(" ") != -1)
	{return true}
return false
}

function AddError(fullErr, errorStr)
{
if (fullErr.length == 0)
	{
	fullErr = "The following Required Fields have not been filled out properly :";
	}
fullErr = fullErr + "\n" + errorStr;
return fullErr;
}

function ValidateEnquiryForm() 
{
//alert("test1")
var AllErrors = ""
var e=0
var s=0
var p=0
var n=0
var b=0
if (ValidEmail(document.CustSrvc.from.value))
	{e++}
if (document.CustSrvc.Subject.selectedIndex==0) 
	{s++}
if (VPhone(document.CustSrvc.Phone.value))
	{p++}
if (VName(document.CustSrvc.FullName.value))
	{n++}
if (!VChar2(document.CustSrvc.body.value))
	{b++}
	
if (n!=0)
	{AllErrors = AddError(AllErrors, " - Please enter your FULL NAME.");}
if (p!=0)
	{AllErrors = AddError(AllErrors, " - Please enter a valid PHONE NUMBER.");}
if (e!=0)
	{AllErrors = AddError(AllErrors, " - Please enter a valid EMAIL ADDRESS.");}
if (s!=0)
	{AllErrors = AddError(AllErrors, " - Please select an AREA OF INTEREST.");}
if (b!=0)
	{AllErrors = AddError(AllErrors, " - Please DESCRIBE YOUR ENQUIRY.");}
if (AllErrors.length == 0)
	{return true;}
else
	{alert(AllErrors);
	return false;}
}

function AddErrorArabic(fullErr, errorStr)
{
if (fullErr.length == 0)
	{
	fullErr = "الحقول المطلوبة التالية ليست كاملة :";
	}
fullErr = fullErr + "\n" + errorStr;
return fullErr;
}


function ValidateEnquiryFormArabic() 
{
//alert("test1")
var AllErrors = ""
var e=0
var s=0
var p=0
var n=0
var b=0
if (ValidEmail(document.CustSrvc.from.value))
	{e++}
if (document.CustSrvc.Subject.selectedIndex==0) 
	{s++}
if (VPhone(document.CustSrvc.Phone.value))
	{p++}
if (VName(document.CustSrvc.FullName.value))
	{n++}
if (!VChar2(document.CustSrvc.body.value))
	{b++}
	
if (n!=0)
	{AllErrors = AddErrorArabic(AllErrors, " - الرجاء إدخال اسمكم الكامل.");}
if (p!=0)
	{AllErrors = AddErrorArabic(AllErrors, " - الرجاء إدخال رقم الهاتف.");}
if (e!=0)
	{AllErrors = AddErrorArabic(AllErrors, " - الرجاء إدخال عنوان بريدكم الإلكتروني.");}
if (s!=0)
	{AllErrors = AddErrorArabic(AllErrors, " - يرجى اختيار موضوع اهتمامكم.");}
if (b!=0)
	{AllErrors = AddErrorArabic(AllErrors, " - الرجاء وصف استفساركم.");}
if (AllErrors.length == 0)
	{return true;}
else
	{alert(AllErrors);
	return false;}
}


function SetDropDownSubject()
{
Instrxs();
GetEmailSubject();
}

function GetEmailSubject()
{
prev = document.referrer;

if (prev.indexOf("/training-dubai/") != -1 || prev.indexOf("/training-courses/") != -1 || prev.indexOf("/header-frame") != -1)
	{
	document.CustSrvc.Subject.selectedIndex = 1;
	}
if (prev.indexOf("/classroom-training-lab-rental") != -1 || prev.indexOf("/a-classroom-training-lab-rental") != -1)
	{
	document.CustSrvc.Subject.selectedIndex = 2;
	}
if (prev.indexOf("/assessment/") != -1)
	{
	document.CustSrvc.Subject.selectedIndex = 3;
	}
if (prev.indexOf("/certification-testing") != -1 || prev.indexOf("/a-certification-testing") != -1)
	{
	document.CustSrvc.Subject.selectedIndex = 4;
	}

//alert(prev);
}

-->
