var tabSel = 'homeTab1';
//=======================
function handleMenu (href, id) { var x=$("#" + id); x.toggle("fast"); }
function handleTab (href, id){ if (id != tabSel){var x=$("#" + tabSel); x.hide();$("#parent-" + tabSel).removeClass("selected");var x=$("#" + id); x.show();$("#parent-" + id).addClass("selected");tabSel = id;}}
//
function MG_AddToMap ()
{
    var url = window.location.href;  
   // alert (url);  
}
function MG_AddToPages (key, id)
{ 
var url = window.location.href;
	var x=$("#viewTitle");
	var title = x.text();	
	//
	window.location.replace ('/my/addPage?pathURL=' + urlencode (url) + '&t=' + trim (title) + '&key=' + key + '&ID=' + id);
}
//
function MG_AddToPagesList (key)
{
	var url = window.location.href;
	var x=$("#viewTitle");
	var title = x.text();	
	//
	window.location.replace ('/my/addPage?pathURL=' + urlencode (url) + '&t=' + trim (title) + '&key=' + key);
}
//=======================

function urlencode( str ) {
                                     
    var ret = str;
    
    ret = ret.toString();
    ret = encodeURIComponent(ret);
    ret = ret.replace(/%20/g, '+');
 
    return ret;
}

function trim(s){
s = s.replace(/\s+/gi, " "); //sacar espacios repetidos dejando solo uno
s = s.replace(/^\s+|\s+$/gi, ""); //sacar espacios blanco principio y final

return s;
}


function aj_home_promos (page)
{
	$.ajax({	url: "/get2home/rdh/promos?page=" + page + '&callBack=promos',cache: false,success: function(html){$("#home-promos-container").html(html); aj_loaded ('promos');}});	
	aj_loading ('promos');
}
function aj_home_eventos (page)
{
	$.ajax({	url: "/get2home/rdh/eventos?page=" + page + '&callBack=eventos',cache: false,success: function(html){$("#home-eventos-container").html(html); aj_loaded ('eventos');}});	
	aj_loading ('eventos');
}
function aj_home_empresas (page)
{
	$.ajax({	url: "/get2home/rdh/empresas?page=" + page + '&callBack=empresas',cache: false,success: function(html){$("#home-empresas-container").html(html); aj_loaded ('empresas');}});	
	aj_loading ('empresas');
}


function aj_loading (theKey)
{
	$('#home-' + theKey + '-container').fadeTo("fast", 0.5);
}
function aj_loaded (theKey)
{
	$('#home-' + theKey + '-container').fadeTo("fast", 1);
}


function aj_loadMyAppsItems (key, page, byPage, t)
{
	//	itemContainer_	
	$("#itemContainer_" + key).load('/get2home/my/apps?page=' + page + '&callBack=' + key + '&byPage=' + byPage + '&t=' + t);	
}

function sliderUserMenu ()
{
	$('#my-user-menu-wrapper').toggle();
	$('#menu-slider').toggleClass("menu-slider-to-close");

}


$("td").toggle(
  function () {
    $(this).addClass("selected");
  },
  function () {
    $(this).removeClass("selected");
  }
);
