function launchWindow(url, features) {
  window.open(url, "_blank", features);
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
///// GENERIC MACROMEDIA SWAP FUNCTIONS

function mOvr(src,clrOver) {
 if (!src.contains(event.fromElement)) {
	 src.style.cursor = 'hand';
	 src.bgColor = clrOver;
	}
 }
 function mOut(src,clrIn) {
	if (!src.contains(event.toElement)) {
	 src.style.cursor = 'default';
	 src.bgColor = clrIn;
	}
 }


function MM_preloadImages() { //v2.0
  if (document.images) {
    var imgFiles = MM_preloadImages.arguments;
    if (document.preloadArray==null) document.preloadArray = new Array();
    var i = document.preloadArray.length;
    with (document) for (var j=0; j<imgFiles.length; j++) if (imgFiles[j].charAt(0)!="#"){
      preloadArray[i] = new Image;
      preloadArray[i++].src = imgFiles[j];
  } }
}

function MM_swapImgRestore() { //v2.0
  if (document.MM_swapImgData != null)
    for (var i=0; i<(document.MM_swapImgData.length-1); i+=2)
      document.MM_swapImgData[i].src = document.MM_swapImgData[i+1];
}

function MM_swapImage() { //v2.0
  var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.MM_swapImgData;
  for (i=0; i < (MM_swapImage.arguments.length-2); i+=3) {
    objStr = MM_swapImage.arguments[(navigator.appName == 'Netscape')?i:i+1];
    if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||
        (objStr.indexOf('document.all[')   ==0 && document.all   ==null))
      objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);
    obj = eval(objStr);
    if (obj != null) {
      swapArray[j++] = obj;
      swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];
      obj.src = MM_swapImage.arguments[i+2];
  } }
  document.MM_swapImgData = swapArray; //used for restore
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}


///// CUSTOM FUNCTIONS
ie4=document.all;
ie55=(ie4&&((navigator.userAgent.indexOf("MSIE 5.5")!=-1)||(navigator.userAgent.indexOf("MSIE 6")!=-1)));
pc=navigator.platform.indexOf('Win32')!=-1;
mac=navigator.platform.indexOf('MacPPC')!=-1;
sinbordes=(ie4&&pc);

//Detection of flash player (almost version 1) (OK in all versions except MSExplorer 4.5 for mac)
var flash=false;
if((navigator.appName!="Netscape")&&(navigator.platform.indexOf("Mac")!=0)) {
 document.write('<SCRIPT LANGUAGE="VBScript"> \n');
 document.write('<!-- \n');
 document.write('	on error resume next \n');
 document.write(' flash = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.1")) \n');
 document.write('rem --> \n');
 document.write('<\/SCRIPT>\n');
}
else if((navigator.mimeTypes)&&(navigator.mimeTypes["application/x-shockwave-flash"])) {
 if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) flash=true;
}

//Funciones de rollover para dos imagenes simultaneas (popup video)
function swap(cual1,cual2){
 im1=cual1; eval('document.'+cual1+'.src="/imgyatv/popups/'+cual1+'on.gif"');
 im2=cual2; eval('document.'+cual2+'.src="/imgyatv/popups/'+cual2+'on.gif"');
}

function rest(){
 eval('document.'+im1+'.src="/imgyatv/popups/'+im1+'.gif"');
 eval('document.'+im2+'.src="/imgyatv/popups/'+im2+'.gif"');
}

//Popups functions
function openWindow(urlToOpen, windowName, windowProperties){ window.open(urlToOpen,windowName,windowProperties); }
function VerAyuda() {	openPopup('/ayuda.html','ayuda','width=580,height=550,scrollbars=1',null); }
function goChat(canal) {	openPopup('/chat/SYatv?s=15250&c='+canal,'v_nick','scrollbars=no,resizable=no,width=315,height=160',null); }
function openAll(type,area) { if(type=="fotos") openPopup('/SYatvAllGalleries?area='+area+'&page=1','allresults','width=350,height=485,scrollbars=yes',null); }
function perpyn(usuario) { self.name="paginas_miya"; openPopup("http://www.ya.com/mi/pasaporte.cfm?nick="+usuario,"pasaporte","width=400,height=300,resizable=no,scrollbars=no,menubar=no,toolbar=no,directories=no,location=no,status=no",null); }

