function setHomepage(webpage){
	if (document.all){
		document.body.style.behavior='url(#default#homepage)';
		document.body.setHomePage(webpage);
		}
	else if (window.sidebar){
		if(window.netscape){
			try{
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
				}
			catch(e){
				alert("this action was aviod by your browser,if you want to enable,please enter about:config in your address line,and change the value of signed.applets.codebase_principal_support to true");
				}
			}
		var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
		prefs.setCharPref('browser.startup.homepage',webpage);
		}
	}
function addBookmark(url, title){
	if(window.sidebar){
		window.sidebar.addPanel(title, url, "");
		}
	else if(document.all){
		window.external.AddFavorite(url, title);
		}
	else if(window.opera && window.print){
		alert('Press ctrl+D to bookmark (Command+D for macs) after you click Ok');
		}
	else if(window.chrome){
		alert('Press ctrl+D to bookmark (Command+D for macs) after you click Ok');
		}
	}
	
function writeBookmarkLink(url, title, text, img)
{
	var insert = '';
	if (img)
		insert = writeBookmarkLinkObject(url, title, '<img src="' + img + '" alt="' + escape(text) + '" title="' + escape(text) + '" />') + '&nbsp';
	insert += writeBookmarkLinkObject(url, title, text);
	document.write(insert);
}
function writeBookmarkLinkObject(url, title, insert)
{
	if (window.sidebar || window.external)
		return ('<a href="javascript:addBookmark(\'' + escape(url) + '\', \'' + escape(title) + '\')" style=" text-decoration:none; color:#000000">' + insert + '</a>');
	else if (window.opera && window.print)
		return ('<a rel="sidebar" href="' + escape(url) + '" title="' + escape(title) + '">' + insert + '</a>');
	return ('');
}
function fireEvent(obj,evt){ 
 
    var fireOnThis = obj; 
    if( document.createEvent ) { 
      var evObj = document.createEvent('MouseEvents'); 
      evObj.initEvent( evt, true, false ); 
      fireOnThis.dispatchEvent(evObj); 
    } else if( document.createEventObject ) { 
      document.createEventObject(); 
      fireOnThis.fireEvent('on'+evt); 
    } 
} 
//onload="scrollTo(100,5000); fireEvent(document.getElementById('backtotop'),'click');"

function scrollToo(url, speed, easing, redirect){

url = url || "#";
speed = speed || "fast";
easing = easing || null;
redirect = (redirect === true || redirect == null) ? true : false;

if(url){

if(url.indexOf("#") != -1){

var aParts = url.split("#",2);
var anchor = $("a[name='"+aParts[1]+"‘]");

if(anchor){

if($(document).height()-anchor.offset().top >= $(window).height()
|| anchor.offset().top > $(window).height()
|| $(document).width()-anchor.offset().left >= $(window).width()
|| anchor.offset().left > $(window).width()){

$('html, body').animate({
scrollTop: anchor.offset().top,
scrollLeft: anchor.offset().left
}, speed, easing, function(){
if(redirect){
window.location = url
}
});

}

return false;

}

}

}

}

function fullscreen(){
	Width=screen.availWidth;
	Height=screen.availHeight;
	window.open(document.URL, '', 
	'toolbar=no,location=no,directories=no,status=no,menubar=no,'+
	'scrollbars=1,resizable=no,copyhistory=1,width='+Width+','+
	'height='+Height+',top=0,left=0','replace');
	} 

function changebackgroundParrilla(idParrilla){
	var parrilla = document.getElementById(idParrilla).style;
	
	fragmentoTexto = idParrilla.split('_');
	var parrillaAct = fragmentoTexto[0];
	for(i=1;i<=8;i++){
		parrillas = parrillaAct+'_content'+i;
		document.getElementById(parrillas).style.backgroundImage="url('images/bg_parrillas.jpg')";
		document.getElementById(parrillas).style.backgroundColor = '';
		}
	
	parrilla.backgroundColor = '#59a6fa';
	parrilla.backgroundImage='';
		
	}

function showHide(obj){	
	//alert(obj);
	var div = document.getElementById(obj);
	if (div.style.display == 'none'){
		for(i=1;i<=30;i++){
			//alert('div_answer'+i);
			var divTemp = document.getElementById('div_answer'+i);
			if(divTemp != null)	divTemp.style.display = 'none';
			}
		div.style.display = '';
		//document.location.href='#'+obj;
		}
	else{
		div.style.display = 'none';
		//document.location.href='#main';
		}
	}

function showDet(id,visibility){
	setVisibility(id,visibility);
	//$('#add').load('DIVadd.php');
	}
	
function setVisibility(id, visibility) {
	document.getElementById(id).style.display = visibility;
	}
	
