function pop_err(fieldname,err_msg)
{
	fieldname.focus();
	alert(err_msg);
}
function isemailaddress(str_email){
	var re = /^[0-9a-z-A-Z-_~=:,|\/\\\'\"]+(\.[0-9a-z-A-Z-_~=:,|\/\\\'\"]+)*@[0-9a-z-A-Z-_~=:,|\/\\\'\"]+(\.[0-9a-z-A-Z-_~=:,|\/\\\'\"]+)+(\.[0-9a-z-A-Z-_~=:,|\/\\\'\"]+)*$/;
	var pos = str_email.search(re);
	if(pos == -1){
		return false;
	}else{
		return true;
	}
}
function isnumeric(num){
	var re = /^[0-9]*$/;
	var pos = num.search(re);
	if(pos == -1){
		return false;
	}else{
		return true;
	}
}

function trim(st)
{
	index = 0;
	for (var i = 0; i < st.length; i++)
	{
		ch = st.charAt(i);
		if (ch == ' ')
			index++;
		else 
			break;
	}
	st = st.substring(index, st.length);
	index = st.length;
	for (i = index-1; i > 0; i--)
	{
		ch = st.charAt(i);
		if (ch==' ')
			index--;
		else
			break;
	}
	st = st.substring(0, index);
	return st;
}

function docontactus()
{
	var doc = document.frm;
	if(doc.txtname.value == "")
	{
		pop_err(doc.txtname,"Please input your name")
		return false;	
	}
	szemail = doc.txtemail.value
	if(szemail == ""){
		pop_err(doc.txtemail,"Please input E-mail address!")
		return false;
	}else{ 
		if(!isemailaddress(szemail)){
			pop_err(doc.txtemail,"E-mail address is invalid! Please input again!")
			return false;
		}
	}
	if(doc.txtphone.value == "")
	{
		pop_err(doc.txtphone,"Please input your phone number")
		return false;	
	}
	if(doc.txtaddress1.value == "")
	{
		pop_err(doc.txtaddress1,"Please input your address")
		return false;	
	}
	if(doc.txtcity.value == "")
	{
		pop_err(doc.txtcity,"Please input your city")
		return false;	
	}
	if(doc.txtzipcode.value == "")
	{
		pop_err(doc.txtzipcode,"Please input zip code")
		return false;	
	}
	if(!isnumeric(doc.txtzipcode.value))
	{
		pop_err(doc.txtzipcode,"Zip code is invalid! Please input again!")
		return false;
	}
	var szhour = doc.txthourse.value
	if(!isnumeric(szhour))
	{
		pop_err(doc.txthourse,"Hour is invalid! Please input again!")
		return false;
	}
	var szminute = doc.txtminute.value
	if(!isnumeric(szminute))
	{
		pop_err(doc.txtminute,"Minute is invalid! Please input again!")
		return false;
	}
	doc.submit()
	return;	
}
function dosendphysicians()
{
	var doc = document.frm;
	if(doc.txtname.value == "")
	{
		pop_err(doc.txtname,"Please input your name")
		return false;	
	}		
	if(doc.txtaddress1.value == "")
	{
		pop_err(doc.txtaddress1,"Please input your address")
		return false;	
	}
	if(doc.txtcity.value == "")
	{
		pop_err(doc.txtcity,"Please input your city")
		return false;	
	}	
	if(doc.txtzipcode.value == "")
	{
		pop_err(doc.txtzipcode,"Please input zip code")
		return false;	
	}
	if(!isnumeric(doc.txtzipcode.value))
	{
		pop_err(doc.txtzipcode,"Zip code is invalid! Please input again!")
		return false;
	}
	if(doc.txtphone.value == "")
	{
		pop_err(doc.txtphone,"Please input your phone number")
		return false;	
	}
	var szhour = doc.txthourse.value
	if(!isnumeric(szhour))
	{
		pop_err(doc.txthourse,"Hour is invalid! Please input again!")
		return false;
	}
	var szminute = doc.txtminute.value
	if(!isnumeric(szminute))
	{
		pop_err(doc.txtminute,"Minute is invalid! Please input again!")
		return false;
	}
	szemail = doc.txtemail.value
	if(szemail == ""){
		pop_err(doc.txtemail,"Please input E-mail address!")
		return false;
	}else{ 
		if(!isemailaddress(szemail)){
			pop_err(doc.txtemail,"E-mail address is invalid! Please input again!")
			return false;
		}
	}
	
	for(var i=0; i<doc.length;i++){
		if(doc.elements[i].type=="file"){
			if(doc.elements[i].value != ""){
				szfile = doc.elements[i].value;	
				var szlen = szfile.length;
				var szfirstlen = szlen - 3;
				var strend = trim(szfile.substr(szfirstlen,szlen));
				if(strend.toLowerCase() != 'doc' && strend.toLowerCase() != 'pdf'){
					pop_err(doc.elements[i],"File upload is invalid. Please upload doc or pdf!");
					return false;
				}
			}
		}
	}
	doc.submit()
	return;	
}
function dosendmedical()
{
	var doc = document.frm;
	if(doc.txtsubject.value == "")
	{
		pop_err(doc.txtsubject,"Please input your subject")
		return false;	
	}
	if(doc.txtname.value == "")
	{
		pop_err(doc.txtname,"Please input your name")
		return false;	
	}		
	if(doc.txtaddress1.value == "")
	{
		pop_err(doc.txtaddress1,"Please input your address")
		return false;	
	}
	if(doc.txtcity.value == "")
	{
		pop_err(doc.txtcity,"Please input your city")
		return false;	
	}	
	if(doc.txtzipcode.value == "")
	{
		pop_err(doc.txtzipcode,"Please input zip code")
		return false;	
	}
	if(!isnumeric(doc.txtzipcode.value))
	{
		pop_err(doc.txtzipcode,"Zip code is invalid! Please input again!")
		return false;
	}
	if(doc.txtphone.value == "")
	{
		pop_err(doc.txtphone,"Please input your phone number")
		return false;	
	}
	var szhour = doc.txthourse.value
	if(!isnumeric(szhour))
	{
		pop_err(doc.txthourse,"Hour is invalid! Please input again!")
		return false;
	}
	var szminute = doc.txtminute.value
	if(!isnumeric(szminute))
	{
		pop_err(doc.txtminute,"Minute is invalid! Please input again!")
		return false;
	}
	szemail = doc.txtemail.value
	if(szemail == ""){
		pop_err(doc.txtemail,"Please input E-mail address!")
		return false;
	}else{ 
		if(!isemailaddress(szemail)){
			pop_err(doc.txtemail,"E-mail address is invalid! Please input again!")
			return false;
		}
	}
	for(var i=0; i<doc.length;i++){
		if(doc.elements[i].type=="file"){
			if(doc.elements[i].value != ""){
				szfile = doc.elements[i].value;	
				var szlen = szfile.length;
				var szfirstlen = szlen - 3;
				var strend = trim(szfile.substr(szfirstlen,szlen));
				if(strend.toLowerCase() != 'doc' && strend.toLowerCase() != 'pdf'){
					pop_err(doc.elements[i],"File upload is invalid. Please upload doc or pdf!");
					return false;
				}
			}
		}
	}
	doc.submit()
	return;	
}
function dosendadministrative()
{
	var doc = document.frm;
	if(doc.txtsubject.value == "")
	{
		pop_err(doc.txtsubject,"Please input your subject")
		return false;	
	}
	if(doc.txtname.value == "")
	{
		pop_err(doc.txtname,"Please input your name")
		return false;	
	}		
	if(doc.txtaddress1.value == "")
	{
		pop_err(doc.txtaddress1,"Please input your address")
		return false;	
	}
	if(doc.txtcity.value == "")
	{
		pop_err(doc.txtcity,"Please input your city")
		return false;	
	}	
	if(doc.txtzipcode.value == "")
	{
		pop_err(doc.txtzipcode,"Please input zip code")
		return false;	
	}
	if(!isnumeric(doc.txtzipcode.value))
	{
		pop_err(doc.txtzipcode,"Zip code is invalid! Please input again!")
		return false;
	}
	if(doc.txtphone.value == "")
	{
		pop_err(doc.txtphone,"Please input your phone number")
		return false;	
	}
	var szhour = doc.txthourse.value
	if(!isnumeric(szhour))
	{
		pop_err(doc.txthourse,"Hour is invalid! Please input again!")
		return false;
	}
	var szminute = doc.txtminute.value
	if(!isnumeric(szminute))
	{
		pop_err(doc.txtminute,"Minute is invalid! Please input again!")
		return false;
	}
	szemail = doc.txtemail.value
	if(szemail == ""){
		pop_err(doc.txtemail,"Please input E-mail address!")
		return false;
	}else{ 
		if(!isemailaddress(szemail)){
			pop_err(doc.txtemail,"E-mail address is invalid! Please input again!")
			return false;
		}
	}
	for(var i=0; i<doc.length;i++){
		if(doc.elements[i].type=="file"){
			if(doc.elements[i].value != ""){
				szfile = doc.elements[i].value;	
				var szlen = szfile.length;
				var szfirstlen = szlen - 3;
				var strend = trim(szfile.substr(szfirstlen,szlen));
				if(strend.toLowerCase() != 'doc' && strend.toLowerCase() != 'pdf'){
					pop_err(doc.elements[i],"File upload is invalid. Please upload doc or pdf!");
					return false;
				}
			}
		}
	}
	doc.submit()
	return;
}
function dophysicianform()
{
	var doc = document.frm;	
	if(doc.txtname.value == "")
	{
		pop_err(doc.txtname,"Please input your name")
		return false;	
	}		
	if(doc.txtaddress1.value == "")
	{
		pop_err(doc.txtaddress1,"Please input your address")
		return false;	
	}
	if(doc.txtcity.value == "")
	{
		pop_err(doc.txtcity,"Please input your city")
		return false;	
	}	
	if(doc.txtzipcode.value == "")
	{
		pop_err(doc.txtzipcode,"Please input zip code")
		return false;	
	}
	if(!isnumeric(doc.txtzipcode.value))
	{
		pop_err(doc.txtzipcode,"Zip code is invalid! Please input again!")
		return false;
	}
	if(doc.txtphone.value == "")
	{
		pop_err(doc.txtphone,"Please input your phone number")
		return false;	
	}
	var szhour = doc.txthourse.value
	if(!isnumeric(szhour))
	{
		pop_err(doc.txthourse,"Hour is invalid! Please input again!")
		return false;
	}
	var szminute = doc.txtminute.value
	if(!isnumeric(szminute))
	{
		pop_err(doc.txtminute,"Minute is invalid! Please input again!")
		return false;
	}
	szemail = doc.txtemail.value
	if(szemail == ""){
		pop_err(doc.txtemail,"Please input E-mail address!")
		return false;
	}else{ 
		if(!isemailaddress(szemail)){
			pop_err(doc.txtemail,"E-mail address is invalid! Please input again!")
			return false;
		}
	}
	doc.submit()
	return;
}
function doadministratorform()
{
	var doc = document.frm;	
	if(doc.txtname.value == "")
	{
		pop_err(doc.txtname,"Please input your name")
		return false;	
	}		
	if(doc.txtaddress1.value == "")
	{
		pop_err(doc.txtaddress1,"Please input your address")
		return false;	
	}
	if(doc.txtcity.value == "")
	{
		pop_err(doc.txtcity,"Please input your city")
		return false;	
	}	
	if(doc.txtzipcode.value == "")
	{
		pop_err(doc.txtzipcode,"Please input zip code")
		return false;	
	}
	if(!isnumeric(doc.txtzipcode.value))
	{
		pop_err(doc.txtzipcode,"Zip code is invalid! Please input again!")
		return false;
	}
	if(doc.txtphone.value == "")
	{
		pop_err(doc.txtphone,"Please input your phone number")
		return false;	
	}
	var szhour = doc.txthourse.value
	if(!isnumeric(szhour))
	{
		pop_err(doc.txthourse,"Hour is invalid! Please input again!")
		return false;
	}
	var szminute = doc.txtminute.value
	if(!isnumeric(szminute))
	{
		pop_err(doc.txtminute,"Minute is invalid! Please input again!")
		return false;
	}
	szemail = doc.txtemail.value
	if(szemail == ""){
		pop_err(doc.txtemail,"Please input E-mail address!")
		return false;
	}else{ 
		if(!isemailaddress(szemail)){
			pop_err(doc.txtemail,"E-mail address is invalid! Please input again!")
			return false;
		}
	}
	doc.submit()
	return;
}
function dooperationsform()
{
	var doc = document.frm;	
	if(doc.txtname.value == "")
	{
		pop_err(doc.txtname,"Please input your name")
		return false;	
	}		
	if(doc.txtaddress1.value == "")
	{
		pop_err(doc.txtaddress1,"Please input your address")
		return false;	
	}
	if(doc.txtcity.value == "")
	{
		pop_err(doc.txtcity,"Please input your city")
		return false;	
	}	
	if(doc.txtzipcode.value == "")
	{
		pop_err(doc.txtzipcode,"Please input zip code")
		return false;	
	}
	if(!isnumeric(doc.txtzipcode.value))
	{
		pop_err(doc.txtzipcode,"Zip code is invalid! Please input again!")
		return false;
	}
	if(doc.txtphone.value == "")
	{
		pop_err(doc.txtphone,"Please input your phone number")
		return false;	
	}
	var szhour = doc.txthourse.value
	if(!isnumeric(szhour))
	{
		pop_err(doc.txthourse,"Hour is invalid! Please input again!")
		return false;
	}
	var szminute = doc.txtminute.value
	if(!isnumeric(szminute))
	{
		pop_err(doc.txtminute,"Minute is invalid! Please input again!")
		return false;
	}
	szemail = doc.txtemail.value
	if(szemail == ""){
		pop_err(doc.txtemail,"Please input E-mail address!")
		return false;
	}else{ 
		if(!isemailaddress(szemail)){
			pop_err(doc.txtemail,"E-mail address is invalid! Please input again!")
			return false;
		}
	}
	doc.submit()
	return;
}
function domarketform()
{
	var doc = document.frm;	
	if(doc.txtname.value == "")
	{
		pop_err(doc.txtname,"Please input your name")
		return false;	
	}		
	if(doc.txtaddress1.value == "")
	{
		pop_err(doc.txtaddress1,"Please input your address")
		return false;	
	}
	if(doc.txtcity.value == "")
	{
		pop_err(doc.txtcity,"Please input your city")
		return false;	
	}	
	if(doc.txtzipcode.value == "")
	{
		pop_err(doc.txtzipcode,"Please input zip code")
		return false;	
	}
	if(!isnumeric(doc.txtzipcode.value))
	{
		pop_err(doc.txtzipcode,"Zip code is invalid! Please input again!")
		return false;
	}
	if(doc.txtphone.value == "")
	{
		pop_err(doc.txtphone,"Please input your phone number")
		return false;	
	}
	var szhour = doc.txthourse.value
	if(!isnumeric(szhour))
	{
		pop_err(doc.txthourse,"Hour is invalid! Please input again!")
		return false;
	}
	var szminute = doc.txtminute.value
	if(!isnumeric(szminute))
	{
		pop_err(doc.txtminute,"Minute is invalid! Please input again!")
		return false;
	}
	szemail = doc.txtemail.value
	if(szemail == ""){
		pop_err(doc.txtemail,"Please input E-mail address!")
		return false;
	}else{ 
		if(!isemailaddress(szemail)){
			pop_err(doc.txtemail,"E-mail address is invalid! Please input again!")
			return false;
		}
	}
	doc.submit()
	return;
}
function dosendprescreen()
{
	var doc = document.frm;	
	if(doc.txtname.value == "")
	{
		pop_err(doc.txtname,"Please input your name")
		return false;	
	}
	szemail = doc.txtemail.value
	if(szemail == ""){
		pop_err(doc.txtemail,"Please input E-mail address!")
		return false;
	}else{ 
		if(!isemailaddress(szemail)){
			pop_err(doc.txtemail,"E-mail address is invalid! Please input again!")
			return false;
		}
	}
	if(doc.txtphone.value == "")
	{
		pop_err(doc.txtphone,"Please input your phone number")
		return false;	
	}
	doc.submit()
	return;
}

