// JavaScript Document
/**************************************************
* Llamada a este archivo desde cualquier página Web.
<!-- ---------------------------------------------------------------------------------------------- -->
<script language="JavaScript" src="css-js/java.js" type="text/JavaScript"></script>
<!-- ---------------------------------------------------------------------------------------------- -->
<!-- Agrega un ícono en la barra de dirección del navegador -->
<link rel="icon" href="img/logo.gif"  type="image/png">
<!-- ---------------------------------------------------------------------------------------------- -->
**************************************************/

//-- ----------------------------------------------------------------------------------------------
// Funciones para abrir ventanar Pop Up.
function ventana(pagina)
{	var nuevaventana
	
	nuevaventana = window.open(pagina, "", "toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=1, resizable=0, width=675, height=500")
}
//-- ----------------------------------------------------------------------------------------------
function ventana_2(pagina)
{	var nuevaventana	
	
	nuevaventana = window.open(pagina, "", "toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0, width=300, height=350")
}

//"#" onClick="ventana('photos/photos.htm');"
//"#" onClick="ventana_2('brochure_requests.htm');"

//-- ----------------------------------------------------------------------------------------------
function ventana_calendario(pagina)
{	var nuevaventana	
	
	nuevaventana = window.open(pagina, "", "toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0, width=300, height=300")
}

//"#" onClick="ventana_calendario('calendario.htm');"
//-- ----------------------------------------------------------------------------------------------

function ventana_avi(pagina)
{	var nuevaventana
	
	nuevaventana = window.open(pagina, "", "toolbar=0, location=0, directories=0, status=0, menubar=1, scrollbars=1, resizable=0, width=780, height=500")
}
//"#" onClick="ventana_avi('avi_international.htm');"

//-- ----------------------------------------------------------------------------------------------
function ventana_promo(pagina)
{	var nuevaventana
	
	nuevaventana = window.open(pagina, "", "toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0, width=480, height=360")
}
//"#" onClick="ventana_promo('offer_01.htm');"
//-- ----------------------------------------------------------------------------------------------
function ventana_grupos(pagina)
{	var nuevaventana
	
	nuevaventana = window.open(pagina, "", "toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0, width=780, height=500")
}
//"#" onClick="ventana_grupos('nombre_grupo.htm');"

//-- ----------------------------------------------------------------------------------------------
//Función que muestra un mensaje de advertencia, según la opción de créditos que se eligió
function evaluar()
{
	opc = form.university.options[form.university.selectedIndex].value
	if (opc == "NMSU (currently student)" || opc == "NMSU (via distance education)")
			alert("Attention!\n\nIt is the responsibility of the student to contact NMSU to complete the corresponding procedures in order to obtain credit. It is absolutely necessary that this process be completed BEFORE the arrival of the student at CPI.");
else
		if (opc == "Directly through my own University")
			alert("Attention!\n\nIt is the responsibility of the student to contact their university to determine proper procedure to obtain credits. If the student has not contacted the university at the time that she/he is registering with CPI, this option should be left blank on the form. To obtain university credits, it is absolutely necessary that CPI know the requirements of the university BEFORE the students’ arrival to Costa Rica.");
}

// Script para la barra de estado.

var speed = 100
var pause = 2500
var timerID = null
var bannerRunning = false
var ar = new Array()
	ar[0] = "Limited Class Size: All CPI classes are limited to four students."
	ar[1] = "Three Campuses: CPI offers the city life, the cloud forest, and the tropical beaches."
	ar[2] = "Family Homestay: you become completely immersed in the culture."
	ar[3] = "Academic Coordinator: Student placement and campus class changes."
	ar[4] = "Support Services: Bilingual office staff to assist at all levels."
	ar[5] = "Free Activities: CPI provides a wide range of activities."
	ar[6] = "Professional Seminars: CPI offers medical and social work seminars."
	ar[7] = "Academic Credits: CPI works with the University of Southern Mississippi."
	ar[8] = "Pricing: CPI offers a high quality language program for a competitive price."
	ar[9] = "Customer Satisfaction: CPI ensures the highest level of customer satisfaction."

	var currentMessage = 0
	var offset = 0

	function stopBanner() {
		if (bannerRunning)
			clearTimeout(timerID)
			bannerRunning = false
		}

	function startBanner() {
		stopBanner()
		showBanner()
	}

	function showBanner() {
	var text = ar[currentMessage]
	if (offset < text.length) {
		if (text.charAt(offset) == " ")
			offset++ 
			var partialMessage = text.substring(0, offset + 1) 
			window.status = partialMessage
			offset++ 
			timerID = setTimeout("showBanner()", speed)
			bannerRunning = true
		} else {
			offset = 0
			currentMessage++
			if (currentMessage == ar.length)
				currentMessage = 0
				timerID = setTimeout("showBanner()", pause)
				bannerRunning = true
			}
		}
