// JavaScript Document
//document.obtm = 0;
function cambioMenu(ob, valoro){
}

function activarProductoNombre(intCategoria, intMarca, intIdProducto, strNombre){
	  	window.focus();
		var j=1;
		var laLista;
		laLista = eval("document.laForma.listaProductos" + intCategoria);
		nombre  = eval("document.laForma.nombreProductos" + intCategoria);
		laLista.value = intIdProducto;
		nombre.value = strNombre;
}
       	
function vigilar() {
	if (_popBusqueda == null)
		return;
	if (_popBusqueda.closed)
		return;
	if (_popBusqueda.necesitaBuscar) {
		//alert(_popBusqueda.intCategoria + "*" + _popBusqueda.intMarca + "*" + _popBusqueda.intIdProducto);
		activarProductoNombre(_popBusqueda.intCategoria, _popBusqueda.intMarca, _popBusqueda.intIdProducto, _popBusqueda.strNombre);
		_popBusqueda.close();
		_popBusqueda = null;
		self.focus();
		return;
	}
	setTimeout("vigilar()", 500);
}


/*LAYER SETUP*/

function layerSetup(layer, w, h) {
    var is = new Is();
    if(is.ns6) {
        page_width=innerWidth;
        page_height=innerHeight;
    } else if(is.ie5 || is.ie55||is.ie6) {
        page_width=document.body.clientWidth;
        page_height=document.body.clientHeight;
    }
    var tb = MM_findObj(layer);

    if(w == undefined && h == undefined ){
        ws= String(tb.style.width).replace("px", "");
        hs= String(tb.style.height).replace("px", "");
        h= Number(hs)
        w= Number(ws)
    }
		if(h != undefined){
				tb.style.top=(page_height/2)-(h/2)+"px";
		}
    tb.style.left=(page_width/2)-(w/2)+"px";
}

function Is() {
    agent  = navigator.userAgent.toLowerCase();
    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);
    this.ns    = ((agent.indexOf('mozilla') != -1) &&
      ((agent.indexOf('spoofer')  ==   -1) && (agent.indexOf('compatible') == -1)));
    this.ns4   = (this.ns && (this.major == 4));
    this.ns6   = (this.ns && (this.major >= 5));
    this.ie    = (agent.indexOf("msie") != -1);
    this.ie3   = (this.ie && (this.major  < 4));
    this.ie4   = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.0") == -1));
    this.ie5   = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.0") != -1));
    this.ie55  = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.5") != -1));
    this.ie6  = (this.ie && (agent.indexOf("msie 6.0")!=-1) );
}
function MM_openBrWindow(theURL,winName,features) {
	pop = window.open(theURL,winName,features);
}
function openTerminos(){	
	MM_openBrWindow('/features/terminos.html','terminos','width=435,height=309')	
}
function openProductos(url){	
	MM_openBrWindow(url,'producto','width=757,height=557,srocrollbars=true')	
}
function openGuia(){	
	window.open("/features/guia/guia.html",'producto','')	
}
function hacerSubmit(str){
  	var r2 = new RegExp('^([\"]{1}[a-zA-Z0-9\\á\\é\\í\\ó\\ú\\-\\.\\ \\+]{1}[a-zA-Z0-9\\á\\é\\í\\ó\\ú\\-\\.\\ \\+]+[\"][\+]?)?[a-zA-Z0-9\\á\\é\\í\\ó\\ú\\-\\.\\ \\+]{1}[a-zA-Z0-9\\á\\é\\í\\ó\\ú\\-\\.\\ \\+]+$')
  	var r3 = new RegExp('^([a-zA-Z0-9\\á\\é\\í\\ó\\ú\\-\\.\\ \\+]{1}[a-zA-Z0-9\\á\\é\\í\\ó\\ú\\-\\.\\ \\+]+[\+]?)?[\"]{1}[a-zA-Z0-9\\á\\é\\í\\ó\\ú\\-\\.\\ \\+]{1}[a-zA-Z0-9\\á\\é\\í\\ó\\ú\\-\\.\\ \\+]+[\"]{1}$');
		if(r3.test(str) || r2.test(str)){
			document.formaBusqueda.texto.value= str;
			document.formaBusqueda.idPortal.value= idPortal;
			document.formaBusqueda.documentosPorPagina.value= documentosXPagina;
			document.formaBusqueda.cantidadMaximaDeDocumentos.value= cantidadMaximaDoc;
			document.formaBusqueda.seccion.value= "/"+aliasPais+"/MAG/";
			document.formaBusqueda.ramas.value= "/"+aliasPais+"/MAG/,/"+aliasPais+"/ENC/,/"+aliasPais+"/CLUB/";
			document.formaBusqueda.submit();
		} else {
			alert("Por favor refina tu búsqueda");
		}
}

//Para cambiar de pais desde el botoncito de la pata:
function openCambiar(){ document.location="/prehome.jsp?cambio=true";}

//Para ir al home desde el botoncito del encabezado:
function openHome(){ document.location="/prehome.jsp";}


/***** para meter el plugin de fb *****/
function loadjscssfile(filename, filetype, callback){
	if (filetype=="js"){ //if filename is a external JavaScript file
		var fileref=document.createElement('script')
		fileref.setAttribute("type","text/javascript")
		fileref.setAttribute("src", filename);
		if(callback!=null && typeof(callback)!="undefined"){
			fileref.onload = fileref.onreadystatechange = function(){
				fileref.onreadystatechange = fileref.onload = null;
				callback();
			}
		}
	}else if (filetype=="css"){ //if filename is an external CSS file
		var fileref=document.createElement("link")
		fileref.setAttribute("rel", "stylesheet")
		fileref.setAttribute("type", "text/css")
		fileref.setAttribute("href", filename)
	}
 	if(typeof fileref!="undefined")  document.getElementsByTagName("head")[0].appendChild(fileref)
}

loadjscssfile("/js/jquery-1.5.2.min.js","js",
	function(){
		//jQuery(document).ready(function () {
		window.onload = function () {
			ponerPluginFBLike();
			
		}
	});


function ponerPluginFBLike(){
	$el = jQuery(document.body).find("img[src*='/imgDocumenta/magazin/gif/btn_magEnviar_generico.gif']");
	$dc	= jQuery("<div>").attr("id","dv_megusta");
	if($el.length>0){ // se busca la imagen de enviar a una amiga
		jQuery($el).css("float","left");
		jQuery($dc).css("float","left");
        jQuery($dc).insertAfter($el);
	}else{
		$el = jQuery(".txt_tituloNormal");
		if($el.length>0){ //se busca ne la tabla de peq en tv
			 jQuery($dc).css("text-align","center");
			 jQuery($el).append($dc);
		}
		
		$el = jQuery(".txt_textoNormal");
		if($el.length>0){ //se busca ne la tabla de ecuelita peq
		var cssObj = {'text-align' : 'center','margin-left' : '-30px'};
			 //jQuery($dc).css("text-align","center");
			 jQuery($dc).css(cssObj);
			 jQuery("<p></p>").html($dc).appendTo($el);
			 //$($dc).insertAfter($el);
		}
	}

	txtFB = '<iframe src="http://www.facebook.com/plugins/like.php?href='+document.location+'&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;font=trebuchet+ms&amp;colorscheme=light&amp;height=30" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:75px; height:30px;" allowTransparency="true"></iframe>';
	
	jQuery($dc).html(txtFB)
}

function closeLayer(divId){
$("#" + divId).hide();
} 




