// 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=no,resizable=no,width=770,height=196');
}

// 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 ValidaNFForm(NF)
{
		// Validar los campos nombre
		if(!textOk(NF.email,"E-Mail"))
			return false;
		valid_email(NF, email);
		// Validar los campos email
		if(!textOk(NF.aname,"Nombre"))
			return false;
		// Validar los campos travelname
		if(!textOk(NF.laname,"Apellidos"))
			return false;
		// Validar los campos IATA
		if(!textOk(NF.address,"Dirección"))
			return false;		
		// Validar los campos address
		if(!textOk(NF.city,"Ciudad"))
			return false;
		// Validar los campos city
		if(!textOk(NF.zip,"Código Postal"))
			return false;
		// Validar los campos zip
		if(!textOk(TPF.empresa,"Nombre de la Compañia"))
			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;
		
		
}
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)
{
	num = ((first) ? slct1st(frm) : numChecked(frm));
	if (!num)
	{	
		alert("Debe seleccionar al menos un parámetro a borrar");
		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();}
  }    

 retualert('El campo "'+display[i]+'" no puede estar vacio.');
      error = true;
      result = false;
      Form.elements[fields[i]].focus();


 return result;
}