var digits="0123456789";var phoneNumberDelimiters="()- ";var validWorldPhoneChars=phoneNumberDelimiters+"+";var minDigitsInIPhoneNumber=10;function isInteger(s)
{var i;for(i=0;i<s.length;i++)
{var c=s.charAt(i);if(((c<"0")||(c>"9")))return false;}
return true;}
function stripCharsInBag(s,bag)
{var i;var returnString="";for(i=0;i<s.length;i++)
{var c=s.charAt(i);if(bag.indexOf(c)==-1)returnString+=c;}
return returnString;}
function trim(s)
{var i;var returnString="";for(i=0;i<s.length;i++)
{var c=s.charAt(i);if(c!=" ")returnString+=c;}
return returnString;}
function checkInternationalPhone(strPhone){var bracket=3
strPhone=trim(strPhone)
if(strPhone.indexOf("+")>1)return false
if(strPhone.indexOf("(")!=-1&&strPhone.indexOf(")")==-1)return false
if(strPhone.indexOf("(")==-1&&strPhone.indexOf(")")!=-1)return false
s=stripCharsInBag(strPhone,validWorldPhoneChars);return(isInteger(s)&&s.length>=minDigitsInIPhoneNumber);}
function verify(fields)
{
	var msg;var empty_fields="";var errors="";var thePosition;var email;var diagnosis_unchecked=0;
	for(var i=0;i<fields.length;i++){
		var formver=fields.elements[i];
		if(formver.name=='Name'){
			if((formver.value==null)||(formver.value=="")||(formver.value==" name")){
				errors+="- "+formver.name+" : Please enter your "+formver.name + "\n";continue;
			}
		}
		if (formver.name== 'diagnosis'){
			if ((formver.value == null) || (formver.value == "") || (formver.value == "Select...")){
				errors += "- " + formver.name + " : Please select a " + formver.name ; continue;
			}
		}
		if(formver.name=='Email'){
			substremail=formver.value.split("@")
			if(formver.value==""){
			}else if(substremail.length>1){
				index=substremail[1].indexOf(".")
				if(index==-1){
					errors+="- Email : Please enter a valid e-mail address\n";continue;
				}
			}else{
				errors+="- Email : Please enter a valid e-mail address\n";continue;
			}
		}
		if(formver.name=='Phone Number'){
			if(checkInternationalPhone(formver.value)==false){
				errors+="- Phone : Please enter a valid phone number (xxx) xxx-xxxx\n";continue;
			}
		}
		if(formver.name=='Diagnosis'){
			//alert(formver.checked);
			if(formver.checked == false){
				diagnosis_unchecked ++;
			}
		}
	}
	if(diagnosis_unchecked == 2){
		errors+="- Diagnosis : Please enter your Diagnosis \n";
	}
	if(!empty_fields&&!errors){
		return checkInternational(fields);
	}
	msg="Pleuralmesothelioma.com\n"
	msg+="______________________________________________________\n\n"
	msg+="The form was not submitted because of the following error(s).\n";msg+="Please correct these error(s) and re-submit.\n";
	msg+="______________________________________________________\n\n"
	if(empty_fields){
		msg+=empty_fields+"\n";
	}
	msg+=errors;alert(msg);return false;
}
function IsNumeric(sText)
{var ValidChars="0123456789.";var IsNumber=true;var Char;for(i=0;i<sText.length&&IsNumber==true;i++)
{Char=sText.charAt(i);if(ValidChars.indexOf(Char)==-1)
{IsNumber=false;}}
return IsNumber;}
sfHover=function(){if(document.getElementById("nav")){var sfEls=document.getElementById("nav").getElementsByTagName("LI");for(var i=0;i<sfEls.length;i++){sfEls[i].onmouseover=function(){this.className+=" sfhover";}
sfEls[i].onmouseout=function(){this.className=this.className.replace(new RegExp(" sfhover\\b"),"");}}}}
if(window.attachEvent)window.attachEvent("onload",sfHover);
function checkInternational(fields){
for(var i=0;i<fields.length;i++){
	var formver=fields.elements[i];
	if(formver.id=='cntry'){
		if (formver.value=="UK"){
			var yesUK = confirm("Based on the information you have provided, you are a resident of the United Kingdom.  Asbestos exposure assistance is local in nature and we believe it would be more beneficial for you to deal directly with an organization located in the United Kingdom that will provide localized advice. With your permission, we would like to direct your inquiry to an organization we have partnered with in the United Kingdom that will better be able to answer any questions you may have. If you consent to the transfer, please click 'OK'");	
			if (yesUK){
				return true;
			}else{ 
				return false; 
			}
		}else if (formver.value=="Australia"){
			var yesAU = confirm("Based on the information you have provided, you are located in Australia. Asbestos exposure assistance is local in nature and we believe it would be more beneficial for you to deal directly with an organization located in Australia that will provide localized assistance. With your permission, we would like to you direct your inquiry to an organization we have partnered with in Australia that will better be able to answer any questions you may have. \n\n We have established a relationship with Shine Lawyers to provide the same excellent services we provide our clients in the United States and abroad, and are confident in their abilities to assist you. Shine Lawyers provides comprehensive no-cost assistance for those suffering from asbestos exposure, including legal, medical, financial, health and related advice. They are not just a law firm but rather a comprehensive organization designed to help assist you with any asbestos-related issue. Shine Lawyers has offices in twenty-four cities and has a comprehensive body of resources available for Australian asbestos exposure victims.\n\n If you indicate to your asbestos advocate your desire to initiate a legal action with Shine Lawyers, you will be asked to sign a retainer agreement explaining your legal rights and responsibilities in connection with a legal action. Generally, such agreements are on a 'no win, no fee' basis, which means that you are not obligated to pay any legal fees unless you win your case, and that the legal fees will be paid by the party responsible for the asbestos exposure, not from your recovery. The Peterson Firm, LLP, which sponsors Pleuralmesothelioma.com, may also co-counsel and assist with the prosecution of the claim at no additional cost to you. \n\n If you consent to the transfer, please click 'OK'");	
			if (yesAU){
				return true;
			}else{ 
				return false; 
			}
		}else{
			return true;
		}
}
}
}

