// JavaScript Document
// Parametro de Navegacion
Navegacion = 0;

var browser = "";
var browsername = navigator.appName;
function new_vod (url,streamtitle,customfeatures) 
{
	windowFeatures = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=624,height=212,titlebar=no';


	var browser = "";
	var browsername = navigator.appName;
	var browserversion = parseInt(navigator.appVersion);
	var browserplatform = navigator.userAgent;
	if (browsername == "Netscape") 
	{
		browser = "ns" + browserversion;
	}
	else
	{
		if (browsername == "Microsoft Internet Explorer") 
		{
			if (browserversion >= 4) 
			{
				browser = "ie" + browserversion;
			}
			else
			{
				browser = "ie3";
			}
		}
	}

	if ((customfeatures) && customfeatures != '') 
	{
		windowFeatures = customfeatures;
	}

	if (url.indexOf(".rm",(url.length-10)) != -1) 
	{
		if (browser != 'ie3') 
		{
			hasplugin = 'false';
			if ( (browserplatform.indexOf('Mac') !=-1) && ( browsername != "Netscape") )  
			{
				numPlugins = 0;
				for (i = 0; i < numPlugins; i++) 
				{
					plugin = navigator.embeds[i];
					if (plugin.name.substring(0,10)=="RealPlayer") 
					{
						hasplugin = 'true';
					}
				}
			}
			else
			{
				numPlugins = navigator.plugins.length;
				for (i = 0; i < numPlugins; i++) 
				{
					plugin = navigator.plugins[i];
					if (plugin.name.substring(0,10)=="RealPlayer") 
					{
						hasplugin = 'true';
					}
				}
			}
			if (browser.substring(0,2) == 'ie') 
			{
				hasplugin = 'true';
			}
			if (hasplugin == 'true') 
			{
				videoWin = window.open (url , 'video', windowFeatures);
				if (streamtitle != '') 
				{
					videoWin.streamtitle=streamtitle;
				}
				videoWin.document.close();		
			}
			else
			{
				stream = url.substring(0,(url.length-5));
				location.href=stream + '.ram';
			}
		}
		else
		{
			videoWin = window.open (url , 'video', windowFeatures);
			if (document.images) 
			{
				if (streamtitle != '') 
				{
					videoWin.streamtitle=streamtitle;
				}
			}
			videoWin.document.close();			
		}		
	}
	else
	{
		videoWin = window.open (url , 'video', windowFeatures);
		if (document.images) 
		{
			if (streamtitle != '') 
			{
				videoWin.streamtitle=streamtitle;
			}
		}
		videoWin.document.close();
	}
}

var browserversion = parseInt(navigator.appVersion);
if (browsername == "Netscape") 
{
	browser = "ns" + browserversion;
}
else
{
	if (browsername == "Microsoft Internet Explorer") 
	{
		if (browserversion >= 4) 
		{
			browser = "ie" + browserversion;
		}
		else 
		{
			browser = "ie3";
		}
	}
}
bName = navigator.appName;
bVer = parseInt(navigator.appVersion);

// this handles the homepage picture of the day
function popNav(url,name,features) 
{
	if ((browser == "ns3","ns4") || (browser == "ie4")) 
	{
		popBox = window.open(url,name,features);
		popBox.focus();
	}
	else
	{
		if (browser == "ie3") 
		{
			popBox = window.open(url,name,features);
		}  
	}
}

function med_vod(vidlocation){

	openWindow(vidlocation,'770x196','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=790,height=710');
}
function med_vod1(vidlocation){

	openWindow(vidlocation,'770x1961','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=790,height=710');
}

// this is for opening pop-up windows
function openWindow (earl,name,widgets) 
{
	host = location.hostname;
	if (host.indexOf('customnews') != -1) 
	{
		var url = 'http://customnews.cnn.com' + earl;
	}
	else
	{
		var url = earl;
	}
	popupWin = window.open (url,name,widgets);
	//popupWin.opener.top.name="opener";
	popupWin.focus();
	
}

