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

function GetTeacherResults(opt)
{
	//debugger;
	var selectText;
	var url = '#';
	switch (opt)
	{
		case 1:
			//selectText = this.document.forms.Form1.selectState.options[this.document.forms.Form1.selectState.selectedIndex].value;

			selectText = this.document.getElementById("selectState").options[this.document.getElementById("selectState").selectedIndex].value;

			/*
			if(selectText.length > 0)
				url = 'ClassesResult.html?opt=' + opt + '&select=' + selectText;
			*/
			
			if(selectText.length > 0)
			{
				while(selectText.indexOf('.') != -1)
				{
					selectText = selectText.replace('.', '');
				}
				while(selectText.indexOf('(') != -1)
				{
					selectText = selectText.replace('(', '');
				}
				while(selectText.indexOf(')') != -1)
				{
					selectText = selectText.replace(')', '');
				}
				selectText = selectText.replace(/ /g,'_');
				selectText = selectText.toLowerCase(); 
				index =  selectText.indexOf('-');
				if(index > -1)
					url = 'usa/' + selectText.substring(index + 1) + '.html';
				else
					url = 'usa/' + selectText + '.html';
			}
			
			break;
		case 2:
			//selectText = this.document.forms.Form1.zipCode.value;
			selectText = this.document.getElementById("zipCode").value;
			if(selectText.length > 0)
				url = 'ClassesResult.html?opt=' + opt + '&select=' + selectText;
			break;
		case 3:
			//selectText = this.document.forms.Form1.studioName.value;
			selectText = this.document.getElementById("studioName").value;
			if(selectText.length > 0)
				url = 'ClassesResult.html?opt=' + opt + '&select=' + selectText;
			break;
		case 4:
			//selectText = this.document.forms.Form1.selectCountry.options[this.document.forms.Form1.selectCountry.selectedIndex].value;
			selectText = this.document.getElementById("selectCountry").options[this.document.getElementById("selectCountry").selectedIndex].value;
			/*
			if(selectText.length > 0)
				url = 'ClassesResult.html?opt=' + opt + '&select=' + selectText;
			*/
			
			if(selectText.length > 0)
			{
				while(selectText.indexOf('.') != -1)
				{
					selectText = selectText.replace('.', '');
				}
				while(selectText.indexOf('(') != -1)
				{
					selectText = selectText.replace('(', '');
				}
				while(selectText.indexOf(')') != -1)
				{
					selectText = selectText.replace(')', '');
				}
				selectText = selectText.replace(/ /g,'_');
				selectText = selectText.toLowerCase();
				url = selectText + '/teachers.html';
			}
			
			break;
		case 5:
			selectText = this.document.getElementById("selectYogaStyle").options[this.document.getElementById("selectYogaStyle").selectedIndex].value;
			if(selectText.length > 0)
				url = 'ClassesResult.html?opt=' + opt + '&select=' + selectText;
			break;
	}
	
	//alert(url);
	location.href = "/" + url;
	//location.href='ClassesResult.html?opt=' + opt + '&select=' + selectText
}

function GetStates()
{
	var result = "";
	arrState = new Array("AL-Alabama","AK-Alaska","AZ-Arizona","AR-Arkansas","CA-California","CO-Colorado","CT-Connecticut","DE-Delaware","DC-District Of Columbia","FL-Florida","GA-Georgia","Guam","HI-Hawaii","ID-Idaho","IL-Illinois","IN-Indiana","IA-Iowa","KS-Kansas","KY-Kentucky","LA-Louisiana","ME-Maine","MD-Maryland","MA-Massachusetts","MI-Michigan","MN-Minnesota","MS-Mississippi","MO-Missouri","MT-Montana","NE-Nebraska","NV-Nevada","NH-New Hampshire","NJ-New Jersey","NM-New Mexico","NY-New York","NC-North Carolina","ND-North Dakota","OH-Ohio","OK-Oklahoma","OR-Oregon","PA-Pennsylvania","PR-Puerto Rico","RI-Rhode Island","SC-South Carolina","SD-South Dakota","TN-Tennessee","TX-Texas","UT-Utah","VI-U.S. Virgin Islands","VT-Vermont","VA-Virginia","WA-Washington","WV-West Virginia","WI-Wisconsin","WY-Wyoming");
	for (x in arrState)
	{
	  result += GetUrlState(arrState[x]);
	}
	return result;
}

function GetUrlState(value)
{
	var selectText;
	var url = '#';
	selectText = value;
	
	if(selectText.length > 0)
	{
		while(selectText.indexOf('.') != -1)
		{
			selectText = selectText.replace('.', '');
		}
		while(selectText.indexOf('(') != -1)
		{
			selectText = selectText.replace('(', '');
		}
		while(selectText.indexOf(')') != -1)
		{
			selectText = selectText.replace(')', '');
		}
		selectText = selectText.replace(/ /g,'_');
		selectText = selectText.toLowerCase(); 
		index =  selectText.indexOf('-');
		if(index > -1)
			url = 'usa/' + selectText.substring(index + 1) + '.html';
		else
			url = 'usa/' + selectText + '.html';
			
	    state = '<a href="/' + url + '">' + value.substring(index + 1) + '</a>, ';
	}	
	return state;
}

function showState(){
	document.write(GetStates());
}

function GetStyles()
{
	var result = "";
	arrStyle = new Array("Ananda","Anusara","Ashtanga","Baptiste","Bikram","Core Strengthening","Forrest Yoga","Hatha","Hot","Integral","Integrative Yoga Therapy","Ishta","Iyengar","Jivamukti","Kali Ray Tri Yoga","Kripalu","Kriya","Kundalini","Partner Yoga","Phoenix Rising Yoga Therapy","Power","Prenatal/Postnatal","Purna Yoga","Restorative","Satyananda Yoga","Scaravelli","Shadow Yoga","Sivananda","Svaroopa","Synergy","Tantra","VariYoga","Viniyoga","Vinyasa Flow","Vinyasa Krama","White Lotus","Yin Yoga","Yoga For Children");
	for (x in arrStyle)
	{
	  result += GetUrlStyle(arrStyle[x]);
	}
	return result;
}

function GetUrlStyle(value)
{
	var selectText;
	var url = '#';
	selectText = value;
	
	if(selectText.length > 0)
	{
		style = '<a href="/ClassesResult.html?opt=5&select=' + selectText + '">' + selectText + '</a>, ';
	}		
	return style;
}

function showYogaStyle(){
	document.write(GetStyles());
}

function CreateListing(){
	window.open('/Teacher-new.aspx', this.target, 'width=410,height=404');	
}

function UpdateListing(){
	
	Email = this.document.getElementById("txtEmailAddress");	
	Password = this.document.getElementById("txtPassword");	
	
	if ((Email.value == "") || (Email.value == Email.defaultValue))
		{
			alert('Please, enter your email.');
			Email.focus();
			return (false);
		}
		else
		{
			if(!ValidateEmail(Email.value))
			{
				alert("Please check your email.");
				Email.focus();
				return false;
			}
		}
		
	if ((Password.value == "") || (Password.value == Password.defaultValue))
		{
			alert('Please, enter your password.');
			Password.focus();
			return (false);
		}

	window.open("/Teacher-update.aspx?e="+Email.value+"&p="+Password.value, this.target, 'width=410,height=404');	
}

function ForgotPassword(){
	window.open('/SendPassword.aspx', this.target, 'width=795,height=324');	
}

