function CustomValidateEmail(source, arguments)
{
    if(arguments)
    {
        var Email = getElementContact(source.controltovalidate);
		Email.value = trim(Email.value);
        if (Email.value == "")
	    {
		    source.errormessage = 'Please, enter your email address.';
		    arguments.IsValid=false;
		    return;
	    }
	    else
	    {
			if(!ValidateEmailCharacters(Email.value))
			{
				source.errormessage = "Please, enter a valid email address.";
			    arguments.IsValid=false;
			    return;
			}	
			
			if(!ValidateEmail(Email.value))
			{
				source.errormessage = "Please, enter a valid email address.";
			    arguments.IsValid=false;
			    return;
			}
			
			if(!ValidateEmailDomain(Email.value))
			{
				source.errormessage = "Please, enter a valid email address.";
			    arguments.IsValid=false;
			    return;
			}
			
			if(!ValidateConsonants(Email.value))
			{
				source.errormessage = "Please, enter a valid email address.";
			    arguments.IsValid=false;
			    return;
			}
	    }
        arguments.IsValid=true;    
    }    
}

function trim(myString)
{
    return myString.replace(/^\s+/g,'').replace(/\s+$/g,'')
}

function CustomValidateGender(source, arguments)
{
    var male =document.getElementById('rbtnMale');	
	var female =document.getElementById('rbtnFemale');
	
    if (!male.checked && !female.checked)
	{
	    source.errormessage =  "Please, select a gender.";
	    arguments.IsValid=false;
	    return (false);
	}
	
	var gender = getElementContact('txtGender');
	gender.value = male.checked?male.value:female.value;
    arguments.IsValid=true;
}

function CustomValidateDate(source, arguments)
{
    var month =getElementContact('txtDatemm');
	var day =getElementContact('txtDatedd');
	var year =getElementContact('txtDateyy');
	
	if (month.value == "" || day.value == "" || year.value == "")
	{
		source.errormessage = "Please, enter your date birth.";
		if (month.value == "")
		    month.focus();
		
		else if (day.value == "")
		    day.focus();
		
		else if (year.value == "")
		    year.focus();
		arguments.IsValid=false;
		return;
	}
	
    var dateF = new Date(year.value,month.value - 1 ,day.value) 
	if(isNaN(dateF) || !ValidateDate(month.value + "/" + day.value +"/" + year.value))
	{
	    source.errormessage = "Please, enter a valid date birth.";
	    arguments.IsValid=false;
	}
	var date = document.getElementById('txtDate');
	date.value = month.value +"/" + day.value + "/" + year.value 
    arguments.IsValid=true;
}

function ValidName(source, arguments)
{    
    var FullName = getElementContact(source.controltovalidate);
	FullName.value = trim(FullName.value);
    if((FullName.value) == "")
    {
        source.errormessage = "Please, enter your name.";
	    arguments.IsValid=false;
	    return;
    }
    else
    {
		if (!ValidateName(FullName.value))
		{
			source.errormessage = "Please, enter a valid name.";
	        arguments.IsValid=false;
	        return;
		}
		if(!ValidateConsonants(FullName.value))
		{
			source.errormessage = "Please, enter a valid name.";
	        arguments.IsValid=false;
	        return;
		}		
    }
    arguments.IsValid=true;
}

function ValidTelephone(source, arguments)
{
    var phone = getElementContact(source.controltovalidate);
    if(trim(phone.value) == "")
    {
        source.errormessage = "Please, enter your phone number.";
	    arguments.IsValid=false;
	    return;
    }
    else
    {
        if(!ValidatePhone(trim(phone.value)))
        {
            source.errormessage = "Please, enter a valid phone number.";
	        arguments.IsValid=false;
	        return;
        }
    }
    arguments.IsValid=true;
}

function ValidNumber(source, arguments)
{
    var number = document.getElementById(source.controltovalidate);
    arguments.IsValid=!isNaN(number.value)
}

function ValidateEmail(valor) 
{    
    if (/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(valor))
     return true;
    else
     return false;
}