function changeContentwrapperPHP(content,id){
	var contentwrapper=$('#contentwrapper');
	if(content=='Noticias') contentwrapper.load('Noticias/index.php?id='+id);
	if(content=='LoUltimo') contentwrapper.load('LoUltimo/index.php?id='+id);
	if(content=='SabQue') contentwrapper.load('SabQue/index.php?id='+id);
	if(content=='Recomendar'){
		contentwrapper.load('inc/Recomendar.php?id='+id);
	}
}
	
function changeContentwrapper(content){
	var contentwrapper=$('#contentwrapper');
	if(content=='parrillajoven') contentwrapper.load('inc/Servicios/parrillajoven.php');
	if(content=='Home') contentwrapper.load('inc/Home.php');
	if(content=='Contacto') contentwrapper.load('inc/Contacto.php');
	if(content=='QuienesSomos') contentwrapper.load('inc/QuienesSomos.php');
	if(content=='AvisosLegales') contentwrapper.load('inc/AvisosLegales.php');
	if(content=='Publicidad') contentwrapper.load('inc/Publicidad.php');
	if(content=='DistribuidoresOficiales') contentwrapper.load('inc/DistribuidoresOficiales/index.php');
	//Noticias
	if(content=='NoticiasListaCompleta') contentwrapper.load('Noticias/ListaCompleta.php');
	//SabQue
	if(content=='SabQueListaCompleta') contentwrapper.load('SabQue/ListaCompleta.php');
	//LoUltimo
	if(content == 'LoUltimoListaCompleta') contentwrapper.load('LoUltimo/ListaCompleta.php');
	//Servicios
	if(content=='Servicios') contentwrapper.load('inc/Servicios/index.php');

	}	
	
function newWindows(url, nombre, ancho, alto){
	xpos=(screen.width/2)-(ancho/2);
	ypos=(screen.height/2)-(alto/2);
	window.open(url,nombre,'resizable=yes,width='+ancho+',height='+alto+',left='+xpos+',top='+ypos+',statusbar=no, toolbar=yes, location=yes, menubar=no,scrollbars=yes');
	}

function openTranslateGoogle(){
	var q = $('#q').val();
	//var url = 'http://translate.google.com/#es|en|'+q;
	var url = 'http://translate.google.com/#es|en|'+q;
	var ancho = 800;
	var alto = 600;
	var xpos=(screen.width/2)-(ancho/2);
	var ypos=(screen.height/2)-(alto/2);
	var nombre = 'ParrillaWeb';
	window.open(url,nombre,'resizable=yes,width='+ancho+',height='+alto+',left='+xpos+',top='+ypos+',statusbar=no, toolbar=no, location=no, menubar=no,scrollbars=yes');
}

function openRAE(){
	var q = $('#q').val();
	var url = 'http://buscon.rae.es/draeI/SrvltConsulta?TIPO_BUS=3&LEMA='+q;
	var ancho = 800;
	var alto = 600;
	var xpos=(screen.width/2)-(ancho/2);
	var ypos=(screen.height/2)-(alto/2);
	var nombre = 'RAE';
	window.open(url,nombre,'resizable=yes,width='+ancho+',height='+alto+',left='+xpos+',top='+ypos+',statusbar=no, toolbar=no, location=no, menubar=no,scrollbars=yes');
}

function openGoogleMaps(){
	var q = $('#q').val();
	var url = 'http://maps.google.es/maps?q='+q;
	var ancho = 800;
	var alto = 600;
	var xpos=(screen.width/2)-(ancho/2);
	var ypos=(screen.height/2)-(alto/2);
	var nombre = 'RAE';
	window.open(url,nombre,'resizable=yes,width='+ancho+',height='+alto+',left='+xpos+',top='+ypos+',statusbar=no, toolbar=no, location=no, menubar=no,scrollbars=yes');
}

function openSinonimos(){
	var q = $('#q').val();
	var url = 'http://www.wordreference.com/sinonimos/'+q;
	var ancho = 800;
	var alto = 600;
	var xpos=(screen.width/2)-(ancho/2);
	var ypos=(screen.height/2)-(alto/2);
	var nombre = 'Sinónimos';
	window.open(url,nombre,'resizable=yes,width='+ancho+',height='+alto+',left='+xpos+',top='+ypos+',statusbar=no, toolbar=no, location=no, menubar=no,scrollbars=yes');
}

function openTiempo(){
	var q = $('#q').val();
	if(q==''){
		var url ='http://www.eltiempo.es/';
	}
	else{
		var url = 'http://www.eltiempo.es/buscar?l='+q;
	}
	var ancho = 800;
	var alto = 600;
	var xpos=(screen.width/2)-(ancho/2);
	var ypos=(screen.height/2)-(alto/2);
	var nombre = 'El Tiempo';
	window.open(url,nombre,'resizable=yes,width='+ancho+',height='+alto+',left='+xpos+',top='+ypos+',statusbar=no, toolbar=no, location=no, menubar=no,scrollbars=yes');
}
