function DoPicUpload(wd){
 closeXplo()
 lft=screen.width-550;
 xplo=window.open('pman.php', wd, 'scrollbars=1,toolbar=0,location=0,directories=0,menuBar=0,resizable,status=1,top=0,left=0,width=500,height=480');
 xplo.focus();
}

function DoPassHash(wd){
 closeXplo()
 lft=screen.width-550;
 xplo=window.open('phashgen.php', wd, 'scrollbars,top=10,left='+lft+',width=500,height=480');
}

function closeXplo(){
 try {
  xplo.close();
 }
 catch(eee){
 }
 finally{
 }
}

function openwindow(url,name){
 xxc=window.open(url,name,'');
 xxc.focus();
 return false;
}

function popupradio(url,wd,ht){
 try {
  radio.close();
 }
 catch(eee){
 }
 finally{
 }
 radio=window.open(url,'radio','left=0,top=0,width='+wd+',height='+ht+',toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,status=0,resizable=0');
 radio.focus();
 return false;
}

function popupwin(url,wd,ht,id){
 if (id){
  x=document.getElementById('foto'+id+'lab_en');
  if (x.value!==''){
   cp=encodeURIComponent(x.value);
   url=url+cp;
   ht=parseInt(ht)+12;
  }
 }
 xxx=window.open(url,'big','left=0,top=0,width='+wd+',height='+ht+',toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,status=0,resizable=0');
 xxx.focus();
 return false;
}

function gopreview2(){
 if (!submitCheck())return false;
 ref=document.ModifyForm.reference.value;
 url='../properties/nerjaprop_router.php?doctype=9&reference='+ref;
 xplo=window.open(url,'big','left=0,top=0,toolbar=0,location=1,directories=0,menuBar=0,scrollbars=1,status=1,resizable=1');
 this.scrollbars=0;
 return false;
}

function charRemaining(tField, nField, maxAllowed) {
 if (tField.value.length > maxAllowed) tField.value = tField.value.substring(0, maxAllowed);
 nField.value = maxAllowed - tField.value.length;
}


function externalLinks(){
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") anchor.target = "mywinxxx";
 }
 var anchors_area = document.getElementsByTagName("area");
 for (var j=0; j<anchors_area.length; j++) {
   var anchor_area = anchors_area[j];
   if (anchor_area.getAttribute("href") && anchor_area.getAttribute("rel") == "external") anchor_area.target = "mywinxxx";
 }
}

function externalLinksNoFollow(){
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "nofollow") anchor.target = "mywinxxx";
 }
}

function externalLinksJavascipt(){
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") && anchor.getAttribute("class") == "sub" && anchor.getAttribute("id") == "sub")
   {
	   anchor.rel = "nofollow";
	   anchor.target = "";
   }
 }
}

function reloadDate() {
	if(document.getElementById('hora')) {
		document.getElementById('hora').innerHTML=new Date().toLocaleTimeString(); 
		setTimeout("reloadDate();", 1000);
	}
}


function nav(value) 
{ 
	if (value != "") 
	{ 
		location.href = value; 
	} 

}


function slideSwitch()
{
    var $active = $('#banner_tc img.active');

    if ( $active.length == 0 ) $active = $('#banner_tc img:last');

    // Usar esto para poner las imágenes en orden
    var $next =  $active.next().length ? $active.next()
        : $('#banner_tc img:first');

    // Descomentar las 3 lineas siguientes para ordenar las imágenes aleatoriamente
	//var $sibs  = $active.siblings();
	//var rndNum = Math.floor(Math.random() * $sibs.length );
	//var $next  = $( $sibs[ rndNum ] );

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 500, function() {
            $active.removeClass('active last-active');
        });
}

//función que muestra la hora en y la va actualizando cada minuto
function muestra_hora()
{
	var fecha= new Date();
	var horas= fecha.getHours();
	var minutos = fecha.getMinutes();
	
	if(minutos>=0 && minutos<=9)
	{
		document.getElementById('hora').innerHTML=horas+':'+'0'+minutos+' h';
	}
	else
	{
		document.getElementById('hora').innerHTML=horas+':'+minutos+' h';
	}
	

	setTimeout('muestra_hora()',60000);
	
	
}

//Función que para el carrusel cuando ponemos el ratón encima de alguno de los items
//y vuelve a andar cuando lo quitamos		
function parar_carrusel(carousel)
{ 
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};


function popup(pagina) 
{
	var opciones="toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, width=500, height=500, top=85, left=140";
	window.open(pagina,"",opciones);
}



function galeria_videos_youtube(data) 
{
	var feed = data.feed;
	var entries = feed.entry || [];
	var html = [];
	var width = "492";
	var height = "330";
	
	for (var i = 0; i < entries.length; i++) 
	{
		var entry = entries[i];
		var title = entry.title.$t;
		var playerUrl = entries[i].media$group.media$content[0].url;
		var titledisplay = "<br /><div class='nombre'>" + title + "</div>";

		if(entries.length>3 && i>3)
		{
			if(i<5)
			{
				html.push( "<div class='nombre'>Ver más videos publicados</div><div id='listado-galerias'>" );	
			}
				
			html.push( "<li><a href='",playerUrl,"&hl=es&fs=1&showinfo=0&rel=0&autoplay=1' rel='shadowbox;width=610;height=482;'>", title, "</a></li>" );
		}
		else
		{
			html.push( titledisplay ,
					   "<div class='marco'><object width='" , width , "' height='" , height ,
					   "'><param name='movie' value='" , playerUrl ,
					   "&hl=en&fx=1&'></param><param name='allowFullScreen' value='true'></param><param name='allowscriptaccess' value='always'></param><embed src='" , 
					   playerUrl ,
					   "&hl=es&fs=1&showinfo=0&rel=0&showsearch=0' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='" , width ,
					   "' height='" , height , "' wmode='transparent'></embed></object></div><div class='espacio'></div>" );
		}
	}
	
	html.push( "</div>" );
	
	document.getElementById('video_galeria').innerHTML = html.join('');
	
} 