function ValidatePhone(incoming)
{
	var ValidChars = "0123456789.()- ";
	var IsCorrect=true;
	var Char;

	for (cont = 0; cont < incoming.length && IsCorrect == true; cont++) 
	{ 
		Char = incoming.charAt(cont); 
		if (ValidChars.indexOf(Char) == -1) 
			return false;
	}
	return true;
}

function ValidateDate(valor)
{
    if (/^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d+$/.test(valor))
        return true;
    else
        return false;
}

function CustomValidateComments(source, arguments)
{
    var Comment = getElementContact(source.controltovalidate);
    if (Comment.value == "")
	{
		source.errormessage = 'Please, enter your Comments.';
		Comment.focus();
		arguments.IsValid=false;
		return;
	}		
    arguments.IsValid=true;
}

function getElementContact(name)
{
    var object = null;
    var tbSmallContact=document.getElementById('tblContactInformation'); 
    for (var i=0; i<tbSmallContact.rows.length; i++)
    {
        for (var j=0; j<tbSmallContact.rows[i].cells.length; j++)
        {
            for (var k=0; k<tbSmallContact.rows[i].cells[j].childNodes.length; k++)
            {                
                if(tbSmallContact.rows[i].cells[j].childNodes[k].id == name)
                {
                   object = tbSmallContact.rows[i].cells[j].childNodes[k];
                   return object;
                }
            }
        }
    }    
}

// survey Navigation
function goToSurveyQuestion()
{	
    if(Page_ClientValidate("ValidateInformation"))
    {
        var study = document.getElementById("hdnStudyInterested");
        var studyValue = study.value;
        
        var tblHid = document.getElementById("tblContactInformation");
        tblHid.style.display = "none";
        var tblShow;
        var tblName;
        
        switch(studyValue)
        {
            case "AcneLight":
                tblName ="tblAcneLight1";
                break;
			case "Diabetes": 
                tblName = "tblDiabetes1";
				break;
            case "Hypertension": 
                tblName = "tblHypertension1";
                break;
            case "BotoxQuality":
                tblName = "tblBotoxQuality1";
                break;
            case "AcneBotox":
                tblName = "tblAcneBotox1";
                break;
	        case "OxygenGel":
                tblName = "tblOxygenGel1";
                break;
            case "SkinTightening":
                tblName = "tblSkinTightening1";
                break;
            case "ColdScoreReduction":
                tblName = "tblHerpesLips1";
                break;				
            case "IntraceuticalAcne":
                tblName = "tblIntraceuticalAcne1";
                break;				
            case "CheekFlattening":
                tblName = "tblCheekFlattening1";
                break;
            case "FacialLaserAssistedLiposuction":
                tblName = "tblCynosure1";
                break;
            case "LipsEnhancement":
                tblName = "tblLips1";
                break;
            case "Rhinoplasty":
                tblName = "tblRhinoplasty1";
                break;
            case "LaserHairRemoval":
                tblName = "tblLaserHair1";
                break;
            case "BotoxPatientSatisfaction":
                tblName = "tblGlabellarLines1";
                break;				
        }
        
        tblShow = document.getElementById(tblName);
        tblShow.style.display = "";
    }
}

function goToSurveyQuestionBK()
{
    if(Page_ClientValidate("ValidateInformation"))
    {
        var study = document.getElementById("ddlStudyInterested");
        var studyIndex = study.selectedIndex;
        
        var tblHid = document.getElementById("tblContactInformation");
        tblHid.style.display = "none";
        var tblShow;
        var tblName;
        
        switch(studyIndex)
        {
            case 0:
                tblName ="tblAcneLight1";
                break;
            case 1: 
                tblName = "tblHypertension1";
                break;
            case 2:
                tblName = "tblBotoxQuality1";
                break;
            case 3:
                tblName = "tblAcneBotox1";
                break;
            
        }
        
        tblShow = document.getElementById(tblName);
        tblShow.style.display = "";
    }
}

