// 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=10, top=10, width=520,height=500');
	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 mailOk(text, msg)
     {	 	
      var str = text.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('The email address is not valid.');
	  text.focus();
	  text.select();
      return result
    }
		
	
    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;	
	}

// Validar los contactos del travel professional
function ValidaContactForm(TPF)
{
		// Validar los campos nombre
		if(!textOk(TPF.email,"Email"))
			return false;
		// Validar email
		if(!mailOk(TPF.email,"Email"))
			return false;
		// Validar los campos email no nulo
		if(!textOk(TPF.Asunto,"Comment"))
			return false;
}


function ValidaTPForm(TPF)
{
		// Validar los campos nombre
		if(!textOk(TPF.aname,"Name"))
			return false;
		// Validar los campos email no nulo
		if(!textOk(TPF.email,"Email"))
			return false;
		// Validar email
		if(!mailOk(TPF.email,"Email"))
			return false;		
		// Validar los campos travelname
		if(!textOk(TPF.travelname,"Company name"))
			return false;
		// Validar los campos Company identifier
		if (isEmpty(TPF.tagencia) || TPF.tagencia.value==0){
			ShowMsgEmpty("Company identifier");
			TPF.tagencia.focus();
			return false;
		}
		// Validar los campos IATA
		if(TPF.tagencia.value!=5)
		{
			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 pass
		if(TPF.pass.value!=TPF.confirmpass.value)
		{
			alert('Los campos Clave y Confirmar clave deben ser iguales');
			TPF.pass.focus();
			return false;
		}		
}
// Funcion que validad Olvido su palabra clave en el Tavel Professional
function ValidaForgotForm(TPF)
{
		// Validar los campos email
		if(!textOk(TPF.email,"Email"))
			return false;
		// Validar los campos de factura
		if(!textOk(TPF.user,"User Name"))
			return false;
		// Validar los campos de factura
		if(!textOk(TPF.pass,"Password"))
			return false;
		// Validar los campos de factura
		if(!textOk(TPF.confirmpass,"Confirm Password"))
			return false;
		// Validar los campos pass
		if(TPF.pass.value!=TPF.confirmpass.value)
		{
			alert('Los campos Clave y Confirmar clave deben ser iguales');
			TPF.pass.focus();
			return false;
		}
}

function ValidaNForm(NF, IntCount)
{	
		if(!mailOk(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;
		}
		if(!IntCount){
			alert("You must check at least one interest");
			//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, Path)
{
	var url = Path + "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";
}


// ******* Funciones para la reserva con fastbooking *******/

var FBRESA = "http://www.fastbookings.biz/DIRECTORY/";

function hhotelPTC(val, lg, codeprice, codetrack, cluster)
{
	hhotelResa(val, lg, codeprice, "", "", codetrack, cluster, "")
}
function hhotelPTC1(val, lg, codeprice, codetrack, cluster)
{
	hhotelResa1(val, lg, codeprice, "", "", codetrack, cluster, "")
}
function hhotelPromo(val, lg, theme)
{
	hhotelResa(val, lg, "DYNPROMO", "", "", "", "", theme)
}
function hhotelNegociated(cname, lg, codeprice, codetrack, cluster)
{
	hhotelResa(cname, lg, codeprice, "", "", codetrack, cluster, "", "negociated=1");
}
function hhotelSearchGroup(cluster, lg, price, nights, title)
{
	hhotelSearch(cluster, lg, price, nights, title, "");
}
function hhotelSearchPartner(cluster, lg, price, codetrack, title)
{
	if (codetrack != "") args = "&from="+codetrack;
	else	args = "";
    hhotelSearch(cluster, lg, price, "", title, "", args);

}
function hhotelSearchPriceDate(cluster, price, nights, title,firstdate)
{
	// firstdate : format "YYMMDD"
	var args="";
	if (firstdate != "") args = "FirstDate="+firstdate;
	hhotelSearch(cluster, "", price, nights, title, "", args);
}

function hhotelDispoprice(theForm)
{
	theForm.action = FBRESA + "dispoprice.phtml";
	window.open('','dispoprice', 'toolbar=no,width=700,height=600,menubar=no,scrollbars=yes,resizable=yes');
	document.idForm.submit();
}
function hhotelSearchPromo(cluster, lg, theme)
{
	hhotelSearch(cluster, lg, "", "", "", theme);
}

function hhotelcancel(cname,lg)
{
  var waction = FBRESA+"cancel.phtml?state=77&Hotelnames="+cname;
  if (lg != "") waction += "&langue="+lg;
  window.open(waction,"reservation","toolbar=no,width=400,height=350,menubar=no,scrollbars=yes,resizable=yes,alwaysRaised=yes");
}

function hhotelResa1(val, lg, codeprice, firstroom, firstdate, codetrack, cluster, theme)
{
	var waction = FBRESA+"preresa.phtml?Hotelnames="+val;
	if (lg != "") waction += "&langue="+lg;
	if (firstroom != "") {
		waction += "&FirstRoomName="+firstroom;
		if (codeprice == "")
			codeprice = "DIRECT";
		}
	if (firstdate != "") {
		waction += "&FirstDate="+firstdate;
		if (codeprice == "")
			codeprice = "DIRECT";
		}
	waction += "&FSTBKNGCode="+codeprice;
	if (codetrack != "") waction += "&FSTBKNGTrackLink="+codetrack;
	if (cluster != "") waction += "&clustername="+cluster;
	if (theme != "") waction += "&theme="+theme;	
	window.open(waction,"reservation","toolbar=no,width=400,height=350,menubar=no,scrollbars=yes,resizable=yes,alwaysRaised=yes");	
	//window.location = waction;
}

function hhotelResa(val, lg, codeprice, firstroom, firstdate, codetrack, cluster, theme)
{
	var waction = FBRESA+"preresa.phtml?Hotelnames="+val;
	if (lg != "") waction += "&langue="+lg;
	if (firstroom != "") {
		waction += "&FirstRoomName="+firstroom;
		if (codeprice == "")
			codeprice = "DIRECT";
		}
	if (firstdate != "") {
		waction += "&FirstDate="+firstdate;
		if (codeprice == "")
			codeprice = "DIRECT";
		}
	waction += "&FSTBKNGCode="+codeprice;
	if (codetrack != "") waction += "&FSTBKNGTrackLink="+codetrack;
	if (cluster != "") waction += "&clustername="+cluster;
	if (theme != "") waction += "&theme="+theme;	
	window.open(waction,"reservation","toolbar=no,width=400,height=350,menubar=no,scrollbars=yes,resizable=yes,alwaysRaised=yes");	
	//window.location = waction;
}

function hhotelSearch(cluster, lg, price, nights, title, theme)
{
	var waction = FBRESA+"crs.phtml?clusterName="+cluster;
	if (lg != "") waction += "&langue="+lg;
	if (price != "") waction += "&FSTBKNGCode="+price;
	if (nights != "") waction += "&nights="+nights;
	if (title != "") waction += "&title="+escape(title);
	if (theme != "") waction += "&theme="+theme;
	window.open(waction,"search","toolbar=no,width=700,height=550,menubar=yes,scrollbars=yes,resizable=yes,alwaysRaised=yes");
}