/*
 * In-Field Label jQuery Plugin
 * http://fuelyourcoding.com/scripts/infield.html
 *
 * Copyright (c) 2009 Doug Neiner
 * Dual licensed under the MIT and GPL licenses.
 * Uses the same license as jQuery, see:
 * http://docs.jquery.com/License
 *
 * @version 0.1
 */
(function($){$.InFieldLabels=function(b,c,d){var f=this;f.$label=$(b);f.label=b;f.$field=$(c);f.field=c;f.$label.data("InFieldLabels",f);f.showing=true;f.init=function(){f.options=$.extend({},$.InFieldLabels.defaultOptions,d);if(f.$field.val()!=""){f.$label.hide();f.showing=false};f.$field.focus(function(){f.fadeOnFocus()}).blur(function(){f.checkForEmpty(true)}).bind('keydown.infieldlabel',function(e){f.hideOnChange(e)}).change(function(e){f.checkForEmpty()}).bind('onPropertyChange',function(){f.checkForEmpty()})};f.fadeOnFocus=function(){if(f.showing){f.setOpacity(f.options.fadeOpacity)}};f.setOpacity=function(a){f.$label.stop().animate({opacity:a},f.options.fadeDuration);f.showing=(a>0.0)};f.checkForEmpty=function(a){if(f.$field.val()==""){f.prepForShow();f.setOpacity(a?1.0:f.options.fadeOpacity)}else{f.setOpacity(0.0)}};f.prepForShow=function(e){if(!f.showing){f.$label.css({opacity:0.0}).show();f.$field.bind('keydown.infieldlabel',function(e){f.hideOnChange(e)})}};f.hideOnChange=function(e){if((e.keyCode==16)||(e.keyCode==9))return;if(f.showing){f.$label.hide();f.showing=false};f.$field.unbind('keydown.infieldlabel')};f.init()};$.InFieldLabels.defaultOptions={fadeOpacity:0.5,fadeDuration:300};$.fn.inFieldLabels=function(c){return this.each(function(){var a=$(this).attr('for');if(!a)return;var b=$("input#"+a+"[type='text'],"+"input#"+a+"[type='password'],"+"textarea#"+a);if(b.length==0)return;(new $.InFieldLabels(this,b[0],c))})}})(jQuery);