function opengame(gameurl,gamewidth,gameheight) {
 if(gamewidth==null) gamewidth=470;
 if(gameheight==null) gameheight=570;
 openPopup(gameurl,'webgame','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+gamewidth+',height='+gameheight,null);
}

function searchFormat() {
	var f=document.formatSearch;
	if(f.query.value=="") {
		alert("Debe introducir un texto en la caja");
		return false;
	}
	if((!f.format[0].checked)&&(!f.format[1].checked)&&(!f.format[2].checked)&&(!f.format[3].checked)&&(!f.format[4].checked)) {
		alert("Debe seleccionar un formato de búsqueda");
		return false;
	}
	f.submit();
}

//Multipopup de noticias (Atlas)
function openMultiPopup(urlToOpen, windowName, windowDestination) {
	name = window.top.name;
	
	if(windowDestination=='News1') { popupw=236; popuph=380; }
	else if(windowDestination=='News2') { popupw=380; popuph=380; }
	else if(windowDestination=='News3') { popupw=510; popuph=380; }
	windowProperties='width='+popupw+',height='+popuph+',left=0,top=0';
	
	if (name=='popupMulti') {
		 top.window.resizeTo(popupw,popuph);
		 top.location.replace(urlToOpen);
	}
  else {
 	 ventana=window.open(urlToOpen,windowName,'fullscreen=yes,scrollbars=yes');
 	 ventana.resizeTo(popupw,popuph); 
   ventana.moveTo(0,0);
	}
}

//Popups de contenidos multimedia
function openPopup2(urlToOpen, windowName, windowProperties, windowDestination) { // ('audio.jsp?.....', null, null, 'Audio')
 if(windowDestination!=null) { //Popup de contenidos multimedia
	   popupw=160; popuph=250;
	
	  windowProperties='width='+popupw+',height='+popuph+',left=0,top=0';
	
		if(urlToOpen.indexOf(".jsp")!=-1) {
			if (windowDestination=="Video") { // call the servlet
				posinicio = urlToOpen.indexOf("?") +1;
				posfinal = urlToOpen.length - posinicio;
				params = urlToOpen.substring(posinicio,posfinal);
				furlToOpen="/SVideoPopup?"+params;
			}
			else { // call the frame_____.jsp
				furlToOpen=""+urlToOpen;
			}
			urlToOpen=""+urlToOpen;
		}
		else {
			furlToOpen=""+urlToOpen;
			urlToOpen=""+urlToOpen;
		}
		
	  if(top.name=="yatvPopup") { //Navegacion desde los popups
			 if((top.popupType.indexOf("News")==0)||(top.popupType=="Text")||(windowDestination=="Text")) { //Se rehace el popup
			    if(sinbordes) {
						top.resizeTo(popupw,popuph); top.location.replace(urlToOpen);
					}
			    else {
						top.name="";
						window.open(urlToOpen,"yatvPopup",windowProperties);
						top.close();
					}
		   }
			 else { //Se navega por frames
					top.popupType=windowDestination;
					parent.location.replace(furlToOpen);
	   	 }
	  }
		else { //Creacion del nuevo popup
			 if(sinbordes) {
			 		newwindow=window.open(urlToOpen,"yatvPopup","fullscreen=yes,scrollbars=yes");
					newwindow.resizeTo(popupw,popuph); newwindow.moveTo(0,0);
			 }
		   else newwindow=window.open(urlToOpen,"yatvPopup",windowProperties);
			 newwindow.focus();
	  }
 }
 else window.open(urlToOpen,windowName,windowProperties);
}  //end of openPopup function


//Popups de contenidos multimedia
function openPopup(urlToOpen, windowName, windowProperties, windowDestination) { // ('audio.jsp?.....', null, null, 'Audio')
 
 if(windowDestination!=null) { //Popup de contenidos multimedia
	   popupw=493; popuph=493;
	
	  windowProperties='width='+popupw+',height='+popuph+',left=0,top=0';
	
		if(urlToOpen.indexOf(".jsp")!=-1) {
			if (windowDestination=="Video") { // call the servlet
			
				posinicio = urlToOpen.indexOf("?") +1;
				posfinal = urlToOpen.length - posinicio;
				params = urlToOpen.substring(posinicio,posfinal);
				furlToOpen="/SVideoPopup?"+params;
			}
			else { // call the frame_____.jsp
				furlToOpen=""+urlToOpen;
			}
			urlToOpen=""+urlToOpen;
		}
		else {
			furlToOpen=""+urlToOpen;
			urlToOpen=""+urlToOpen;
		}
		
	  if(top.name=="yatvPopup") { //Navegacion desde los popups
			 if((top.popupType.indexOf("News")==0)||(top.popupType=="Text")||(windowDestination=="Text")) { //Se rehace el popup
			    if(sinbordes) {
						top.resizeTo(popupw,popuph); top.location.replace(urlToOpen);
					}
			    else {
						top.name="";
						window.open(urlToOpen,"yatvPopup",windowProperties);
						top.close();
					}
		   }
			 else { //Se navega por frames
					top.popupType=windowDestination;
					parent.location.replace(furlToOpen);
	   	 }
	  }
		else { //Creacion del nuevo popup
			 if(sinbordes) {
			 		newwindow=window.open(urlToOpen,"yatvPopup","fullscreen=yes,scrollbars=yes");
					newwindow.resizeTo(popupw,popuph); newwindow.moveTo(0,0);
			 }
		   else newwindow=window.open(urlToOpen,"yatvPopup",windowProperties);
			 newwindow.focus();
	  }
 }
 else window.open(urlToOpen,windowName,windowProperties);
}  //end of openPopup function

function VerFoto(idnew, num, clink) {
  if(num==null) num=1;
  openPopup('photo.jsp?f='+idnew+'&n='+num, null, null, 'Photo');
  if(clink!=null) location.href=clink;
}

function VerVideo(idnew, num, speed, clink) {
	var nt=Math.random();
	if(num==null) num=1;
	openPopup('video.jsp?f='+idnew+'&n='+num+'&c='+speed+'&x='+nt, null, null,'Video');
	if(clink!=null) location.href=clink;
}

function VerVideoBuscador(idvideo, speed, clink) {
	var nt=Math.random();
	openPopup('video.jsp?v='+idvideo+'&c='+speed+'&x='+nt, null, null,'Video');
	if(clink!=null) location.href=clink;
}

function VerAudio( idnew, num, speed, clink) {
	if(num==null) num=1;
	if(speed==null) speed=1;
 	openPopup('audio.jsp?f='+idnew+'&n='+num,null,null,'Audio');
  if(clink!=null) location.href=clink;
}

function VerAudioBuscador(idaudio,speed,clink) {
	if(speed==null) speed=1;
	openPopup('audio.jsp?a='+idaudio,null,null,'Audio');
 if(clink!=null) location.href=clink;
}

function VerMultiPopup(idnew,widthpopup,type,num,clink){
	var nt=Math.random();
	if(num==null) num=0;
  openMultiPopup('/jsp/multinews.jsp?f='+idnew+'&w='+widthpopup+'&t='+type+'&n='+num+'&x='+nt,'popupMulti','News'+widthpopup);
  if(clink!=null) location.href=clink;
}

function VerMasVideos(mode,id,nameOf) {
	var nt=Math.random();
	openPopup('/multimedia?mode='+mode+'&query='+id+'&format=video&source='+nameOf+'&x='+nt,'results','width=350,height=470,scrollbars=yes',null);
}

function VerNoticia(idsection,idnew,clink) {
 if(idsection==null) idsection=0;
 openPopup('text.jsp?s=0&f='+idnew+'&a=1',null,null,'Text');
 if(clink!=null) location.href=clink;
}

function LanzaDescarga(fichero,clink) {
 location.href=fichero;
 if(clink!=null) location.href=clink;
}

function LanzaUrl(url) { window.open(url,''); }

function RedirectPopUp(){
	TestCookie();
}

function TestCookie () {	
	var cookieOn = true;
	if(document.cookie.length>0) {
		cookies=unescape(document.cookie);
		offset=cookies.indexOf("YATV");
		if(offset == -1) cookieOn = false;	}
 else cookieOn = false;
	if(!cookieOn) openPopup('/personalizar/','personalizar','width=344,height=395,scrollbars=no',null);
}
