///// Dart - checkM8 segmentation
var chechkm8inactive = false;

function selectRedirect(e) {
	if (e.options[e.selectedIndex].value != "") {
		window.location.href = e.options[e.selectedIndex].value;
	}
}

function LanzaUrl(url) {
	window.open(url, '');
}

function LanzaDescarga(fichero, enlace) {
	location.href = fichero;
	if (enlace != null)
		location.href = enlace;
}

function VerVideo(idnew, num, speed, enlace) {
	if (num == null)
		num = 1;
	location.href = 'http://www.yatv.com/video/yatv2_video_n_'+idnew+'_'+num+'.html';
	return false;
}

function VerVideoBuscador(idvideo, speed, enlace) {
	location.href = 'http://www.yatv.com/video/yatv2_video_v_'+idvideo+'_1.html';
	return false;
}

function VerAudio(idnew, num, speed, enlace) {
	if (num == null)
		num = 1;
	location.href = 'http://www.yatv.com/audio/yatv2_audio_n_'+idnew+'_'+num+'.html';
  	return false;
}

function VerAudioBuscador(idaudio, speed, enlace) {
	location.href = 'http://www.yatv.com/audio/yatv2_audio_a_'+idaudio+'_1.html';
	return false;
}

function VerMasVideos(mode, id, nameOf) {
	location.href = 'http://www2.yatv.com/jsp/JYatvSearchResults.jsp?mode=text&format=video&query='+nameOf+'&offset=0';
}

var urlSendFriend;
function sendFriend(){
	f = document.forms["F_FRIEND"];
	f.URL.value = window.location.href;
	window.open(urlSendFriend, "FriendWindow", "width=210,height=325,resizable=no,scrollbars=no,menubar=no,toolbar=no,directories=no,location=no,status=no");
	f.target = "FriendWindow";
	f.submit();
}

//Popups functions
function openWindow(urlToOpen, windowName, windowProperties){ window.open(urlToOpen,windowName,windowProperties); }
function VerAyuda() {	openWindow('http://www2.yatv.com/yatv/ayuda.jsp','ayuda','width=580,height=550,scrollbars=1'); }
function goChatOld(canal) {	window.location.href = "http://chat.ya.com/SChat?N=" +canal; }
function goChat(canal) { openWindow('http://www.yatv.com/error/yatv20_chat_nick.htm?c='+canal,'v_nick','scrollbars=no,resizable=no,width=330,height=160'); }
function openAll(type,area) { if(type=="fotos") openWindow('http://www2.yatv.com/SYatvAllGalleries?area='+area+'&page=1','allresults','width=350,height=485,scrollbars=yes'); }
function perpyn(usuario) { self.name="paginas_miya"; openWindow("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"); }

function opengame(gameurl,gamewidth,gameheight) {
	if(gamewidth == null) gamewidth=470;
	if(gameheight == null) gameheight=570;
	openWindow(gameurl, 'webgame', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+gamewidth+',height='+gameheight);
}

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) {
		if (window.location.host.indexOf("desarrollo") != -1) {
			openWindow('http://desarrollo.sdv.yatv2.jif.es/personalizar/', 'Personalizar', 'width=300,height=470');
		} else {
			openWindow('http://www2.yatv.com/personalizar/', 'Personalizar', 'width=300,height=470');
		}
	}
}

function showFilm(idFilm){
	if (document.provinceList.provinces.selectedIndex!=0){
		document.location='http://www2.yatv.com/cartelera/cartelera.jsp?s=cines&amp;f=' + idFilm 
		 + '&amp;p=' + document.provinceList.provinces[document.provinceList.provinces.selectedIndex].value;
	}
}

function ver (){
	if ((screen.width > 1000) && (document.body.clientWidth > 880)){
		document.getElementById('layer_100').style.visibility = 'visible';
	}
	else {
		document.getElementById('layer_100').style.visibility = 'hidden';
	}
}

function pub100x600(section){
	ord=Math.random()*10000000000000000;
	kw="";
	document.write('<SCRIPT LANGUAGE="JavaScript" SRC="http://ad.es.doubleclick.net/adj/mbguapos.ya.com/' + section + ';kw='+kw+';tile=3;sz=100x600;ord=' + ord + '?" ><\/SCRIPT>');
	window.onresize = ver;
}