function closeWindow () 
{
	parent.close ();
}

function goTW()
{
	var URL = document.pathfinder.site.options[document.pathfinder.site.selectedIndex].value;
	window.location.href = URL;
}
function new_vod1(vidlocation){

	openWindow(vidlocation,'500x465','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=500,height=465');
	popupWin.opener.top.name="closed";
}

function new_vod2(vidlocation){

	openWindow(vidlocation,'500x448','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=500,height=448');
	popupWin.opener.top.name="closed";
}

function new_vod3(vidlocation){

	openWindow(vidlocation,'770x465','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=500,height=465');
	popupWin.opener.top.name="closed";
}

function new_vod4(vidlocation){

	openWindow(vidlocation,'563x223','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=563,height=126');
	popupWin.opener.top.name="closed";
}

function new_vod5(vidlocation){

	openWindow(vidlocation,'374x160','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,left=197, top=200, width=384,height=140');
	popupWin.opener.top.name="closed";
}

function new_vod6(vidlocation){

	openWindow(vidlocation,'497x305','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,left=197, top=200, width=502,height=400');
	popupWin.opener.top.name="closed";
}
function localizacion(vidlocation){

	openWindow(vidlocation,'449x249','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,left=197, top=200, width=449,height=249');
	popupWin.opener.top.name="closed";
}

function new_vod7(vidlocation){

	openWindow(vidlocation,'563x223','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=592,height=247');
	popupWin.opener.top.name="closed";
}

function new_vod8(vidlocation){

	openWindow(vidlocation,'449x249','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=449,height=249');
	popupWin.opener.top.name="closed";
}

function new_vod9(vidlocation){

	openWindow(vidlocation,'563x223','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=450,height=50');
	popupWin.opener.top.name="closed";
}

function getParams() {
var idx = document.URL.indexOf('?');
var params = new Array();
	if (idx != -1) {
		var pairs = document.URL.substring(idx+1, document.URL.length).split('&');
		for (var i=0; i<pairs.length; i++) 
		{
			nameVal = pairs[i].split('=');
			params[nameVal[0]] = nameVal[1];
   		}
	}
return params;
}

function ShowMsgEmpty(fieldname) 
	{
  		 alert("No puede dejar el campo <<"+fieldname+">> vacío."); 
	}

	
  	// Funcion que retornal si el campo es nulo
	function isEmpty(e) 
	{
        if ((e.value == null) || (e.value == ""))
    		return true;
	}
  	// Funcion que valida un campo de texto
  	function textOk(text,msg) {
		if (isEmpty(text)){
			ShowMsgEmpty(msg);
			text.focus();
			text.select();
			return false;
		}
	return true;	
	}
		
	
    function textYes(text,msg) {
 	if ((text.value==1) && (msg.value!=null)){
			alert("Si selecciona la opcion yes tiene que marcar un hotel."); 
			text.focus();
			text.select();
			return false;
		}
	return true;	
	}