// poner en el onLoad="startBanner();"
// -->
//-- ----------------------------------------------------------------------------------------------

// Script para el formulario de solicitud, valida los campos marcados como requeridos requeridos.
//application.htm	
	function alerta(elementa, mensaje)
		{
			alert(mensaje);
			elementa.focus();
		}
		
		function valida_email(cadena)
		{
			var salir;
			salir=0;
			if ((cadena.indexOf("@") != 0) && (cadena.indexOf("@") != -1))
			{
				subcadena = cadena.substring(cadena.indexOf("@"),cadena.length)
				if ((subcadena.indexOf(".") != 1) && (subcadena.indexOf(".") != -1) && (subcadena.lastIndexOf("@") == 0) && (subcadena.lastIndexOf(".") != subcadena.length -1))
				{
					salir = 1;
				}
			}
			return salir;
		}
		
		function validar_radios(radio) //Valida que algún botón radio esté marcado, recive el nombre del objeto radio por parámetro. 
		{
			var i;
			var aux;
			aux=0; //Indica que no hay botones de radio marcados
			i=0;	
			while (i < radio.length)
			{ 
				if (radio[i].checked)
				{
					aux=1;
					break; 
				}
				i++;
			}
									
				return aux;	
		}
		
		function validar(form)
		//valida los campos del formulario de inscripción.
		{
			var bandera = false;
			
			if (form.realname.value=="")
			{ 
				alerta(form.realname, "Please, enter your name.");
			}
			else if (form.gender.selectedIndex ==0)
			{
				alerta(form.gender, "Please, choose your gender.");
			}
			else if (form.age.value=="")
			{	
				alerta(form.age,"Please, enter your age.")
			}			
			else if (form.address.value=="")
			{	
				alerta(form.address,"Please, enter your mailing address.")
			}
			else if (form.city.value=="")
			{
				alerta(form.city, "Please, enter the name of your city.");
			}
			else if (form.state.value=="")
			{
				alerta(form.state, "Please, enter the name of your state.");
			}
			else if (form.email.value=="")
			{
				alerta(form.email, "Please, enter your e-mail address.");
			}
			else if (valida_email(form.email.value)=='0')
			{
				alerta(form.email,"Please, enter a correct e-mail address.")
			}
			else if (form.email2.value=="")
			{
				alerta(form.email2, "Please, re-enter your e-mail address.");
			}
			else if (form.email.value!=form.email2.value)
			{
				alerta(form.email2, "The e-mail does not match.");
			}
			else if (form.phone.value=="")
			{
				alerta(form.phone, "Please, enter your phone number.");
			}
			else if (form.cell_phone_number.value=="")
			{
				alerta(form.cell_phone_number, "Please, enter your Cell Phone Number.");
			}
			else if (form.credits.selectedIndex ==0)
			{
				alerta(form.credits, "Do you need University Credits?");
 			}
			else if (form.credits.selectedIndex ==1 && form.university.selectedIndex==0)
			{
				alerta(form.university, "You must specify your program for credits");
 			}
			else if ((form.credits.selectedIndex ==1 && form.university.selectedIndex!=1) && form.other_university.value=="")
			{
				alerta(form.other_university, "You must specify your university or college name");
			}
			else if (form.credits.selectedIndex !=1 && form.other_university.value!="")
			{
				alerta(form.credits, "If you are earning credits please choose -Yes-");
			}
			else if (form.start_day.selectedIndex ==0)
			{
				alerta(form.start_day, "You must specify the day that you will begin (Mondays)");
			}
			else if (form.start_month.selectedIndex ==0)
			{
				alerta(form.start_month, "You must specify the month in that you will begin");
			}
			else if (form.start_year.selectedIndex ==0)
			{
				alerta(form.start_year, "You must specify the year that you will begin");
			}
			else if (form.end_day.selectedIndex ==0)
			{
				alerta(form.end_day, "You must specify the day that you will finish (fridays)");
			}
			else if (form.end_month.selectedIndex ==0)
			{
				alerta(form.end_month, "You must specify the month in that you will finish");
			}
			else if (form.end_year.selectedIndex ==0)
			{
				alerta(form.end_year, "You must specify the year that you will finish");
			}
			else if (form.total_weeks.value=="")
			{
				alerta(form.total_weeks, "You must specify the amount of weeks in total" + "\nthat you are going to study at each campus");
			}
			// Empieza a validar los datos para el Primer Campus
			else if (form.first_campus.selectedIndex ==0)
			{
				alerta(form.first_campus, "You must specify which campus you will be studying at first");
			}
			else if (form.weeks_first_campus.value=="")
			{
				alerta(form.weeks_first_campus, "You must specify how many weeks" + "\nyou want to study in " + form.first_campus.options[form.first_campus.selectedIndex].text );
			}
			else if (form.hours_first_campus.selectedIndex ==0)
			{
				alerta(form.hours_first_campus, "Choose how many hours a day you will study in " + form.first_campus.options[form.first_campus.selectedIndex].text );
			}
			else if (form.lodging_first_campus.selectedIndex==0)
			{
				alerta(form.lodging_first_campus, "Please, choose lodging in " + form.first_campus.options[form.first_campus.selectedIndex].text + ".");
			}		
			/*Valida el hospedaje para el Primer campus - La opciones 3 y 4 son para CPI Flamingo, únicamente.
			else if(((form.first_campus.selectedIndex!=3) && (form.lodging_first_campus.selectedIndex==3)) || ((form.first_campus.selectedIndex!=3) && (form.lodging_first_campus.selectedIndex==4)))
			{
				alerta(form.lodging_first_campus, "The lodging option you have choosen is not available in " + form.first_campus.options[form.first_campus.selectedIndex].text + ".");
			}*/
			
			// Empieza a validar los datos pora el segundo campus.
			else if ((form.second_campus.selectedIndex!=0) && (form.weeks_second_campus.value==""))
			{
				alerta(form.weeks_second_campus, "You must specify how many weeks" + "\nyou want to study in " + form.second_campus.options[form.second_campus.selectedIndex].text );
			}
			else if ((form.second_campus.selectedIndex!=0) && (form.hours_second_campus.selectedIndex==0))
			{
				alerta(form.hours_second_campus, "Choose how many hours a day you will study in " + form.second_campus.options[form.second_campus.selectedIndex].text );
			}
			else if ((form.second_campus.selectedIndex==0) && (form.weeks_second_campus.value!=""))
			{
				alerta(form.second_campus, "You must specify which will be your second campus");
			}
			else if ((form.second_campus.selectedIndex==0) && (form.hours_second_campus.selectedIndex!=0))
			{
				alerta(form.second_campus, "You must specify which will be your second campus");
			}
			else if ((form.second_campus.selectedIndex!=0) && (form.lodging_second_campus.selectedIndex==0))
			{
				alerta(form.lodging_second_campus, "Please, choose lodging in " + form.second_campus.options[form.second_campus.selectedIndex].text + ".");
			}
			//Valida el hospedaje para el Segundo campus - La opciones 3 y 4 son para CPI Flamingo, únicamente.
			/*else if(((form.second_campus.selectedIndex!=3) && (form.lodging_second_campus.selectedIndex==3)) || ((form.second_campus.selectedIndex!=3) && (form.lodging_second_campus.selectedIndex==4)))
			{
				alerta(form.lodging_second_campus, "The lodging option you have choosen is not available in " + form.second_campus.options[form.second_campus.selectedIndex].text + ".");
			}*/
			
			// Empieza a validar los datos pora el tercer campus.
			else if ((form.third_campus.selectedIndex!=0) && (form.weeks_third_campus.value==""))
			{
				alerta(form.weeks_third_campus, "You must specify how many weeks" + "\nyou want to study in " + form.third_campus.options[form.third_campus.selectedIndex].text );
			}
			else if ((form.third_campus.selectedIndex!=0) && (form.hours_third_campus.selectedIndex==0))
			{
				alerta(form.hours_third_campus, "Choose how many hours a day you will study in " + form.third_campus.options[form.third_campus.selectedIndex].text );	
			}
			else if ((form.third_campus.selectedIndex==0) && (form.weeks_third_campus.value!=""))
			{
				alerta(form.third_campus, "You must specify which will be your third campus");
			}
			else if ((form.third_campus.selectedIndex==0) && (form.hours_third_campus.selectedIndex!=0))
			{
				alerta(form.third_campus, "You must specify which will be your third campus");
			}
			else if ((form.third_campus.selectedIndex!=0) && (form.lodging_third_campus.selectedIndex==0))
			{
				alerta(form.lodging_third_campus, "Please, choose lodging in " + form.third_campus.options[form.third_campus.selectedIndex].text + ".");
			}
			//Valida el hospedaje para el Tercer campus - La opciones 3y 4 son para CPI Flamingo, únicamente.
			/*else if(((form.third_campus.selectedIndex!=3) && (form.lodging_third_campus.selectedIndex==3)) || ((form.third_campus.selectedIndex!=3) && (form.lodging_third_campus.selectedIndex==4)))
			{
				alerta(form.lodging_third_campus, "The lodging option you have choosen is not available in " + form.third_campus.options[form.third_campus.selectedIndex].text + ".");
			}*/
			
			//Fin de validación de hospedaje  en el Tercer campus	
			else
			{
			 	bandera = true;
			}
		 return bandera;
		}