function goToQuestion(next,question,from,to,to2,asociatequestion)
{    
    if(question != null)
	{
	    var rdo = document.getElementById(question);
	    var tags = rdo.getElementsByTagName("input");
		
	    if (next && !radioButtomListChecked(question))
	    {
	        alert('Please, select any option');
                return (false);
	    }
	    
	    if(tags.length > 3)
	    {    
	        if (!tags[0].checked && !tags[1].checked && !tags[2].checked && !tags[3].checked && next)
	        {
	            return;
	        }        
	           
	        if(!next)
	        {
	            tags[0].checked = false;
	            tags[1].checked = false;
	            tags[2].checked = false;
	            tags[3].checked = false;
	        }
	    }
	    else if(tags.length > 2)
	    {    
	        if (!tags[0].checked && !tags[1].checked && !tags[2].checked && next)
	        {
	            return;
	        }
	          
	        if(!next)
	        {
	            tags[0].checked = false;
	            tags[1].checked = false;
	            tags[2].checked = false;
	        }
	    }
	    else
	    {    
	        if (!tags[0].checked && !tags[1].checked && next)
	        {
	            return;
	        }        
	           
	        if(!next)
	        {
	            tags[0].checked = false;
	            tags[1].checked = false;
	        }
	    }
	    
    }
    switch(from)
    {
        //  Cynosure
        case "tblCynosure1":
            if (tags[1].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblCynosure2":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblCynosure3":
            if (tags[1].checked && next)
            {
                gotoNotQualify();
            }
            break;    
        case "tblCynosure4":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }           
            break;     
        case "tblCynosure5":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblCynosure6":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblCynosure7":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblCynosure8":
            if (tags[1].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblCynosure9":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
				return (false);
            }
            break;
                 
        //  CheekFlattening
        case "tblCheekFlattening1":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblCheekFlattening2":
            if (tags[1].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblCheekFlattening3":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;    
        case "tblCheekFlattening4":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }           
            break;     
        case "tblCheekFlattening5":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblCheekFlattening6":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblCheekFlattening7":
            if(tags[0].checked && next)
            {
                to = to2;
            }
            break;
        case "tblCheekFlattening7a1":
            if((tags[0].checked || tags[1].checked) && next)
            {
                gotoNotQualify();
            }            
            break;  
        case "tblCheekFlattening8":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }           
            break;   
        case "tblCheekFlattening9":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }           
            break;   
        case "tblCheekFlattening10":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
                return (false);
            }           
            break;
		//  IntraceuticalAcne
        case "tblIntraceuticalAcne1":
            if (tags[1].checked && next)
            {
                gotoNotQualify();
            }
            break;  
        case "tblIntraceuticalAcne2":
            if (tags[1].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblIntraceuticalAcne3":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblIntraceuticalAcne4":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblIntraceuticalAcne5":
            if (to2)
            {
                if (tags[0].checked && next)
                {
                    to = to2;
                }
            }
            break;
        case "tblIntraceuticalAcne5a1":
            if (tags[1].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblIntraceuticalAcne6":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
                return (false);
            }
            break;
		//  ColdScoreReduction
        case "tblHerpesLips1":
            if (tags[1].checked && next)
            {
                gotoNotQualify();
            }
            break;  
        case "tblHerpesLips2":
            if ((tags[0].checked || tags[3].checked) && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblHerpesLips3":
            if (tags[1].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblHerpesLips4":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblHerpesLips5":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
                return (false);
            }
            break;
		//  AcneLight
        case "tblAcneLight1":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblAcneLight2":
            if (tags[1].checked && next)
            {
                gotoNotQualify();
            } 
            break;
        case "tblAcneLight3":
            if(to2)
            {       
                if (tags[0].checked && next)
                {
                    to = to2;
                }
            }
            break;
        case "tblAcneLight4a1":            
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }        
            break;
        case "tblAcneLight4a2":
            if (tags[0].checked && next)
            {
                gotoNotQualify();             
            }
            break;
        case "tblAcneLight4a3":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
                return (false);
            }
           
            break;
        case "tblAcneLight4b1":            
            if (tags[1].checked && to2 && next)
            {
                to = to2;
            }  
            break;
        case "tblAcneLight4b2":
            if (tags[1].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblAcneLight4b3":            
            if(asociatequestion)
            {
                var rdoAsociate = document.getElementById(asociatequestion);
                var tagsAsociate = rdoAsociate.getElementsByTagName("input");
                if(tagsAsociate[1].checked && !next)
                {
                    to = to2;
                }
            }
            if (tags[0].checked && next)
            {
                gotoNotQualify();
                return (false);
            }
           
            break;    
        
		//  Diabetes
		case "tblDiabetes1":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;			
		case "tblDiabetes2":
            if (tags[1].checked && next)
            {
                gotoNotQualify();
            }
            break;
		case "tblDiabetes3":
            if (tags[1].checked && next)
            {
                gotoNotQualify();
            }
            break;            
        //  Hypertension
        case "tblHypertension1":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblHypertension2":
            if (tags[1].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblHypertension3":
            if (tags[1].checked && next)
            {
                gotoNotQualify();
            }
            break;    
        case "tblHypertension4":
            
            if (to2 && tags[0].checked && next)
            {
                to = to2;
            }
           
            break;     
        case "tblHypertension5":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblHypertension6":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblHypertension7":
            if(asociatequestion)
            {
                var rdoAsociate = document.getElementById(asociatequestion);
                var tagsAsociate = rdoAsociate.getElementsByTagName("input");
                if(tagsAsociate[0].checked && !next)
                {
                    to = to2;
                }
            }
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            
            break;  
        case "tblHypertension8":
            if (tags[1].checked && next)
            {
                gotoNotQualify();
                return (false);
            }
           
            break;   
        
        
        
        // Botox quality    
        case "tblBotoxQuality1":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblBotoxQuality2":
            if (tags[1].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblBotoxQuality3":
            if (to2 && tags[0].checked && next)
            {
                to = to2;
            }
            break;    
        case "tblBotoxQuality4":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;     
        case "tblBotoxQuality5":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblBotoxQuality6":
            if(asociatequestion)
            {
                var rdoAsociate = document.getElementById(asociatequestion);
                var tagsAsociate = rdoAsociate.getElementsByTagName("input");
                if(tagsAsociate[0].checked && !next)
                {
                    to = to2;
                }
            }
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblBotoxQuality7":            
            if (tags[0].checked && next)
            {
                gotoNotQualify();
                return (false);
            }
           
            break;        
        
        
        
        // Acne
        case "tblAcneBotox1":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblAcneBotox2":
            if (tags[1].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblAcneBotox3":
            if (to2 && tags[0].checked && next)
            {
                to = to2;
            }
            break;    
        case "tblAcneBotox4":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;     
        case "tblAcneBotox5":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblAcneBotox6":
            if(asociatequestion)
            {
                var rdoAsociate = document.getElementById(asociatequestion);
                var tagsAsociate = rdoAsociate.getElementsByTagName("input");
                if(tagsAsociate[0].checked && !next)
                {
                    to = to2;
                }
            }
            if (tags[1].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblAcneBotox7":
            if (to2 && tags[1].checked && next)
            {
                to = to2;
            }
            break;        
        case "tblAcneBotox8":
            if (tags[1].checked && next)
            {
                gotoNotQualify();
            }
            break;    
        
        case "tblAcneBotox9":
            if(asociatequestion)
            {
                var rdoAsociate = document.getElementById(asociatequestion);
                var tagsAsociate = rdoAsociate.getElementsByTagName("input");
                if(tagsAsociate[1].checked && !next)
                {
                    to = to2;
                }
            }
            
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;    
        
        case "tblAcneBotox10":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;   
        
        case "tblAcneBotox11":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;  
        
        case "tblAcneBotox12":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;  
        
        case "tblAcneBotox13":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;  
        case "tblAcneBotox14":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
                return (false);
            }
            
            break;
// Oxygen Gel
        case "tblOxygenGel1":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblOxygenGel2":
            if (tags[1].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblOxygenGel3":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;    
        case "tblOxygenGel4":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;     
        case "tblOxygenGel5":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblOxygenGel6":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblOxygenGel7":
            if (tags[1].checked && next)
            {
                gotoNotQualify();
            }
            break;        
        case "tblOxygenGel8":
			 if (to2 && tags[1].checked && next)
            {
                to = to2;
            }
            break;    
	case "tblOxygenGel8a1":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            if (tags[1].checked && next)
            {
                gotoNotQualify();
            }
            break;
	case "tblOxygenGel9":		    
		    if (to2 && tags[1].checked && next)
            {
                to = to2;
            }
			if(asociatequestion)
            {
               var rdoAsociate = document.getElementById(asociatequestion);
               var tagsAsociate = rdoAsociate.getElementsByTagName("input");
               if(tagsAsociate[1].checked && !next)
               {
                   to = to2;
               }
            }			 
            break;    
	case "tblOxygenGel9a1":
            if ((tags[0].checked ||tags[1].checked) && next)
            {
                gotoNotQualify();
            }
            break;   
	case "tblOxygenGel10":		    
			if(asociatequestion)
            {
                var rdoAsociate = document.getElementById(asociatequestion);
                var tagsAsociate = rdoAsociate.getElementsByTagName("input");
                if(tagsAsociate[1].checked && !next)
                {
                    to = to2;
                }
            }
			 if (to2 && tags[1].checked && next)
            {
                to = to2;
            }
            break;    
	case "tblOxygenGel10a1":
            if ((tags[0].checked ||tags[1].checked) && next)
            {
                gotoNotQualify();
            }
            break; 
	case "tblOxygenGel11":
			if(asociatequestion)
            {
                var rdoAsociate = document.getElementById(asociatequestion);
                var tagsAsociate = rdoAsociate.getElementsByTagName("input");
                if(tagsAsociate[1].checked && !next)
                {
                    to = to2;
                }
            }
			 if (to2 && tags[1].checked && next)
            {
                to = to2;
            }
            break;    
	case "tblOxygenGel11a1":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;
	case "tblOxygenGel12":
		if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
			if(asociatequestion)
            {
                var rdoAsociate = document.getElementById(asociatequestion);
                var tagsAsociate = rdoAsociate.getElementsByTagName("input");
                if(tagsAsociate[1].checked && !next)
                {
                    to = to2;
                }
            }            
            break;
        		
	// Skin Tightening Study
        case "tblSkinTightening1":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblSkinTightening2":
            if (tags[1].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblSkinTightening3":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;    
        case "tblSkinTightening4":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;     
        case "tblSkinTightening5":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblSkinTightening6":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;
        case "tblSkinTightening7":
            if (tags[1].checked && next)
            {
                gotoNotQualify();
            }
            break;        
        case "tblSkinTightening8":
			 if (to2 && tags[1].checked && next)
            {
                to = to2;
            }
            break;    
	case "tblSkinTightening8a1":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            if (tags[1].checked && next)
            {
                gotoNotQualify();
            }            
            break;
	case "tblSkinTightening9":		    
	    if (to2 && tags[1].checked && next)
            {
                to = to2;
            }
	    if(asociatequestion)
            {
               var rdoAsociate = document.getElementById(asociatequestion);
               var tagsAsociate = rdoAsociate.getElementsByTagName("input");
               if(tagsAsociate[1].checked && !next)
               {
                   to = to2;
               }
            }			 
            break;    
	case "tblSkinTightening9a1":
            if ((tags[0].checked ||tags[1].checked) && next)
            {
                gotoNotQualify();
            }
            break;   
	case "tblSkinTightening10":		    
		if(asociatequestion)
            {
               var rdoAsociate = document.getElementById(asociatequestion);
               var tagsAsociate = rdoAsociate.getElementsByTagName("input");
               if(tagsAsociate[1].checked && !next)
               {
                   to = to2;
               }
            }
		 if (to2 && tags[1].checked && next)
            {
                to = to2;
            }
            break;    
	case "tblSkinTightening10a1":
            if ((tags[0].checked ||tags[1].checked) && next)
            {
                gotoNotQualify();
            }
            break; 
	case "tblSkinTightening11":
	     if(asociatequestion)
            {
                var rdoAsociate = document.getElementById(asociatequestion);
                var tagsAsociate = rdoAsociate.getElementsByTagName("input");
                if(tagsAsociate[1].checked && !next)
                {
                    to = to2;
                }
            }
		 if (to2 && tags[1].checked && next)
            {
                to = to2;
            }
            break;    
	case "tblSkinTightening11a1":
            if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
            break;
	case "tblSkinTightening12":
	    if (tags[0].checked && next)
            {
                gotoNotQualify();
            }
	    if(asociatequestion)
            {
                var rdoAsociate = document.getElementById(asociatequestion);
                var tagsAsociate = rdoAsociate.getElementsByTagName("input");
                if(tagsAsociate[1].checked && !next)
                {
                    to = to2;
                }
            }            
            break;       			

//  Lips
    case "tblLips1":
        if (tags[0].checked && next)
        {
            gotoNotQualify();
        }
        break;
    case "tblLips2":
        if (tags[1].checked && next)
        {
            gotoNotQualify();
        }
        break;
    case "tblLips3":
        if(to2)
        {       
            if (tags[0].checked && next)
            {
                to = to2;
            }
        }
    break;    
    case "tblLips4":
        if (tags[0].checked && next)
        {
            gotoNotQualify();
        }           
        break;     
    case "tblLips5":
        if (tags[0].checked && next)
        {
            gotoNotQualify();
        }
        break;
    case "tblLips6":
        if (tags[0].checked && next)
        {
            gotoNotQualify();
        }
        break;
    case "tblLips7":
     if(asociatequestion)
        {
            var rdoAsociate = document.getElementById(asociatequestion);
            var tagsAsociate = rdoAsociate.getElementsByTagName("input");
            if(tagsAsociate[0].checked && !next)
            {
                to = to2;
            }
        }
    
	 if (to2 && tags[1].checked && next)
        {
            to = to2;
        }
        break;
    case "tblLips7a1":
        if((tags[0].checked || tags[1].checked) && next)
        {
            gotoNotQualify();
        }            
        break;  
    case "tblLips8":
        if (tags[0].checked && next)
        {
            gotoNotQualify();
        }           
        break;   
    case "tblLips9":
	    if (to2 && tags[1].checked && next)
        {
            to = to2;
        }
        break;
    case "tblLips9a1":
        if (tags[1].checked && next)
        {
            gotoNotQualify();
        }
        break;    
    case "tblLips10":
	    if (to2 && tags[1].checked && next)
        {
            to = to2;
        }
        break;
    case "tblLips10a1":
        if((tags[0].checked || tags[1].checked) && next)
        {
            gotoNotQualify();
        }            
        break;
    case "tblLips11":
        if (tags[0].checked && next)
        {
            gotoNotQualify();
            return (false);
        }
        break;
        
    //Rhinoplasty
    case "tblRhinoplasty1":
        if (tags[1].checked && next)
        {
            gotoNotQualify();
            return (false);
        }
        break;
    case "tblRhinoplasty2":
        if (tags[1].checked && next)
        {
            gotoNotQualify();
            return (false);
        }
        break;
    case "tblRhinoplasty3":
        if (tags[0].checked && next)
        {
            gotoNotQualify();
            return (false);
        }
        break;
//  LaserHair
    case "tblLaserHair1":
        if (tags[0].checked && next)
        {
            gotoNotQualify();
        }
        break;
    case "tblLaserHair2":
        if (tags[1].checked && next)
        {
            gotoNotQualify();
        }
        break;
    case "tblLaserHair2a1":
        if (tags[2].checked && next)
        {
            gotoNotQualify();
        }            
        break;          
    case "tblLaserHair3":
        if(to2)
        {       
            if (tags[0].checked && next)
            {
                to = to2;
            }
        }
    break;    
    case "tblLaserHair4":
        if (tags[0].checked && next)
        {
            gotoNotQualify();
        }           
        break;     
    case "tblLaserHair5":
        if (tags[0].checked && next)
        {
            gotoNotQualify();
        }
        break;
    case "tblLaserHair6":
        if (tags[0].checked && next)
        {
            gotoNotQualify();
        }
        break;
    case "tblLaserHair7":
     if(asociatequestion)
        {
            var rdoAsociate = document.getElementById(asociatequestion);
            var tagsAsociate = rdoAsociate.getElementsByTagName("input");
            if(tagsAsociate[0].checked && !next)
            {
                to = to2;
            }
        }
    
	 if (to2 && tags[0].checked && next)
        {
            to = to2;
        }
        break;
    case "tblLaserHair7a1":
        if (tags[0].checked && next)
        {
            gotoNotQualify();
        }            
        break;  
    case "tblLaserHair8":
        if (tags[0].checked && next)
        {
            gotoNotQualify();
        }           
        break;   
    case "tblLaserHair9":
	    if (to2 && tags[0].checked && next)
        {
            to = to2;
        }
        break;
    case "tblLaserHair9a1":
        if (tags[1].checked && next)
        {
            gotoNotQualify();
        }
        break;    
    case "tblLaserHair10":
        if (tags[0].checked && next)
        {
            gotoNotQualify();
        }
        break;
    case "tblLaserHair11":
        if (tags[0].checked && next)
        {
            gotoNotQualify();
            return (false);
        }
        break;
//  GlabellarLines
    case "tblGlabellarLines1":
        if (tags[0].checked && next)
        {
            gotoNotQualify();
        }
        break;
    case "tblGlabellarLines2":
        if (tags[1].checked && next)
        {
            gotoNotQualify();
        }
        break;        
    case "tblGlabellarLines3":
        if(to2)
        {       
            if (tags[0].checked && next)
            {
                to = to2;
            }
        }
    break;    
    case "tblGlabellarLines4":
        if (tags[0].checked && next)
        {
            gotoNotQualify();
        }           
        break;     
    case "tblGlabellarLines5":
        if (tags[0].checked && next)
        {
            gotoNotQualify();
        }
        break;
    case "tblGlabellarLines6":
        if (tags[0].checked && next)
        {
            gotoNotQualify();
        }
        break;
    case "tblGlabellarLines7":
        if (tags[0].checked && next)
        {
            gotoNotQualify();
        }           
        break;   
    case "tblGlabellarLines8":
        if (tags[0].checked && next)
        {
            gotoNotQualify();
        }           
        break;   
    case "tblGlabellarLines9":
	    if (to2 && tags[0].checked && next)
        {
            to = to2;
        }
        break;
    case "tblGlabellarLines9a1":
        if (tags[1].checked && next)
        {
            gotoNotQualify();
        }
        break;    
    case "tblGlabellarLines10":
	    if (to2 && tags[0].checked && next)
        {
            to = to2;
        }
        break;
    case "tblGlabellarLines10a1":
        if (tags[1].checked && next)
        {
            gotoNotQualify();
        }
        break;  		
    case "tblGlabellarLines11":
	    if (to2 && tags[0].checked && next)
        {
            to = to2;
        }
        break;
    case "tblGlabellarLines11a1":
        if (tags[0].checked && next)
        {
            gotoNotQualify();
        }
        break;  		
    case "tblGlabellarLines12":
        if (tags[0].checked && next)
        {
            gotoNotQualify();
            return (false);
        }
        break;
    }
    
    var tblHid = document.getElementById(from);
    tblHid.style.display = "none";
    var tblShow = document.getElementById(to);
    tblShow.style.display = "";
}

function gotoNotQualify()
{
    window.location = "/NoQualifyPage.html";
    //alert('no qualify');
}

function radioButtomListChecked(name)
{
    var checkBoxName = "";
    var object = null;
    var tbCheckBoxList = document.getElementById(name); 
    for (var i=0; i < tbCheckBoxList.rows.length; i++)
    {
        for (var j=0; j < tbCheckBoxList.rows[i].cells.length; j++)
        {
            for (var k=0; k < tbCheckBoxList.rows[i].cells[j].childNodes.length; k++)
            {
                checkBoxName = name + "_" + i;
                if(tbCheckBoxList.rows[i].cells[j].childNodes[k].id == checkBoxName)
                {
                   object = tbCheckBoxList.rows[i].cells[j].childNodes[k];
                   if (object.checked)
                        return true;
                }
            }
        }
       
    }
    return false;
}

function ValidateConsonants(valor) 
{
	   valor = valor.toLowerCase();
	if (/[bcdfghjklmnpqrstvwxyz]{7}/.test(valor))
		return false;
	else
		return true;
}

function ValidateEmailDomain(valor) 
{
	valor = valor.toLowerCase();
	if (/.ru$|.sk$|.ua$/i.test(valor))
		return false;	
	else
		return true;
} 

function ValidateEmailCharacters(valor)
{
	valor = valor.toLowerCase();
	var ValidChars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_";   
	var Char;
	var IsCorrect=true;
	
	for (cont = 0; cont < valor.length && IsCorrect == true; cont++) 
	{ 
		Char = valor.charAt(cont); 
		if (ValidChars.indexOf(Char) == -1) {
			return false;
		}
	}
	return true;
}

function ValidateName(valor) 
{
		valor = valor.toLowerCase();
	if (/^[a-z ]+$/i.test(valor))
		return true;
	else
		return false;
}

		
function ValidateAreaCode(incoming)
{
	var ValidChars = "0123456789";			
	var Char;
	var IsCorrect=true;
	
	for (cont = 0; cont < incoming.length && IsCorrect == true; cont++) 
	{ 
		Char = incoming.charAt(cont); 
		if (ValidChars.indexOf(Char) == -1) {
			 
			 return false;
		}
	}
	return true;
}


function CustomValidateCity(source, arguments)
{    
    var city = getElementContact(source.controltovalidate);
	city.value = trim(city.value);
    if((city.value) == "")
	{
		source.errormessage = "Please, enter your city.";
		arguments.IsValid=false;
		return;
	
	}
	else
    {
		if (!ValidateName(city.value))
		{
			source.errormessage = "Please, enter a valid city.";
	        arguments.IsValid=false;
	        return;
		}
		if(!ValidateConsonants(city.value))
		{
			source.errormessage = "Please, enter a valid city.";
	        arguments.IsValid=false;
	        return;
		}		
    }
    arguments.IsValid=true;
}

function CustomValidateState(source, arguments)
{    
    var state = getElementContact(source.controltovalidate);
	state.value = trim(state.value);
    if((state.value) == "")
	{
		source.errormessage = "Please, enter your state.";
		arguments.IsValid=false;
		return;
	}
	else
    {
		if (!ValidateName(state.value))
		{
			source.errormessage = "Please, enter a valid state.";
	        arguments.IsValid=false;
	        return;
		}
		if(!ValidateConsonants(state.value))
		{
			source.errormessage = "Please, enter a valid state.";
	        arguments.IsValid=false;
	        return;
		}		
    }
    arguments.IsValid=true;
}

function CustomValidateZip(source, arguments)
{    
    var zip = getElementContact(source.controltovalidate);
	zip.value = trim(zip.value);
    if((zip.value) == "")
	{
		source.errormessage = "Please, enter your zip.";
		arguments.IsValid=false;
		return;
	}    
	else{
		if (!ValidateAreaCode(zip.value))
		{
			source.errormessage = "Please, enter a valid zip.";
	        arguments.IsValid=false;
	        return;
		}
    }
    arguments.IsValid=true;
}