function ValidaTPForm(TPF)
{
		// Validar los campos nombre
		if(!textOk(TPF.aname,"Name"))
			return false;
		// Validar los campos email
		if(!textOk(TPF.email,"Email"))
			return false;
		// Validar los campos travelname
		if(!textOk(TPF.travelname,"Travel name"))
			return false;
		// Validar los campos IATA
		if(!textOk(TPF.IATA,"IATA"))
			return false;		
		// Validar los campos address
		if(!textOk(TPF.address,"Address"))
			return false;
		// Validar los campos city
		if(!textOk(TPF.city,"City"))
			return false;
		// Validar los campos zip
		if(!textOk(TPF.zip,"Zip"))
			return false;
		// Validar los campos country
		if (isEmpty(TPF.country)|| TPF.country.value==0){
			ShowMsgEmpty("Country");
			TPF.country.focus();
			return false;
		}
		// Validar los campos phone
		if(!textOk(TPF.phone,"Phone"))
			return false;
		// Validar los campos de factura
		if(!textOk(TPF.user,"User Name"))
			return false;
		// Validar los campos pass
		if(!textOk(TPF.pass,"Password"))
			return false;
		// Validar los campos confirmpass
		
		
}
function ValidaNForm(NF)
{
			
		/*if(!textOk(NF.email,"Email"))
			return false;
		if(!textOk(NF.fname,"First Name"))
			return false;
		if(!textOk(NF.lname,"Last Name"))
			return false;
		if(!textOk(NF.address,"Address"))
			return false;
		if(!textOk(NF.city,"City"))
			return false;
		if(!textOk(NF.zip,"Zip/Post Code"))
			return false;
			
		if (isEmpty(NF.country)|| NF.country.value==0){
			ShowMsgEmpty("Country");
			NF.country.focus();
			return false;
		}
		if (isEmpty(NF.language)|| NF.language.value==0){
			ShowMsgEmpty("Prefered Languages");
			NF.language.focus();
			return false;
		}*/		
			
}

//****************************************************

function getParams() {
var idx = document.URL.indexOf('?');
var params = new Array();
	if (idx != -1) {
		var pairs = document.URL.substring(idx+1, document.URL.length).split('&');
		for (var i=0; i<pairs.length; i++) 
		{
			nameVal = pairs[i].split('=');
			params[nameVal[0]] = nameVal[1];
   		}
	}
return params;
}

// Funcion para onmaouse over de las imagenes
function Rollover(theImage, theSrc)
{
var objStr,obj;
	if(document.images)
	{
		if (typeof(theImage) == 'string') 
		{
			objStr = 'document.' + theImage;
			obj = eval(objStr);
			obj.src = theSrc;
		} 
		else if ((typeof(theImage) == 'object') && theImage && theImage.src) 
		{
			theImage.src = theSrc;
		}
	}
}

// Funcion que muestra la noticia
function ShowNew(New)
{
	var url = "http://new.solmeliacuba.net/news/new_popup.php?new=" + New + "&longtext=true";
	openWindow(url,'563x223','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=498,height=350');
	popupWin.opener.top.name="closed";
}

//*********************************************

function numChecked()
{
	j=0;
	for(i=0;i< frm.length;i++)
	{
		e=frm.elements[i];
		if (e.type=='checkbox' && e.name != 'allbox' && e.checked)
		j++;		
	}
	return j;
}

function Subm(act,first,dosub)
{
    switch (act)
	{
		case 'Asig':		
			msg = "Debe seleccionar al menos una asignatura";
			break;
		case 'Espec':	
			msg = "Debe seleccionar al menos una especialidad";
			break;
		default:
			msg = "Debe seleccionar al menos un parámetro a borrar";
	}
	
	num = ((first) ? slct1st(frm) : numChecked(frm));
	if (!num)
	{	
		alert(msg);
		return false;
	}
}

// Validacion de correo electronico
function valid_email(form_name, field_name)
 {
  var form = eval('document.'+form_name);
  var str = form.elements[field_name].value; 
  result =  ((str.indexOf('@') != -1) && (str.indexOf('@') != 0) && (str.indexOf('@') != str.length -1) && (str.indexOf('.') != -1) && (str.indexOf('.') != 0) && (str.indexOf('.') != str.length -1))  
  if (!result)
  {
   alert('La dirección de correo electrónico no es valida');
   form.elements[field_name].focus();
   form.elements[field_name].select();
  }

  return result;
 }
 
// Validacion de formularios
function valid_all(Form)
{
 result = true;
 error = false;
 for (var i = 1; ((i < fields.length) && (!error)); i++)
  {
   if ((Form.elements[fields[i]].value == '') || (Form.elements[fields[i]].value == 0))
     {alert('El campo "'+display[i]+'" no puede estar vacio.');
      error = true;
      result = false;
      Form.elements[fields[i]].focus();}
  }    

 return result;
}