//<FORM NAME="orderform" ACTION=/cgi/form METHOD=POST onsubmit="return validar(this)">	

<!-- ---------------------------------------------------------------------------------------------- -->

//Valida las variables de la página: brochure_requests.htm
						
		function validar_broreq(form)
		{
			var bandera = false;
			if (form.realname.value=="")
			{
				alerta(form.realname, "Please, enter your name.");
			}				
			else if (form.house_number.value=="")
			{	
				alerta(form.house_number,"Please, enter your house number.")
			}
			else if (form.street.value=="")
			{	
				alerta(form.street,"Please, enter your street.")
			}
			else if (form.city.value=="")
			{	
				alerta(form.city,"Please, enter your city.")
			}
			else if (form.state.value=="")
			{	
				alerta(form.state,"Please, enter your state.")
			}
			else if (form.zipcode.value=="")
			{	
				alerta(form.zipcode,"Please, enter your zip code.")
			}
			else if (form.country.value=="")
			{	
				alerta(form.country,"Please, enter your country.")
			}
			else
			{
			 	bandera = true;
			}
		 return bandera;
		}
//<form action="/cgi/form" method="post" name="form" onsubmit="return validar_broreq(this)">
<!-- ---------------------------------------------------------------------------------------------- -->

	function validar_question(form)
		{
			var bandera = false;
			if (form.realname.value=="")
			{
				alerta(form.realname, "Please, enter your name.");
			}			
			else if (form.email.value=="")
			{
				alerta(form.email, "Please, enter your e-mail.");
			}
			else if (valida_email(form.email.value)=='0')
			{
				alerta(form.email,"Please, enter a valid mail.")
			}			
			else if (form.Text.value=="")
			{	alerta(form.Text,"Please, enter your consultation.")
			}
			else
			{
			 	bandera = true;
			}
		 return bandera;
		}
//<form action="/cgi/form" method="post" name="form" onsubmit="return validar_question(this)">
<!-- ---------------------------------------------------------------------------------------------- -->


//-- ----------------------------------------------------------------------------------------------


//Este script se usa para crear un  cuadro y llamar otra página dentro de él. 

//<script language="" type="text/javascript">

/***********************************************
* IFRAME Scroller script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

//specify path to your external page:
/*
var iframesrc="external.htm"

//You may change most attributes of iframe tag below, such as width and height:
document.write('<iframe id="datamain" src="'+iframesrc+'" width="235px" height="105px" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="1" scrolling="no"></iframe>')

</script>
//-- ----------------------------------------------------------------------------------------------

*/



