// JavaScript Document

$(document).ready(function(){
						   

//ocultamos los mensajes del formulario validador
$('.class_exp').hide();
//ocultamos los contenidos de beneficios e ingredientes de los productos
$('#div_product_benefits').hide();
$('#div_product_ingredients').hide();
$('a.link_tab_product').click(function(){
	
	$('.content_products').hide();
	$('#div_'+this.id).fadeIn();
	
});

//Append a div with hover class to all the LI
	$('#navMenu li').append('<div class="hover"><\/div>');


	$('#navMenu li').hover(
		
		//Mouseover, fadeIn the hidden hover class	
		function() {
			
			$(this).children('div').fadeIn('1000');	
		
		}, 
	
		//Mouseout, fadeOut the hover class
		function() {
		
			$(this).children('div').fadeOut('1000');	
		
	}).click (function () {
	
		//Add selected class if user clicked on it
	//	$(this).addClass('selected');
		
	});

$('a.tTip').tinyTips('title');
			$('a.imgTip').tinyTips('<img src="images/demo-image.jpg" /><br />You can even put images or any other markup in the tooltips.');
			$('img.tTip').tinyTips('title');
			$('h1.tagline').tinyTips('tinyTips are totally awesome!');


/*-------------------------MULTIPLE UPLOAD DE LAS GALERIAS----------------------*/


var numero = 0;

// Funciones comunes
c= function (tag) { // Crea un elemento
   return document.createElement(tag);
}

d = function (id) { // Retorna un elemento en base al id
   return document.getElementById(id);
}

e = function (evt) { // Retorna el evento
   return (!evt) ? event : evt;
}

f = function (evt) { // Retorna el objeto que genera el evento
   return evt.srcElement ?  evt.srcElement : evt.target;
}

addField = function () {
   container = d('files');
   span = c('SPAN');
   span.className = 'file';
   span.id = 'file' + (++numero);
   field = c('INPUT');   
   field.name = 'archivos[]';
   field.type = 'file';
   a = c('A');
   a.name = span.id;
   a.href = '#';
   a.onclick = removeField;
   a.innerHTML = 'Quitar';
   span.appendChild(field);
   span.appendChild(a);
   container.appendChild(span);
}

removeField = function (evt) {

   lnk = f(e(evt));
   span = d(lnk.name);
   span.parentNode.removeChild(span);
}



 $("#content_rte").jqrte_setIcon();
			 $("#content_rte").jqrte_setContent();
			try{
			 $("#content_rte").jqrte();
		  }
		  catch(e){}

});


//Funciones para el editor de noticias
function close_link_box_editnews(item_type,div_id)
{
	
	var str='div #'+div_id;
	$(str).slideUp('slow');
}


function open_link_box_editnews(item_type,div_id)
{
	var str='div #'+div_id;
	$(str).slideToggle('slow');
}

//Funcion que muestra un div oculta pasandole el id
function show_divcontent_hide(div_id)
{
	var str='div #'+div_id;
	$(str).slideToggle('slow');
}


function add_link_sendmessageid(div_content,input_id_list,user_log,user_name,user_id)
{
	var valortxt=document.getElementById(input_id_list).value;
	document.getElementById(input_id_list).value=valortxt+user_log+" - '"+user_name+"';";
	show_divcontent_hide(div_content);

	
}

function prueba()
{
	var frame= document.getElementById("wym_iframe_edit");
	sel= frame.contentDocument.getSelection();
	alert(sel);
}