// Funcion que validad noticias
function ValidaNewForm(TPF)
{
     	// Validar los campos email
		if(!textOk(TPF.titular,"Titulo"))
			return false;
		// Validar los campos de factura
		if(!textOk(TPF.descripcion,"Texto de la noticia"))
			return false;
		// Validar los campos de factura
		if(!textOk(TPF.Fechaini,"Fecha de inicio"))
			return false;
		// Validar los campos de factura
		if(!textOk(TPF.duracion,"Duración"))
			return false;		
}

// Funcion que validad noticias
function ValidaBanForm(TPF)
{
     	// Validar los campos email
		if(!textOk(TPF.nombre,"Nombre"))
			return false;
		// Validar los campos de factura
		if(!textOk(TPF.url,"URL"))
			return false;
		// Validar los campos de factura
		if(!textOk(TPF.file,"Imagen"))
			return false;
		// Validar los campos country
		if (isEmpty(TPF.idioma)|| TPF.idioma.value==0){
			ShowMsgEmpty("Idioma");
			TPF.idioma.focus();
			return false;
		}		
}

// Funcion que valida contactos
function ValidaContactForm(TPF)
{
     	// Validar los campos email
		if(!textOk(TPF.nombre,"Nombre"))
			return false;
		// Validar los campos de factura
		if(!textOk(TPF.email,"Correo electrónico"))
			return false;			
}

// Funcion que valida Sitios de interes
function ValidaSitesForm(TPF)
{
     	// Validar los campos email
		if(!textOk(TPF.nombre,"Nombre"))
			return false;
		// Validar los campos de factura
		if(!textOk(TPF.url,"URL"))
			return false;			
}

// Funcion que validad FAQ
function ValidaFAQForm(TPF)
{
		// Validar los campos country
		if (isEmpty(TPF.categoria)|| TPF.categoria.value==0){
			ShowMsgEmpty("Categoría");
			TPF.categoria.focus();
			return false;
		}	
     	// Validar los campos email
		if(!textOk(TPF.pregunta,"Pregunta"))
			return false;
		// Validar los campos de factura
		if(!textOk(TPF.respuesta,"Respuesta"))
			return false;			
}
// Funcion que validad usuario
function ValidaUsersForm(TPF)
{
		
     	// Validar los campos email
		if(!textOk(TPF.nombre,"Nombre"))
			return false;
		// Validar los campos de factura
		if(!textOk(TPF.usuario,"Usuario"))
			return false;
		// Validar los campos de factura
		if(!textOk(TPF.clave,"Clave"))
			return false;
		// Validar los campos de factura
		if(!textOk(TPF.confirmclave,"Confirmar Clave"))
			return false;
		if(TPF.confirmclave.value!=TPF.clave.value)
		{
			alert("Los campos Clave y Confirmar clave tienen que ser iguales")
			TPF.clave.focus();
			return false;			
		}
}
// Funcion que validad usuario
function ValidaEventsForm(TPF)
{
		
     	// Validar los campos email
		if(!textOk(TPF.nombre,"Nombre"))
			return false;
		// Validar los campos de factura
		if(!textOk(TPF.fecha,"Fecha"))
			return false;
		// Validar los campos de factura
		if(!textOk(TPF.descripcion,"Descripción"))
			return false;
		// Validar los campos de factura
		if(!textOk(TPF.duracion,"Duración"))
			return false;
		// Validar los campos de factura
		if(!textOk(TPF.coordinador,"Coordinador"))
			return false;
			// Validar los campos de factura
		if(!textOk(TPF.sede,"Sede"))
			return false;
		// Validar los campos de factura
		if(!textOk(TPF.file,"Imagen"))
			return false;
}
