var $jquery = jQuery.noConflict();
function getMethods(obj) {
  var result = [];
  for (var id in obj) {
    try {
      if (typeof(obj[id]) == "function") {
        result.push(id + ": " + obj[id].toString());
      }
    } catch (err) {
      result.push(id + ": inaccessible");
    }
  }
  return result;
}


$jquery(document).ready(function() {
	var popOut = "#popout";
	var adBox = "#adbox";
	var adWidth = $jquery(adBox).width() + $jquery("#cap").width();
	
	function openAd() {
	    $jquery(popOut).css("z-index","100");
	    $jquery(popOut).width(adWidth+"px");
	    $jquery(adBox).animate({marginLeft: "0"},1200);
	}
	function closeAd() {
	    $jquery(adBox).animate({marginLeft: "-"+adWidth+"px"},1200,"linear",
	        function(){ $jquery(popOut).width($jquery(".cap").width() + "px"); }
	    );
	    
	}
	$jquery("#open").click(function() {
	    //$jquery(popOut).css("width","320");
	    openAd();
	    return false;
	});
	$jquery("#close").click(function() {
	    closeAd();
	    //$jquery(popOut).css("z-index","-20");
	    return false; 
	});
	//$(popOut).animate({opacity: 1.0}, 1500, "linear", openAd);
	
	
	// CODIGO SUBMENUS
	$jquery("ul.submenu").parent().append("<span></span>");
	$jquery("ul.menu li").click(function() { //Al hacer click se ejecuta...
	//Con este codigo aplicamos el movimiento de arriva y abajo para el submenu
	$jquery(this).find("ul.submenu").slideDown('fast').show(); //Menu desplegable al hacer click
	$jquery(this).hover(function() {
	}, function(){
	$jquery(this).parent().find("ul.submenu").slideUp('slow'); //Ocultamos el submenu cuando el raton sale fuera del submenu
	});
	}).hover(function() {
	$jquery(this).addClass("subhover"); //Agregamos la clase subhover
	}, function(){  //Cunado sale el cursor, sacamos la clase
	$jquery(this).removeClass("subhover");
	});
	
	
	////////// SCROLL DE MENU
	//Get our elements for faster access and set overlay width
	var div = $jquery('div.sc_menu'),
	ul = $jquery('ul.sc_menu'),
	ulPadding = 50;
	
	//Get menu width
	var divWidth = div.width();
	
	//Remove scrollbars	
	div.css({overflow: 'hidden'});
	
	//Find last image container
	var lastLi = ul.find('li:last-child');
	
	//When user move mouse over menu
	div.mousemove(function(e){
		//As images are loaded ul width increases,
		//so we recalculate it each time
		var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;	
		var left = (e.pageX - div.offset().left) * (ulWidth-divWidth) / divWidth;
		div.scrollLeft(left);
	});
	///////////
	
	
});

/*
$(function(){
		//Get our elements for faster access and set overlay width
		
	});
	/*]]>*/

function LightboxDelegate(url,caption) {
	var objLink = document.createElement('a');
	objLink.setAttribute('href',url);
	objLink.setAttribute('rel','lightbox');
	objLink.setAttribute('title',caption);
	Lightbox.prototype.start(objLink);
}


